Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
- [\#512](https://github.com/cosmos/evm/pull/512) Add integration test for appside mempool.
- [\#568](https://github.com/cosmos/evm/pull/568) Avoid unnecessary block notifications when the event bus is already set up.
- [\#511](https://github.com/cosmos/evm/pull/511) Minor code cleanup for `AddPrecompileFn`.
- [\#544](https://github.com/cosmos/evm/pull/544) Parse logs from the txResult.Data and avoid emitting EVM events to cosmos-sdk events.
- [\#576](https://github.com/cosmos/evm/pull/576) Parse logs from the txResult.Data and avoid emitting EVM events to cosmos-sdk events.
- [\#584](https://github.com/cosmos/evm/pull/584) Fill block hash and timestamp for json rpc.
- [\#582](https://github.com/cosmos/evm/pull/582) Add block max-gas (from genesis.json) and new min-tip (from app.toml/flags) ingestion into mempool config
- [\#598](https://github.com/cosmos/evm/pull/598) Reduce number of times CreateQueryContext in mempool.
- [\#606](https://github.com/cosmos/evm/pull/606) Regenerate mock file for bank keeper related test.
Expand Down
273 changes: 205 additions & 68 deletions api/cosmos/evm/vm/v1/tx.pulsar.go

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions proto/cosmos/evm/vm/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ message MsgEthereumTxResponse {
uint64 gas_used = 5;
// max_used_gas specifies the gas consumed by the transaction, not including refunds
uint64 max_used_gas = 6;
// include the block hash for json-rpc to use
bytes block_hash = 7;
// include the block timestamp for json-rpc to use
uint64 block_timestamp = 8;
}

// MsgUpdateParams defines a Msg for updating the x/vm module parameters.
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/x/vm/test_statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,6 @@ func (s *KeeperTestSuite) TestAddLog() {
},
&ethtypes.Log{
Address: addr,
TxHash: txHash,
Topics: make([]common.Hash, 0),
},
func(vm.StateDB) {},
Expand All @@ -743,7 +742,6 @@ func (s *KeeperTestSuite) TestAddLog() {
},
&ethtypes.Log{
Address: addr,
TxHash: txHash3,
Topics: make([]common.Hash, 0),
},
func(vm.StateDB) {},
Expand Down
16 changes: 8 additions & 8 deletions x/vm/keeper/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,15 +506,15 @@ func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context, msg core.Message, trace
if vmError == vm.ErrExecutionReverted.Error() {
ret = evm.Interpreter().ReturnData()
}

logs := stateDB.GetLogs(uint64(ctx.BlockHeight()), common.BytesToHash(ctx.HeaderHash()), evm.Context.Time) //#nosec G115 -- int overflow is not a concern here
return &types.MsgEthereumTxResponse{
GasUsed: gasUsed.TruncateInt().Uint64(),
MaxUsedGas: maxUsedGas,
VmError: vmError,
Ret: ret,
Logs: types.NewLogsFromEth(logs),
Hash: txConfig.TxHash.Hex(),
GasUsed: gasUsed.TruncateInt().Uint64(),
MaxUsedGas: maxUsedGas,
VmError: vmError,
Ret: ret,
Logs: types.NewLogsFromEth(stateDB.Logs()),
Hash: txConfig.TxHash.Hex(),
BlockHash: ctx.HeaderHash(),
BlockTimestamp: evm.Context.Time,
}, nil
}

Expand Down
12 changes: 0 additions & 12 deletions x/vm/statedb/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,23 +218,11 @@ func (s *StateDB) cache() error {
func (s *StateDB) AddLog(log *ethtypes.Log) {
s.journal.append(addLogChange{})

log.TxHash = s.txConfig.TxHash
log.TxIndex = s.txConfig.TxIndex
log.Index = s.txConfig.LogIndex + uint(len(s.logs))
s.logs = append(s.logs, log)
}

// GetLogs returns the logs matching the specified transaction hash, and annotates
// them with the given blockNumber and blockHash.
func (s *StateDB) GetLogs(blockNumber uint64, blockHash common.Hash, blockTime uint64) []*ethtypes.Log {
for _, l := range s.logs {
l.BlockNumber = blockNumber
l.BlockHash = blockHash
l.BlockTimestamp = blockTime
}
return s.logs
}

// Logs returns the logs of current transaction.
func (s *StateDB) Logs() []*ethtypes.Log {
return s.logs
Expand Down
20 changes: 8 additions & 12 deletions x/vm/statedb/statedb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ var (
address common.Address = common.BigToAddress(big.NewInt(101))
address2 common.Address = common.BigToAddress(big.NewInt(102))
address3 common.Address = common.BigToAddress(big.NewInt(103))
blockHash common.Hash = common.BigToHash(big.NewInt(9999))
emptyTxConfig statedb.TxConfig = statedb.NewEmptyTxConfig()
)

Expand Down Expand Up @@ -600,17 +599,14 @@ func (suite *StateDBTestSuite) TestLog() {
})
suite.Require().Equal(1, len(db.Logs()))
expecedLog := &ethtypes.Log{
Address: address,
Topics: []common.Hash{},
Data: data,
BlockNumber: 1,
BlockHash: blockHash,
BlockTimestamp: 1,
TxHash: txHash,
TxIndex: 1,
Index: 1,
Address: address,
Topics: []common.Hash{},
Data: data,
BlockNumber: 1,
TxIndex: 1,
Index: 1,
}
suite.Require().Equal(expecedLog, db.GetLogs(1, blockHash, 1)[0])
suite.Require().Equal(expecedLog, db.Logs()[0])

db.AddLog(&ethtypes.Log{
Address: address,
Expand All @@ -620,7 +616,7 @@ func (suite *StateDBTestSuite) TestLog() {
})
suite.Require().Equal(2, len(db.Logs()))
expecedLog.Index++
suite.Require().Equal(expecedLog, db.GetLogs(1, blockHash, 1)[1])
suite.Require().Equal(expecedLog, db.Logs()[1])
}

func (suite *StateDBTestSuite) TestRefund() {
Expand Down
168 changes: 123 additions & 45 deletions x/vm/types/tx.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions x/vm/types/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ func logsFromTxResponse(dst []*ethtypes.Log, rsp *MsgEthereumTxResponse, blockNu
l := log.ToEthereum()
l.TxHash = txHash
l.BlockNumber = blockNumber
if len(rsp.BlockHash) > 0 {
l.BlockHash = common.BytesToHash(rsp.BlockHash)
}
if rsp.BlockTimestamp > 0 {
l.BlockTimestamp = rsp.BlockTimestamp
}
dst = append(dst, l)
}
return dst
Expand Down
Loading