Skip to content

Commit

Permalink
Add block number for receipt (sei-protocol#1682)
Browse files Browse the repository at this point in the history
Fix block number is not written to receipt
  • Loading branch information
yzang2019 authored May 17, 2024
1 parent bdb98c8 commit 2babe51
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions x/evm/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Val
TxHashHex: deferredInfo.TxHash.Hex(),
TransactionIndex: uint32(deferredInfo.TxIndx),
VmError: deferredInfo.Error,
BlockNumber: uint64(ctx.BlockHeight()),
})
continue
}
Expand Down
7 changes: 4 additions & 3 deletions x/evm/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ func TestABCI(t *testing.T) {
surplus, err := s.Finalize()
require.Nil(t, err)
require.Equal(t, sdk.ZeroInt(), surplus)
k.AppendToEvmTxDeferredInfo(ctx.WithTxIndex(1), ethtypes.Bloom{}, common.Hash{}, surplus)
k.AppendToEvmTxDeferredInfo(ctx.WithTxIndex(1), ethtypes.Bloom{}, common.Hash{4}, surplus)
// 3rd tx
s = state.NewDBImpl(ctx.WithTxIndex(3), k, false)
s.SubBalance(evmAddr2, big.NewInt(5000000000000), tracing.BalanceChangeUnspecified)
s.AddBalance(evmAddr1, big.NewInt(5000000000000), tracing.BalanceChangeUnspecified)
surplus, err = s.Finalize()
require.Nil(t, err)
require.Equal(t, sdk.ZeroInt(), surplus)
k.AppendToEvmTxDeferredInfo(ctx.WithTxIndex(3), ethtypes.Bloom{}, common.Hash{}, surplus)
k.AppendToEvmTxDeferredInfo(ctx.WithTxIndex(3), ethtypes.Bloom{}, common.Hash{3}, surplus)
k.SetTxResults([]*abci.ExecTxResult{{Code: 0}, {Code: 0}, {Code: 0}, {Code: 0}})
m.EndBlock(ctx, abci.RequestEndBlock{})
require.Equal(t, uint64(0), k.BankKeeper().GetBalance(ctx, k.AccountKeeper().GetModuleAddress(types.ModuleName), "usei").Amount.Uint64())
Expand All @@ -97,7 +97,7 @@ func TestABCI(t *testing.T) {
surplus, err = s.Finalize()
require.Nil(t, err)
require.Equal(t, sdk.NewInt(1000000000000), surplus)
k.AppendToEvmTxDeferredInfo(ctx.WithTxIndex(2), ethtypes.Bloom{}, common.Hash{}, surplus)
k.AppendToEvmTxDeferredInfo(ctx.WithTxIndex(2), ethtypes.Bloom{}, common.Hash{2}, surplus)
k.SetTxResults([]*abci.ExecTxResult{{Code: 0}, {Code: 0}, {Code: 0}})
m.EndBlock(ctx, abci.RequestEndBlock{})
require.Equal(t, uint64(1), k.BankKeeper().GetBalance(ctx, k.AccountKeeper().GetModuleAddress(types.ModuleName), "usei").Amount.Uint64())
Expand All @@ -110,6 +110,7 @@ func TestABCI(t *testing.T) {
m.EndBlock(ctx, abci.RequestEndBlock{})
receipt, err := k.GetReceipt(ctx, common.Hash{1})
require.Nil(t, err)
require.Equal(t, receipt.BlockNumber, uint64(ctx.BlockHeight()))
require.Equal(t, receipt.VmError, "test error")

// fourth block with locked tokens in coinbase address
Expand Down

0 comments on commit 2babe51

Please sign in to comment.