Skip to content

Commit

Permalink
fix precompiles accAddress parse err
Browse files Browse the repository at this point in the history
  • Loading branch information
trestinlsd committed Aug 25, 2024
1 parent 5dfa8a3 commit 87ec5a6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
3 changes: 0 additions & 3 deletions precompiles/avs/avs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,11 @@ interface IAVSManager {


/// @dev Called by the avs manager service register an operator as the owner of a BLS public key.
/// @param operator is the operator for whom the key is being registered
/// @param name the name of public keys
/// @param pubKey the public keys of the operator
/// @param pubkeyRegistrationSignature the public keys of the operator
/// @param pubkeyRegistrationMessageHash the public keys of the operator
function registerBLSPublicKey(
string memory operator,
string calldata name,
bytes calldata pubKey,
bytes calldata pubkeyRegistrationSignature,
Expand Down Expand Up @@ -175,7 +173,6 @@ interface IAVSManager {
/// @param operator the address of the delegator
/// @param pubKey the address of the validator
event RegisterBLSPublicKey(
string indexed operator,
string name,
bytes pubKey,
bytes pubkeyRegistrationSignature,
Expand Down
25 changes: 15 additions & 10 deletions precompiles/avs/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,13 @@ func (p Precompile) Challenge(
if !ok || operatorAddress == "" {
return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 3, "string", operatorAddress)
}
challengeParams.OperatorAddress = sdk.AccAddress(operatorAddress)
err := p.avsKeeper.RaiseAndResolveChallenge(ctx, challengeParams)
operator, err := sdk.AccAddressFromBech32(operatorAddress)
if err != nil {
return nil, err
}

challengeParams.OperatorAddress = operator
err = p.avsKeeper.RaiseAndResolveChallenge(ctx, challengeParams)
if err != nil {
return nil, err
}
Expand All @@ -239,27 +244,27 @@ func (p Precompile) RegisterBLSPublicKey(
}
blsParams := &avskeeper.BlsParams{}
blsParams.Operator = sdk.AccAddress(origin[:]).String()
name, ok := args[1].(string)
name, ok := args[0].(string)
if !ok || name == "" {
return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "string", name)
return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 0, "string", name)
}
blsParams.Name = name

pubkeyBz, ok := args[2].([]byte)
pubkeyBz, ok := args[1].([]byte)
if !ok {
return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 2, "[]byte", pubkeyBz)
return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "[]byte", pubkeyBz)
}
blsParams.PubKey = pubkeyBz

pubkeyRegistrationSignature, ok := args[3].([]byte)
pubkeyRegistrationSignature, ok := args[2].([]byte)
if !ok {
return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 3, "[]byte", pubkeyRegistrationSignature)
return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 2, "[]byte", pubkeyRegistrationSignature)
}
blsParams.PubkeyRegistrationSignature = pubkeyRegistrationSignature

pubkeyRegistrationMessageHash, ok := args[4].([]byte)
pubkeyRegistrationMessageHash, ok := args[3].([]byte)
if !ok {
return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 4, "[]byte", pubkeyRegistrationMessageHash)
return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 3, "[]byte", pubkeyRegistrationMessageHash)
}
blsParams.PubkeyRegistrationMessageHash = pubkeyRegistrationMessageHash

Expand Down

0 comments on commit 87ec5a6

Please sign in to comment.