Skip to content

Commit a9cb401

Browse files
authored
add erc20 migration guide (#485)
1 parent 1d8b9e1 commit a9cb401

File tree

2 files changed

+399
-11
lines changed

2 files changed

+399
-11
lines changed

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

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- [ ] Bump **`cosmos/evm` to v0.4.0** and align **Cosmos SDK / IBC / CometBFT** constraints.
88
- [ ] Rewire **keepers** and **AppModule** (imports, constructors, `RegisterServices`).
99
- [ ] 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).
1011
- [ ] Implement **store/params migrations** in your **UpgradeHandler**.
1112

1213
---
@@ -135,7 +136,7 @@ Add a public method to register a listener by `txHash`:
135136

136137
```go
137138
// 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
139140
app.pendingTxListeners = append(app.pendingTxListeners, listener)
140141
}
141142
```
@@ -174,25 +175,25 @@ func defaultOptionals() Optionals {
174175
// from addresscodec "github.com/cosmos/cosmos-sdk/codec/address"(sdk.GetConfig()
175176
// from sdk "github.com/cosmos/cosmos-sdk/types".GetBech32ValidatorAddrPrefix()),
176177
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()
178179
// from sdk "github.com/cosmos/cosmos-sdk/types".GetBech32ConsensusAddrPrefix()),
179180
ConsensusAddrCodec: addresscodec.NewBech32Codec
180181
}
181182
}
182183

183184
type Option func(*Optionals)
184185

185-
// from "cosmossdk.io/core/address")
186+
// from "cosmossdk.io/core/address")
186187
// Option { return func(o *Optionals){ o.AddressCodec = c } }
187-
func WithAddressCodec(c address.Codec
188+
func WithAddressCodec(c address.Codec
188189

189-
// from "cosmossdk.io/core/address")
190+
// from "cosmossdk.io/core/address")
190191
// Option { return func(o *Optionals){ o.ValidatorAddrCodec = c } }
191-
func WithValidatorAddrCodec(c address.Codec
192+
func WithValidatorAddrCodec(c address.Codec
192193

193-
// from "cosmossdk.io/core/address")
194+
// from "cosmossdk.io/core/address")
194195
// Option { return func(o *Optionals){ o.ConsensusAddrCodec = c } }
195-
func WithConsensusAddrCodec(c address.Codec
196+
func WithConsensusAddrCodec(c address.Codec
196197
```
197198

198199
### 4.3 Update the precompile factory to accept options
@@ -232,9 +233,9 @@ func WithConsensusAddrCodec(c address.Codec
232233
*(app/keepers/precompiles.go)*
233234

234235
```diff
235-
- govPrecompile, err := govprecompile.NewPrecompile
236+
- govPrecompile, err := govprecompile.NewPrecompile
236237
- // from govprecompile "github.com/cosmos/evm/precompiles/gov"(govKeeper, cdc)
237-
+ govPrecompile, err := govprecompile.NewPrecompile
238+
+ govPrecompile, err := govprecompile.NewPrecompile
238239
+ // from govprecompile "github.com/cosmos/evm/precompiles/gov"(govKeeper, cdc, options.AddressCodec)
239240
```
240241

@@ -333,7 +334,41 @@ pcs := NewAvailableStaticPrecompiles(ctx, /* ... keepers ... */, opts...)
333334

334335
---
335336

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
337372

338373
- [ ] `go.mod` has **no `replace`** lines for `github.com/cosmos/evm`.
339374
- [ ] Node boots with expected **RPC namespaces**.

0 commit comments

Comments
 (0)