Skip to content

Commit

Permalink
Problem: custom cache store impl not unified with sdk
Browse files Browse the repository at this point in the history
Solution:
- unify the refactored cache store with sdk

Update CHANGELOG.md

Signed-off-by: yihuang <[email protected]>

mount object stores

fix

fix test

cleanup

fix ctx

fix lint
  • Loading branch information
yihuang committed Apr 1, 2024
1 parent e3e4649 commit 0493897
Show file tree
Hide file tree
Showing 22 changed files with 74 additions and 2,337 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- (feemarket) [#433](https://github.com/crypto-org-chain/ethermint/pull/433) Fix sdk int conversion panic with baseFee.
* (rpc) [#434](https://github.com/crypto-org-chain/ethermint/pull/434) No need gasPrice when patch gasUsed for `eth_getTransactionReceipt`.
* (rpc) [#439](https://github.com/crypto-org-chain/ethermint/pull/439), [#441](https://github.com/crypto-org-chain/ethermint/pull/441) Align trace response for failed tx with go-ethereum.
* (statedb) [#446](https://github.com/crypto-org-chain/ethermint/pull/446) Re-use the cache store implementation with sdk.

### State Machine Breaking

Expand Down
16 changes: 5 additions & 11 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ type EthermintApp struct {
keys map[string]*storetypes.KVStoreKey
tkeys map[string]*storetypes.TransientStoreKey
memKeys map[string]*storetypes.MemoryStoreKey
okeys map[string]*storetypes.ObjectStoreKey

// keepers
AccountKeeper authkeeper.AccountKeeper
Expand Down Expand Up @@ -330,6 +331,7 @@ func NewEthermintApp(
// Add the EVM transient store key
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey, feemarkettypes.TransientKey)
memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
okeys := storetypes.NewObjectStoreKeys(banktypes.ObjectStoreKey)

// load state streaming if enabled
if err := bApp.RegisterStreamingServices(appOpts, keys); err != nil {
Expand All @@ -347,6 +349,7 @@ func NewEthermintApp(
keys: keys,
tkeys: tkeys,
memKeys: memKeys,
okeys: okeys,
}

// init params keeper and subspaces
Expand Down Expand Up @@ -386,6 +389,7 @@ func NewEthermintApp(
app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec,
runtime.NewKVStoreService(keys[banktypes.StoreKey]),
okeys[banktypes.ObjectStoreKey],
app.AccountKeeper,
app.BlockedAddrs(),
authAddr,
Expand Down Expand Up @@ -496,24 +500,13 @@ func NewEthermintApp(

// Set authority to x/gov module account to only expect the module account to update params
evmSs := app.GetSubspace(evmtypes.ModuleName)
allKeys := make(map[string]storetypes.StoreKey, len(keys)+len(tkeys)+len(memKeys))
for k, v := range keys {
allKeys[k] = v
}
for k, v := range tkeys {
allKeys[k] = v
}
for k, v := range memKeys {
allKeys[k] = v
}
app.EvmKeeper = evmkeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(keys[evmtypes.StoreKey]),
keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], authtypes.NewModuleAddress(govtypes.ModuleName),
app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper,
tracer,
nil,
allKeys,
)

// register the proposal types
Expand Down Expand Up @@ -769,6 +762,7 @@ func NewEthermintApp(
app.MountKVStores(keys)
app.MountTransientStores(tkeys)
app.MountMemoryStores(memKeys)
app.MountObjectStores(okeys)

// initialize BaseApp
app.SetInitChainer(app.InitChainer)
Expand Down
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ require (
github.com/spf13/viper v1.18.2
github.com/status-im/keycard-go v0.2.0
github.com/stretchr/testify v1.9.0
github.com/tidwall/btree v1.7.0
github.com/tidwall/gjson v1.14.4
github.com/tidwall/sjson v1.2.5
github.com/tyler-smith/go-bip39 v1.1.0
Expand Down Expand Up @@ -205,6 +204,7 @@ require (
github.com/subosito/gotenv v1.6.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/tidwall/btree v1.7.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
Expand Down Expand Up @@ -241,9 +241,12 @@ require (
)

replace (
cosmossdk.io/store => github.com/yihuang/cosmos-sdk/store v0.0.0-20240401113147-37956eeb8606
// use cosmos keyring
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
github.com/cockroachdb/pebble => github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811
// release/v0.50.x
github.com/cosmos/cosmos-sdk => github.com/crypto-org-chain/cosmos-sdk v0.46.0-beta2.0.20240401080707-77efecc0520d
github.com/ethereum/go-ethereum => github.com/crypto-org-chain/go-ethereum v1.10.20-0.20231207063621-43cf32d91c3e
// Fix upstream GHSA-h395-qcrw-5vmq vulnerability.
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,6 @@ cosmossdk.io/log v1.3.1 h1:UZx8nWIkfbbNEWusZqzAx3ZGvu54TZacWib3EzUYmGI=
cosmossdk.io/log v1.3.1/go.mod h1:2/dIomt8mKdk6vl3OWJcPk2be3pGOS8OQaLUM/3/tCM=
cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
cosmossdk.io/store v1.0.2 h1:lSg5BTvJBHUDwswNNyeh4K/CbqiHER73VU4nDNb8uk0=
cosmossdk.io/store v1.0.2/go.mod h1:EFtENTqVTuWwitGW1VwaBct+yDagk7oG/axBMPH+FXs=
cosmossdk.io/tools/confix v0.1.1 h1:aexyRv9+y15veH3Qw16lxQwo+ki7r2I+g0yNTEFEQM8=
cosmossdk.io/tools/confix v0.1.1/go.mod h1:nQVvP1tHsGXS83PonPVWJtSbddIqyjEw99L4M3rPJyQ=
cosmossdk.io/x/circuit v0.1.0 h1:IAej8aRYeuOMritczqTlljbUVHq1E85CpBqaCTwYgXs=
Expand Down Expand Up @@ -381,8 +379,6 @@ github.com/cosmos/cosmos-db v1.0.2 h1:hwMjozuY1OlJs/uh6vddqnk9j7VamLv+0DBlbEXbAK
github.com/cosmos/cosmos-db v1.0.2/go.mod h1:Z8IXcFJ9PqKK6BIsVOB3QXtkKoqUOp1vRvPT39kOXEA=
github.com/cosmos/cosmos-proto v1.0.0-beta.4 h1:aEL7tU/rLOmxZQ9z4i7mzxcLbSCY48OdY7lIWTLG7oU=
github.com/cosmos/cosmos-proto v1.0.0-beta.4/go.mod h1:oeB+FyVzG3XrQJbJng0EnV8Vljfk9XvTIpGILNU/9Co=
github.com/cosmos/cosmos-sdk v0.50.5-0.20240318121607-9a59234c4202 h1:rQbmfBwvL4PUdRbyor+Ro3WrX1MxjgOIexf5fct6iIQ=
github.com/cosmos/cosmos-sdk v0.50.5-0.20240318121607-9a59234c4202/go.mod h1:VAp+d9UcrbMZyZPetVZBOTQj/lNAOrcD2ADGoFCChCA=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE=
Expand Down Expand Up @@ -417,6 +413,8 @@ github.com/creachadair/tomledit v0.0.24 h1:5Xjr25R2esu1rKCbQEmjZYlrhFkDspoAbAKb6
github.com/creachadair/tomledit v0.0.24/go.mod h1:9qHbShRWQzSCcn617cMzg4eab1vbLCOjOshAWSzWr8U=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/crypto-org-chain/cosmos-sdk v0.46.0-beta2.0.20240401080707-77efecc0520d h1:i7NVRj8FFAcOzfTWLZ8G++qDTSR1fWnRwcTSuBZP/A0=
github.com/crypto-org-chain/cosmos-sdk v0.46.0-beta2.0.20240401080707-77efecc0520d/go.mod h1:nRk8EA8/fEG4zSme2i/Rq5z3k7TrlsHkOYhrY79hhD8=
github.com/crypto-org-chain/go-ethereum v1.10.20-0.20231207063621-43cf32d91c3e h1:vnyepPQ/m25+19xcTuBUdRxmltZ/EjVWNqEjhg7Ummk=
github.com/crypto-org-chain/go-ethereum v1.10.20-0.20231207063621-43cf32d91c3e/go.mod h1:+a8pUj1tOyJ2RinsNQD4326YS+leSoKGiG/uVVb0x6Y=
github.com/danieljoos/wincred v1.2.0 h1:ozqKHaLK0W/ii4KVbbvluM91W2H3Sh0BncbUNPS7jLE=
Expand Down Expand Up @@ -1127,6 +1125,8 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
github.com/yihuang/cosmos-sdk/store v0.0.0-20240401113147-37956eeb8606 h1:A7TTyvAtu7qYR+8AZ5Bb5FATAjWaIHqKTtYlKNQi6pc=
github.com/yihuang/cosmos-sdk/store v0.0.0-20240401113147-37956eeb8606/go.mod h1:lfuLI1f4o+0SGtlHQS4x5qsjRcZZfYqG8bp3k8hM0M8=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
10 changes: 6 additions & 4 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ schema = 3
version = "v1.3.0"
hash = "sha256-EEFK43Cr0g0ndhQhkIKher0FqV3mvkmE9z0sP7uVSHg="
[mod."cosmossdk.io/store"]
version = "v1.0.2"
hash = "sha256-mEaBNfU892M3V6qTMEDXb1GLaywlyouTRC5XfVqNSMs="
version = "v0.0.0-20240401113147-37956eeb8606"
hash = "sha256-0yj6ToF5tiOsJ7B3sBS9lLLEDVrKJxi1tNlqRcWauDw="
replaced = "github.com/yihuang/cosmos-sdk/store"
[mod."cosmossdk.io/tools/confix"]
version = "v0.1.1"
hash = "sha256-/Et2FFhb4XfakbLFvGQK3QxN5Y7alzO+DGfi2/EWbxo="
Expand Down Expand Up @@ -160,8 +161,9 @@ schema = 3
version = "v1.0.0-beta.4"
hash = "sha256-5Kn82nsZfiEtuwhhLZqmMxdAY1tX/Fi3HJ0/MEaRohw="
[mod."github.com/cosmos/cosmos-sdk"]
version = "v0.50.5-0.20240318121607-9a59234c4202"
hash = "sha256-JKBGS1Tcq95mp7UVGIBusf96z6ksZyyDCCyOSacpcFA="
version = "v0.46.0-beta2.0.20240401080707-77efecc0520d"
hash = "sha256-kp8xXSle0X8PW4uIHXmfkGHjj3y6KTpcbvW+oJHsLzI="
replaced = "github.com/crypto-org-chain/cosmos-sdk"
[mod."github.com/cosmos/go-bip39"]
version = "v1.0.0"
hash = "sha256-Qm2aC2vaS8tjtMUbHmlBSagOSqbduEEDwc51qvQaBmA="
Expand Down
140 changes: 0 additions & 140 deletions store/cachekv/README.md

This file was deleted.

44 changes: 0 additions & 44 deletions store/cachekv/bench_helper_test.go

This file was deleted.

Loading

0 comments on commit 0493897

Please sign in to comment.