From 23d77246db11a9434443012c7c1df14a9fa09c1f Mon Sep 17 00:00:00 2001 From: Lucas Bertrand Date: Tue, 10 Oct 2023 12:00:55 -0700 Subject: [PATCH 1/3] fix(`observer`): remove error return in `IsAuthorized` (#1250) * update function * regenerate interfaces * update for crosschain --- testutil/keeper/mocks/crosschain/account.go | 2 +- testutil/keeper/mocks/crosschain/bank.go | 2 +- testutil/keeper/mocks/crosschain/fungible.go | 2 +- testutil/keeper/mocks/crosschain/observer.go | 16 +++------------- testutil/keeper/mocks/crosschain/staking.go | 2 +- testutil/keeper/mocks/fungible/account.go | 2 +- testutil/keeper/mocks/fungible/bank.go | 2 +- testutil/keeper/mocks/fungible/evm.go | 2 +- testutil/keeper/mocks/fungible/observer.go | 2 +- x/crosschain/keeper/keeper_chain_nonces.go | 10 ++++------ .../keeper_cross_chain_tx_vote_inbound_tx.go | 5 ++--- .../keeper_cross_chain_tx_vote_outbound_tx.go | 5 ++--- x/crosschain/keeper/keeper_gas_price.go | 9 ++++----- x/crosschain/keeper/keeper_out_tx_tracker.go | 7 ++----- x/crosschain/types/expected_keepers.go | 2 +- x/observer/keeper/keeper_utils.go | 8 ++++---- x/observer/keeper/msg_server_add_blame_vote.go | 5 ++--- x/observer/keeper/msg_server_add_block_header.go | 5 ++--- 18 files changed, 34 insertions(+), 54 deletions(-) diff --git a/testutil/keeper/mocks/crosschain/account.go b/testutil/keeper/mocks/crosschain/account.go index bde82aa1df..69df546af1 100644 --- a/testutil/keeper/mocks/crosschain/account.go +++ b/testutil/keeper/mocks/crosschain/account.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.34.2. DO NOT EDIT. +// Code generated by mockery v2.35.2. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/crosschain/bank.go b/testutil/keeper/mocks/crosschain/bank.go index bf4e73987b..8b4e4c1b04 100644 --- a/testutil/keeper/mocks/crosschain/bank.go +++ b/testutil/keeper/mocks/crosschain/bank.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.34.2. DO NOT EDIT. +// Code generated by mockery v2.35.2. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/crosschain/fungible.go b/testutil/keeper/mocks/crosschain/fungible.go index ba803b9a52..1a1452f5c7 100644 --- a/testutil/keeper/mocks/crosschain/fungible.go +++ b/testutil/keeper/mocks/crosschain/fungible.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.34.2. DO NOT EDIT. +// Code generated by mockery v2.35.2. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/crosschain/observer.go b/testutil/keeper/mocks/crosschain/observer.go index 0f1d2b310c..8ddc1504cd 100644 --- a/testutil/keeper/mocks/crosschain/observer.go +++ b/testutil/keeper/mocks/crosschain/observer.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.34.2. DO NOT EDIT. +// Code generated by mockery v2.35.2. DO NOT EDIT. package mocks @@ -333,27 +333,17 @@ func (_m *CrosschainObserverKeeper) GetParams(ctx types.Context) observertypes.P } // IsAuthorized provides a mock function with given fields: ctx, address, chain -func (_m *CrosschainObserverKeeper) IsAuthorized(ctx types.Context, address string, chain *common.Chain) (bool, error) { +func (_m *CrosschainObserverKeeper) IsAuthorized(ctx types.Context, address string, chain *common.Chain) bool { ret := _m.Called(ctx, address, chain) var r0 bool - var r1 error - if rf, ok := ret.Get(0).(func(types.Context, string, *common.Chain) (bool, error)); ok { - return rf(ctx, address, chain) - } if rf, ok := ret.Get(0).(func(types.Context, string, *common.Chain) bool); ok { r0 = rf(ctx, address, chain) } else { r0 = ret.Get(0).(bool) } - if rf, ok := ret.Get(1).(func(types.Context, string, *common.Chain) error); ok { - r1 = rf(ctx, address, chain) - } else { - r1 = ret.Error(1) - } - - return r0, r1 + return r0 } // IsInboundEnabled provides a mock function with given fields: ctx diff --git a/testutil/keeper/mocks/crosschain/staking.go b/testutil/keeper/mocks/crosschain/staking.go index 0faf55a58a..7288ae4125 100644 --- a/testutil/keeper/mocks/crosschain/staking.go +++ b/testutil/keeper/mocks/crosschain/staking.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.34.2. DO NOT EDIT. +// Code generated by mockery v2.35.2. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/fungible/account.go b/testutil/keeper/mocks/fungible/account.go index 81f510c6d3..6a77932f69 100644 --- a/testutil/keeper/mocks/fungible/account.go +++ b/testutil/keeper/mocks/fungible/account.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.34.2. DO NOT EDIT. +// Code generated by mockery v2.35.2. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/fungible/bank.go b/testutil/keeper/mocks/fungible/bank.go index da56574169..d04228faf7 100644 --- a/testutil/keeper/mocks/fungible/bank.go +++ b/testutil/keeper/mocks/fungible/bank.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.34.2. DO NOT EDIT. +// Code generated by mockery v2.35.2. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/fungible/evm.go b/testutil/keeper/mocks/fungible/evm.go index e0ac00173c..fe04262d80 100644 --- a/testutil/keeper/mocks/fungible/evm.go +++ b/testutil/keeper/mocks/fungible/evm.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.34.2. DO NOT EDIT. +// Code generated by mockery v2.35.2. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/fungible/observer.go b/testutil/keeper/mocks/fungible/observer.go index fc7ec327b6..d627f7d980 100644 --- a/testutil/keeper/mocks/fungible/observer.go +++ b/testutil/keeper/mocks/fungible/observer.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.34.2. DO NOT EDIT. +// Code generated by mockery v2.35.2. DO NOT EDIT. package mocks diff --git a/x/crosschain/keeper/keeper_chain_nonces.go b/x/crosschain/keeper/keeper_chain_nonces.go index 90291845ed..7ecd816075 100644 --- a/x/crosschain/keeper/keeper_chain_nonces.go +++ b/x/crosschain/keeper/keeper_chain_nonces.go @@ -4,13 +4,12 @@ import ( "context" "fmt" - zetaObserverTypes "github.com/zeta-chain/zetacore/x/observer/types" - "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/query" "github.com/zeta-chain/zetacore/x/crosschain/types" + observertypes "github.com/zeta-chain/zetacore/x/observer/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) @@ -108,12 +107,11 @@ func (k msgServer) NonceVoter(goCtx context.Context, msg *types.MsgNonceVoter) ( ctx := sdk.UnwrapSDKContext(goCtx) chain := k.zetaObserverKeeper.GetParams(ctx).GetChainFromChainID(msg.ChainId) if chain == nil { - return nil, zetaObserverTypes.ErrSupportedChains + return nil, observertypes.ErrSupportedChains } - ok, err := k.zetaObserverKeeper.IsAuthorized(ctx, msg.Creator, chain) - if !ok { - return nil, err + if ok := k.zetaObserverKeeper.IsAuthorized(ctx, msg.Creator, chain); !ok { + return nil, observertypes.ErrNotAuthorizedPolicy } chainNonce, isFound := k.GetChainNonces(ctx, chain.ChainName.String()) diff --git a/x/crosschain/keeper/keeper_cross_chain_tx_vote_inbound_tx.go b/x/crosschain/keeper/keeper_cross_chain_tx_vote_inbound_tx.go index 62c7813976..a384c320ba 100644 --- a/x/crosschain/keeper/keeper_cross_chain_tx_vote_inbound_tx.go +++ b/x/crosschain/keeper/keeper_cross_chain_tx_vote_inbound_tx.go @@ -77,9 +77,8 @@ func (k msgServer) VoteOnObservedInboundTx(goCtx context.Context, msg *types.Msg tssPub = tss.TssPubkey } // IsAuthorized does various checks against the list of observer mappers - ok, err := k.zetaObserverKeeper.IsAuthorized(ctx, msg.Creator, observationChain) - if !ok { - return nil, err + if ok := k.zetaObserverKeeper.IsAuthorized(ctx, msg.Creator, observationChain); !ok { + return nil, observerTypes.ErrNotAuthorizedPolicy } index := msg.Digest() diff --git a/x/crosschain/keeper/keeper_cross_chain_tx_vote_outbound_tx.go b/x/crosschain/keeper/keeper_cross_chain_tx_vote_outbound_tx.go index f8b845a925..f7d781bfd2 100644 --- a/x/crosschain/keeper/keeper_cross_chain_tx_vote_outbound_tx.go +++ b/x/crosschain/keeper/keeper_cross_chain_tx_vote_outbound_tx.go @@ -73,9 +73,8 @@ func (k msgServer) VoteOnObservedOutboundTx(goCtx context.Context, msg *types.Ms return nil, err } //Check is msg.Creator is authorized to vote - ok, err := k.zetaObserverKeeper.IsAuthorized(ctx, msg.Creator, observationChain) - if !ok { - return nil, err + if ok := k.zetaObserverKeeper.IsAuthorized(ctx, msg.Creator, observationChain); !ok { + return nil, observerTypes.ErrNotAuthorizedPolicy } // Check if CCTX exists diff --git a/x/crosschain/keeper/keeper_gas_price.go b/x/crosschain/keeper/keeper_gas_price.go index 63ea8e527f..50a103bec9 100644 --- a/x/crosschain/keeper/keeper_gas_price.go +++ b/x/crosschain/keeper/keeper_gas_price.go @@ -13,7 +13,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/query" "github.com/zeta-chain/zetacore/x/crosschain/types" - zetaObserverTypes "github.com/zeta-chain/zetacore/x/observer/types" + observertypes "github.com/zeta-chain/zetacore/x/observer/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) @@ -127,11 +127,10 @@ func (k msgServer) GasPriceVoter(goCtx context.Context, msg *types.MsgGasPriceVo chain := k.zetaObserverKeeper.GetParams(ctx).GetChainFromChainID(msg.ChainId) if chain == nil { - return nil, zetaObserverTypes.ErrSupportedChains + return nil, observertypes.ErrSupportedChains } - ok, err := k.zetaObserverKeeper.IsAuthorized(ctx, msg.Creator, chain) - if !ok { - return nil, err + if ok := k.zetaObserverKeeper.IsAuthorized(ctx, msg.Creator, chain); !ok { + return nil, observertypes.ErrNotAuthorizedPolicy } if chain == nil { return nil, sdkerrors.Wrap(types.ErrUnsupportedChain, fmt.Sprintf("ChainID : %d ", msg.ChainId)) diff --git a/x/crosschain/keeper/keeper_out_tx_tracker.go b/x/crosschain/keeper/keeper_out_tx_tracker.go index 5053687bd4..a11329aea2 100644 --- a/x/crosschain/keeper/keeper_out_tx_tracker.go +++ b/x/crosschain/keeper/keeper_out_tx_tracker.go @@ -173,11 +173,8 @@ func (k msgServer) AddToOutTxTracker(goCtx context.Context, msg *types.MsgAddToO adminPolicyAccount := k.zetaObserverKeeper.GetParams(ctx).GetAdminPolicyAccount(observertypes.Policy_Type_group1) isAdmin := msg.Creator == adminPolicyAccount - isObserver, err := k.zetaObserverKeeper.IsAuthorized(ctx, msg.Creator, chain) - if err != nil { - ctx.Logger().Error("Error while checking if the account is an observer", err) - return nil, cosmoserrors.Wrap(observertypes.ErrNotAuthorized, fmt.Sprintf("error IsAuthorized %s", msg.Creator)) - } + isObserver := k.zetaObserverKeeper.IsAuthorized(ctx, msg.Creator, chain) + // Sender needs to be either the admin policy account or an observer if !(isAdmin || isObserver) { return nil, cosmoserrors.Wrap(observertypes.ErrNotAuthorized, fmt.Sprintf("Creator %s", msg.Creator)) diff --git a/x/crosschain/types/expected_keepers.go b/x/crosschain/types/expected_keepers.go index fc5960b5e5..5b83869099 100644 --- a/x/crosschain/types/expected_keepers.go +++ b/x/crosschain/types/expected_keepers.go @@ -63,7 +63,7 @@ type ZetaObserverKeeper interface { SetLastObserverCount(ctx sdk.Context, lbc *zetaObserverTypes.LastObserverCount) AddVoteToBallot(ctx sdk.Context, ballot zetaObserverTypes.Ballot, address string, observationType zetaObserverTypes.VoteType) (zetaObserverTypes.Ballot, error) CheckIfFinalizingVote(ctx sdk.Context, ballot zetaObserverTypes.Ballot) (zetaObserverTypes.Ballot, bool) - IsAuthorized(ctx sdk.Context, address string, chain *common.Chain) (bool, error) + IsAuthorized(ctx sdk.Context, address string, chain *common.Chain) bool FindBallot(ctx sdk.Context, index string, chain *common.Chain, observationType zetaObserverTypes.ObservationType) (ballot zetaObserverTypes.Ballot, isNew bool, err error) AddBallotToList(ctx sdk.Context, ballot zetaObserverTypes.Ballot) GetBlockHeader(ctx sdk.Context, hash []byte) (val common.BlockHeader, found bool) diff --git a/x/observer/keeper/keeper_utils.go b/x/observer/keeper/keeper_utils.go index e36cd8e934..8424985d31 100644 --- a/x/observer/keeper/keeper_utils.go +++ b/x/observer/keeper/keeper_utils.go @@ -32,17 +32,17 @@ func (k Keeper) CheckIfFinalizingVote(ctx sdk.Context, ballot types.Ballot) (typ } // IsAuthorized checks whether a signer is authorized to sign , by checking their address against the observer mapper which contains the observer list for the chain and type -func (k Keeper) IsAuthorized(ctx sdk.Context, address string, chain *common.Chain) (bool, error) { +func (k Keeper) IsAuthorized(ctx sdk.Context, address string, chain *common.Chain) bool { observerMapper, found := k.GetObserverMapper(ctx, chain) if !found { - return false, errors.Wrap(types.ErrNotAuthorized, fmt.Sprintf("observer list not present for chain %s", chain.String())) + return false } for _, obs := range observerMapper.ObserverList { if obs == address { - return true, nil + return true } } - return false, errors.Wrap(types.ErrNotAuthorized, fmt.Sprintf("address: %s", address)) + return false } func (k Keeper) FindBallot(ctx sdk.Context, index string, chain *common.Chain, observationType types.ObservationType) (ballot types.Ballot, isNew bool, err error) { diff --git a/x/observer/keeper/msg_server_add_blame_vote.go b/x/observer/keeper/msg_server_add_blame_vote.go index b21bd30c69..1330cc4815 100644 --- a/x/observer/keeper/msg_server_add_blame_vote.go +++ b/x/observer/keeper/msg_server_add_blame_vote.go @@ -19,9 +19,8 @@ func (k msgServer) AddBlameVote(goCtx context.Context, vote *types.MsgAddBlameVo return nil, sdkerrors.Wrap(crosschainTypes.ErrUnsupportedChain, fmt.Sprintf("ChainID %d, Blame vote", vote.ChainId)) } // IsAuthorized does various checks against the list of observer mappers - ok, err := k.IsAuthorized(ctx, vote.Creator, observationChain) - if !ok { - return nil, err + if ok := k.IsAuthorized(ctx, vote.Creator, observationChain); !ok { + return nil, types.ErrNotAuthorizedPolicy } index := vote.Digest() diff --git a/x/observer/keeper/msg_server_add_block_header.go b/x/observer/keeper/msg_server_add_block_header.go index 8ee4ffa5cd..185fd9d061 100644 --- a/x/observer/keeper/msg_server_add_block_header.go +++ b/x/observer/keeper/msg_server_add_block_header.go @@ -17,9 +17,8 @@ func (k msgServer) AddBlockHeader(goCtx context.Context, msg *types.MsgAddBlockH // check authorization for this chain chain := common.GetChainFromChainID(msg.ChainId) - ok, err := k.IsAuthorized(ctx, msg.Creator, chain) - if !ok { - return nil, cosmoserrors.Wrap(types.ErrNotAuthorizedPolicy, err.Error()) + if ok := k.IsAuthorized(ctx, msg.Creator, chain); !ok { + return nil, types.ErrNotAuthorizedPolicy } // add vote to ballot From aa94a913cc77cf4ae9d2814c4fff371c7a34d9f5 Mon Sep 17 00:00:00 2001 From: Lucas Bertrand Date: Tue, 10 Oct 2023 13:29:47 -0700 Subject: [PATCH 2/3] fix(`GetForeignCoinFromAsset`): Ethereum comparaison checksum/non-checksum format (#1261) * fix error message * compare with ETH address type * tests * goimport --------- Co-authored-by: brewmaster012 <88689859+brewmaster012@users.noreply.github.com> --- x/crosschain/types/errors.go | 4 +- x/fungible/keeper/foreign_coins.go | 9 +- x/fungible/keeper/foreign_coins_test.go | 120 ++++++++++++++---------- 3 files changed, 81 insertions(+), 52 deletions(-) diff --git a/x/crosschain/types/errors.go b/x/crosschain/types/errors.go index ac6a1497f5..da0674b5c3 100644 --- a/x/crosschain/types/errors.go +++ b/x/crosschain/types/errors.go @@ -12,10 +12,10 @@ var ( ErrNotEnoughZetaBurnt = errorsmod.Register(ModuleName, 1109, "not enough zeta burnt") ErrCannotFindReceiverNonce = errorsmod.Register(ModuleName, 1110, "cannot find receiver chain nonce") - ErrGasCoinNotFound = errorsmod.Register(ModuleName, 1113, "gas coin not found for SenderChain") + ErrGasCoinNotFound = errorsmod.Register(ModuleName, 1113, "gas coin not found for sender chain") ErrUnableToParseAddress = errorsmod.Register(ModuleName, 1115, "cannot parse address and data") ErrCannotProcessWithdrawal = errorsmod.Register(ModuleName, 1116, "cannot process withdrawal event") - ErrForeignCoinNotFound = errorsmod.Register(ModuleName, 1118, "gas coin not found for SenderChain") + ErrForeignCoinNotFound = errorsmod.Register(ModuleName, 1118, "foreign coin not found for sender chain") ErrNotEnoughPermissions = errorsmod.Register(ModuleName, 1119, "not enough permissions for current actions") ErrCannotFindPendingNonces = errorsmod.Register(ModuleName, 1121, "cannot find pending nonces") diff --git a/x/fungible/keeper/foreign_coins.go b/x/fungible/keeper/foreign_coins.go index 7450b66cd8..faa96d2876 100644 --- a/x/fungible/keeper/foreign_coins.go +++ b/x/fungible/keeper/foreign_coins.go @@ -5,6 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" + ethcommon "github.com/ethereum/go-ethereum/common" "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -93,9 +94,15 @@ func (k Keeper) GetGasCoinForForeignCoin(ctx sdk.Context, chainID int64) (types. // GetForeignCoinFromAsset returns the foreign coin for a given asset for a given chain func (k Keeper) GetForeignCoinFromAsset(ctx sdk.Context, asset string, chainID int64) (types.ForeignCoins, bool) { + if !ethcommon.IsHexAddress(asset) { + return types.ForeignCoins{}, false + } + assetAddr := ethcommon.HexToAddress(asset) + foreignCoinList := k.GetAllForeignCoinsForChain(ctx, chainID) for _, coin := range foreignCoinList { - if coin.Asset == asset && coin.ForeignChainId == chainID { + coinAssetAddr := ethcommon.HexToAddress(coin.Asset) + if coinAssetAddr == assetAddr && coin.ForeignChainId == chainID { return coin, true } } diff --git a/x/fungible/keeper/foreign_coins_test.go b/x/fungible/keeper/foreign_coins_test.go index 347630002d..0a5a0f37f0 100644 --- a/x/fungible/keeper/foreign_coins_test.go +++ b/x/fungible/keeper/foreign_coins_test.go @@ -77,56 +77,78 @@ func TestKeeper_GetGasCoinForForeignCoin(t *testing.T) { } func TestKeeperGetForeignCoinFromAsset(t *testing.T) { - k, ctx, _, _ := keepertest.FungibleKeeper(t) + t.Run("can get foreign coin from asset", func(t *testing.T) { + k, ctx, _, _ := keepertest.FungibleKeeper(t) - gasAsset := sample.EthAddress().String() + gasAsset := sample.EthAddress().String() - // populate - setForeignCoins(ctx, k, - types.ForeignCoins{ - Zrc20ContractAddress: sample.EthAddress().String(), - Asset: sample.EthAddress().String(), - ForeignChainId: 1, - CoinType: common.CoinType_ERC20, - Name: "foo", - }, - types.ForeignCoins{ - Zrc20ContractAddress: sample.EthAddress().String(), - Asset: gasAsset, - ForeignChainId: 1, - CoinType: common.CoinType_ERC20, - Name: "bar", - }, - types.ForeignCoins{ - Zrc20ContractAddress: sample.EthAddress().String(), - Asset: sample.EthAddress().String(), - ForeignChainId: 1, - CoinType: common.CoinType_Gas, - Name: "foo", - }, - types.ForeignCoins{ - Zrc20ContractAddress: sample.EthAddress().String(), - Asset: sample.EthAddress().String(), - ForeignChainId: 2, - CoinType: common.CoinType_ERC20, - Name: "foo", - }, - types.ForeignCoins{ - Zrc20ContractAddress: sample.EthAddress().String(), - Asset: sample.EthAddress().String(), - ForeignChainId: 2, - CoinType: common.CoinType_ERC20, - Name: "foo", - }, - ) + // populate + setForeignCoins(ctx, k, + types.ForeignCoins{ + Zrc20ContractAddress: sample.EthAddress().String(), + Asset: sample.EthAddress().String(), + ForeignChainId: 1, + CoinType: common.CoinType_ERC20, + Name: "foo", + }, + types.ForeignCoins{ + Zrc20ContractAddress: sample.EthAddress().String(), + Asset: gasAsset, + ForeignChainId: 1, + CoinType: common.CoinType_ERC20, + Name: "bar", + }, + types.ForeignCoins{ + Zrc20ContractAddress: sample.EthAddress().String(), + Asset: sample.EthAddress().String(), + ForeignChainId: 1, + CoinType: common.CoinType_Gas, + Name: "foo", + }, + types.ForeignCoins{ + Zrc20ContractAddress: sample.EthAddress().String(), + Asset: sample.EthAddress().String(), + ForeignChainId: 2, + CoinType: common.CoinType_ERC20, + Name: "foo", + }, + types.ForeignCoins{ + Zrc20ContractAddress: sample.EthAddress().String(), + Asset: sample.EthAddress().String(), + ForeignChainId: 2, + CoinType: common.CoinType_ERC20, + Name: "foo", + }, + ) - fc, found := k.GetForeignCoinFromAsset(ctx, gasAsset, 1) - require.True(t, found) - require.Equal(t, "bar", fc.Name) - fc, found = k.GetForeignCoinFromAsset(ctx, sample.EthAddress().String(), 1) - require.False(t, found) - fc, found = k.GetForeignCoinFromAsset(ctx, gasAsset, 2) - require.False(t, found) - fc, found = k.GetForeignCoinFromAsset(ctx, gasAsset, 3) - require.False(t, found) + fc, found := k.GetForeignCoinFromAsset(ctx, gasAsset, 1) + require.True(t, found) + require.Equal(t, "bar", fc.Name) + fc, found = k.GetForeignCoinFromAsset(ctx, sample.EthAddress().String(), 1) + require.False(t, found) + fc, found = k.GetForeignCoinFromAsset(ctx, "invalid_address", 1) + require.False(t, found) + fc, found = k.GetForeignCoinFromAsset(ctx, gasAsset, 2) + require.False(t, found) + fc, found = k.GetForeignCoinFromAsset(ctx, gasAsset, 3) + require.False(t, found) + }) + + t.Run("can get foreign coin with non-checksum address", func(t *testing.T) { + k, ctx, _, _ := keepertest.FungibleKeeper(t) + + setForeignCoins(ctx, k, + types.ForeignCoins{ + Zrc20ContractAddress: sample.EthAddress().String(), + Asset: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", + ForeignChainId: 1, + CoinType: common.CoinType_ERC20, + Name: "foo", + }, + ) + + fc, found := k.GetForeignCoinFromAsset(ctx, "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", 1) + require.True(t, found) + require.Equal(t, "foo", fc.Name) + }) } From ed35305f67fd76f943f79ef0473de8ea4aae8b88 Mon Sep 17 00:00:00 2001 From: Lucas Bertrand Date: Tue, 10 Oct 2023 13:58:43 -0700 Subject: [PATCH 3/3] feat(`fungible`): add ability to update gas limit (#1260) * add new field * update message type * message new logic --- docs/spec/fungible/messages.md | 1 + proto/fungible/events.proto | 2 + proto/fungible/tx.proto | 4 + x/crosschain/keeper/gas_payment_test.go | 12 +- ...blocker_deploy_system_contracts_privnet.go | 9 +- x/fungible/keeper/evm.go | 62 +++++- .../msg_server_update_zrc20_withdraw_fee.go | 37 ++-- ...g_server_update_zrc20_withdraw_fee_test.go | 141 ++++++++++++-- x/fungible/types/events.pb.go | 178 ++++++++++++++---- .../message_update_zrc20_withdraw_fee.go | 16 +- .../message_update_zrc20_withdraw_fee_test.go | 52 ++++- x/fungible/types/tx.pb.go | 164 ++++++++++------ 12 files changed, 527 insertions(+), 151 deletions(-) diff --git a/docs/spec/fungible/messages.md b/docs/spec/fungible/messages.md index 3977d2212c..984455ff41 100644 --- a/docs/spec/fungible/messages.md +++ b/docs/spec/fungible/messages.md @@ -78,6 +78,7 @@ message MsgUpdateZRC20WithdrawFee { string creator = 1; string zrc20_address = 2; string new_withdraw_fee = 6; + string new_gas_limit = 7; } ``` diff --git a/proto/fungible/events.proto b/proto/fungible/events.proto index 37c4feb10f..4c66f1a940 100644 --- a/proto/fungible/events.proto +++ b/proto/fungible/events.proto @@ -34,6 +34,8 @@ message EventZRC20WithdrawFeeUpdated { string old_withdraw_fee = 5; string new_withdraw_fee = 6; string signer = 7; + string old_gas_limit = 8; + string new_gas_limit = 9; } message EventZRC20PausedStatusUpdated { diff --git a/proto/fungible/tx.proto b/proto/fungible/tx.proto index aa5161a592..34608edb22 100644 --- a/proto/fungible/tx.proto +++ b/proto/fungible/tx.proto @@ -24,6 +24,10 @@ message MsgUpdateZRC20WithdrawFee { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Uint", (gogoproto.nullable) = false ]; + string new_gas_limit = 7 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Uint", + (gogoproto.nullable) = false + ]; } message MsgUpdateZRC20WithdrawFeeResponse {} diff --git a/x/crosschain/keeper/gas_payment_test.go b/x/crosschain/keeper/gas_payment_test.go index f76d878607..e110017694 100644 --- a/x/crosschain/keeper/gas_payment_test.go +++ b/x/crosschain/keeper/gas_payment_test.go @@ -232,7 +232,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { zrc20 := setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, chainID, "foobar", "foobar") _, err := zk.FungibleKeeper.UpdateZRC20WithdrawFee( sdk.UnwrapSDKContext(ctx), - fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, zrc20.String(), sdk.NewUint(withdrawFee)), + fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, zrc20.String(), sdk.NewUint(withdrawFee), math.Uint{}), ) require.NoError(t, err) k.SetGasPrice(ctx, types.GasPrice{ @@ -330,7 +330,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { zrc20 := setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, chainID, "foobar", "foobar") _, err := zk.FungibleKeeper.UpdateZRC20WithdrawFee( sdk.UnwrapSDKContext(ctx), - fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, zrc20.String(), sdk.NewUint(withdrawFee)), + fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, zrc20.String(), sdk.NewUint(withdrawFee), math.Uint{}), ) require.NoError(t, err) k.SetGasPrice(ctx, types.GasPrice{ @@ -384,7 +384,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { ) _, err := zk.FungibleKeeper.UpdateZRC20WithdrawFee( sdk.UnwrapSDKContext(ctx), - fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, gasZRC20.String(), sdk.NewUint(withdrawFee)), + fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, gasZRC20.String(), sdk.NewUint(withdrawFee), math.Uint{}), ) require.NoError(t, err) k.SetGasPrice(ctx, types.GasPrice{ @@ -497,7 +497,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { gasZRC20 := setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, chainID, "foo", "foo") _, err := zk.FungibleKeeper.UpdateZRC20WithdrawFee( sdk.UnwrapSDKContext(ctx), - fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, gasZRC20.String(), sdk.NewUint(withdrawFee)), + fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, gasZRC20.String(), sdk.NewUint(withdrawFee), math.Uint{}), ) require.NoError(t, err) k.SetGasPrice(ctx, types.GasPrice{ @@ -551,7 +551,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { ) _, err := zk.FungibleKeeper.UpdateZRC20WithdrawFee( sdk.UnwrapSDKContext(ctx), - fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, gasZRC20.String(), sdk.NewUint(withdrawFee)), + fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, gasZRC20.String(), sdk.NewUint(withdrawFee), math.Uint{}), ) require.NoError(t, err) k.SetGasPrice(ctx, types.GasPrice{ @@ -605,7 +605,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { ) _, err := zk.FungibleKeeper.UpdateZRC20WithdrawFee( sdk.UnwrapSDKContext(ctx), - fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, gasZRC20.String(), sdk.NewUint(withdrawFee)), + fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, gasZRC20.String(), sdk.NewUint(withdrawFee), math.Uint{}), ) require.NoError(t, err) k.SetGasPrice(ctx, types.GasPrice{ diff --git a/x/fungible/keeper/begin_blocker_deploy_system_contracts_privnet.go b/x/fungible/keeper/begin_blocker_deploy_system_contracts_privnet.go index 18301cb3d8..803510d38d 100644 --- a/x/fungible/keeper/begin_blocker_deploy_system_contracts_privnet.go +++ b/x/fungible/keeper/begin_blocker_deploy_system_contracts_privnet.go @@ -7,6 +7,8 @@ import ( "fmt" "math/big" + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/zeta-chain/zetacore/common" @@ -146,7 +148,12 @@ func (k Keeper) TestUpdateZRC20WithdrawFee(goCtx context.Context) error { creator := k.observerKeeper.GetParams(ctx).GetAdminPolicyAccount(observertypes.Policy_Type_group1) for _, foreignCoin := range foreignCoins { - msg := types.NewMsgUpdateZRC20WithdrawFee(creator, foreignCoin.Zrc20ContractAddress, sdk.NewUint(uint64(foreignCoin.ForeignChainId))) + msg := types.NewMsgUpdateZRC20WithdrawFee( + creator, + foreignCoin.Zrc20ContractAddress, + sdk.NewUint(uint64(foreignCoin.ForeignChainId)), + math.Uint{}, + ) _, err := k.UpdateZRC20WithdrawFee(ctx, msg) if err != nil { return err diff --git a/x/fungible/keeper/evm.go b/x/fungible/keeper/evm.go index f176cf71c3..8606804bea 100644 --- a/x/fungible/keeper/evm.go +++ b/x/fungible/keeper/evm.go @@ -201,7 +201,67 @@ func (k Keeper) DepositZRC20( if err != nil { return nil, err } - return k.CallEVM(ctx, *zrc20ABI, types.ModuleAddressEVM, contract, BigIntZero, nil, true, false, "deposit", to, amount) + return k.CallEVM( + ctx, + *zrc20ABI, + types.ModuleAddressEVM, + contract, + BigIntZero, + nil, + true, + false, + "deposit", + to, + amount, + ) +} + +// UpdateZRC20ProtocolFlatFee updates the protocol flat fee for a given ZRC20 contract +func (k Keeper) UpdateZRC20ProtocolFlatFee( + ctx sdk.Context, + zrc20Addr common.Address, + newFee *big.Int, +) (*evmtypes.MsgEthereumTxResponse, error) { + zrc20ABI, err := zrc20.ZRC20MetaData.GetAbi() + if err != nil { + return nil, err + } + return k.CallEVM( + ctx, + *zrc20ABI, + types.ModuleAddressEVM, + zrc20Addr, + BigIntZero, + nil, + true, + false, + "updateProtocolFlatFee", + newFee, + ) +} + +// UpdateZRC20GasLimit updates the gas limit for a given ZRC20 contract +func (k Keeper) UpdateZRC20GasLimit( + ctx sdk.Context, + zrc20Addr common.Address, + newGasLimit *big.Int, +) (*evmtypes.MsgEthereumTxResponse, error) { + zrc20ABI, err := zrc20.ZRC20MetaData.GetAbi() + if err != nil { + return nil, err + } + return k.CallEVM( + ctx, + *zrc20ABI, + types.ModuleAddressEVM, + zrc20Addr, + BigIntZero, + nil, + true, + false, + "updateGasLimit", + newGasLimit, + ) } // DepositZRC20AndCallContract deposits into ZRC4 and call contract function in a single tx diff --git a/x/fungible/keeper/msg_server_update_zrc20_withdraw_fee.go b/x/fungible/keeper/msg_server_update_zrc20_withdraw_fee.go index 7c72496770..2cdb6f30b0 100644 --- a/x/fungible/keeper/msg_server_update_zrc20_withdraw_fee.go +++ b/x/fungible/keeper/msg_server_update_zrc20_withdraw_fee.go @@ -8,7 +8,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ethcommon "github.com/ethereum/go-ethereum/common" - "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" "github.com/zeta-chain/zetacore/x/fungible/types" zetaObserverTypes "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -36,28 +35,24 @@ func (k Keeper) UpdateZRC20WithdrawFee(goCtx context.Context, msg *types.MsgUpda if err != nil { return nil, cosmoserrors.Wrapf(types.ErrContractCall, "failed to query protocol flat fee (%s)", err.Error()) } - - zrc20ABI, err := zrc20.ZRC20MetaData.GetAbi() + oldGasLimit, err := k.QueryGasLimit(ctx, zrc20Addr) if err != nil { - return nil, cosmoserrors.Wrapf(types.ErrABIGet, "failed to get zrc20 abi") + return nil, cosmoserrors.Wrapf(types.ErrContractCall, "failed to query gas limit (%s)", err.Error()) } - // call the contract method to update the fee + // call the contract methods tmpCtx, commit := ctx.CacheContext() - _, err = k.CallEVM( - tmpCtx, - *zrc20ABI, - types.ModuleAddressEVM, - zrc20Addr, - BigIntZero, - nil, - true, - false, - "updateProtocolFlatFee", - msg.NewWithdrawFee.BigInt(), - ) - if err != nil { - return nil, cosmoserrors.Wrapf(types.ErrContractCall, "failed to call zrc20 contract updateProtocolFlatFee method (%s)", err.Error()) + if !msg.NewWithdrawFee.IsNil() { + _, err = k.UpdateZRC20ProtocolFlatFee(tmpCtx, zrc20Addr, msg.NewWithdrawFee.BigInt()) + if err != nil { + return nil, cosmoserrors.Wrapf(types.ErrContractCall, "failed to call zrc20 contract updateProtocolFlatFee method (%s)", err.Error()) + } + } + if !msg.NewGasLimit.IsNil() { + _, err = k.UpdateZRC20GasLimit(tmpCtx, zrc20Addr, msg.NewGasLimit.BigInt()) + if err != nil { + return nil, cosmoserrors.Wrapf(types.ErrContractCall, "failed to call zrc20 contract updateGasLimit method (%s)", err.Error()) + } } err = ctx.EventManager().EmitTypedEvent( @@ -67,8 +62,10 @@ func (k Keeper) UpdateZRC20WithdrawFee(goCtx context.Context, msg *types.MsgUpda CoinType: coin.CoinType, Zrc20Address: zrc20Addr.Hex(), OldWithdrawFee: oldWithdrawFee.String(), - NewWithdrawFee: msg.NewWithdrawFee.BigInt().String(), + NewWithdrawFee: msg.NewWithdrawFee.String(), Signer: msg.Creator, + OldGasLimit: oldGasLimit.String(), + NewGasLimit: msg.NewGasLimit.String(), }, ) if err != nil { diff --git a/x/fungible/keeper/msg_server_update_zrc20_withdraw_fee_test.go b/x/fungible/keeper/msg_server_update_zrc20_withdraw_fee_test.go index 1b2cc0374b..9de490dc8b 100644 --- a/x/fungible/keeper/msg_server_update_zrc20_withdraw_fee_test.go +++ b/x/fungible/keeper/msg_server_update_zrc20_withdraw_fee_test.go @@ -33,22 +33,56 @@ func TestKeeper_UpdateZRC20WithdrawFee(t *testing.T) { zrc20Addr := setupGasCoin(t, ctx, k, sdkk.EvmKeeper, chainID, "alpha", "alpha") // initial protocol fee is zero - fee, err := k.QueryProtocolFlatFee(ctx, zrc20Addr) + protocolFee, err := k.QueryProtocolFlatFee(ctx, zrc20Addr) require.NoError(t, err) - require.Zero(t, fee.Uint64()) + require.Zero(t, protocolFee.Uint64()) - // can update the fee + // can update the protocol fee and gas limit _, err = k.UpdateZRC20WithdrawFee(ctx, types.NewMsgUpdateZRC20WithdrawFee( admin, zrc20Addr.String(), math.NewUint(42), + math.NewUint(42), )) require.NoError(t, err) // can query the updated fee - fee, err = k.QueryProtocolFlatFee(ctx, zrc20Addr) + protocolFee, err = k.QueryProtocolFlatFee(ctx, zrc20Addr) + require.NoError(t, err) + require.Equal(t, uint64(42), protocolFee.Uint64()) + gasLimit, err := k.QueryGasLimit(ctx, zrc20Addr) require.NoError(t, err) - require.Equal(t, uint64(42), fee.Uint64()) + require.Equal(t, uint64(42), gasLimit.Uint64()) + + // can update protocol fee only + _, err = k.UpdateZRC20WithdrawFee(ctx, types.NewMsgUpdateZRC20WithdrawFee( + admin, + zrc20Addr.String(), + math.NewUint(43), + math.Uint{}, + )) + require.NoError(t, err) + protocolFee, err = k.QueryProtocolFlatFee(ctx, zrc20Addr) + require.NoError(t, err) + require.Equal(t, uint64(43), protocolFee.Uint64()) + gasLimit, err = k.QueryGasLimit(ctx, zrc20Addr) + require.NoError(t, err) + require.Equal(t, uint64(42), gasLimit.Uint64()) + + // can update gas limit only + _, err = k.UpdateZRC20WithdrawFee(ctx, types.NewMsgUpdateZRC20WithdrawFee( + admin, + zrc20Addr.String(), + math.Uint{}, + math.NewUint(44), + )) + require.NoError(t, err) + protocolFee, err = k.QueryProtocolFlatFee(ctx, zrc20Addr) + require.NoError(t, err) + require.Equal(t, uint64(43), protocolFee.Uint64()) + gasLimit, err = k.QueryGasLimit(ctx, zrc20Addr) + require.NoError(t, err) + require.Equal(t, uint64(44), gasLimit.Uint64()) }) t.Run("should fail if not authorized", func(t *testing.T) { @@ -57,8 +91,9 @@ func TestKeeper_UpdateZRC20WithdrawFee(t *testing.T) { _, err := k.UpdateZRC20WithdrawFee(ctx, types.NewMsgUpdateZRC20WithdrawFee( sample.AccAddress(), sample.EthAddress().String(), - math.NewUint(42)), - ) + math.NewUint(42), + math.Uint{}, + )) require.ErrorIs(t, err, sdkerrors.ErrUnauthorized) }) @@ -70,8 +105,9 @@ func TestKeeper_UpdateZRC20WithdrawFee(t *testing.T) { _, err := k.UpdateZRC20WithdrawFee(ctx, types.NewMsgUpdateZRC20WithdrawFee( admin, "invalid_address", - math.NewUint(42)), - ) + math.NewUint(42), + math.Uint{}, + )) require.ErrorIs(t, err, sdkerrors.ErrInvalidAddress) }) @@ -83,8 +119,9 @@ func TestKeeper_UpdateZRC20WithdrawFee(t *testing.T) { _, err := k.UpdateZRC20WithdrawFee(ctx, types.NewMsgUpdateZRC20WithdrawFee( admin, sample.EthAddress().String(), - math.NewUint(42)), - ) + math.NewUint(42), + math.Uint{}, + )) require.ErrorIs(t, err, types.ErrForeignCoinNotFound) }) @@ -102,12 +139,13 @@ func TestKeeper_UpdateZRC20WithdrawFee(t *testing.T) { _, err := k.UpdateZRC20WithdrawFee(ctx, types.NewMsgUpdateZRC20WithdrawFee( admin, zrc20.String(), - math.NewUint(42)), - ) + math.NewUint(42), + math.Uint{}, + )) require.ErrorIs(t, err, types.ErrContractCall) }) - t.Run("should fail if contract call for setting new fee fails", func(t *testing.T) { + t.Run("should fail if contract call for setting new protocol fee fails", func(t *testing.T) { k, ctx, _, zk := keepertest.FungibleKeeperWithMocks(t, keepertest.FungibleMockOptions{UseEVMMock: true}) k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) mockEVMKeeper := keepertest.GetFungibleEVMMock(t, k) @@ -139,6 +177,16 @@ func TestKeeper_UpdateZRC20WithdrawFee(t *testing.T) { false, ).Return(&evmtypes.MsgEthereumTxResponse{Ret: protocolFlatFee}, nil) + gasLimit, err := zrc20ABI.Methods["GAS_LIMIT"].Outputs.Pack(big.NewInt(42)) + require.NoError(t, err) + mockEVMKeeper.On( + "ApplyMessage", + mock.Anything, + mock.Anything, + mock.Anything, + false, + ).Return(&evmtypes.MsgEthereumTxResponse{Ret: gasLimit}, nil) + // this is the update call (commit == true) mockEVMKeeper.On( "ApplyMessage", @@ -151,8 +199,71 @@ func TestKeeper_UpdateZRC20WithdrawFee(t *testing.T) { _, err = k.UpdateZRC20WithdrawFee(ctx, types.NewMsgUpdateZRC20WithdrawFee( admin, zrc20Addr.String(), - math.NewUint(42)), + math.NewUint(42), + math.Uint{}, + )) + require.ErrorIs(t, err, types.ErrContractCall) + + mockEVMKeeper.AssertExpectations(t) + }) + + t.Run("should fail if contract call for setting new protocol fee fails", func(t *testing.T) { + k, ctx, _, zk := keepertest.FungibleKeeperWithMocks(t, keepertest.FungibleMockOptions{UseEVMMock: true}) + k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) + mockEVMKeeper := keepertest.GetFungibleEVMMock(t, k) + + // setup + admin := sample.AccAddress() + setAdminPolicies(ctx, zk, admin, observertypes.Policy_Type_group2) + zrc20Addr := sample.EthAddress() + k.SetForeignCoins(ctx, sample.ForeignCoins(t, zrc20Addr.String())) + + // evm mocks + mockEVMKeeper.On("EstimateGas", mock.Anything, mock.Anything).Maybe().Return( + &evmtypes.EstimateGasResponse{Gas: 1000}, + nil, ) + mockEVMKeeper.On("WithChainID", mock.Anything).Maybe().Return(ctx) + mockEVMKeeper.On("ChainID").Maybe().Return(big.NewInt(1)) + + // this is the query (commit == false) + zrc20ABI, err := zrc20.ZRC20MetaData.GetAbi() + require.NoError(t, err) + protocolFlatFee, err := zrc20ABI.Methods["PROTOCOL_FLAT_FEE"].Outputs.Pack(big.NewInt(42)) + require.NoError(t, err) + mockEVMKeeper.On( + "ApplyMessage", + mock.Anything, + mock.Anything, + mock.Anything, + false, + ).Return(&evmtypes.MsgEthereumTxResponse{Ret: protocolFlatFee}, nil) + + gasLimit, err := zrc20ABI.Methods["GAS_LIMIT"].Outputs.Pack(big.NewInt(42)) + require.NoError(t, err) + mockEVMKeeper.On( + "ApplyMessage", + mock.Anything, + mock.Anything, + mock.Anything, + false, + ).Return(&evmtypes.MsgEthereumTxResponse{Ret: gasLimit}, nil) + + // this is the update call (commit == true) + mockEVMKeeper.On( + "ApplyMessage", + mock.Anything, + mock.Anything, + mock.Anything, + true, + ).Return(&evmtypes.MsgEthereumTxResponse{}, errors.New("transaction failed")) + + _, err = k.UpdateZRC20WithdrawFee(ctx, types.NewMsgUpdateZRC20WithdrawFee( + admin, + zrc20Addr.String(), + math.Uint{}, + math.NewUint(42), + )) require.ErrorIs(t, err, types.ErrContractCall) mockEVMKeeper.AssertExpectations(t) diff --git a/x/fungible/types/events.pb.go b/x/fungible/types/events.pb.go index c00e084019..9f3f881138 100644 --- a/x/fungible/types/events.pb.go +++ b/x/fungible/types/events.pb.go @@ -209,6 +209,8 @@ type EventZRC20WithdrawFeeUpdated struct { OldWithdrawFee string `protobuf:"bytes,5,opt,name=old_withdraw_fee,json=oldWithdrawFee,proto3" json:"old_withdraw_fee,omitempty"` NewWithdrawFee string `protobuf:"bytes,6,opt,name=new_withdraw_fee,json=newWithdrawFee,proto3" json:"new_withdraw_fee,omitempty"` Signer string `protobuf:"bytes,7,opt,name=signer,proto3" json:"signer,omitempty"` + OldGasLimit string `protobuf:"bytes,8,opt,name=old_gas_limit,json=oldGasLimit,proto3" json:"old_gas_limit,omitempty"` + NewGasLimit string `protobuf:"bytes,9,opt,name=new_gas_limit,json=newGasLimit,proto3" json:"new_gas_limit,omitempty"` } func (m *EventZRC20WithdrawFeeUpdated) Reset() { *m = EventZRC20WithdrawFeeUpdated{} } @@ -293,6 +295,20 @@ func (m *EventZRC20WithdrawFeeUpdated) GetSigner() string { return "" } +func (m *EventZRC20WithdrawFeeUpdated) GetOldGasLimit() string { + if m != nil { + return m.OldGasLimit + } + return "" +} + +func (m *EventZRC20WithdrawFeeUpdated) GetNewGasLimit() string { + if m != nil { + return m.NewGasLimit + } + return "" +} + type EventZRC20PausedStatusUpdated struct { MsgTypeUrl string `protobuf:"bytes,1,opt,name=msg_type_url,json=msgTypeUrl,proto3" json:"msg_type_url,omitempty"` Zrc20Addresses []string `protobuf:"bytes,2,rep,name=zrc20_addresses,json=zrc20Addresses,proto3" json:"zrc20_addresses,omitempty"` @@ -371,43 +387,45 @@ func init() { func init() { proto.RegisterFile("fungible/events.proto", fileDescriptor_858e6494730deffd) } var fileDescriptor_858e6494730deffd = []byte{ - // 564 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0xdd, 0x6e, 0xd3, 0x30, - 0x14, 0xc7, 0x97, 0x75, 0xeb, 0x5a, 0x6b, 0x8c, 0x61, 0x0a, 0x0a, 0x1d, 0x44, 0x55, 0xb9, 0xa0, - 0x37, 0x4b, 0xaa, 0x22, 0x1e, 0x60, 0x14, 0x90, 0x26, 0x81, 0x84, 0x3a, 0x26, 0xa4, 0xdd, 0x44, - 0x6e, 0x7c, 0x96, 0x5a, 0x4a, 0xec, 0x28, 0x76, 0xe9, 0xb2, 0xa7, 0xe0, 0x8e, 0x0b, 0xde, 0x84, - 0x27, 0xe0, 0x72, 0xdc, 0x71, 0x89, 0xda, 0x17, 0x41, 0x76, 0xdc, 0x2f, 0x10, 0xa3, 0x57, 0x3d, - 0xc7, 0x3d, 0x1f, 0x3f, 0xff, 0xcf, 0x89, 0xd1, 0x83, 0xcb, 0x31, 0x8f, 0xd9, 0x30, 0x81, 0x00, - 0x3e, 0x01, 0x57, 0xd2, 0xcf, 0x72, 0xa1, 0x04, 0x3e, 0xba, 0x06, 0x45, 0xa2, 0x11, 0x61, 0xdc, - 0x37, 0x96, 0xc8, 0xc1, 0x9f, 0x47, 0x36, 0xef, 0x47, 0x22, 0x4d, 0x05, 0x0f, 0xca, 0x9f, 0x32, - 0xa3, 0x79, 0x6f, 0x51, 0x48, 0x5d, 0xd9, 0xa3, 0x46, 0x2c, 0x62, 0x61, 0xcc, 0x40, 0x5b, 0xe5, - 0x69, 0xfb, 0x9b, 0x83, 0x9a, 0xaf, 0x75, 0xaf, 0xb3, 0x42, 0x2a, 0x48, 0xfb, 0x82, 0xab, 0x9c, - 0x44, 0xea, 0x3c, 0xa3, 0x44, 0x01, 0xc5, 0x2d, 0xb4, 0x9f, 0xca, 0x38, 0x54, 0x45, 0x06, 0xe1, - 0x38, 0x4f, 0x5c, 0xa7, 0xe5, 0x74, 0xea, 0x03, 0x94, 0xca, 0xf8, 0x43, 0x91, 0xc1, 0x79, 0x9e, - 0xe0, 0x2e, 0x6a, 0x70, 0x98, 0x84, 0x91, 0x4d, 0x0c, 0x09, 0xa5, 0x39, 0x48, 0xe9, 0x6e, 0x9b, - 0x48, 0xcc, 0x61, 0x32, 0x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, 0x49, 0x97, 0xfa, 0xed, - 0x9b, 0xc3, 0xf9, 0x8c, 0x3b, 0xe8, 0x50, 0x6f, 0xc5, 0xc4, 0xa2, 0x86, 0x97, 0x00, 0x56, 0xd1, - 0x03, 0x91, 0xd0, 0x95, 0x1b, 0xe8, 0x48, 0xbd, 0x71, 0x6b, 0x91, 0xd5, 0x32, 0x92, 0xc3, 0x64, - 0x35, 0x72, 0xb9, 0x37, 0x7b, 0x6b, 0x7b, 0xf3, 0xc3, 0x41, 0x4f, 0x96, 0xea, 0xbc, 0x27, 0x63, - 0x09, 0xf4, 0x4c, 0x11, 0x35, 0x96, 0x9b, 0xcb, 0xf3, 0x0c, 0xdd, 0x5d, 0xbb, 0x14, 0xe8, 0x95, - 0xaf, 0x68, 0x88, 0xd5, 0x6b, 0x81, 0xc4, 0xef, 0x50, 0x95, 0x44, 0x8a, 0x09, 0x6e, 0x95, 0x7a, - 0xe1, 0xdf, 0xf2, 0x35, 0xfb, 0x25, 0xc0, 0x2a, 0xd2, 0x89, 0x49, 0x1e, 0xd8, 0x22, 0xff, 0xfa, - 0x16, 0x5e, 0x9e, 0x7e, 0x9f, 0x7a, 0xce, 0xcd, 0xd4, 0x73, 0x7e, 0x4d, 0x3d, 0xe7, 0xf3, 0xcc, - 0xdb, 0xba, 0x99, 0x79, 0x5b, 0x3f, 0x67, 0xde, 0xd6, 0x45, 0x10, 0x33, 0x35, 0x1a, 0x0f, 0xf5, - 0x80, 0x02, 0xdd, 0xf0, 0xd8, 0xf4, 0x0e, 0xe6, 0xbd, 0x83, 0xab, 0x60, 0xf9, 0x58, 0x14, 0x19, - 0xc8, 0x61, 0xd5, 0x3c, 0x0d, 0xcf, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0x63, 0xa1, 0x97, 0xec, - 0x8e, 0x04, 0x00, 0x00, + // 593 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcb, 0x6e, 0xd3, 0x4c, + 0x14, 0xae, 0x9b, 0x36, 0x6d, 0xa6, 0x97, 0xbf, 0xff, 0x50, 0x90, 0x49, 0xc1, 0xaa, 0xc2, 0x82, + 0x6e, 0x6a, 0x57, 0x45, 0x3c, 0x40, 0x29, 0x17, 0x55, 0x02, 0x09, 0xa5, 0x54, 0x48, 0xdd, 0x58, + 0x13, 0xcf, 0xa9, 0x3b, 0x92, 0x3d, 0x63, 0x79, 0x26, 0xb8, 0xee, 0x53, 0xb0, 0xe3, 0x5d, 0x78, + 0x02, 0x96, 0x65, 0xc7, 0x12, 0x35, 0x2f, 0x82, 0xe6, 0xe2, 0x5c, 0x40, 0x94, 0xac, 0x72, 0xce, + 0xe4, 0x3b, 0xe7, 0xfb, 0xfc, 0x9d, 0x33, 0x83, 0xee, 0x5f, 0x0c, 0x79, 0xca, 0x06, 0x19, 0x44, + 0xf0, 0x09, 0xb8, 0x92, 0x61, 0x51, 0x0a, 0x25, 0xf0, 0xce, 0x35, 0x28, 0x92, 0x5c, 0x12, 0xc6, + 0x43, 0x13, 0x89, 0x12, 0xc2, 0x06, 0xd9, 0xbd, 0x97, 0x88, 0x3c, 0x17, 0x3c, 0xb2, 0x3f, 0xb6, + 0xa2, 0xfb, 0xff, 0xb8, 0x91, 0xba, 0x72, 0x47, 0xdb, 0xa9, 0x48, 0x85, 0x09, 0x23, 0x1d, 0xd9, + 0xd3, 0xde, 0x57, 0x0f, 0x75, 0x5f, 0x69, 0xae, 0xd3, 0x5a, 0x2a, 0xc8, 0x8f, 0x05, 0x57, 0x25, + 0x49, 0xd4, 0x59, 0x41, 0x89, 0x02, 0x8a, 0x77, 0xd1, 0x7a, 0x2e, 0xd3, 0x58, 0xd5, 0x05, 0xc4, + 0xc3, 0x32, 0xf3, 0xbd, 0x5d, 0x6f, 0xaf, 0xd3, 0x47, 0xb9, 0x4c, 0x3f, 0xd4, 0x05, 0x9c, 0x95, + 0x19, 0x3e, 0x40, 0xdb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8e, 0x34, + 0xe1, 0xbe, 0xe1, 0x8e, 0x1a, 0xee, 0xe8, 0x2a, 0x9a, 0x3c, 0x3a, 0x75, 0x01, 0x72, 0xd0, 0x36, + 0x4f, 0xcc, 0xb3, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xaf, 0x60, 0xaf, 0x2f, 0xd6, 0x04, 0x00, + 0x00, } func (m *EventSystemContractUpdated) Marshal() (dAtA []byte, err error) { @@ -559,6 +577,20 @@ func (m *EventZRC20WithdrawFeeUpdated) MarshalToSizedBuffer(dAtA []byte) (int, e _ = i var l int _ = l + if len(m.NewGasLimit) > 0 { + i -= len(m.NewGasLimit) + copy(dAtA[i:], m.NewGasLimit) + i = encodeVarintEvents(dAtA, i, uint64(len(m.NewGasLimit))) + i-- + dAtA[i] = 0x4a + } + if len(m.OldGasLimit) > 0 { + i -= len(m.OldGasLimit) + copy(dAtA[i:], m.OldGasLimit) + i = encodeVarintEvents(dAtA, i, uint64(len(m.OldGasLimit))) + i-- + dAtA[i] = 0x42 + } if len(m.Signer) > 0 { i -= len(m.Signer) copy(dAtA[i:], m.Signer) @@ -767,6 +799,14 @@ func (m *EventZRC20WithdrawFeeUpdated) Size() (n int) { if l > 0 { n += 1 + l + sovEvents(uint64(l)) } + l = len(m.OldGasLimit) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.NewGasLimit) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } return n } @@ -1493,6 +1533,70 @@ func (m *EventZRC20WithdrawFeeUpdated) Unmarshal(dAtA []byte) error { } m.Signer = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OldGasLimit", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OldGasLimit = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewGasLimit", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NewGasLimit = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipEvents(dAtA[iNdEx:]) diff --git a/x/fungible/types/message_update_zrc20_withdraw_fee.go b/x/fungible/types/message_update_zrc20_withdraw_fee.go index 1b1d6de1ec..fb2b98955c 100644 --- a/x/fungible/types/message_update_zrc20_withdraw_fee.go +++ b/x/fungible/types/message_update_zrc20_withdraw_fee.go @@ -1,6 +1,9 @@ package types import ( + cosmoserror "cosmossdk.io/errors" + math "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ethcommon "github.com/ethereum/go-ethereum/common" @@ -10,11 +13,12 @@ const TypeMsgUpdateZRC20WithdrawFee = "update_zrc20_withdraw_fee" var _ sdk.Msg = &MsgUpdateZRC20WithdrawFee{} -func NewMsgUpdateZRC20WithdrawFee(creator string, zrc20 string, newFee sdk.Uint) *MsgUpdateZRC20WithdrawFee { +func NewMsgUpdateZRC20WithdrawFee(creator string, zrc20 string, newFee math.Uint, newGasLimit math.Uint) *MsgUpdateZRC20WithdrawFee { return &MsgUpdateZRC20WithdrawFee{ Creator: creator, Zrc20Address: zrc20, NewWithdrawFee: newFee, + NewGasLimit: newGasLimit, } } @@ -23,7 +27,7 @@ func (msg *MsgUpdateZRC20WithdrawFee) Route() string { } func (msg *MsgUpdateZRC20WithdrawFee) Type() string { - return TypeMsgUpdateSystemContract + return TypeMsgUpdateZRC20WithdrawFee } func (msg *MsgUpdateZRC20WithdrawFee) GetSigners() []sdk.AccAddress { @@ -42,14 +46,14 @@ func (msg *MsgUpdateZRC20WithdrawFee) GetSignBytes() []byte { func (msg *MsgUpdateZRC20WithdrawFee) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + return cosmoserror.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } // check if the system contract address is valid if !ethcommon.IsHexAddress(msg.Zrc20Address) { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid system contract address (%s)", msg.Zrc20Address) + return cosmoserror.Wrapf(sdkerrors.ErrInvalidAddress, "invalid system contract address (%s)", msg.Zrc20Address) } - if msg.NewWithdrawFee.IsNil() { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid withdraw fee (%s)", msg.NewWithdrawFee) + if msg.NewWithdrawFee.IsNil() && msg.NewGasLimit.IsNil() { + return cosmoserror.Wrapf(sdkerrors.ErrInvalidRequest, "nothing to update") } return nil diff --git a/x/fungible/types/message_update_zrc20_withdraw_fee_test.go b/x/fungible/types/message_update_zrc20_withdraw_fee_test.go index 9c9e3a38b4..2aba73d42a 100644 --- a/x/fungible/types/message_update_zrc20_withdraw_fee_test.go +++ b/x/fungible/types/message_update_zrc20_withdraw_fee_test.go @@ -3,7 +3,8 @@ package types_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" + math "cosmossdk.io/math" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/testutil/sample" @@ -21,7 +22,7 @@ func TestMsgUpdateZRC20WithdrawFee_ValidateBasic(t *testing.T) { msg: types.MsgUpdateZRC20WithdrawFee{ Creator: "invalid_address", Zrc20Address: sample.EthAddress().String(), - NewWithdrawFee: sdk.NewUint(1), + NewWithdrawFee: math.NewUint(1), }, err: sdkerrors.ErrInvalidAddress, }, @@ -30,15 +31,17 @@ func TestMsgUpdateZRC20WithdrawFee_ValidateBasic(t *testing.T) { msg: types.MsgUpdateZRC20WithdrawFee{ Creator: sample.AccAddress(), Zrc20Address: "invalid_address", - NewWithdrawFee: sdk.NewUint(1), + NewWithdrawFee: math.NewUint(1), }, err: sdkerrors.ErrInvalidAddress, }, { - name: "invalid new withdraw fee", + name: "both withdraw fee and gas limit nil", msg: types.MsgUpdateZRC20WithdrawFee{ - Creator: sample.AccAddress(), - Zrc20Address: sample.EthAddress().String(), + Creator: sample.AccAddress(), + Zrc20Address: sample.EthAddress().String(), + NewGasLimit: math.Uint{}, + NewWithdrawFee: math.Uint{}, }, err: sdkerrors.ErrInvalidRequest, }, @@ -47,7 +50,42 @@ func TestMsgUpdateZRC20WithdrawFee_ValidateBasic(t *testing.T) { msg: types.MsgUpdateZRC20WithdrawFee{ Creator: sample.AccAddress(), Zrc20Address: sample.EthAddress().String(), - NewWithdrawFee: sdk.NewUint(1), + NewWithdrawFee: math.NewUint(42), + NewGasLimit: math.NewUint(42), + }, + }, + { + name: "withdraw fee can be zero", + msg: types.MsgUpdateZRC20WithdrawFee{ + Creator: sample.AccAddress(), + Zrc20Address: sample.EthAddress().String(), + NewWithdrawFee: math.ZeroUint(), + NewGasLimit: math.NewUint(42), + }, + }, + { + name: "withdraw fee can be nil", + msg: types.MsgUpdateZRC20WithdrawFee{ + Creator: sample.AccAddress(), + Zrc20Address: sample.EthAddress().String(), + NewGasLimit: math.NewUint(42), + }, + }, + { + name: "gas limit can be zero", + msg: types.MsgUpdateZRC20WithdrawFee{ + Creator: sample.AccAddress(), + Zrc20Address: sample.EthAddress().String(), + NewGasLimit: math.ZeroUint(), + NewWithdrawFee: math.NewUint(42), + }, + }, + { + name: "gas limit can be nil", + msg: types.MsgUpdateZRC20WithdrawFee{ + Creator: sample.AccAddress(), + Zrc20Address: sample.EthAddress().String(), + NewWithdrawFee: math.NewUint(42), }, }, } diff --git a/x/fungible/types/tx.pb.go b/x/fungible/types/tx.pb.go index 41271cd126..476981cc21 100644 --- a/x/fungible/types/tx.pb.go +++ b/x/fungible/types/tx.pb.go @@ -60,6 +60,7 @@ type MsgUpdateZRC20WithdrawFee struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` Zrc20Address string `protobuf:"bytes,2,opt,name=zrc20_address,json=zrc20Address,proto3" json:"zrc20_address,omitempty"` NewWithdrawFee github_com_cosmos_cosmos_sdk_types.Uint `protobuf:"bytes,6,opt,name=new_withdraw_fee,json=newWithdrawFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Uint" json:"new_withdraw_fee"` + NewGasLimit github_com_cosmos_cosmos_sdk_types.Uint `protobuf:"bytes,7,opt,name=new_gas_limit,json=newGasLimit,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Uint" json:"new_gas_limit"` } func (m *MsgUpdateZRC20WithdrawFee) Reset() { *m = MsgUpdateZRC20WithdrawFee{} } @@ -775,64 +776,65 @@ func init() { func init() { proto.RegisterFile("fungible/tx.proto", fileDescriptor_197fdedece277fa0) } var fileDescriptor_197fdedece277fa0 = []byte{ - // 899 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x4b, 0x6f, 0xdb, 0x46, - 0x10, 0x16, 0xad, 0xf8, 0xa1, 0xa9, 0x2d, 0xcb, 0x5b, 0x21, 0x61, 0xe5, 0x42, 0x76, 0x98, 0x02, - 0x51, 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 0xb3, 0xa2, 0x6a, - 0x5f, 0x5d, 0x25, 0x2a, 0x25, 0xf3, 0x52, 0x81, 0xeb, 0x39, 0x63, 0xe7, 0x8b, 0xcb, 0x01, 0x4f, - 0xc6, 0xd5, 0xee, 0x5d, 0x2d, 0x6e, 0x06, 0xa5, 0xa9, 0x07, 0xc3, 0x25, 0x29, 0x4d, 0xc6, 0x5d, - 0x96, 0x52, 0xde, 0x97, 0x5e, 0x36, 0x73, 0xde, 0xd8, 0xba, 0xbb, 0x00, 0x76, 0x36, 0xf0, 0xe2, - 0x66, 0xbe, 0x60, 0xf0, 0x4c, 0xb2, 0x1a, 0x9b, 0x3a, 0x8b, 0xb0, 0xca, 0x06, 0x2e, 0xc4, 0x6a, - 0xd6, 0xd0, 0x38, 0x7c, 0xf8, 0xea, 0xac, 0xae, 0xbc, 0x3e, 0xab, 0x2b, 0xff, 0x9e, 0xd5, 0x95, - 0x97, 0xe7, 0xf5, 0xc2, 0xeb, 0xf3, 0x7a, 0xe1, 0xef, 0xf3, 0x7a, 0xe1, 0xa9, 0x9e, 0x99, 0x55, - 0x21, 0xf4, 0x9e, 0x3c, 0x45, 0x4f, 0x4e, 0xd1, 0x9f, 0xe9, 0x6f, 0x1f, 0xa2, 0xe1, 0xe0, 0xea, - 0xae, 0xc8, 0x47, 0xe4, 0xa7, 0xff, 0x07, 0x00, 0x00, 0xff, 0xff, 0x62, 0x38, 0xf4, 0x5f, 0xa1, - 0x0a, 0x00, 0x00, + // 913 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0xcb, 0x6e, 0xdb, 0x46, + 0x14, 0x15, 0xad, 0xf8, 0xa1, 0x1b, 0x5b, 0x96, 0x59, 0x21, 0x61, 0xe5, 0x42, 0x76, 0x98, 0x02, + 0x51, 0x03, 0x58, 0x74, 0xd5, 0x47, 0x50, 0xa0, 0x4d, 0x61, 0x2b, 0x71, 0x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, 0xea, 0x4b, 0xe3, 0xd3, 0xab, 0x30, 0xa7, 0x65, 0x55, 0xbe, + 0x5c, 0x24, 0x2b, 0x21, 0xf3, 0x5a, 0x81, 0x5b, 0x19, 0xb6, 0xf3, 0xf9, 0xf5, 0x80, 0xc7, 0xf3, + 0x2a, 0x0f, 0x17, 0xcb, 0x9b, 0x42, 0x69, 0xe2, 0x2b, 0xe4, 0x9a, 0x94, 0xc6, 0xf3, 0xae, 0x4b, + 0x29, 0xeb, 0x4d, 0x2f, 0xc5, 0x9c, 0x65, 0x5b, 0x0f, 0xe6, 0xc0, 0x4e, 0x27, 0x5e, 0x2d, 0xe6, + 0x2b, 0x8c, 0x67, 0x9c, 0xd5, 0x88, 0xeb, 0xcc, 0xc3, 0x2a, 0x9d, 0x38, 0x17, 0xab, 0x69, 0xa6, + 0x71, 0xf8, 0xe4, 0xcd, 0x79, 0x55, 0x79, 0x7b, 0x5e, 0x55, 0xfe, 0x39, 0xaf, 0x2a, 0xaf, 0x2f, + 0xaa, 0xb9, 0xb7, 0x17, 0xd5, 0xdc, 0x5f, 0x17, 0xd5, 0xdc, 0x0b, 0x23, 0xe5, 0x55, 0x01, 0xf4, + 0x9e, 0x7c, 0x8a, 0x11, 0x3f, 0xc5, 0x78, 0x69, 0x5c, 0x7e, 0xdd, 0x06, 0xc6, 0xd5, 0x5e, 0x91, + 0x5f, 0xa6, 0x9f, 0xfc, 0x17, 0x00, 0x00, 0xff, 0xff, 0x42, 0x83, 0xe6, 0x96, 0xf6, 0x0a, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1151,6 +1153,16 @@ func (m *MsgUpdateZRC20WithdrawFee) MarshalToSizedBuffer(dAtA []byte) (int, erro _ = i var l int _ = l + { + size := m.NewGasLimit.Size() + i -= size + if _, err := m.NewGasLimit.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a { size := m.NewWithdrawFee.Size() i -= size @@ -1660,6 +1672,8 @@ func (m *MsgUpdateZRC20WithdrawFee) Size() (n int) { } l = m.NewWithdrawFee.Size() n += 1 + l + sovTx(uint64(l)) + l = m.NewGasLimit.Size() + n += 1 + l + sovTx(uint64(l)) return n } @@ -2000,6 +2014,40 @@ func (m *MsgUpdateZRC20WithdrawFee) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewGasLimit", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NewGasLimit.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:])