Skip to content

Commit 5bd3c38

Browse files
committed
Merge remote-tracking branch 'origin/main' into e2e
2 parents ffa9a7d + 26e34eb commit 5bd3c38

File tree

1 file changed

+93
-59
lines changed

1 file changed

+93
-59
lines changed

docs/migrations/v0.4.0_to_v0.5.0.md

Lines changed: 93 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,35 @@ following list includes references within `evmd` that have been moved.
7777

7878
### Mempool
7979

80-
#### Minimal setups: nothing to change
80+
#### Custom initializer
8181

82-
If you use the default mempool wiring (no custom pools), your existing code continues to work. If `BlockGasLimit` is 0, it defaults to `100_000_000`. If `BroadCastTxFn` is not set, it's also set to a default value.
82+
The mempool configuration can now be handled by a helper function. If you prefer to use the configuration from `app.toml` and CLI flags, you can refactor your mempool setup:
83+
84+
- **Before**: Manual configuration in app.go
85+
```go
86+
mempoolConfig := &evmmempool.EVMMempoolConfig{
87+
AnteHandler: app.GetAnteHandler(),
88+
BlockGasLimit: blockGasLimit,
89+
MinTip: minTip,
90+
}
91+
evmMempool := evmmempool.NewExperimentalEVMMempool(
92+
app.CreateQueryContext, logger, app.EVMKeeper, app.FeeMarketKeeper,
93+
app.txConfig, app.clientCtx, mempoolConfig,
94+
)
95+
```
96+
- **After**: Using helper function (optional). See https://github.com/cosmos/evm/blob/42e1141c9b00432020e69945e565f60f80ab501d/evmd/mempool.go for the reference implementation
97+
```go
98+
if err := app.configureEVMMempool(appOpts, logger); err != nil {
99+
panic(fmt.Sprintf("failed to configure EVM mempool: %s", err.Error()))
100+
}
101+
```
102+
103+
The helper function reads configuration from `appOpts` or applies defaults if omitted. Note that `NewExperimentalEVMMempool` now takes an additional `cosmosPoolMaxTx` parameter, with a recommended default value being `4096` or `0` (uncapped).
104+
105+
106+
#### Simple config migration
107+
108+
If `BlockGasLimit` is 0, it defaults to `100_000_000`. If `BroadCastTxFn` is not set, it's also set to a default value.
83109

84110
```go
85111
mempoolConfig := &evmmempool.EVMMempoolConfig{
@@ -183,40 +209,35 @@ These options can also be set via CLI flags:
183209

184210
A new flag `--mempool.max-txs` allows limiting the maximum number of transactions in the Cosmos mempool. Set to 0 or -1 for unbounded (default: 0).
185211

186-
##### Simplified Mempool Setup
187-
188-
The mempool configuration can now be handled by a helper function. If you prefer to use the configuration from `app.toml` and CLI flags, you can refactor your mempool setup:
212+
The function signature for `NewExperimentalEVMMempool` also changed to add a cosmosPoolMaxTx field:
189213

190-
```go
191-
// Before: Manual configuration in app.go
192-
mempoolConfig := &evmmempool.EVMMempoolConfig{
193-
AnteHandler: app.GetAnteHandler(),
194-
BlockGasLimit: blockGasLimit,
195-
MinTip: minTip,
196-
}
197-
evmMempool := evmmempool.NewExperimentalEVMMempool(
198-
app.CreateQueryContext, logger, app.EVMKeeper, app.FeeMarketKeeper,
199-
app.txConfig, app.clientCtx, mempoolConfig,
214+
```diff
215+
func NewExperimentalEVMMempool(
216+
getCtxCallback func(height int64, prove bool) (sdk.Context, error),
217+
logger log.Logger,
218+
vmKeeper VMKeeperI,
219+
feeMarketKeeper FeeMarketKeeperI,
220+
txConfig client.TxConfig,
221+
clientCtx client.Context,
222+
config *EVMMempoolConfig,
223+
+ cosmosPoolMaxTx int,
200224
)
201-
202-
// After: Using helper function (optional)
203-
// See evmd/mempool.go for reference implementation
204-
if err := app.configureEVMMempool(appOpts, logger); err != nil {
205-
panic(fmt.Sprintf("failed to configure EVM mempool: %s", err.Error()))
206-
}
207225
```
208226

209-
The helper function reads configuration from `appOpts` and applies defaults where needed. Note that `NewExperimentalEVMMempool` now takes an additional `cosmosPoolMaxTx` parameter.
210-
211-
### Default Precompiles
227+
#### EVM Chain ID
212228

213-
Default precompiles have been moved to `/evm/precompiles/types/defaults.go` and the function name was
214-
changed to `DefaultStaticPrecompiles`. The function signature has also changed, and now takes pointers
215-
as inputs for the `Erc20Keeper` and `TransferKeeper`. Finally, the `WithStaticPrecompiles` builder
216-
function can now happen *alongside the keeper instantiation*, and not after. The new wiring is shown below:
229+
The EVM chain ID is now retrieved directly from `appOpts` instead of being passed as a parameter. In `app.go`, the chain ID is obtained using:
217230

218231
```go
219-
app.EVMKeeper = evmkeeper.NewKeeper(
232+
evmChainID := cast.ToUint64(appOpts.Get(srvflags.EVMChainID))
233+
```
234+
235+
See `evmd/app.go:216` for the reference implementation.
236+
237+
The EVM Keeper now also takes in evmChainID as a parameter:
238+
239+
```diff
240+
app.EVMKeeper = evmkeeper.NewKeeper(
220241
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], keys,
221242
authtypes.NewModuleAddress(govtypes.ModuleName),
222243
app.AccountKeeper,
@@ -225,39 +246,11 @@ function can now happen *alongside the keeper instantiation*, and not after. The
225246
app.FeeMarketKeeper,
226247
&app.ConsensusParamsKeeper,
227248
&app.Erc20Keeper,
249+
+ evmChainID,
228250
tracer,
229-
).WithStaticPrecompiles(
230-
precompiletypes.DefaultStaticPrecompiles(
231-
*app.StakingKeeper,
232-
app.DistrKeeper,
233-
app.PreciseBankKeeper,
234-
&app.Erc20Keeper, // UPDATED
235-
&app.TransferKeeper, // UPDATED
236-
app.IBCKeeper.ChannelKeeper,
237-
app.GovKeeper,
238-
app.SlashingKeeper,
239-
appCodec,
240-
),
241251
)
242252
```
243253

244-
### Denom Configs
245-
246-
[#661](https://github.com/cosmos/evm/pull/661) removes the instantiation of chain configs via app.go
247-
and moves them to state or genesis.
248-
It is critical to remove any use of EvmAppOptions as calling the configurator will panic the chain
249-
at runtime during startup.
250-
251-
#### EVM Chain ID
252-
253-
The EVM chain ID is now retrieved directly from `appOpts` instead of being passed as a parameter. In `app.go`, the chain ID is obtained using:
254-
255-
```go
256-
evmChainID := cast.ToUint64(appOpts.Get(srvflags.EVMChainID))
257-
```
258-
259-
See `evmd/app.go:216` for the reference implementation.
260-
261254
#### Function Signature Changes
262255

263256
In `app.go`, remove evmChainID and evmAppOptions from the NewApp signature.
@@ -304,6 +297,47 @@ Then, remove any reference of evmAppOptions being called:
304297
`evmd_config.go`, `chain_id.go`, `config.go`, `constants.go` have been moved to
305298
`github.com/cosmos/evm/config` and may be removed to your repo.
306299

300+
### Denom Configs
301+
302+
[#661](https://github.com/cosmos/evm/pull/661) removes the instantiation of chain configs via app.go
303+
and moves them to state or genesis.
304+
It is critical to remove any use of EvmAppOptions as calling the configurator will panic the chain
305+
at runtime during startup.
306+
307+
### Default Precompiles
308+
309+
Default precompiles have been moved to `/evm/precompiles/types/defaults.go` and the function name was
310+
changed to `DefaultStaticPrecompiles`. The function signature has also changed, and now takes pointers
311+
as inputs for the `Erc20Keeper` and `TransferKeeper`. Finally, the `WithStaticPrecompiles` builder
312+
function can now happen *alongside the keeper instantiation*, and not after. The new wiring is shown below:
313+
314+
```go
315+
app.EVMKeeper = evmkeeper.NewKeeper(
316+
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], keys,
317+
authtypes.NewModuleAddress(govtypes.ModuleName),
318+
app.AccountKeeper,
319+
app.PreciseBankKeeper,
320+
app.StakingKeeper,
321+
app.FeeMarketKeeper,
322+
&app.ConsensusParamsKeeper,
323+
&app.Erc20Keeper,
324+
evmChainID,
325+
tracer,
326+
).WithStaticPrecompiles(
327+
precompiletypes.DefaultStaticPrecompiles(
328+
*app.StakingKeeper,
329+
app.DistrKeeper,
330+
app.PreciseBankKeeper,
331+
&app.Erc20Keeper, // UPDATED
332+
&app.TransferKeeper, // UPDATED
333+
app.IBCKeeper.ChannelKeeper,
334+
app.GovKeeper,
335+
app.SlashingKeeper,
336+
appCodec,
337+
),
338+
)
339+
```
340+
307341
#### UpgradeHandler
308342

309343
As the configs have been moved to state and genesis, you must include an UpgradeHandler if your chain does
@@ -323,7 +357,7 @@ Please refer to the [upgrade example](https://github.com/cosmos/evm/blob/0995962
323357

324358
---
325359

326-
## 3) Build & quick tests
360+
## 4) Build & quick tests
327361

328362
```bash
329363
go build ./...

0 commit comments

Comments
 (0)