Skip to content

Commit 6bc5b70

Browse files
authored
fix(evm): wire mempool and custom start command (#235)
* fix(evm): wire mempool and custom start command * cl * updates
1 parent bde6b54 commit 6bc5b70

File tree

8 files changed

+118
-15
lines changed

8 files changed

+118
-15
lines changed

evm/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# EVM App Changelog
22

3+
## [`v0.1.1`](https://github.com/ignite/apps/releases/tag/evm/v0.1.1)
4+
5+
- [#235](https://github.com/ignite/apps/pull/235) Wire EVM mempool and correct start command.
6+
37
## [`v0.1.0`](https://github.com/ignite/apps/releases/tag/evm/v0.1.0)
48

59
- First release of the EVM app compatible with Ignite >= v29.5.0

evm/go.mod

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/gobuffalo/genny/v2 v2.1.0
77
github.com/gobuffalo/plush/v4 v4.1.22
88
github.com/hashicorp/go-plugin v1.6.3
9-
github.com/ignite/cli/v29 v29.5.0
9+
github.com/ignite/cli/v29 v29.6.0
1010
github.com/stretchr/testify v1.10.0
1111
)
1212

@@ -61,7 +61,7 @@ require (
6161
github.com/cosmos/btcutil v1.0.5 // indirect
6262
github.com/cosmos/cosmos-db v1.1.1 // indirect
6363
github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect
64-
github.com/cosmos/cosmos-sdk v0.53.3 // indirect
64+
github.com/cosmos/cosmos-sdk v0.53.4 // indirect
6565
github.com/cosmos/go-bip39 v1.0.0 // indirect
6666
github.com/cosmos/gogogateway v1.2.0 // indirect
6767
github.com/cosmos/gogoproto v1.7.0 // indirect
@@ -199,7 +199,7 @@ require (
199199
github.com/sourcegraph/conc v0.3.0 // indirect
200200
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e // indirect
201201
github.com/spf13/afero v1.12.0 // indirect
202-
github.com/spf13/cast v1.8.0 // indirect
202+
github.com/spf13/cast v1.9.2 // indirect
203203
github.com/spf13/cobra v1.9.1 // indirect
204204
github.com/spf13/pflag v1.0.7 // indirect
205205
github.com/spf13/viper v1.20.1 // indirect
@@ -216,6 +216,7 @@ require (
216216
go.mongodb.org/mongo-driver v1.14.0 // indirect
217217
go.opencensus.io v0.24.0 // indirect
218218
go.uber.org/multierr v1.11.0 // indirect
219+
go.yaml.in/yaml/v2 v2.4.2 // indirect
219220
golang.org/x/arch v0.17.0 // indirect
220221
golang.org/x/crypto v0.40.0 // indirect
221222
golang.org/x/exp v0.0.0-20250718183923-645b1fa84792 // indirect
@@ -236,5 +237,5 @@ require (
236237
gotest.tools/v3 v3.5.2 // indirect
237238
nhooyr.io/websocket v1.8.6 // indirect
238239
pgregory.net/rapid v1.2.0 // indirect
239-
sigs.k8s.io/yaml v1.4.0 // indirect
240+
sigs.k8s.io/yaml v1.6.0 // indirect
240241
)

evm/go.sum

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ github.com/cosmos/cosmos-db v1.1.1 h1:FezFSU37AlBC8S98NlSagL76oqBRWq/prTPvFcEJNC
170170
github.com/cosmos/cosmos-db v1.1.1/go.mod h1:AghjcIPqdhSLP/2Z0yha5xPH3nLnskz81pBx3tcVSAw=
171171
github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA=
172172
github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec=
173-
github.com/cosmos/cosmos-sdk v0.53.3 h1:GbDJNUP9OD0gGDVnjecZVZr0ZReD1BtIIxmtgrAsWiw=
174-
github.com/cosmos/cosmos-sdk v0.53.3/go.mod h1:90S054hIbadFB1MlXVZVC5w0QbKfd1P4b79zT+vvJxw=
173+
github.com/cosmos/cosmos-sdk v0.53.4 h1:kPF6vY68+/xi1/VebSZGpoxQqA52qkhUzqkrgeBn3Mg=
174+
github.com/cosmos/cosmos-sdk v0.53.4/go.mod h1:7U3+WHZtI44dEOnU46+lDzBb2tFh1QlMvi8Z5JugopI=
175175
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
176176
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
177177
github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE=
@@ -423,7 +423,6 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
423423
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
424424
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
425425
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
426-
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
427426
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
428427
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
429428
github.com/google/go-github/v48 v48.2.0 h1:68puzySE6WqUY9KWmpOsDEQfDZsso98rT6pZcz9HqcE=
@@ -514,8 +513,8 @@ github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmK
514513
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
515514
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
516515
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
517-
github.com/ignite/cli/v29 v29.5.0 h1:fEY/LTz8xjSC+UBiwCssoIB/5w2pn3UW2gIohl0OcTI=
518-
github.com/ignite/cli/v29 v29.5.0/go.mod h1:dICC6a96N8eYxqwgar3buBduNlA4e+AVs4vH6IJltL8=
516+
github.com/ignite/cli/v29 v29.6.0 h1:+HaYMD1unqfIo4NbHzwVCnwf9ovYCsPVlo+hS2XLolQ=
517+
github.com/ignite/cli/v29 v29.6.0/go.mod h1:YCMxU6oBvOgb+SehwksJknNwOEj5wN7CFm7V10RU9/M=
519518
github.com/ignite/web v1.0.8 h1:St3L6UJj70+h16+No5em8Vn2Hx93tS2G1MyWO/Kt1cc=
520519
github.com/ignite/web v1.0.8/go.mod h1:WZWBaBYF8RazN7dE462BLpvXDY8ScacxcJ07BKwX/jY=
521520
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
@@ -819,8 +818,8 @@ github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e h1:qpG
819818
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA=
820819
github.com/spf13/afero v1.12.0 h1:UcOPyRBYczmFn6yvphxkn9ZEOY65cpwGKb5mL36mrqs=
821820
github.com/spf13/afero v1.12.0/go.mod h1:ZTlWwG4/ahT8W7T0WQ5uYmjI9duaLQGy3Q2OAl4sk/4=
822-
github.com/spf13/cast v1.8.0 h1:gEN9K4b8Xws4EX0+a0reLmhq8moKn7ntRlQYgjPeCDk=
823-
github.com/spf13/cast v1.8.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
821+
github.com/spf13/cast v1.9.2 h1:SsGfm7M8QOFtEzumm7UZrZdLLquNdzFYfIbEXntcFbE=
822+
github.com/spf13/cast v1.9.2/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
824823
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
825824
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
826825
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
@@ -925,6 +924,10 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9E
925924
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
926925
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
927926
go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
927+
go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI=
928+
go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU=
929+
go.yaml.in/yaml/v3 v3.0.3 h1:bXOww4E/J3f66rav3pX3m8w6jDE4knZjGOw8b5Y6iNE=
930+
go.yaml.in/yaml/v3 v3.0.3/go.mod h1:tBHosrYAkRZjRAOREWbDnBXUf08JOwYq++0QNwQiWzI=
928931
golang.org/x/arch v0.17.0 h1:4O3dfLzd+lQewptAHqjewQZQDyEdejz3VwgeYwkZneU=
929932
golang.org/x/arch v0.17.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk=
930933
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
@@ -1215,6 +1218,6 @@ nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYm
12151218
pgregory.net/rapid v1.2.0 h1:keKAYRcjm+e1F0oAuU5F5+YPAWcyxNNRK2wud503Gnk=
12161219
pgregory.net/rapid v1.2.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04=
12171220
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
1218-
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
1219-
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
1221+
sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs=
1222+
sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4=
12201223
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=

evm/integration/app_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,19 @@ func TestEVM(t *testing.T) {
7070
if !strings.Contains(buf.String(), "Querying commands for the evm module") {
7171
t.Errorf("evmappd doesn't contain evm modules: %s", buf.String())
7272
}
73+
buf.Reset()
7374

75+
env.Must(env.Exec("check evmappd start cmd",
76+
step.NewSteps(step.New(
77+
step.Exec(bin, "start", "--help"),
78+
step.Stdout(buf),
79+
step.Workdir(app.SourcePath()),
80+
)),
81+
))
82+
83+
if !strings.Contains(buf.String(), "--evm.") {
84+
t.Errorf("evmappd doesn't contain evm modules: %s", buf.String())
85+
}
7486
buf.Reset()
7587
}
7688

evm/template/files/app/ante.go.plush

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ func (app *App) setAnteHandler(txConfig client.TxConfig, maxGasWanted uint64) {
2626
SigGasConsumer: evmante.SigVerificationGasConsumer,
2727
MaxTxGasWanted: maxGasWanted,
2828
TxFeeChecker: cosmosevmante.NewDynamicFeeChecker(app.FeeMarketKeeper),
29-
PendingTxListener: func(hash common.Hash) {},
29+
PendingTxListener: func(hash common.Hash) {
30+
for _, listener := range app.pendingTxListeners {
31+
listener(hash)
32+
}
33+
},
3034
}
3135
if err := options.Validate(); err != nil {
3236
panic(err)

evm/template/files/app/evm.go.plush

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ import (
1010
"cosmossdk.io/core/appmodule"
1111
storetypes "cosmossdk.io/store/types"
1212
"cosmossdk.io/x/tx/signing"
13+
"github.com/cosmos/cosmos-sdk/baseapp"
14+
"github.com/cosmos/cosmos-sdk/client"
1315
"github.com/cosmos/cosmos-sdk/client/flags"
1416
"github.com/cosmos/cosmos-sdk/codec"
1517
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
1618
servertypes "github.com/cosmos/cosmos-sdk/server/types"
1719
sdk "github.com/cosmos/cosmos-sdk/types"
20+
sdkmempool "github.com/cosmos/cosmos-sdk/types/mempool"
1821
"github.com/cosmos/cosmos-sdk/types/module"
1922
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
2023
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
@@ -23,6 +26,7 @@ import (
2326
"github.com/spf13/cast"
2427

2528
evmconfig "github.com/cosmos/evm/config"
29+
evmmempool "github.com/cosmos/evm/mempool"
2630
"github.com/cosmos/evm/precompiles/bech32"
2731
"github.com/cosmos/evm/precompiles/p256"
2832
srvflags "github.com/cosmos/evm/server/flags"
@@ -35,6 +39,7 @@ import (
3539
"github.com/cosmos/evm/x/vm"
3640
evmkeeper "github.com/cosmos/evm/x/vm/keeper"
3741
evmtypes "github.com/cosmos/evm/x/vm/types"
42+
"github.com/ethereum/go-ethereum/common"
3843
gethvm "github.com/ethereum/go-ethereum/core/vm"
3944
)
4045

@@ -142,6 +147,44 @@ func (app *App) postRegisterEVMModules() error {
142147
return nil
143148
}
144149

150+
// setEVMMempool sets the EVM priority nonce mempool
151+
// it is required for the ethereum json rpc server to work
152+
func (app *App) setEVMMempool() {
153+
if evmtypes.GetChainConfig() != nil {
154+
mempoolConfig := &evmmempool.EVMMempoolConfig{
155+
AnteHandler: app.BaseApp.AnteHandler(),
156+
BlockGasLimit: 100_000_000,
157+
}
158+
159+
evmMempool := evmmempool.NewExperimentalEVMMempool(app.CreateQueryContext, app.Logger(), app.EVMKeeper, app.FeeMarketKeeper, app.txConfig, app.clientCtx, mempoolConfig)
160+
app.EVMMempool = evmMempool
161+
162+
app.SetMempool(evmMempool)
163+
checkTxHandler := evmmempool.NewCheckTxHandler(evmMempool)
164+
app.SetCheckTxHandler(checkTxHandler)
165+
166+
abciProposalHandler := baseapp.NewDefaultProposalHandler(evmMempool, app)
167+
abciProposalHandler.SetSignerExtractionAdapter(evmmempool.NewEthSignerExtractionAdapter(sdkmempool.NewDefaultSignerExtractionAdapter()))
168+
app.SetPrepareProposal(abciProposalHandler.PrepareProposalHandler())
169+
}
170+
}
171+
172+
// RegisterPendingTxListener a function that registers a listener for pending transactions.
173+
func (app *App) RegisterPendingTxListener(listener func(common.Hash)) {
174+
app.pendingTxListeners = append(app.pendingTxListeners, listener)
175+
}
176+
177+
// SetClientCtx a function that sets the client context on the app, required by EVM module implementation.
178+
func (app *App) SetClientCtx(ctx client.Context) {
179+
app.clientCtx = ctx
180+
}
181+
182+
// GetMempool returns the mempool of the app.
183+
// It is required by the EVM application interface.
184+
func (app *App) GetMempool() sdkmempool.ExtMempool {
185+
return app.EVMMempool
186+
}
187+
145188
// getCustomEVMActivators defines a map of opcode modifiers associated
146189
// with a key defining the corresponding EIP.
147190
func getCustomEVMActivators() map[int]func(*gethvm.JumpTable) {

evm/template/generator_app.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ func appModify(appPath, binaryName string) genny.RunFn {
3030
xast.WithNamedImport("feemarketkeeper", "github.com/cosmos/evm/x/feemarket/keeper"),
3131
xast.WithNamedImport("ibctransferkeeper", "github.com/cosmos/evm/x/ibc/transfer/keeper"),
3232
xast.WithNamedImport("evmkeeper", "github.com/cosmos/evm/x/vm/keeper"),
33+
xast.WithNamedImport("evmante", "github.com/cosmos/evm/ante"),
34+
xast.WithNamedImport("evmmempool", "github.com/cosmos/evm/mempool"),
3335
)
3436
if err != nil {
3537
return err
@@ -55,6 +57,14 @@ func appModify(appPath, binaryName string) genny.RunFn {
5557
content, err = xast.ModifyStruct(
5658
content,
5759
"App",
60+
xast.AppendStructValue(
61+
"clientCtx",
62+
"client.Context",
63+
),
64+
xast.AppendStructValue(
65+
"pendingTxListeners",
66+
"[]evmante.PendingTxListener",
67+
),
5868
xast.AppendStructValue(
5969
"FeeGrantKeeper",
6070
"feegrantkeeper.Keeper",
@@ -71,6 +81,10 @@ func appModify(appPath, binaryName string) genny.RunFn {
7181
"Erc20Keeper",
7282
"erc20keeper.Keeper",
7383
),
84+
xast.AppendStructValue(
85+
"EVMMempool",
86+
"*evmmempool.ExperimentalEVMMempool",
87+
),
7488
)
7589
if err != nil {
7690
return err
@@ -106,7 +120,9 @@ func appModify(appPath, binaryName string) genny.RunFn {
106120
xast.AppendFuncCodeAtLine(
107121
`// set ante handlers
108122
maxGasWanted := cast.ToUint64(appOpts.Get(evmsrvflags.EVMMaxTxGasWanted))
109-
app.setAnteHandler(app.txConfig, maxGasWanted)`,
123+
app.setAnteHandler(app.txConfig, maxGasWanted)
124+
// set evm mempool
125+
app.setEVMMempool()`,
110126
12,
111127
),
112128
)

evm/template/generator_cmd.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func commandsModify(appPath, binaryName string) genny.RunFn {
2020
content, err := xast.AppendImports(
2121
f.String(),
2222
xast.WithNamedImport("cosmosevmcmd", "github.com/cosmos/evm/client"),
23+
xast.WithNamedImport("cosmosevmserver", "github.com/cosmos/evm/server"),
2324
)
2425
if err != nil {
2526
return err
@@ -33,6 +34,25 @@ func commandsModify(appPath, binaryName string) genny.RunFn {
3334
return err
3435
}
3536

37+
// replace server.AddCommandsWithStartCmdOptions with cosmosevmserver.AddCommands
38+
content, err = xast.ModifyFunction(content, "initRootCmd",
39+
xast.RemoveFuncCall("server.AddCommandsWithStartCmdOptions"),
40+
xast.AppendFuncAtLine(`// add Cosmos EVM' flavored TM commands to start server, etc.
41+
cosmosevmserver.AddCommands(
42+
rootCmd,
43+
cosmosevmserver.NewDefaultStartOptions(func(l log.Logger, d dbm.DB, w io.Writer, ao servertypes.AppOptions) cosmosevmserver.Application {
44+
return newApp(l, d, w, ao).(cosmosevmserver.Application)
45+
}, app.DefaultNodeHome),
46+
appExport,
47+
addModuleInitFlags,
48+
)`,
49+
1,
50+
),
51+
)
52+
if err != nil {
53+
return err
54+
}
55+
3656
// add keyring commands
3757
content = strings.Replace(
3858
content,

0 commit comments

Comments
 (0)