diff --git a/CHANGELOG.md b/CHANGELOG.md index 170ec7a334..a44c6db444 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,6 @@ ### State Machine Breaking * [#1407](https://github.com/crypto-org-chain/cronos/pull/1407) Add end-to-end encryption module. -* [#1458](https://github.com/crypto-org-chain/cronos/pull/1458) Adjust require gas for recvPacket when ReceiverChainIsSource. ### Improvements diff --git a/x/cronos/keeper/precompiles/relayer.go b/x/cronos/keeper/precompiles/relayer.go index 8556b2ab82..88d9d3b17d 100644 --- a/x/cronos/keeper/precompiles/relayer.go +++ b/x/cronos/keeper/precompiles/relayer.go @@ -13,8 +13,6 @@ import ( "github.com/ethereum/go-ethereum/params" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" cronosevents "github.com/crypto-org-chain/cronos/v2/x/cronos/events" "github.com/crypto-org-chain/cronos/v2/x/cronos/events/bindings/cosmos/precompile/relayer" "github.com/crypto-org-chain/cronos/v2/x/cronos/types" @@ -60,10 +58,6 @@ const ( UpdateClientAndAcknowledgement = "updateClientAndAcknowledgement" UpdateClientAndTimeout = "updateClientAndTimeout" UpdateClientAndTimeoutOnClose = "updateClientAndTimeoutOnClose" - - GasForUpdateClient = 111894 - GasWhenReceiverChainIsSource = 51705 - GasWhenReceiverChainIsNotSource = 144025 ) func init() { @@ -99,7 +93,7 @@ func init() { case ChannelCloseConfirm: relayerGasRequiredByMethod[methodID] = 31199 case RecvPacket: - relayerGasRequiredByMethod[methodID] = GasWhenReceiverChainIsNotSource + relayerGasRequiredByMethod[methodID] = 144025 case Acknowledgement: relayerGasRequiredByMethod[methodID] = 61781 case Timeout: @@ -113,7 +107,7 @@ func init() { case UpdateClientAndChannelOpenConfirm: relayerGasRequiredByMethod[methodID] = 132734 case UpdateClientAndRecvPacket: - relayerGasRequiredByMethod[methodID] = GasForUpdateClient + GasWhenReceiverChainIsNotSource + relayerGasRequiredByMethod[methodID] = 257120 case UpdateClientAndConnectionOpenInit: relayerGasRequiredByMethod[methodID] = 131649 case UpdateClientAndConnectionOpenAck: @@ -171,34 +165,6 @@ func (bc *RelayerContract) RequiredGas(input []byte) (gas uint64) { var methodID [4]byte copy(methodID[:], input[:4]) requiredGas, ok := relayerGasRequiredByMethod[methodID] - method, err := irelayerABI.MethodById(methodID[:]) - if err != nil { - panic(err) - } - if method.Name == RecvPacket || method.Name == UpdateClientAndRecvPacket { - args, err := method.Inputs.Unpack(input[4:]) - if err != nil { - panic(err) - } - i := args[0].([]byte) - if method.Name == UpdateClientAndRecvPacket { - i = args[1].([]byte) - } - var msg channeltypes.MsgRecvPacket - if err = bc.cdc.Unmarshal(i, &msg); err != nil { - panic(err) - } - var data ibctransfertypes.FungibleTokenPacketData - if err = ibctransfertypes.ModuleCdc.UnmarshalJSON(msg.Packet.GetData(), &data); err != nil { - panic(err) - } - if ibctransfertypes.ReceiverChainIsSource(msg.Packet.GetSourcePort(), msg.Packet.GetSourceChannel(), data.Denom) { - requiredGas = GasWhenReceiverChainIsSource - if method.Name == UpdateClientAndRecvPacket { - requiredGas += GasForUpdateClient - } - } - } intrinsicGas, _ := core.IntrinsicGas(input, nil, false, bc.isHomestead, bc.isIstanbul, bc.isShanghai) defer func() { methodName := relayerMethodNamedByMethod[methodID]