From 924232f02e901f01f32d31f595de5dc39cdc261e Mon Sep 17 00:00:00 2001 From: yihuang Date: Tue, 14 Dec 2021 22:52:22 +0800 Subject: [PATCH 1/3] fix: empty log topics shouldn't be encoded as nil (#840) * Problem: empty topics shouldn't be encoded as nil Closes: #839 Solution: - encode it as empty array * fix unit tests * changelog --- CHANGELOG.md | 4 ++++ x/evm/keeper/statedb_test.go | 4 ++++ x/evm/types/logs.go | 12 ++++++------ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cf84534fc..ffc7597d80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## Unreleased +### State Machine Breaking + +- (evm) [tharsis#840](https://github.com/tharsis/ethermint/pull/840) Store empty topics as empty array rather than nil. + ### Improvements * (evm) [tharsis#826](https://github.com/tharsis/ethermint/issues/826) Improve allocation of bytes of `tx.To` address. diff --git a/x/evm/keeper/statedb_test.go b/x/evm/keeper/statedb_test.go index 7c69072b45..a3cb8cafdf 100644 --- a/x/evm/keeper/statedb_test.go +++ b/x/evm/keeper/statedb_test.go @@ -592,6 +592,7 @@ func (suite *KeeperTestSuite) TestAddLog() { ðtypes.Log{ Address: addr, TxHash: txHash, + Topics: make([]common.Hash, 0), }, func() {}, }, @@ -606,6 +607,7 @@ func (suite *KeeperTestSuite) TestAddLog() { TxHash: txHash2, TxIndex: 1, Index: 1, + Topics: make([]common.Hash, 0), }, func() { suite.app.EvmKeeper.SetTxHashTransient(txHash) @@ -624,6 +626,7 @@ func (suite *KeeperTestSuite) TestAddLog() { ðtypes.Log{ Address: addr, TxHash: txHash3, + Topics: make([]common.Hash, 0), }, func() {}, }, @@ -638,6 +641,7 @@ func (suite *KeeperTestSuite) TestAddLog() { TxHash: txHash4, TxIndex: 1, Index: 1, + Topics: make([]common.Hash, 0), }, func() { suite.app.EvmKeeper.SetTxHashTransient(txHash) diff --git a/x/evm/types/logs.go b/x/evm/types/logs.go index 75cea38896..4cf73c94dc 100644 --- a/x/evm/types/logs.go +++ b/x/evm/types/logs.go @@ -70,9 +70,9 @@ func (log *Log) Validate() error { // ToEthereum returns the Ethereum type Log from a Ethermint proto compatible Log. func (log *Log) ToEthereum() *ethtypes.Log { - var topics []common.Hash // nolint: prealloc - for i := range log.Topics { - topics = append(topics, common.HexToHash(log.Topics[i])) + topics := make([]common.Hash, len(log.Topics)) + for i, topic := range log.Topics { + topics[i] = common.HexToHash(topic) } return ðtypes.Log{ @@ -108,9 +108,9 @@ func LogsToEthereum(logs []*Log) []*ethtypes.Log { // NewLogFromEth creates a new Log instance from a Ethereum type Log. func NewLogFromEth(log *ethtypes.Log) *Log { - var topics []string // nolint: prealloc - for _, topic := range log.Topics { - topics = append(topics, topic.String()) + topics := make([]string, len(log.Topics)) + for i, topic := range log.Topics { + topics[i] = topic.String() } return &Log{ From 68f1d1c8e61e6d4028b03b14fa93dbcd2bc3e762 Mon Sep 17 00:00:00 2001 From: Prajjwol Gautam Date: Tue, 14 Dec 2021 11:05:03 -0800 Subject: [PATCH 2/3] ci: resort to github's clean up policy (#842) --- .github/workflows/clean-artifacts.yml | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 .github/workflows/clean-artifacts.yml diff --git a/.github/workflows/clean-artifacts.yml b/.github/workflows/clean-artifacts.yml deleted file mode 100644 index 6cd244de89..0000000000 --- a/.github/workflows/clean-artifacts.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Remove old artifacts -# Remove old artifacts runs a crob job that removes old artifacts -# generated from the split tests workflow. - -on: - schedule: - # Every day at 1am - - cron: "0 1 * * *" - -jobs: - remove-old-artifacts: - runs-on: ubuntu-latest - timeout-minutes: 10 - - steps: - - name: Remove old artifacts - uses: c-hive/gha-remove-artifacts@v1.2.0 - with: - age: "7 days" From 5d237a5ee41454424f98cb11d5054d25bc44b3b7 Mon Sep 17 00:00:00 2001 From: Emmanuel T Odeke Date: Tue, 14 Dec 2021 18:05:11 -0800 Subject: [PATCH 3/3] fix: remove duplicated gasPrice derivation (#836) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Noticed in an audit, this change removes a duplicated gasPrice conversion that was first made in: https://github.com/tharsis/ethermint/blob/423944bf799816b6db214fabebcf1b334d3b0826/x/evm/types/tx_args.go#L76-L78 as well as in https://github.com/tharsis/ethermint/blob/423944bf799816b6db214fabebcf1b334d3b0826/x/evm/types/tx_args.go#L88-L90 Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> --- x/evm/types/tx_args.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/x/evm/types/tx_args.go b/x/evm/types/tx_args.go index 85ea7c0ef8..24e16f60e2 100644 --- a/x/evm/types/tx_args.go +++ b/x/evm/types/tx_args.go @@ -85,10 +85,6 @@ func (args *TransactionArgs) ToTransaction() *MsgEthereumTx { maxPriorityFeePerGas = sdk.NewIntFromBigInt(args.MaxPriorityFeePerGas.ToInt()) } - if args.GasPrice != nil { - gasPrice = sdk.NewIntFromBigInt(args.GasPrice.ToInt()) - } - if args.Value != nil { value = sdk.NewIntFromBigInt(args.Value.ToInt()) }