Skip to content

Commit

Permalink
Add association logic in simulate
Browse files Browse the repository at this point in the history
  • Loading branch information
codchen committed Apr 30, 2024
1 parent 3c6e9f6 commit 3fee83f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions evmrpc/simulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,18 @@ func (b *Backend) StateAtTransaction(ctx context.Context, block *ethtypes.Block,
// set block context time as of the block time (block time is the time of the CURRENT block)
blockContext.Time = block.Time()

// set address association for the sender if not present. Note that here we take the shortcut
// of querying from the latest height with the assumption that if this tx has been processed
// at all then its association must be present in the latest height
_, associated := b.keeper.GetSeiAddress(statedb.Ctx(), msg.From)
if !associated {
seiAddr, associatedNow := b.keeper.GetSeiAddress(b.ctxProvider(LatestCtxHeight), msg.From)
if !associatedNow {
return nil, vm.BlockContext{}, nil, nil, fmt.Errorf("address %s is not associated in the latest height", msg.From.Hex())
}
b.keeper.SetAddressMapping(statedb.Ctx(), seiAddr, msg.From)
}

if idx == txIndex {
return tx, *blockContext, statedb, emptyRelease, nil
}
Expand Down

0 comments on commit 3fee83f

Please sign in to comment.