Skip to content

Commit 1fcfa49

Browse files
yihuangaljo242
andauthored
feat: add block time in derived logs (#502)
* Problem: no block time in derived logs Closes: #501 ref: * ethereum/go-ethereum#31887 * ethereum/execution-apis#639 fix test * change proto * fix tests * fix lint * changelog --------- Co-authored-by: Alex | Interchain Labs <[email protected]>
1 parent ec57b96 commit 1fcfa49

File tree

22 files changed

+388
-288
lines changed

22 files changed

+388
-288
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
### FEATURES
2626

2727
- [\#346](https://github.com/cosmos/evm/pull/346) Add eth_createAccessList method and implementation
28+
- [\#502](https://github.com/cosmos/evm/pull/502) Add block time in derived logs.
2829

2930
### STATE BREAKING
3031

api/cosmos/evm/vm/v1/evm.pulsar.go

Lines changed: 159 additions & 98 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mempool/blockchain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func (b Blockchain) StateAt(hash common.Hash) (vm.StateDB, error) {
199199
}
200200

201201
appHash := ctx.BlockHeader().AppHash
202-
stateDB := statedb.New(ctx, b.vmKeeper, statedb.NewEmptyTxConfig(common.Hash(appHash)))
202+
stateDB := statedb.New(ctx, b.vmKeeper, statedb.NewEmptyTxConfig())
203203

204204
b.logger.Debug("StateDB created successfully", "app_hash", common.Hash(appHash).Hex())
205205
return stateDB, nil

precompiles/common/balance_handler_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func TestAfterBalanceChange(t *testing.T) {
149149
tKey := storetypes.NewTransientStoreKey("test_t")
150150
ctx := sdktestutil.DefaultContext(storeKey, tKey)
151151

152-
stateDB := statedb.New(ctx, mocks.NewEVMKeeper(), statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash())))
152+
stateDB := statedb.New(ctx, mocks.NewEVMKeeper(), statedb.NewEmptyTxConfig())
153153

154154
_, addrs, err := testutil.GeneratePrivKeyAddressPairs(2)
155155
require.NoError(t, err)
@@ -191,7 +191,7 @@ func TestAfterBalanceChangeErrors(t *testing.T) {
191191
storeKey := storetypes.NewKVStoreKey("test")
192192
tKey := storetypes.NewTransientStoreKey("test_t")
193193
ctx := sdktestutil.DefaultContext(storeKey, tKey)
194-
stateDB := statedb.New(ctx, mocks.NewEVMKeeper(), statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash())))
194+
stateDB := statedb.New(ctx, mocks.NewEVMKeeper(), statedb.NewEmptyTxConfig())
195195

196196
_, addrs, err := testutil.GeneratePrivKeyAddressPairs(1)
197197
require.NoError(t, err)

proto/cosmos/evm/vm/v1/evm.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ message Log {
265265
// reorganisation. You must pay attention to this field if you receive logs
266266
// through a filter query.
267267
bool removed = 9;
268+
269+
// block_timestamp is the timestamp of the block in which the transaction was
270+
uint64 block_timestamp = 10 [ (gogoproto.jsontag) = "blockTimestamp" ];
268271
}
269272

270273
// TxResult stores results of Tx execution.

tests/integration/precompiles/gov/test_gov.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,10 @@ func (s *PrecompileTestSuite) TestRun() {
107107
s.Require().NoError(err, "failed to instantiate EVM config")
108108

109109
// Instantiate EVM
110-
headerHash := ctx.HeaderHash()
111110
stDB := statedb.New(
112111
ctx,
113112
s.network.App.GetEVMKeeper(),
114-
statedb.NewEmptyTxConfig(common.BytesToHash(headerHash)),
113+
statedb.NewEmptyTxConfig(),
115114
)
116115
evm := s.network.App.GetEVMKeeper().NewEVM(
117116
ctx, *msg, cfg, nil, stDB,

tests/integration/precompiles/staking/test_staking.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,11 +436,10 @@ func (s *PrecompileTestSuite) TestRun() {
436436
s.Require().NoError(err, "failed to instantiate EVM config")
437437

438438
// Instantiate EVM
439-
headerHash := ctx.HeaderHash()
440439
stDB := statedb.New(
441440
ctx,
442441
s.network.App.GetEVMKeeper(),
443-
statedb.NewEmptyTxConfig(common.BytesToHash(headerHash)),
442+
statedb.NewEmptyTxConfig(),
444443
)
445444
evm := s.network.App.GetEVMKeeper().NewEVM(
446445
ctx, *msg, cfg, nil, stDB,

tests/integration/x/vm/test_genesis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func (s *GenesisTestSuite) TestInitGenesis() {
119119
ctx = s.network.GetContext()
120120
vmdb = statedb.New(
121121
ctx, s.network.App.GetEVMKeeper(),
122-
statedb.NewEmptyTxConfig(common.BytesToHash(ctx.HeaderHash())))
122+
statedb.NewEmptyTxConfig())
123123

124124
tc.malleate(s.network)
125125
err := vmdb.Commit()

tests/integration/x/vm/test_grpc_query.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,6 @@ func (s *KeeperTestSuite) TestQueryTxLogs() {
425425
for _, tc := range testCases {
426426
s.Run(fmt.Sprintf("Case %s", tc.msg), func() {
427427
txCfg := statedb.NewTxConfig(
428-
common.BytesToHash(s.Network.GetContext().HeaderHash()),
429428
txHash,
430429
txIndex,
431430
logIndex,

tests/integration/x/vm/test_hooks.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ func (s *KeeperTestSuite) TestEvmHooks() {
7070
ctx := s.Network.GetContext()
7171
txHash := common.BigToHash(big.NewInt(1))
7272
vmdb := statedb.New(ctx, k, statedb.NewTxConfig(
73-
common.BytesToHash(ctx.HeaderHash()),
7473
txHash,
7574
0,
7675
0,

0 commit comments

Comments
 (0)