feat: evm 0.6.0 adjustment changes#272
Open
AryaLanjewar3005 wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
push-chain — adjustments for cosmos/evm (push-chain-evm) v0.6.0
This document describes the changes made to the
push-chainapplication(
github.com/pushchain/push-chain-node) so that it builds and runs against theupgraded
push-chain-evmdependency (cosmos/evm v0.6.0, previouslyv0.5.1).
It is the companion to the evm-side document
(
push-chain-evm/docs/migrations/PUSHCHAIN_v0.5.1_to_v0.6.0.md) and follows theofficial cosmos/evm guide:
Every change below is a direct consequence of a v0.6.0 breaking change unless
marked (general).
1. Dependency reconciliation (go.mod / go.sum)
go mod tidyabsorbed push-chain-evm v0.6.0's transitive bumps. The cosmos-sdkreplacepin is deliberately unchanged.2. IBC transfer module rewiring — the largest change
Why: cosmos/evm v0.6.0 deletes its custom
x/ibc/transfermodule. ItsERC-20 conversion responsibilities move to the standard ibc-go transfer module
wrapped by the erc20 IBC middleware, plus the ICS20 precompile. push-chain's
appimported and wired the now-deleted module, so it had to be re-pointed.2.1 Imports —
app/app.go(
app.TransferKeeper's declared type staysibctransferkeeper.Keeper— only thepackage the alias points to changed, so the field/usages are unaffected.)
precompiles.gohad the same import swap fortransferkeeper.2.2
TransferKeeperconstruction —app/app.goThe custom keeper took an extra
Erc20Keeperand had nolegacySubspaceparameter. The standard ibc-go keeper is the reverse:
app.TransferKeeper = ibctransferkeeper.NewKeeper( appCodec, runtime.NewKVStoreService(keys[ibctransfertypes.StoreKey]), + nil, // legacySubspace (standard keeper param; no params subspace) app.RatelimitKeeper, // ICS4Wrapper (push-chain's rate-limit middleware — unchanged) app.IBCKeeper.ChannelKeeper, app.MsgServiceRouter(), app.AccountKeeper, app.BankKeeper, - app.Erc20Keeper, // removed — conversion now via the erc20 middleware authtypes.NewModuleAddress(govtypes.ModuleName).String(), )SetAddressCodecis intentionally not called. The example app (evmd) setsan EVM/hex address codec, but push-chain's previous custom keeper used the
default bech32 codec, and the standard keeper also defaults to bech32. Not
calling it therefore preserves push-chain's existing behavior. (Switching to the
hex codec would be a new feature, not a migration requirement.)
2.3 ERC-20 IBC middleware —
app/app.goTo preserve the ERC-20 ↔ IBC conversion the custom keeper used to perform in its
OnRecvPacket/msg-server override, theerc20middleware is inserted directlyabove the transfer base app — exactly as
evmdv0.6.0 wires it:Final stack (bottom→top): transfer → erc20 → callbacks → packet-forward.
The
erc20package was already imported byapp, so no new import was needed.push-chain's packet-forward / callbacks / rate-limit / wasm wiring is untouched.
3. ICS20 precompile — new
erc20Keeperargument —app/precompiles.goWhy: v0.6.0's
ics20.NewPrecompile(...)gained anerc20Keeper cmn.ERC20Keeperparameter (the precompile now performs ERC-20conversion itself).
ibcTransferPrecompile := ics20precompile.NewPrecompile( bankKeeper, stakingKeeper, transferKeeper, channelKeeper, + erc20Kpr, )erc20Kpris push-chain's existing*erc20Keeper.Keeper. The v0.6.0cmn.ERC20Keeperinterface addsIsERC20Enabled,GetTokenPairID, andConvertERC20IntoCoinsForNativeToken(... stateDB, callFromPrecompile); the realevm keeper implements all of them, so no push-chain-side implementation was
needed (push-chain passes the real keeper, not a wrapper).
4. EVM call API changes in
x/uexecutorWhy: v0.6.0 changed
CallEVMto takestateDB *statedb.StateDBandcallFromPrecompile bool, and forbids a nil StateDB (ErrNilStateDB).push-chain's universal-executor module calls
CallEVMextensively.(
DerivedEVMCallis push-chain's own function and its signature is unchanged, sothose call sites were left as-is.)
4.1
EVMKeeperinterface —x/uexecutor/types/expected_keepers.gotype EVMKeeper interface { + // NewStateDB returns a fresh StateDB to pass into CallEVM (now required). + NewStateDB(ctx sdk.Context) *statedb.StateDB CallEVM( ctx sdk.Context, + stateDB *statedb.StateDB, abi abi.ABI, from, contract common.Address, - commit bool, + commit, callFromPrecompile bool, gasCap *big.Int, method string, args ...interface{}, ) (*types.MsgEthereumTxResponse, error) … }NewStateDB(ctx)is a small helper added to the evm keeper(
x/vm/keeper/statedb.go) precisely so push-chain — which holds the EVM keeperthrough this interface — can build the now-mandatory StateDB without listing all
of
statedb.Keeper's methods on the interface.4.2 Call sites —
x/uexecutor/keeper/evm.go,gas_fee.goEvery
k.evmKeeper.CallEVM(ctx, abi, from, contract, commit, gasCap, …)became:i.e. a fresh per-call StateDB as the 2nd arg and
callFromPrecompile = false(these are module/keeper-context calls, not precompile-context calls).
4.3 Mocks & tests
x/uexecutor/mocks/mock_evmkeeper.go— regeneratedCallEVMmock for the newsignature and added a
NewStateDBmock method/recorder.x/uexecutor/keeper/msg_server_test.go—EXPECT().CallEVM(...)matcher argcount updated (9 fixed + varargs), and
EXPECT().NewStateDB(...).Return(nil).AnyTimes()added (production now calls
NewStateDBto build the StateDB arg).MockEVMKeeperinkeeper_test.gois not assigned to thetypes.EVMKeeperinterface, so it needed no change.5. Test-only call-site updates (mechanical)
The same
CallEVMsignature change rippled into test helpers and integrationtests that call
app.EVMKeeper.CallEVM(...)directly. Each got the<app>.EVMKeeper.NewStateDB(ctx)StateDB arg and thecallFromPrecompile(
false) flag inserted:test/utils/contracts_setup.gotest/integration/uexecutor/inbound_cea_gas_and_payload_test.gotest/integration/uexecutor/inbound_cea_payload_test.gotest/integration/uexecutor/inbound_cea_smart_contract_test.gotest/integration/uexecutor/inbound_solana_test.gotest/integration/uexecutor/inbound_synthetic_bridge_test.gotest/integration/uexecutor/vote_chain_meta_test.gotest/integration/utss/fund_migration_test.go6. Live-network upgrade consideration — transfer module
ConsensusVersion 5 → 6Not a code change, but important for a live upgrade.
push-chain-evm's removed custom transfer module reported
ConsensusVersion() = 5.The standard ibc-go v10 transfer module reports
ConsensusVersion() = 6. Both usethe same module name (
transfer) and store key, so on a livev0.5 → v0.6upgrade the SDK module manager will run the standard transfer module's registered
v5 → v6 migration,
MigrateDenomTraceToDenom(denomTrace → denom format).This is inherent to v0.6.0 (the custom module no longer exists) and is handled
automatically by push-chain's existing upgrade pattern — a named handler under
app/upgrades/<name>/whoseCreateUpgradeHandlercallsmm.RunMigrations(ctx, configurator, fromVM). NoStoreUpgrades(Added/Deleted)are needed for the transfer module (same store key).
Action at release time: add the v0.6.0 named upgrade handler (following the
existing
app/upgrades/nooppattern). No evm module (x/vm,x/erc20,x/feemarket,x/precisebank) bumped itsConsensusVersion, so no other evmstate migration is triggered. Fresh-genesis deployments and the test suites need
nothing extra.
7. Building & testing push-chain
push-chain links the native
godklslibrary from the siblingdkls23-rscrate,so build it first:
Build:
Test (mirrors the Makefile: native lib on the loader path + the evm build tags;
DYLD_*is the macOS equivalent ofLD_LIBRARY_PATH):Result: full suite 43 packages ok / 0 failed, including
x/uexecutor(keeper + msg_server),
test/integration/uexecutor,test/integration/utss,and the
apppackage (which exercises the rewired IBC transfer stack and the newCallEVM path).
8. Files changed in push-chain
app/app.goNewKeeper(nillegacySubspace, dropErc20Keeper); adderc20.NewIBCMiddleware.app/precompiles.gotransferkeeperimport → ibc-go v10; passerc20Kprto ICS20 precompile.go.mod/go.sumgo mod tidy); SDK pin unchanged.x/uexecutor/types/expected_keepers.goEVMKeeperinterface: newCallEVMsignature +NewStateDB.x/uexecutor/keeper/evm.go,gas_fee.goCallEVMcall sites updated.x/uexecutor/mocks/mock_evmkeeper.goCallEVM+ newNewStateDB.x/uexecutor/keeper/msg_server_test.goNewStateDBexpectation.test/utils/contracts_setup.go+ 7test/integration/**filesCallEVMcall sites updated.Nothing is committed or pushed.
References
Changes
Testing
go test ./...Checklist