From d8fb3e04ba0705ed11e57c2a170d21a50ca7c538 Mon Sep 17 00:00:00 2001 From: Devon Bear Date: Thu, 2 Nov 2023 13:15:40 -0400 Subject: [PATCH 1/4] reset gas meter in prepare proposal --- cosmos/go.mod | 1 + cosmos/go.sum | 1 + cosmos/miner/miner.go | 21 ++++++++++++++++----- cosmos/x/evm/keeper/processor.go | 3 ++- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/cosmos/go.mod b/cosmos/go.mod index 0df1cd382..71c74ba1a 100644 --- a/cosmos/go.mod +++ b/cosmos/go.mod @@ -16,6 +16,7 @@ require ( cosmossdk.io/log v1.2.1 cosmossdk.io/math v1.1.3-rc.1 cosmossdk.io/store v1.0.0-rc.0 + cosmossdk.io/x/evidence v0.0.0-20230818115413-c402c51a1508 cosmossdk.io/x/tx v0.11.0 github.com/btcsuite/btcd v0.23.2 github.com/btcsuite/btcd/btcutil v1.1.3 diff --git a/cosmos/go.sum b/cosmos/go.sum index 01aa4eddc..8b47e6e91 100644 --- a/cosmos/go.sum +++ b/cosmos/go.sum @@ -51,6 +51,7 @@ cosmossdk.io/math v1.1.3-rc.1 h1:NebCNWDqb1MJRNfvxr4YY7d8FSYgkuB3L75K6xvM+Zo= cosmossdk.io/math v1.1.3-rc.1/go.mod h1:l2Gnda87F0su8a/7FEKJfFdJrM0JZRXQaohlgJeyQh0= cosmossdk.io/store v1.0.0-rc.0 h1:9DwOjuUYxDtYxn/REkTxGQAmxlIGfRroB35MQ8TrxF4= cosmossdk.io/store v1.0.0-rc.0/go.mod h1:FtBDOJmwtOZfmKKF65bKZbTYgS3bDNjjo3nP76dAegk= +cosmossdk.io/x/evidence v0.0.0-20230818115413-c402c51a1508 h1:R9H1lDpcPSkrLOnt6IDE38o0Wp8xE/+BAxocb0oyX4I= cosmossdk.io/x/tx v0.11.0 h1:Ak2LIC06bXqPbpMIEorkQbwVddRvRys1sL3Cjm+KPfs= cosmossdk.io/x/tx v0.11.0/go.mod h1:tzuC7JlfGivYuIO32JbvvY3Ft9s6FK1+r0/nGHiHwtM= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= diff --git a/cosmos/miner/miner.go b/cosmos/miner/miner.go index 10bccbc69..66caee826 100644 --- a/cosmos/miner/miner.go +++ b/cosmos/miner/miner.go @@ -23,6 +23,9 @@ package miner import ( "context" + "fmt" + + storetypes "cosmossdk.io/store/types" abci "github.com/cometbft/cometbft/abci/types" @@ -90,11 +93,6 @@ func (m *Miner) PrepareProposal( err error ) - // We have to prime the state plugin. - if err = m.keeper.SetLatestQueryContext(ctx); err != nil { - return nil, err - } - // We have to run the PreBlocker && BeginBlocker to get the chain into the state // it'll be in when the EVM transaction actually runs. if _, err = m.app.PreBlocker(ctx, nil); err != nil { @@ -103,6 +101,19 @@ func (m *Miner) PrepareProposal( return nil, err } + fmt.Println(ctx.GasMeter().GasConsumed(), "REEE") + + ctx.GasMeter().RefundGas(ctx.GasMeter().GasConsumed(), "prepare proposal") + ctx.BlockGasMeter().RefundGas(ctx.BlockGasMeter().GasConsumed(), "prepare proposal") + ctx = ctx.WithKVGasConfig(storetypes.GasConfig{}). + WithTransientKVGasConfig(storetypes.GasConfig{}). + WithGasMeter(storetypes.NewInfiniteGasMeter()) + + // We have to prime the state plugin. + if err = m.keeper.SetLatestQueryContext(ctx); err != nil { + return nil, err + } + // Trigger the geth miner to build a block. if payloadEnvelopeBz, err = m.buildBlock(ctx); err != nil { return nil, err diff --git a/cosmos/x/evm/keeper/processor.go b/cosmos/x/evm/keeper/processor.go index 38d3037ac..d29b95b8e 100644 --- a/cosmos/x/evm/keeper/processor.go +++ b/cosmos/x/evm/keeper/processor.go @@ -48,7 +48,8 @@ func (k *Keeper) ProcessPayloadEnvelope( // Reset GasMeter to 0. gasMeter.RefundGas(gasMeter.GasConsumed(), "reset before evm block") blockGasMeter.RefundGas(blockGasMeter.GasConsumed(), "reset before evm block") - defer gasMeter.ConsumeGas(gasMeter.GasConsumed(), "reset after evm") + defer gasMeter.RefundGas(gasMeter.GasConsumed(), "reset after evm") + defer blockGasMeter.RefundGas(blockGasMeter.GasConsumed(), "reset after evm") if err = envelope.UnmarshalJSON(msg.Data); err != nil { return nil, fmt.Errorf("failed to unmarshal payload envelope: %w", err) From 5c2401b0a8a4867f7dcad93717f30c0d912b786f Mon Sep 17 00:00:00 2001 From: Devon Bear Date: Thu, 2 Nov 2023 13:16:28 -0400 Subject: [PATCH 2/4] tidy sync --- cosmos/go.mod | 1 - cosmos/go.sum | 1 - e2e/testapp/go.mod | 12 +++++++----- e2e/testapp/go.sum | 47 ++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 46 insertions(+), 15 deletions(-) diff --git a/cosmos/go.mod b/cosmos/go.mod index 71c74ba1a..0df1cd382 100644 --- a/cosmos/go.mod +++ b/cosmos/go.mod @@ -16,7 +16,6 @@ require ( cosmossdk.io/log v1.2.1 cosmossdk.io/math v1.1.3-rc.1 cosmossdk.io/store v1.0.0-rc.0 - cosmossdk.io/x/evidence v0.0.0-20230818115413-c402c51a1508 cosmossdk.io/x/tx v0.11.0 github.com/btcsuite/btcd v0.23.2 github.com/btcsuite/btcd/btcutil v1.1.3 diff --git a/cosmos/go.sum b/cosmos/go.sum index 8b47e6e91..01aa4eddc 100644 --- a/cosmos/go.sum +++ b/cosmos/go.sum @@ -51,7 +51,6 @@ cosmossdk.io/math v1.1.3-rc.1 h1:NebCNWDqb1MJRNfvxr4YY7d8FSYgkuB3L75K6xvM+Zo= cosmossdk.io/math v1.1.3-rc.1/go.mod h1:l2Gnda87F0su8a/7FEKJfFdJrM0JZRXQaohlgJeyQh0= cosmossdk.io/store v1.0.0-rc.0 h1:9DwOjuUYxDtYxn/REkTxGQAmxlIGfRroB35MQ8TrxF4= cosmossdk.io/store v1.0.0-rc.0/go.mod h1:FtBDOJmwtOZfmKKF65bKZbTYgS3bDNjjo3nP76dAegk= -cosmossdk.io/x/evidence v0.0.0-20230818115413-c402c51a1508 h1:R9H1lDpcPSkrLOnt6IDE38o0Wp8xE/+BAxocb0oyX4I= cosmossdk.io/x/tx v0.11.0 h1:Ak2LIC06bXqPbpMIEorkQbwVddRvRys1sL3Cjm+KPfs= cosmossdk.io/x/tx v0.11.0/go.mod h1:tzuC7JlfGivYuIO32JbvvY3Ft9s6FK1+r0/nGHiHwtM= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= diff --git a/e2e/testapp/go.mod b/e2e/testapp/go.mod index aa34d4249..6a02922a8 100644 --- a/e2e/testapp/go.mod +++ b/e2e/testapp/go.mod @@ -26,8 +26,8 @@ require ( github.com/onsi/gomega v1.27.10 github.com/spf13/cobra v1.7.0 github.com/spf13/viper v1.16.0 - pkg.berachain.dev/polaris/cosmos v0.0.0-20231012162131-c1edabdcf30e - pkg.berachain.dev/polaris/eth v0.0.0-20231010191645-a5ed99983be4 + pkg.berachain.dev/polaris/cosmos v0.0.0-20231101202254-949a826ae454 + pkg.berachain.dev/polaris/eth v0.0.0-20231031220135-f3bf0d0ee45f ) require ( @@ -52,7 +52,10 @@ require ( 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.8.0 // indirect + github.com/btcsuite/btcd v0.23.2 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect + github.com/btcsuite/btcd/btcutil v1.1.3 // indirect + github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect github.com/bytedance/sonic v1.10.0 // indirect github.com/cenkalti/backoff/v4 v4.2.0 // indirect github.com/cespare/xxhash v1.1.0 // indirect @@ -89,7 +92,6 @@ require ( github.com/dgraph-io/badger/v2 v2.2007.4 // indirect github.com/dgraph-io/ristretto v0.1.1 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect - github.com/docker/docker v24.0.7+incompatible // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.5.0 // indirect github.com/emicklei/dot v1.6.0 // indirect @@ -266,8 +268,8 @@ require ( gotest.tools/v3 v3.5.1 // indirect nhooyr.io/websocket v1.8.6 // indirect pgregory.net/rapid v1.1.0 // indirect - pkg.berachain.dev/polaris/contracts v0.0.0-20231010191645-a5ed99983be4 // indirect - pkg.berachain.dev/polaris/lib v0.0.0-20231010191645-a5ed99983be4 // indirect + pkg.berachain.dev/polaris/contracts v0.0.0-20231023174626-bf146d519cd3 // indirect + pkg.berachain.dev/polaris/lib v0.0.0-20231031220135-f3bf0d0ee45f // indirect rsc.io/tmplfunc v0.0.3 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) diff --git a/e2e/testapp/go.sum b/e2e/testapp/go.sum index 889a8f6f8..49ba73122 100644 --- a/e2e/testapp/go.sum +++ b/e2e/testapp/go.sum @@ -243,6 +243,7 @@ github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrd github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I= github.com/adlio/schema v1.3.3/go.mod h1:1EsRssiv9/Ce2CMzq5DoL7RiMshhuigQxrR4DMV9fHg= +github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -283,12 +284,31 @@ github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsy github.com/bits-and-blooms/bitset v1.8.0 h1:FD+XqgOZDUxxZ8hzoBFuV9+cGWY9CslN6d5MS5JVb4c= github.com/bits-and-blooms/bitset v1.8.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= +github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= +github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= +github.com/btcsuite/btcd v0.23.0/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY= +github.com/btcsuite/btcd v0.23.2 h1:/YOgUp25sdCnP5ho6Hl3s0E438zlX+Kak7E6TgBgoT0= +github.com/btcsuite/btcd v0.23.2/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY= +github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA= +github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= +github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= +github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE= github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ= github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= +github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= +github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= +github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= +github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= +github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= +github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/bufbuild/protocompile v0.6.0 h1:Uu7WiSQ6Yj9DbkdnOe7U4mNKp58y9WDMKDn28/ZlunY= github.com/bufbuild/protocompile v0.6.0/go.mod h1:YNP35qEYoYGme7QMtz5SBCoN4kL4g12jTtjuzRNdjpE= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= @@ -403,15 +423,19 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/danieljoos/wincred v1.2.0 h1:ozqKHaLK0W/ii4KVbbvluM91W2H3Sh0BncbUNPS7jLE= github.com/danieljoos/wincred v1.2.0/go.mod h1:FzQLLMKBFdvu+osBrnFODiv32YGwCfx0SkRa/eYHgec= +github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/deckarep/golang-set/v2 v2.3.1 h1:vjmkvJt/IV27WXPyYQpAh4bRyWJc5Y435D17XQ9QU5A= github.com/deckarep/golang-set/v2 v2.3.1/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= +github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/deepmap/oapi-codegen v1.13.4 h1:lRRQ8JAXaz5/4oidKFyk3fFZFQsbv0BzRtvDKDnvIfM= github.com/deepmap/oapi-codegen v1.13.4/go.mod h1:/h5nFQbTAMz4S/WtBz8sBfamlGByYKDr21O2uoNgCYI= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= @@ -786,6 +810,8 @@ github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097 h1:vilfsD github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= +github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jhump/protoreflect v1.15.2 h1:7YppbATX94jEt9KLAc5hICx4h6Yt3SaavhQRsIUEHP0= github.com/jhump/protoreflect v1.15.2/go.mod h1:4ORHmSBmlCW8fh3xHmJMGyul1zNqZK4Elxc8qKP+p1k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= @@ -797,6 +823,7 @@ github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -815,6 +842,7 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW 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= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= @@ -946,6 +974,7 @@ github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4= github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= +github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= @@ -1202,6 +1231,7 @@ go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.4.0 h1:A8WCeEWhLwPBKNbFi5Wv5UTCBx5zzubnXDlMOFAzFMc= golang.org/x/arch v0.4.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -1259,6 +1289,7 @@ golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1853,14 +1884,14 @@ nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0 nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= pgregory.net/rapid v1.1.0 h1:CMa0sjHSru3puNx+J0MIAuiiEV4N0qj8/cMWGBBCsjw= pgregory.net/rapid v1.1.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= -pkg.berachain.dev/polaris/contracts v0.0.0-20231010191645-a5ed99983be4 h1:q9gSJk2kQQbz/3cPcXGCW+JdQvxAm+7ukcDqzZiUcmw= -pkg.berachain.dev/polaris/contracts v0.0.0-20231010191645-a5ed99983be4/go.mod h1:LwuVx7lVFkIa/EXGNz2536i+YTK/mEU4A1vQJFZ8y4Q= -pkg.berachain.dev/polaris/cosmos v0.0.0-20231012162131-c1edabdcf30e h1:wpN0jFBorlIymQH41f1Wx1MHgODABs1sAeHMI6fg1kw= -pkg.berachain.dev/polaris/cosmos v0.0.0-20231012162131-c1edabdcf30e/go.mod h1:SeId0o7/S/oz7n7Ix9GMihe49jCZIDpTTBPyVReyM7k= -pkg.berachain.dev/polaris/eth v0.0.0-20231010191645-a5ed99983be4 h1:gOqKP7ZCzIU1NZrwdISnxswAatut/6Xi7JjdSpHbZk8= -pkg.berachain.dev/polaris/eth v0.0.0-20231010191645-a5ed99983be4/go.mod h1:HuT/i4PZCz3ItXAvDWHA31z4OZ10we6RH6xz+Fq0Nlw= -pkg.berachain.dev/polaris/lib v0.0.0-20231010191645-a5ed99983be4 h1:3zGPs5JJpBtysLMNWa5wKEhwC+j3p5AAK0gZ1fWuEc8= -pkg.berachain.dev/polaris/lib v0.0.0-20231010191645-a5ed99983be4/go.mod h1:OcMl9wH8872Q4++ikKXIm1FC4FbuGUWHxrjb6LCzvIY= +pkg.berachain.dev/polaris/contracts v0.0.0-20231023174626-bf146d519cd3 h1:HuPF3//LfKdnWf4kBKsEBTIvtyzD7ikz/KdoKGxYzDg= +pkg.berachain.dev/polaris/contracts v0.0.0-20231023174626-bf146d519cd3/go.mod h1:YZZ0c17iFXlmnPyi59b/uaTD4IH71YrMQVn6W9PCVsY= +pkg.berachain.dev/polaris/cosmos v0.0.0-20231101202254-949a826ae454 h1:p0VrUGKALVr9lPkC24mfQD5E9QIa3fEGZ+VCjSviUqs= +pkg.berachain.dev/polaris/cosmos v0.0.0-20231101202254-949a826ae454/go.mod h1:rwvWL1M9Lo4iIDR1JEBx3rVZR7bgepxV+KI3y8HpxhY= +pkg.berachain.dev/polaris/eth v0.0.0-20231031220135-f3bf0d0ee45f h1:ig3uCqDoaCvbZ4uVDGWeADSSUBAFr8QOAbirQBLFdE8= +pkg.berachain.dev/polaris/eth v0.0.0-20231031220135-f3bf0d0ee45f/go.mod h1:oMkuuC++8LHdw05BX+QHtzX/YHMAKZHnE/fWBMMa+P8= +pkg.berachain.dev/polaris/lib v0.0.0-20231031220135-f3bf0d0ee45f h1:mho28mqM87UH9A3fBeC3qugV2u9QgOpYJnc1zZkfZQs= +pkg.berachain.dev/polaris/lib v0.0.0-20231031220135-f3bf0d0ee45f/go.mod h1:6w+5Axb6GV66PLllrYf7h1G3x8Pwu5nvd7ZiibiI3HM= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= From 15af6f32ed0fb5e7e459d901c11e726fba9dd73f Mon Sep 17 00:00:00 2001 From: Devon Bear Date: Thu, 2 Nov 2023 13:18:06 -0400 Subject: [PATCH 3/4] lint --- cosmos/miner/miner.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/cosmos/miner/miner.go b/cosmos/miner/miner.go index 66caee826..4d5b3daac 100644 --- a/cosmos/miner/miner.go +++ b/cosmos/miner/miner.go @@ -23,7 +23,6 @@ package miner import ( "context" - "fmt" storetypes "cosmossdk.io/store/types" @@ -101,8 +100,6 @@ func (m *Miner) PrepareProposal( return nil, err } - fmt.Println(ctx.GasMeter().GasConsumed(), "REEE") - ctx.GasMeter().RefundGas(ctx.GasMeter().GasConsumed(), "prepare proposal") ctx.BlockGasMeter().RefundGas(ctx.BlockGasMeter().GasConsumed(), "prepare proposal") ctx = ctx.WithKVGasConfig(storetypes.GasConfig{}). From 1aa9047c2f58d7f19fee5798cc60182f09a085c3 Mon Sep 17 00:00:00 2001 From: Devon Bear Date: Thu, 2 Nov 2023 13:20:18 -0400 Subject: [PATCH 4/4] lint --- cosmos/go.mod | 1 + cosmos/go.sum | 1 + cosmos/miner/msgs.go | 78 ++++++++++++++++++++++++++++++++ cosmos/x/evm/keeper/processor.go | 4 ++ 4 files changed, 84 insertions(+) create mode 100644 cosmos/miner/msgs.go diff --git a/cosmos/go.mod b/cosmos/go.mod index 0df1cd382..71c74ba1a 100644 --- a/cosmos/go.mod +++ b/cosmos/go.mod @@ -16,6 +16,7 @@ require ( cosmossdk.io/log v1.2.1 cosmossdk.io/math v1.1.3-rc.1 cosmossdk.io/store v1.0.0-rc.0 + cosmossdk.io/x/evidence v0.0.0-20230818115413-c402c51a1508 cosmossdk.io/x/tx v0.11.0 github.com/btcsuite/btcd v0.23.2 github.com/btcsuite/btcd/btcutil v1.1.3 diff --git a/cosmos/go.sum b/cosmos/go.sum index 01aa4eddc..8b47e6e91 100644 --- a/cosmos/go.sum +++ b/cosmos/go.sum @@ -51,6 +51,7 @@ cosmossdk.io/math v1.1.3-rc.1 h1:NebCNWDqb1MJRNfvxr4YY7d8FSYgkuB3L75K6xvM+Zo= cosmossdk.io/math v1.1.3-rc.1/go.mod h1:l2Gnda87F0su8a/7FEKJfFdJrM0JZRXQaohlgJeyQh0= cosmossdk.io/store v1.0.0-rc.0 h1:9DwOjuUYxDtYxn/REkTxGQAmxlIGfRroB35MQ8TrxF4= cosmossdk.io/store v1.0.0-rc.0/go.mod h1:FtBDOJmwtOZfmKKF65bKZbTYgS3bDNjjo3nP76dAegk= +cosmossdk.io/x/evidence v0.0.0-20230818115413-c402c51a1508 h1:R9H1lDpcPSkrLOnt6IDE38o0Wp8xE/+BAxocb0oyX4I= cosmossdk.io/x/tx v0.11.0 h1:Ak2LIC06bXqPbpMIEorkQbwVddRvRys1sL3Cjm+KPfs= cosmossdk.io/x/tx v0.11.0/go.mod h1:tzuC7JlfGivYuIO32JbvvY3Ft9s6FK1+r0/nGHiHwtM= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= diff --git a/cosmos/miner/msgs.go b/cosmos/miner/msgs.go new file mode 100644 index 000000000..c0d3b1dd2 --- /dev/null +++ b/cosmos/miner/msgs.go @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: BUSL-1.1 +// +// Copyright (C) 2023, Berachain Foundation. All rights reserved. +// Use of this software is govered by the Business Source License included +// in the LICENSE file of this repository and at www.mariadb.com/bsl11. +// +// ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY +// TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER +// VERSIONS OF THE LICENSED WORK. +// +// THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF +// LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF +// LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). +// +// TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON +// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, +// EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND +// TITLE. + +package miner + +import ( + evidence "cosmossdk.io/x/evidence/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + crisis "github.com/cosmos/cosmos-sdk/x/crisis/types" + gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + govbeta "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + slashing "github.com/cosmos/cosmos-sdk/x/slashing/types" + staking "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +var ( + // DefaultAllowedMsgs are messages that can be submitted by external users. + DefaultAllowedMsgs = map[string]sdk.Msg{ + // crisis + "cosmos.crisis.v1beta1.MsgVerifyInvariant": &crisis.MsgVerifyInvariant{}, + "cosmos.crisis.v1beta1.MsgVerifyInvariantResponse": nil, + + // evidence + "cosmos.evidence.v1beta1.Equivocation": nil, + "cosmos.evidence.v1beta1.MsgSubmitEvidence": &evidence.MsgSubmitEvidence{}, + "cosmos.evidence.v1beta1.MsgSubmitEvidenceResponse": nil, + + // gov + "cosmos.gov.v1.MsgDeposit": &gov.MsgDeposit{}, + "cosmos.gov.v1.MsgDepositResponse": nil, + "cosmos.gov.v1.MsgVote": &gov.MsgVote{}, + "cosmos.gov.v1.MsgVoteResponse": nil, + "cosmos.gov.v1.MsgVoteWeighted": &gov.MsgVoteWeighted{}, + "cosmos.gov.v1.MsgVoteWeightedResponse": nil, + "cosmos.gov.v1beta1.MsgDeposit": &govbeta.MsgDeposit{}, + "cosmos.gov.v1beta1.MsgDepositResponse": nil, + "cosmos.gov.v1beta1.MsgVote": &govbeta.MsgVote{}, + "cosmos.gov.v1beta1.MsgVoteResponse": nil, + "cosmos.gov.v1beta1.MsgVoteWeighted": &govbeta.MsgVoteWeighted{}, + "cosmos.gov.v1beta1.MsgVoteWeightedResponse": nil, + "cosmos.gov.v1beta1.TextProposal": nil, + + // slashing + "cosmos.slashing.v1beta1.MsgUnjail": &slashing.MsgUnjail{}, + "cosmos.slashing.v1beta1.MsgUnjailResponse": nil, + + // staking + "cosmos.staking.v1beta1.MsgCreateValidator": &staking.MsgCreateValidator{}, + "cosmos.staking.v1beta1.MsgCreateValidatorResponse": nil, + "cosmos.staking.v1beta1.MsgEditValidator": &staking.MsgEditValidator{}, + "cosmos.staking.v1beta1.MsgEditValidatorResponse": nil, + + // tx + "cosmos.tx.v1beta1.Tx": nil, + + // upgrade + "cosmos.upgrade.v1beta1.CancelSoftwareUpgradeProposal": nil, + "cosmos.upgrade.v1beta1.SoftwareUpgradeProposal": nil, + } +) diff --git a/cosmos/x/evm/keeper/processor.go b/cosmos/x/evm/keeper/processor.go index d29b95b8e..960809d7a 100644 --- a/cosmos/x/evm/keeper/processor.go +++ b/cosmos/x/evm/keeper/processor.go @@ -24,6 +24,8 @@ import ( "context" "fmt" + storetypes "cosmossdk.io/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/beacon/engine" @@ -61,6 +63,8 @@ func (k *Keeper) ProcessPayloadEnvelope( } // Prepare should be moved to the blockchain? THIS IS VERY HOOD YES NEEDS TO BE MOVED. + ctx = sCtx.WithKVGasConfig(storetypes.GasConfig{}). + WithTransientKVGasConfig(storetypes.GasConfig{}) k.chain.PreparePlugins(ctx) if err = k.chain.InsertBlockAndSetHead(block); err != nil { return nil, err