Skip to content

Commit 672a3e7

Browse files
yihuangmmsqe
andauthored
Problem: eth tx sender recovery is slow (#928)
* Problem: eth tx sender recovery is slow Solution: - update ethermint dependency, do it once in ante handler and cache the result * fix build * update upstream * fix lint * fix versiondb * fix memiavl * fix upgrade integration test --------- Co-authored-by: mmsqe <mavis@crypto.com>
1 parent 392eee6 commit 672a3e7

File tree

9 files changed

+162
-127
lines changed

9 files changed

+162
-127
lines changed

app/bench_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ func benchmarkERC20Transfer(b *testing.B, db dbm.DB) {
100100

101101
// mint to sender
102102
amount := int64(100000000)
103-
ret, err := app.CronosKeeper.CallModuleCRC21(ctx, contractAddr, "mint_by_cronos_module", address, big.NewInt(amount))
103+
_, err = app.CronosKeeper.CallModuleCRC21(ctx, contractAddr, "mint_by_cronos_module", address, big.NewInt(amount))
104104
require.NoError(b, err)
105105

106106
// check balance
107-
ret, err = app.CronosKeeper.CallModuleCRC21(ctx, contractAddr, "balanceOf", address)
107+
ret, err := app.CronosKeeper.CallModuleCRC21(ctx, contractAddr, "balanceOf", address)
108108
require.NoError(b, err)
109109
require.Equal(b, uint64(amount), binary.BigEndian.Uint64(ret[32-8:]))
110110

@@ -118,6 +118,7 @@ func benchmarkERC20Transfer(b *testing.B, db dbm.DB) {
118118
idx := int64(i*txsPerBlock + j)
119119
recipient := common.BigToAddress(big.NewInt(idx))
120120
data, err := types.ModuleCRC21Contract.ABI.Pack("transfer", recipient, big.NewInt(1))
121+
require.NoError(b, err)
121122
bz, err := signTx(evmtypes.NewTx(chainID, uint64(idx), &contractAddr, big.NewInt(0), 210000, gasPrice, nil, nil, data, nil))
122123
require.NoError(b, err)
123124
transferTxs = append(transferTxs, bz)

app/upgrades.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
package app
22

33
import (
4+
"fmt"
5+
6+
storetypes "github.com/cosmos/cosmos-sdk/store/types"
47
sdk "github.com/cosmos/cosmos-sdk/types"
58
"github.com/cosmos/cosmos-sdk/types/module"
69
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
10+
gravitytypes "github.com/peggyjv/gravity-bridge/module/v2/x/gravity/types"
711
)
812

913
func (app *App) RegisterUpgradeHandlers() {
@@ -23,4 +27,20 @@ func (app *App) RegisterUpgradeHandlers() {
2327
// `v1.0.0` upgrade plan will clear the `extra_eips` parameters, and upgrade ibc-go to v5.2.0.
2428
planName := "v2.0.0-testnet3"
2529
app.UpgradeKeeper.SetUpgradeHandler(planName, upgradeHandlerV2)
30+
31+
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
32+
if err != nil {
33+
panic(fmt.Sprintf("failed to read upgrade info from disk %s", err))
34+
}
35+
36+
if !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
37+
if upgradeInfo.Name == planName {
38+
storeUpgrades := storetypes.StoreUpgrades{
39+
Added: []string{gravitytypes.StoreKey},
40+
}
41+
42+
// configure store loader that checks if version == upgradeHeight and applies store upgrades
43+
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
44+
}
45+
}
2646
}

go.mod

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
cosmossdk.io/errors v1.0.0-beta.7
77
cosmossdk.io/math v1.0.0-beta.4
88
github.com/armon/go-metrics v0.4.1
9-
github.com/cosmos/cosmos-sdk v0.46.10
9+
github.com/cosmos/cosmos-sdk v0.46.11
1010
github.com/cosmos/gogoproto v1.4.2
1111
github.com/cosmos/ibc-go/v5 v5.2.0
1212
github.com/crypto-org-chain/cronos/versiondb v0.0.0
@@ -22,22 +22,22 @@ require (
2222
github.com/spf13/cast v1.5.0
2323
github.com/spf13/cobra v1.6.1
2424
github.com/spf13/pflag v1.0.5
25-
github.com/stretchr/testify v1.8.1
26-
github.com/tendermint/tendermint v0.34.26
25+
github.com/stretchr/testify v1.8.2
26+
github.com/tendermint/tendermint v0.34.27
2727
github.com/tendermint/tm-db v0.6.7
2828
golang.org/x/exp v0.0.0-20230206171751-46f607a40771
29-
google.golang.org/genproto v0.0.0-20230202175211-008b39050e57
29+
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4
3030
google.golang.org/grpc v1.53.0
3131
google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8
3232
gopkg.in/yaml.v2 v2.4.0
3333
)
3434

3535
require (
36-
cloud.google.com/go v0.107.0 // indirect
37-
cloud.google.com/go/compute v1.15.1 // indirect
36+
cloud.google.com/go v0.110.0 // indirect
37+
cloud.google.com/go/compute v1.18.0 // indirect
3838
cloud.google.com/go/compute/metadata v0.2.3 // indirect
39-
cloud.google.com/go/iam v0.8.0 // indirect
40-
cloud.google.com/go/storage v1.27.0 // indirect
39+
cloud.google.com/go/iam v0.12.0 // indirect
40+
cloud.google.com/go/storage v1.28.1 // indirect
4141
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
4242
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
4343
github.com/99designs/keyring v1.2.1 // indirect
@@ -63,6 +63,7 @@ require (
6363
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
6464
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
6565
github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect
66+
github.com/cometbft/cometbft-db v0.7.0 // indirect
6667
github.com/confio/ics23/go v0.9.0 // indirect
6768
github.com/cosmos/btcutil v1.0.5 // indirect
6869
github.com/cosmos/cosmos-proto v1.0.0-beta.1 // indirect
@@ -102,7 +103,7 @@ require (
102103
github.com/google/go-cmp v0.5.9 // indirect
103104
github.com/google/orderedcode v0.0.1 // indirect
104105
github.com/google/uuid v1.3.0 // indirect
105-
github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect
106+
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
106107
github.com/googleapis/gax-go/v2 v2.7.0 // indirect
107108
github.com/gorilla/handlers v1.5.1 // indirect
108109
github.com/gorilla/websocket v1.5.0 // indirect
@@ -182,18 +183,18 @@ require (
182183
github.com/valyala/histogram v1.2.0 // indirect
183184
github.com/zondax/hid v0.9.1 // indirect
184185
github.com/zondax/ledger-go v0.14.1 // indirect
185-
go.etcd.io/bbolt v1.3.6 // indirect
186+
go.etcd.io/bbolt v1.3.7 // indirect
186187
go.opencensus.io v0.24.0 // indirect
187188
go.uber.org/atomic v1.10.0 // indirect
188-
golang.org/x/crypto v0.6.0 // indirect
189-
golang.org/x/net v0.7.0 // indirect
190-
golang.org/x/oauth2 v0.4.0 // indirect
189+
golang.org/x/crypto v0.7.0 // indirect
190+
golang.org/x/net v0.8.0 // indirect
191+
golang.org/x/oauth2 v0.5.0 // indirect
191192
golang.org/x/sync v0.1.0 // indirect
192-
golang.org/x/sys v0.5.0 // indirect
193-
golang.org/x/term v0.5.0 // indirect
194-
golang.org/x/text v0.7.0 // indirect
193+
golang.org/x/sys v0.6.0 // indirect
194+
golang.org/x/term v0.6.0 // indirect
195+
golang.org/x/text v0.8.0 // indirect
195196
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
196-
google.golang.org/api v0.103.0 // indirect
197+
google.golang.org/api v0.110.0 // indirect
197198
google.golang.org/appengine v1.6.7 // indirect
198199
gopkg.in/ini.v1 v1.67.0 // indirect
199200
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
@@ -203,13 +204,15 @@ require (
203204
)
204205

205206
replace (
207+
// https://github.com/cometbft/cometbft-db/pull/42
208+
github.com/cometbft/cometbft-db => github.com/crypto-org-chain/cometbft-db v0.0.0-20230306031617-b3e4fd3331c4
206209
// Ref: https://forum.cosmos.network/t/ibc-security-advisory-dragonberry/7702
207210
github.com/confio/ics23/go => github.com/confio/ics23/go v0.9.0
208-
github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.46.10
211+
github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.46.11
209212
github.com/crypto-org-chain/cronos/memiavl => ./memiavl
210213
github.com/crypto-org-chain/cronos/versiondb => ./versiondb
211214
github.com/ethereum/go-ethereum => github.com/crypto-org-chain/go-ethereum v1.10.19-deepcopy-jumptable
212-
github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.20.4-cronos
215+
github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.20.8-cronos.0.20230315032257-cb741e1d8196
213216
// Fix upstream GHSA-h395-qcrw-5vmq vulnerability.
214217
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
215218
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0
@@ -219,10 +222,10 @@ replace (
219222
github.com/miguelmota/go-ethereum-hdwallet => github.com/crypto-org-chain/go-ethereum-hdwallet v0.1.2
220223

221224
github.com/peggyjv/gravity-bridge/module/v2 => github.com/crypto-org-chain/gravity-bridge/module/v2 v2.0.1-0.20230126051749-d984b1562242
222-
223-
// use informal system fork of tendermint
224-
github.com/tendermint/tendermint => github.com/informalsystems/tendermint v0.34.26
225+
// use cometbft
226+
github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.27
225227
// https://github.com/crypto-org-chain/tm-db/tree/release/v0.6.x
228+
// still need this replacement for indirect dependencies on tm-db
226229
github.com/tendermint/tm-db => github.com/crypto-org-chain/tm-db v0.6.8-0.20230118040049-14dc6b00a5b3
227230

228231
// TODO: remove after fixed https://github.com/cosmos/cosmos-sdk/issues/11364

0 commit comments

Comments
 (0)