Skip to content

Commit

Permalink
The tracing in precompiles/bank/bank.go needs to use `GetEVMAddress…
Browse files Browse the repository at this point in the history
…OrDefault` otherwise we generate app mistmatches
  • Loading branch information
maoueh committed Jun 13, 2024
1 parent 67bd0af commit 8418897
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
7 changes: 3 additions & 4 deletions precompiles/bank/bank.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,9 @@ func (p Precompile) sendNative(ctx sdk.Context, method *abi.Method, args []inter
}

if hooks := tracers.GetCtxEthTracingHooks(ctx); hooks != nil && hooks.OnBalanceChange != nil && (value.Sign() != 0) {
receveirEvmAddr, found := p.evmKeeper.GetEVMAddress(ctx, receiverSeiAddr)
if !found {
return nil, fmt.Errorf("sei address %s is not associated, this shouldn't happen at this point since SendCoinsAndWei above worked", receiverSeiAddr)
}
// The SendCoinsAndWei function above works with Sei addresses that haven't been associated here. Hence we cannot
// use `GetEVMAddress` and enforce to have a mapping. So we use GetEVMAddressOrDefault to get the EVM address.
receveirEvmAddr := p.evmKeeper.GetEVMAddressOrDefault(ctx, receiverSeiAddr)

tracers.TraceTransferEVMValue(ctx, hooks, p.bankKeeper, senderSeiAddr, caller, receiverSeiAddr, receveirEvmAddr, value)
}
Expand Down
1 change: 1 addition & 0 deletions precompiles/common/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type EVMKeeper interface {
GetSeiAddress(sdk.Context, common.Address) (sdk.AccAddress, bool)
GetSeiAddressOrDefault(ctx sdk.Context, evmAddress common.Address) sdk.AccAddress // only used for getting precompile Sei addresses
GetEVMAddress(sdk.Context, sdk.AccAddress) (common.Address, bool)
GetEVMAddressOrDefault(sdk.Context, sdk.AccAddress) common.Address
GetCodeHash(sdk.Context, common.Address) common.Hash
GetPriorityNormalizer(ctx sdk.Context) sdk.Dec
GetBaseDenom(ctx sdk.Context) string
Expand Down

0 comments on commit 8418897

Please sign in to comment.