Skip to content

Commit

Permalink
avoid concensus break
Browse files Browse the repository at this point in the history
  • Loading branch information
haiyizxx committed Sep 30, 2024
1 parent 6472b09 commit 9359849
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions x/axelarnet/message_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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
}
Expand All @@ -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,
Expand Down

0 comments on commit 9359849

Please sign in to comment.