|
7 | 7 | - [ ] Bump **`cosmos/evm` to v0.4.0** and align **Cosmos SDK / IBC / CometBFT** constraints. |
8 | 8 | - [ ] Rewire **keepers** and **AppModule** (imports, constructors, `RegisterServices`). |
9 | 9 | - [ ] Audit and migrate **EVM & FeeMarket params** (EIP-1559 knobs, denom/decimals). |
| 10 | +- [ ] Migrate existing **ERC20 dynamic/native precompiles** to new storage format (see Section 9). |
10 | 11 | - [ ] Implement **store/params migrations** in your **UpgradeHandler**. |
11 | 12 |
|
12 | 13 | --- |
@@ -135,7 +136,7 @@ Add a public method to register a listener by `txHash`: |
135 | 136 |
|
136 | 137 | ```go |
137 | 138 | // from "github.com/ethereum/go-ethereum/common")) { |
138 | | -func (app *MyApp) RegisterPendingTxListener(listener func(common.Hash |
| 139 | +func (app *MyApp) RegisterPendingTxListener(listener func(common.Hash |
139 | 140 | app.pendingTxListeners = append(app.pendingTxListeners, listener) |
140 | 141 | } |
141 | 142 | ``` |
@@ -174,25 +175,25 @@ func defaultOptionals() Optionals { |
174 | 175 | // from addresscodec "github.com/cosmos/cosmos-sdk/codec/address"(sdk.GetConfig() |
175 | 176 | // from sdk "github.com/cosmos/cosmos-sdk/types".GetBech32ValidatorAddrPrefix()), |
176 | 177 | ValidatorAddrCodec: addresscodec.NewBech32Codec |
177 | | - // from addresscodec "github.com/cosmos/cosmos-sdk/codec/address"(sdk.GetConfig() |
| 178 | + // from addresscodec "github.com/cosmos/cosmos-sdk/codec/address"(sdk.GetConfig() |
178 | 179 | // from sdk "github.com/cosmos/cosmos-sdk/types".GetBech32ConsensusAddrPrefix()), |
179 | 180 | ConsensusAddrCodec: addresscodec.NewBech32Codec |
180 | 181 | } |
181 | 182 | } |
182 | 183 |
|
183 | 184 | type Option func(*Optionals) |
184 | 185 |
|
185 | | -// from "cosmossdk.io/core/address") |
| 186 | +// from "cosmossdk.io/core/address") |
186 | 187 | // Option { return func(o *Optionals){ o.AddressCodec = c } } |
187 | | -func WithAddressCodec(c address.Codec |
| 188 | +func WithAddressCodec(c address.Codec |
188 | 189 |
|
189 | | -// from "cosmossdk.io/core/address") |
| 190 | +// from "cosmossdk.io/core/address") |
190 | 191 | // Option { return func(o *Optionals){ o.ValidatorAddrCodec = c } } |
191 | | -func WithValidatorAddrCodec(c address.Codec |
| 192 | +func WithValidatorAddrCodec(c address.Codec |
192 | 193 |
|
193 | | -// from "cosmossdk.io/core/address") |
| 194 | +// from "cosmossdk.io/core/address") |
194 | 195 | // Option { return func(o *Optionals){ o.ConsensusAddrCodec = c } } |
195 | | -func WithConsensusAddrCodec(c address.Codec |
| 196 | +func WithConsensusAddrCodec(c address.Codec |
196 | 197 | ``` |
197 | 198 |
|
198 | 199 | ### 4.3 Update the precompile factory to accept options |
@@ -232,9 +233,9 @@ func WithConsensusAddrCodec(c address.Codec |
232 | 233 | *(app/keepers/precompiles.go)* |
233 | 234 |
|
234 | 235 | ```diff |
235 | | -- govPrecompile, err := govprecompile.NewPrecompile |
| 236 | +- govPrecompile, err := govprecompile.NewPrecompile |
236 | 237 | - // from govprecompile "github.com/cosmos/evm/precompiles/gov"(govKeeper, cdc) |
237 | | -+ govPrecompile, err := govprecompile.NewPrecompile |
| 238 | ++ govPrecompile, err := govprecompile.NewPrecompile |
238 | 239 | + // from govprecompile "github.com/cosmos/evm/precompiles/gov"(govKeeper, cdc, options.AddressCodec) |
239 | 240 | ``` |
240 | 241 |
|
@@ -333,7 +334,41 @@ pcs := NewAvailableStaticPrecompiles(ctx, /* ... keepers ... */, opts...) |
333 | 334 |
|
334 | 335 | --- |
335 | 336 |
|
336 | | -## 9) Verify before tagging |
| 337 | +## 9) ERC20 Precompiles Migration |
| 338 | + |
| 339 | +**This is a breaking change for chains with existing ERC20 token pairs.** |
| 340 | + |
| 341 | +The storage mechanism for ERC20 precompiles has fundamentally changed in v0.4.0. Without proper migration, your ERC20 tokens will become inaccessible via EVM, showing zero balances and failing all operations. |
| 342 | + |
| 343 | +### Quick Impact Check |
| 344 | + |
| 345 | +Your chain needs this migration if you have: |
| 346 | + |
| 347 | +- IBC tokens converted to ERC20 |
| 348 | +- Token factory tokens with ERC20 representations |
| 349 | +- Any existing `DynamicPrecompiles` or `NativePrecompiles` in storage |
| 350 | + |
| 351 | +### Migration |
| 352 | + |
| 353 | +For full details see: [ERC20 Precompiles Migration Guide](./v0.4.0_erc20_precompiles_migration.md) |
| 354 | + |
| 355 | +*Thanks to Mantra team for their work on this: [MANTRA-Chain Implementation](https://github.com/MANTRA-Chain/mantrachain/pull/409)* |
| 356 | + |
| 357 | +### Quick Verification |
| 358 | + |
| 359 | +Post-upgrade, verify your migration succeeded: |
| 360 | + |
| 361 | +```bash |
| 362 | +# Check ERC20 balance (should NOT be 0 if tokens existed before) |
| 363 | +cast call $TOKEN_ADDRESS "balanceOf(address)" $USER_ADDRESS --rpc-url http://localhost:8545 |
| 364 | + |
| 365 | +# Verify precompiles in state |
| 366 | +evmd export | jq '.app_state.erc20.dynamic_precompiles' |
| 367 | +``` |
| 368 | + |
| 369 | +--- |
| 370 | + |
| 371 | +## 10) Verify before tagging |
337 | 372 |
|
338 | 373 | - [ ] `go.mod` has **no `replace`** lines for `github.com/cosmos/evm`. |
339 | 374 | - [ ] Node boots with expected **RPC namespaces**. |
|
0 commit comments