From 87ec5a6539ea9c17f21ff0c0f9e2e27dc1996ace Mon Sep 17 00:00:00 2001 From: trestin Date: Sun, 25 Aug 2024 20:29:34 +0800 Subject: [PATCH] fix precompiles accAddress parse err --- precompiles/avs/avs.sol | 3 --- precompiles/avs/tx.go | 25 +++++++++++++++---------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/precompiles/avs/avs.sol b/precompiles/avs/avs.sol index 6e66fc09c..d6b8895bf 100644 --- a/precompiles/avs/avs.sol +++ b/precompiles/avs/avs.sol @@ -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, @@ -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, diff --git a/precompiles/avs/tx.go b/precompiles/avs/tx.go index 207757df3..4f70f3589 100644 --- a/precompiles/avs/tx.go +++ b/precompiles/avs/tx.go @@ -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 } @@ -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