From 93598495a9d0236f5a93f56fd0f89a21e728e795 Mon Sep 17 00:00:00 2001 From: Haiyi Zhong Date: Fri, 27 Sep 2024 17:37:02 +0800 Subject: [PATCH] avoid concensus break --- x/axelarnet/message_handler.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/x/axelarnet/message_handler.go b/x/axelarnet/message_handler.go index 74bd42bdb..d612265e3 100644 --- a/x/axelarnet/message_handler.go +++ b/x/axelarnet/message_handler.go @@ -246,6 +246,12 @@ func validateMessage(ctx sdk.Context, ibcK keeper.IBCKeeper, n types.Nexus, ibcP func handleMessage(ctx sdk.Context, n types.Nexus, b types.BankKeeper, sourceAddress nexus.CrossChainAddress, msg Message, token keeper.Coin) error { id, txID, nonce := n.GenerateMessageID(ctx) + // ignore token for call contract + _, err := deductFee(ctx, b, msg.Fee, token, id, sourceAddress.Chain.Name, nexus.ChainName(msg.DestinationChain)) + if err != nil { + return err + } + destChain, ok := n.GetChain(ctx, nexus.ChainName(msg.DestinationChain)) if !ok { // try forwarding it to wasm router if destination chain is not registered @@ -254,12 +260,6 @@ func handleMessage(ctx sdk.Context, n types.Nexus, b types.BankKeeper, sourceAdd destChain = nexus.Chain{Name: destChainName, SupportsForeignAssets: false, KeyType: tss.None, Module: wasm.ModuleName} } - // ignore token for call contract - _, err := deductFee(ctx, b, msg.Fee, token, id, sourceAddress.Chain.Name, destChain.Name) - if err != nil { - return err - } - recipient := nexus.CrossChainAddress{Chain: destChain, Address: msg.DestinationAddress} m := nexus.NewGeneralMessage( id, @@ -287,9 +287,7 @@ func handleMessage(ctx sdk.Context, n types.Nexus, b types.BankKeeper, sourceAdd func handleMessageWithToken(ctx sdk.Context, n types.Nexus, b types.BankKeeper, sourceAddress nexus.CrossChainAddress, msg Message, token keeper.Coin) error { id, txID, nonce := n.GenerateMessageID(ctx) - destChain := funcs.MustOk(n.GetChain(ctx, nexus.ChainName(msg.DestinationChain))) - - token, err := deductFee(ctx, b, msg.Fee, token, id, sourceAddress.Chain.Name, destChain.Name) + token, err := deductFee(ctx, b, msg.Fee, token, id, sourceAddress.Chain.Name, nexus.ChainName(msg.DestinationChain)) if err != nil { return err } @@ -298,6 +296,7 @@ func handleMessageWithToken(ctx sdk.Context, n types.Nexus, b types.BankKeeper, return err } + destChain := funcs.MustOk(n.GetChain(ctx, nexus.ChainName(msg.DestinationChain))) recipient := nexus.CrossChainAddress{Chain: destChain, Address: msg.DestinationAddress} m := nexus.NewGeneralMessage( id,