feat: evm upgrade 0.6.0#32
Open
AryaLanjewar3005 wants to merge 5 commits into
Open
Conversation
* Changelog * fix line length
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.
Description
push-chain-evm — cosmos/evm v0.5.1 → v0.6.0 Upgrade
Describing how
push-chain-evmupgraded from the v0.5.1baseline to v0.6.0, how every upstream breaking change was absorbed, and —
most importantly — how the push-chain–specific functionality was preserved.
1. Merge strategy & fork relationship
push-chain-evm's module path isgithub.com/cosmos/evm; it is a direct fork.The relevant commit graph:
merge-base(HEAD, v0.6.0) == v0.5.1, so the upgrade is a clean three-way merge:the upstream v0.5.1 → v0.6.0 diff is applied on top of the fork.
cosmos/evmwas added as theupstreamremote and v0.6.0 fetched, then:git remote add upstream https://github.com/cosmos/evm.git git fetch upstream --tags git merge v0.6.0 # left UNCOMMITTED on branch evm-upgrade-0.6.0The v0.5.1→v0.6.0 delta touches ~101 files. Git auto-merged all but 3; the
auto-merges were then verified semantically (see (#6-auto-merged-files--semantic-verification)).
2. What v0.6.0 changes (the breaking surface)
CallEVM,CallEVMWithData,ApplyMessage,ApplyMessageWithConfignow take an explicitstateDB *statedb.StateDB(2nd param) and acallFromPrecompile bool(aftercommit). The caller now owns the StateDB; passingnilreturns the newErrNilStateDB.CommitWithCacheCtx→FlushToCacheCtx;AddPrecompileFn/RevertMultiStoredrop theireventsargument; newprocessedEventsCount+MarkEventProcessed/IsEventProcessed; precompile-call event revert now usesEventManager().OverrideEvents(...).x/ibc/transfermodule is deleted. ERC-20 ↔ IBC conversion moves tox/erc20/keeper/convert.go+ theerc20IBC middleware + the ICS20 precompile.ics20.NewPrecompile(...)gains anerc20Keeper cmn.ERC20Keeperparameter.cmn.ERC20KeeperIsERC20Enabled,GetTokenPairID,ConvertERC20IntoCoinsForNativeToken(...).types.ErrNilStateDB("stateDB cannot be nil").go.yaml.in/yaml/v3; theretractblock expands.3. Conflict resolutions (3 files)
3.1
x/vm/keeper/call_evm.go— the central conflictThis file contains both push-chain's derived-transaction engine and the
upstream
CallEVM/CallEVMWithDatawhose signatures changed. Resolution:Function signatures were taken from v0.6.0 (
stateDB+callFromPrecompile).CallEVMWithDatawas resolved to a unified body that honors bothcontracts:
stateDBstraight through, so the v0.6.0nil-StateDB contract (
ErrNilStateDB) is preserved — this is required byupstream tests (
TestCallEVM/TestCallEVMWithData/…nil statedb).(
a05ad85a — "use cache context in CallEVMWithData to prevent gas meter overflow on revert") by not callingResetGasMeterAndConsumeGas(ctx, ctx.GasMeter().Limit())on a revert(which can overflow the parent gas meter). In v0.6.0 the EVM already rolls
back the reverted call frame via its own snapshot, so the previous
cache-context wrap is no longer needed:
DerivedEVMCallWithData(push-chain) was adapted to the newApplyMessageWithConfigsignature by creating its StateDB on the cachecontext (
callFromPrecompile=false, derived txs are not precompile calls):All derived-tx semantics — the cache-context commit, ABCI event emission
(
ethereum_tx/tx_log/message), the shared monotonic eth-tx index, thegasless gas reporting, and the reverted-execution bloom/event guards — are
unchanged.
3.2
x/ibc/transfer/module.go— modify/deletev0.6.0 deletes the entire custom transfer module; push-chain had only added a
ConsensusVersion() = 5override to it. The deletion was accepted(
git rm -r x/ibc/transfer) because v0.6.0 rewires every consumer(
evmd/app.go,interfaces.go,precompiles/types/*,x/erc20/keeper/keeper.go)to the standard ibc-go transfer module + erc20 middleware. (The downstream
consequence of the
ConsensusVersion 5 → 6change is documented in thepush-chain upgrade doc.)
3.3
Makefile— systemtests legacy binaryBase v0.5.1 built a
v0.4legacy binary; v0.6.0 changedtest-systemto build av0.5binary viagit checkout v0.5.1. push-chain had previously replaced thatfragile
git checkout(which dirtiesgo.mod) with an isolated git worktreebuild (audit/CI fix
db3fbd13). The resolution keeps push-chain's robustworktree approach but retargets it to v0.5.1 (
build-v05), matching themerged
tests/systemtests/upgrade_test.gowhich now tests thev0.5.0-to-v0.6.0upgrade and expectsbinaries/v0.5/evmd.4. push-chain customizations preserved (verified)
DerivedEVMCall/DerivedEVMCallWithData)x/vm/keeper/call_evm.goApplyMessageWithConfigsignature.isUnsigned,unsignedTxAsMessage,fromparam ontraceTx/TraceBlock)x/vm/keeper/grpc_query.goRefundGas(ctx, msg, leftoverGas, gasUsed, baseFee, denom)burnsbaseFee × gasUsedx/vm/keeper/gas.go+ call instate_transition.goindexer/kv_indexer.gorpc/backend/*,rpc/types/*,rpc/namespaces/ethereum/eth/api.gox/vm/keeper/call_evm.gov2/migrate_params.go,migrator.go)x/vm/migrations/...x/vm/statedb/statedb.goNew()processedEventsCountinit, which would otherwise dereference a nil EventManager).5. push-chain compatibility patches added during the upgrade
5.1
(*Keeper).NewStateDB(ctx)—x/vm/keeper/statedb.goA small convenience that returns
statedb.New(ctx, k, statedb.NewEmptyTxConfig()).It lets external modules that consume the EVM keeper through an interface
(e.g. push-chain's
x/uexecutor) construct the now-mandatory non-nil StateDBwithout exposing all 12
statedb.Keepermethods on their interface.5.2
overrideEventManagerEventsshim —x/vm/statedb/journal.goSee §7.
5.3 Test coin-config nil-guard —
x/vm/types/denom_config_testing.goThe
-tags=testcoin-denom getters now fall back to a non-nil zero value whenthe global
testingEvmCoinInfois momentarily nil. This mirrors the productiongetEvmCoinInfo()nil-guard (CHANGELOG cosmos#816) and fixes a test-harness race(see §8).
5.4
TestRefundGas/invalid GasPricefix —tests/integration/x/vm/test_state_transition.goA pre-existing push-chain test bug: it passed
leftoverGas = 0, soremaining = leftoverGas × gasPrice = 0and the negative-price error path wasnever hit. Changed to
leftoverGas = params.TxGas(withexpGasRefund = 0) sothe case actually exercises the error. (Verified failing identically on
pre-merge HEAD.)
6. Auto-merged files — semantic verification
These were auto-merged by git and then verified to contain both sides:
x/vm/keeper/grpc_query.go— v0.6.0 addsstatedb.New(...)before everyApplyMessageWithConfigcall (note the value vs. pointer receiver:statedb.New(ctx, &k, …)inEthCall/EstimateGasInternal/predecessor loop,statedb.New(ctx, k, …)intraceTxWithMsg); push-chain's derived-tx tracinghelpers and the
from common.Addressparameter are intact.x/vm/keeper/state_transition.go— v0.6.0's StateDB creation inApplyTransaction+ the newApplyMessage(WithConfig)signatures, alongsidepush-chain's
RefundGas(..., res.GasUsed, cfg.BaseFee, ...)baseFeeBurn call.x/vm/statedb/statedb.go— push-chain's nil-EventManager guard +v0.6.0's
processedEventsCount/FlushToCacheCtx.x/vm/types/errors.go— push-chain's raw-bytesRevertError+v0.6.0's
ErrNilStateDB.go.mod/go.sum/evmd/go.mod/evmd/go.sum— v0.6.0's dependency bumpswith
go mod tidy.The v0.6.0-only files that push-chain never modified were taken wholesale and
already use the new APIs:
x/erc20/keeper/{evm,msg_server,convert,ibc_callbacks}.go,x/ibc/callbacks/keeper/keeper.go,precompiles/common/{precompile,balance_handler,interfaces}.go,precompiles/ics20/*,evmd/app.go,interfaces.go,precompiles/types/*.7. cosmos-sdk v0.50 compatibility: the
OverrideEventsshimv0.6.0's precompile-call event revert calls
s.cacheCtx.EventManager().OverrideEvents(pc.prevEvents)inx/vm/statedb/journal.go.EventManager.OverrideEventsonly exists incosmos-sdk v0.53, but push-chain pins cosmos-sdk v0.50.x for the whole
application (the rest of v0.6.0 is v0.50-compatible).
Bumping the parent's SDK constellation was rejected as out of scope — it would
cascade (
cosmossdk.io/collections v0.4 → v1.3,api v0.7.5 → v0.9.2,x/tx v0.13 → v0.14, …). Instead, a behavior-identical in-place shim was added:Why in-place (and not a fresh-EventManager swap): precompiles obtain the
cache context via
stateDB.GetCacheContext(), which shares the sameEventManagerpointer asstateDB.cacheCtx.OverrideEventsmutates thatmanager in place, so all holders observe the revert. A swap
(
cacheCtx.WithEventManager(new)) only updatesstateDB.cacheCtxand divergesfrom outstanding copies — this was confirmed to break
x/vm/statedb/balance_events_test.goand nested-precompile reverts. The shimreproduces
OverrideEventsexactly and works on both v0.50 and v0.53.8. Testing & results
Standalone builds and tests use the cosmos/evm
testbuild tag:Passing (push-chain-critical):
indexer(derived KV-indexer),rpc/backend(derived logs/gas/tracing/tx_info),x/vm/statedb(incl. the precompile event-revert path through the shim).evmdTestKeeperTestSuite— allTestDerivedEVMCall*,TestRefundGas(baseFeeBurn),
TestApplyMessage*incl. the nil-StateDB cases,TestCallEVM/TestCallEVMWithDataincl. the nil-StateDB cases.evmdERC20 keeper + ERC20 precompile integration (thecallFromPrecompile=truepath), IBC callbacks, mempool, and the fullprecompile suite.
Pre-existing failures (NOT introduced by this upgrade) — each verified to
fail identically on pre-merge HEAD (
96231e7a):evmd/.../precompiles/bankTestBankPrecompileIntegrationTestSuite(totalSupply / supplyOf). The queries are sent as gas-paying transactions;
push-chain's baseFeeBurn burns base fees and lowers total supply below the
upstream test's hard-coded expectation. (Fixing it would require teaching that
upstream test about baseFeeBurn.)
evmd/.../integrationTestBackend/TestGetTransactionReceipt/success_-_tx_not_found— a pre-existing backend mock expectation.
A mempool-test regression (
evmd/.../integration/mempool) was introduced andfixed: a leaked
legacypoolreorg goroutine of a torn-down test network readthe global
testingEvmCoinInfoduring a between-test reset nil-window (exposed byv0.6.0 timing). Resolved by the test-coin-config nil-guard (§5.3); the suite now
passes deterministically.
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
mainbranch