diff --git a/app/app.go b/app/app.go index 3b9251cf..7b3605f8 100644 --- a/app/app.go +++ b/app/app.go @@ -140,7 +140,6 @@ import ( validatorvestingrest "github.com/0glabs/0g-chain/x/validator-vesting/client/rest" validatorvestingtypes "github.com/0glabs/0g-chain/x/validator-vesting/types" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/vm" ) var ( @@ -496,6 +495,16 @@ func NewApp( app.accountKeeper, ) + // dasigners keeper + app.dasignersKeeper = dasignerskeeper.NewKeeper(keys[dasignerstypes.StoreKey], appCodec, app.stakingKeeper, govAuthAddrStr) + // precopmiles + precompiles := make(map[common.Address]vm.PrecompiledContract) + daSignersPrecompile, err := dasignersprecompile.NewDASignersPrecompile(app.dasignersKeeper) + if err != nil { + panic("initialize precompile failed") + } + precompiles[daSignersPrecompile.Address()] = daSignersPrecompile + app.evmKeeper = evmkeeper.NewKeeper( appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], govAuthAddr, @@ -503,31 +512,10 @@ func NewApp( app.precisebankKeeper, // x/precisebank in place of x/bank app.stakingKeeper, app.feeMarketKeeper, - vm.NewEVM, options.EVMTrace, evmSubspace, precompiles, ) - // dasigners keeper - app.dasignersKeeper = dasignerskeeper.NewKeeper(keys[dasignerstypes.StoreKey], appCodec, app.stakingKeeper, govAuthAddrStr) - // precopmiles - precompiles := make(map[common.Address]vm.PrecompiledContract) - daSignersPrecompile, err := dasignersprecompile.NewDASignersPrecompile(app.dasignersKeeper) - if err != nil { - panic("initialize precompile failed") - } - precompiles[daSignersPrecompile.Address()] = daSignersPrecompile - - // dasigners keeper - app.dasignersKeeper = dasignerskeeper.NewKeeper(keys[dasignerstypes.StoreKey], appCodec, app.stakingKeeper, govAuthAddrStr) - // precopmiles - precompiles := make(map[common.Address]vm.PrecompiledContract) - daSignersPrecompile, err := dasignersprecompile.NewDASignersPrecompile(app.dasignersKeeper) - if err != nil { - panic("initialize precompile failed") - } - precompiles[daSignersPrecompile.Address()] = daSignersPrecompile - app.evmutilKeeper.SetEvmKeeper(app.evmKeeper) // It's important to note that the PFM Keeper must be initialized before the Transfer Keeper diff --git a/cmd/0gchaind/iavlviewer/data.go b/cmd/0gchaind/iavlviewer/data.go index 6dd63c76..1098a958 100644 --- a/cmd/0gchaind/iavlviewer/data.go +++ b/cmd/0gchaind/iavlviewer/data.go @@ -31,10 +31,7 @@ func newDataCmd(opts ethermintserver.StartOptions) *cobra.Command { } printKeys(tree) - hash, err := tree.Hash() - if err != nil { - return err - } + hash := tree.Hash() fmt.Printf("Hash: %X\n", hash) fmt.Printf("Size: %X\n", tree.Size()) diff --git a/cmd/0gchaind/iavlviewer/hash.go b/cmd/0gchaind/iavlviewer/hash.go index 7e411d32..9fd1d379 100644 --- a/cmd/0gchaind/iavlviewer/hash.go +++ b/cmd/0gchaind/iavlviewer/hash.go @@ -28,11 +28,7 @@ func newHashCmd(opts ethermintserver.StartOptions) *cobra.Command { return err } - hash, err := tree.Hash() - if err != nil { - return err - } - fmt.Printf("Hash: %X\n", hash) + fmt.Printf("Hash: %X\n", tree.Hash()) return nil }, diff --git a/cmd/0gchaind/iavlviewer/root.go b/cmd/0gchaind/iavlviewer/root.go index 822104bd..ea96e01f 100644 --- a/cmd/0gchaind/iavlviewer/root.go +++ b/cmd/0gchaind/iavlviewer/root.go @@ -2,15 +2,19 @@ package iavlviewer import ( "fmt" + "os" "strconv" - dbm "github.com/cometbft/cometbft-db" + "cosmossdk.io/log" + dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/server" + "github.com/cosmos/cosmos-sdk/store/wrapper" ethermintserver "github.com/evmos/ethermint/server" "github.com/spf13/cobra" "github.com/cosmos/iavl" + iavldb "github.com/cosmos/iavl/db" ) const ( @@ -54,7 +58,9 @@ func openPrefixTree(opts ethermintserver.StartOptions, cmd *cobra.Command, prefi } }() - tree, err := readTree(db, version, []byte(prefix)) + cosmosdb := wrapper.NewCosmosDB(db) + + tree, err := readTree(cosmosdb, version, []byte(prefix)) if err != nil { return nil, fmt.Errorf("failed to read tree with prefix %s: %s", prefix, err) } @@ -69,10 +75,7 @@ func readTree(db dbm.DB, version int, prefix []byte) (*iavl.MutableTree, error) db = dbm.NewPrefixDB(db, prefix) } - tree, err := iavl.NewMutableTree(db, DefaultCacheSize, false) - if err != nil { - return nil, err - } + tree := iavl.NewMutableTree(iavldb.NewWrapper(db), DefaultCacheSize, false, log.NewLogger(os.Stdout)) ver, err := tree.LoadVersion(int64(version)) if err != nil { return nil, err diff --git a/cmd/0gchaind/shard.go b/cmd/0gchaind/shard.go index 7840f353..e07f7e3c 100644 --- a/cmd/0gchaind/shard.go +++ b/cmd/0gchaind/shard.go @@ -219,9 +219,12 @@ func shardApplicationDb(multistore *rootmulti.Store, startBlock, endBlock int64) } if len(pruneHeights) > 0 { + // prune application state fmt.Printf("pruning application state to height %d\n", startBlock) - if err := multistore.PruneStores(true, pruneHeights); err != nil { - return fmt.Errorf("failed to prune application state: %s", err) + for _, pruneHeight := range pruneHeights { + if err := multistore.PruneStores(pruneHeight); err != nil { + return fmt.Errorf("failed to prune application state: %s", err) + } } } diff --git a/go.mod b/go.mod index 405035ea..0e05236b 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.21 require ( cosmossdk.io/errors v1.0.1 + cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 cosmossdk.io/simapp v0.0.0-20231127212628-044ff4d8c015 github.com/Kava-Labs/opendb v0.0.0-20240719173129-a2f11f6d7e51 @@ -11,7 +12,8 @@ require ( github.com/cometbft/cometbft v0.37.9 github.com/cometbft/cometbft-db v0.9.1 github.com/coniks-sys/coniks-go v0.0.0-20180722014011-11acf4819b71 - github.com/consensys/gnark-crypto v0.5.3 + github.com/consensys/gnark-crypto v0.12.1 + github.com/cosmos/cosmos-db v1.0.2 github.com/cosmos/cosmos-proto v1.0.0-beta.5 github.com/cosmos/cosmos-sdk v0.47.10 github.com/cosmos/go-bip39 v1.0.0 @@ -51,7 +53,6 @@ require ( cosmossdk.io/api v0.3.1 // indirect cosmossdk.io/core v0.6.1 // indirect cosmossdk.io/depinject v1.0.0-alpha.4 // indirect - cosmossdk.io/log v1.3.1 // indirect cosmossdk.io/tools/rosetta v0.2.1 // indirect filippo.io/edwards25519 v1.0.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect @@ -66,6 +67,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect + github.com/bits-and-blooms/bitset v1.7.0 // indirect github.com/btcsuite/btcd v0.24.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect github.com/btcsuite/btcd/btcutil v1.1.5 // indirect @@ -83,7 +85,6 @@ require ( github.com/confio/ics23/go v0.9.0 // indirect github.com/consensys/bavard v0.1.13 // indirect github.com/cosmos/btcutil v1.0.5 // indirect - github.com/cosmos/cosmos-db v1.0.2 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect @@ -230,6 +231,7 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect nhooyr.io/websocket v1.8.6 // indirect pgregory.net/rapid v1.1.0 // indirect + rsc.io/tmplfunc v0.0.3 // indirect ) replace ( @@ -240,14 +242,15 @@ replace ( github.com/cometbft/cometbft-db => github.com/kava-labs/cometbft-db v0.9.1-kava.2 // Use cosmos-sdk fork with backported fix for unsafe-reset-all, staking transfer events, and custom tally handler support // github.com/cosmos/cosmos-sdk => github.com/0glabs/cosmos-sdk v0.46.11-kava.3 - github.com/cosmos/cosmos-sdk => github.com/0glabs/cosmos-sdk v0.47.10-0glabs.4 + github.com/cosmos/cosmos-sdk => github.com/0glabs/cosmos-sdk v0.47.10-0glabs.5 + github.com/cosmos/iavl => github.com/kava-labs/iavl v1.2.0-kava.1 // See https://github.com/cosmos/cosmos-sdk/pull/13093 github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2 // Tracking kava-labs/go-ethereum kava/release/v1.10 branch // TODO: Tag before release github.com/ethereum/go-ethereum => github.com/evmos/go-ethereum v1.10.26-evmos-rc2 // Use ethermint fork that respects min-gas-price with NoBaseFee true and london enabled, and includes eip712 support - github.com/evmos/ethermint => github.com/0glabs/ethermint v0.21.0-0g.v3.1.0 + github.com/evmos/ethermint => github.com/0glabs/ethermint v0.21.0-0g.v3.1.1 // See https://github.com/cosmos/cosmos-sdk/pull/10401, https://github.com/cosmos/cosmos-sdk/commit/0592ba6158cd0bf49d894be1cef4faeec59e8320 github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.0 // Downgraded to avoid bugs in following commits which causes "version does not exist" errors diff --git a/go.sum b/go.sum index e311000e..0a204ac9 100644 --- a/go.sum +++ b/go.sum @@ -209,10 +209,10 @@ filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek= filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= git.sr.ht/~sircmpwn/getopt v0.0.0-20191230200459-23622cc906b3/go.mod h1:wMEGFFFNuPos7vHmWXfszqImLppbc0wEhh6JBfJIUgw= git.sr.ht/~sircmpwn/go-bare v0.0.0-20210406120253-ab86bc2846d9/go.mod h1:BVJwbDfVjCjoFiKrhkei6NdGcZYpkDkdyCdg1ukytRA= -github.com/0glabs/cosmos-sdk v0.47.10-0glabs.4 h1:y3rHLHDXgXOsnMYFqpBsgrcr3QTYp6UWjPMWNtI/NzQ= -github.com/0glabs/cosmos-sdk v0.47.10-0glabs.4/go.mod h1:c5uoGavjxx3l1jh9ouyruLWxhsIhfrEcyHKgc84BOIo= -github.com/0glabs/ethermint v0.21.0-0g.v3.1.0 h1:DOwcwW6UkFyd7tep0av4xNnogvj9Mdy3NF2YwNgnP2E= -github.com/0glabs/ethermint v0.21.0-0g.v3.1.0/go.mod h1:MjUzm+q5TiZIBNVq29B3a5Lx0A946QXBBvSSqD4l8ks= +github.com/0glabs/cosmos-sdk v0.47.10-0glabs.5 h1:CwL3i7ccMjOXpKnJ9w0WkM7UpTWLXa/W2ZAwpxFUfb8= +github.com/0glabs/cosmos-sdk v0.47.10-0glabs.5/go.mod h1:KskIVnhXTFqrw7CDccMvx7To5KzUsOomIsQV7sPGOog= +github.com/0glabs/ethermint v0.21.0-0g.v3.1.1 h1:mz7WwR0gefTSokmiTugpZEZ1BtQIHZjgi/ufeexrfJw= +github.com/0glabs/ethermint v0.21.0-0g.v3.1.1/go.mod h1:MjUzm+q5TiZIBNVq29B3a5Lx0A946QXBBvSSqD4l8ks= github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs= github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4= github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.1/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM= @@ -413,7 +413,6 @@ github.com/consensys/bavard v0.1.8-0.20210915155054-088da2f7f54a/go.mod h1:9ItSM github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= github.com/consensys/gnark-crypto v0.4.1-0.20210426202927-39ac3d4b3f1f/go.mod h1:815PAHg3wvysy0SyIqanF8gZ0Y1wjk/hrDHD/iT88+Q= -github.com/consensys/gnark-crypto v0.5.3 h1:4xLFGZR3NWEH2zy+YzvzHicpToQR8FXFbfLNvpGB+rE= github.com/consensys/gnark-crypto v0.5.3/go.mod h1:hOdPlWQV1gDLp7faZVeg8Y0iEPFaOUnCc4XeCCk96p0= github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= @@ -439,8 +438,6 @@ github.com/cosmos/gogogateway v1.2.0/go.mod h1:iQpLkGWxYcnCdz5iAdLcRBSw3h7NXeOkZ github.com/cosmos/gogoproto v1.4.2/go.mod h1:cLxOsn1ljAHSV527CHOtaIP91kK6cCrZETRBrkzItWU= github.com/cosmos/gogoproto v1.4.10 h1:QH/yT8X+c0F4ZDacDv3z+xE3WU1P1Z3wQoLMBRJoKuI= github.com/cosmos/gogoproto v1.4.10/go.mod h1:3aAZzeRWpAwr+SS/LLkICX2/kDFyaYVzckBDzygIxek= -github.com/cosmos/iavl v1.2.0 h1:kVxTmjTh4k0Dh1VNL046v6BXqKziqMDzxo93oh3kOfM= -github.com/cosmos/iavl v1.2.0/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.1.3 h1:MZGDMETv72suFpTAD6VPGqSIm1FJcChtk2HmVh9D+Bo= github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.1.3/go.mod h1:UvDmcGIWJPIytq+Q78/ff5NTOsuX/7IrNgEugTW5i0s= github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.1.1-ibc-go-v7.3-wasmvm-v1.5 h1:sMoHjep+KInjMrppNCEutMVm1p8nI9WhKCuMQ+EcUHw= @@ -739,6 +736,7 @@ github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLe github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o= github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw= +github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -908,6 +906,8 @@ github.com/kava-labs/cometbft v0.37.9-kava.1 h1:0mMsAhpV8p0peD9sabIZ//M4nP6LiiZ0 github.com/kava-labs/cometbft v0.37.9-kava.1/go.mod h1:j0Q3RqrCd+cztWCugs3obbzC4NyHGBPZZjtm/fWV00I= github.com/kava-labs/cometbft-db v0.9.1-kava.2 h1:ZQaio886ifvml9XtJB4IYHhlArgA3+/a5Zwidg7H2J8= github.com/kava-labs/cometbft-db v0.9.1-kava.2/go.mod h1:PvUZbx7zeR7I4CAvtKBoii/5ia5gXskKjDjIVpt7gDw= +github.com/kava-labs/iavl v1.2.0-kava.1 h1:HPme3nVrR25XshEFDckMg6fp0tVfpAjTi32/5Iiyuzk= +github.com/kava-labs/iavl v1.2.0-kava.1/go.mod h1:HidWWLVAtODJqFD6Hbne2Y0q3SdxByJepHUOeoH4LiI= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=