Repository navigation
feat(evm): fix internal CREATE derivation and add PUSH0 behind ForkEVMCompat - #1354
Conversation
… fork EVM-internal CREATE used hash(txHash||origin), so every CREATE inside one transaction produced the same address. EVM.Create also accepted an existing account silently, so a factory deploying two children in one call had the second overwrite the first while the transaction still reported success. Gate the Ethereum behaviour behind ForkEVMContractCreateV2. Registered at MaxHeight (off by default, opt-in per chain) like ForkEVMTransferRevert: enabling it from genesis on an existing chain would rewrite historical execution. - CREATE address = CreateAddress(executing account, its nonce); the caller nonce is incremented before any create snapshot and persisted in contract state, so it survives across transactions and failed creates. - Newly created contracts start at nonce 1 (EIP-161); an account with a nonce is no longer treated as non-existent. - CREATE/CREATE2 fail with ErrContractAddressCollision (consuming the forwarded gas) when the target already has a nonce or code. - ErrCodeStoreOutOfGas rolls the creation back instead of keeping the account and pushing its address. - CREATE/CREATE2 forward 63/64 of the remaining gas (EIP-150); CREATE2 no longer halves it, and converts value precision for ETH-signed transactions the same way CREATE does. Address construction for the new path bypasses the chain33 address driver: a btc-format driver cannot parse a 0x hex string and produced an all-zero raw address. Fork-off execution is unchanged; the nonceChange KV write is gated on the same fork. Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
withdrawTicketBalance compared the post-withdraw coins balance with the pre-withdraw ticket balance. The ticket balance also grows with mining rewards, so the check only held when it happened to be exactly 100000 and failed intermittently otherwise (observed 100005 vs 100001 on the same head). Record the coins balance before the withdraw and assert the increase is the withdrawn amount, allowing a small tolerance for fees and rounding. Co-authored-by: Claude <noreply@anthropic.com>
The withdraw moves 100000 coins minus a ~0.1 coin fee, so the expected increase is exactly 99999.9 and the previous 99999.9 lower bound sat on the floating-point boundary: the same balances can compare either side of it depending on their magnitude and on the awk implementation. Use a 99999 lower bound instead, and make jq fail on a missing balance rather than silently comparing a null as zero. Co-authored-by: Claude <noreply@anthropic.com>
ForkEVMContractCreateV2 and ForkEVMTransferRevert are independent forks, but the full Ethereum semantics need both: this fork keeps the nonce of a failed CREATE, and the transfer-revert fork rolls back the value attached to it. Add a test that enables both, and document the pairing next to the fork. Co-authored-by: Claude <noreply@anthropic.com>
The fork now covers the whole Ethereum compatibility set (CREATE semantics, new opcodes and the gas schedule), so a semantic name without a version suffix is clearer: there is no "V1" fork to pair with. Co-authored-by: Claude <noreply@anthropic.com>
Solidity 0.8.20 and later emit PUSH0 by default, so a contract built with a current solc cannot be deployed without it. The fork selects a Berlin-based instruction set that adds PUSH0 (0x5f) and BASEFEE (0x48); the chain has no base-fee mechanism, so BASEFEE pushes zero. Both cost 2 gas. Fork off keeps the existing instruction set, so the two bytes remain invalid and nothing else changes. Co-Authored-By: Claude Code <noreply@anthropic.com>
db0a569 to
19e346b
Compare
|
整体判断:修复方向正确。 建议按优先级:
另: 以上 1–3 建议合并前处理,或至少作为已知限制写进发布说明。 |
A contract deployed before the fork has code but no stored nonce, so its first post-fork internal CREATE used nonce 0 where Ethereum uses 1. Under the fork such an account is now treated as nonce 1, through one helper shared by the address derivation and the increment. The top-level ETH-signed deploy now builds the address from the raw 20 bytes instead of round-tripping through the address driver, which under a btc driver produced an all-zero address, and it applies the same nonce/code collision rule as the internal create, so a balance-only address can be deployed to. The runtime fork checks read the height from the state DB, the same source the state layer and the interpreter use. The account emptiness helper drops its nonce branch: an account with a nonce but no code cannot be loaded from state, so the branch never decided anything. Tests cover the 63/64 forwarding for both creates, a create inside a constructor, CREATE2 incrementing the caller nonce, the pre-fork nonce rule, the top-level raw address and balance-only collision, and the fork key in the three shipped configurations. The ci2 withdraw check no longer hides a jq failure behind a local declaration, so a failed read fails the script instead of asserting against a zero. Co-Authored-By: Claude Code <noreply@anthropic.com>
StartConsensus is started as a goroutine by SetQueueClient. When the node is configured as a validator but its client was built without a genesis document, MakeGenesisValidatorMgr dereferences nil and the panic takes the process down. Log and return instead; a node without a genesis document cannot build a validator set anyway. Co-Authored-By: Claude Code <noreply@anthropic.com>
|
已按建议逐条处理(1–7 已改,第 8 条写进 PR 描述):
另外, |
|
🎉 This PR is included in version 1.77.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
What
Two EVM incompatibilities, both gated by one new dapp fork,
ForkEVMCompat:CREATEderived a colliding address (EVM 合约内部 create(Solidity new)地址冲突:同一笔交易内 factory 创建的多个子合约地址相同,后者覆盖前者,且交易显示成功 #1351).opCreateusedhash(txHash || origin), so every internal create in a transaction received the same address, andEVM.Createaccepted an existing account: a second child silently overwrote the first while the transaction still reported success.PUSH0(0x5f) andBASEFEE(0x48) were missing (evm: PUSH0 (0x5f) and other Shanghai/Cancun opcodes are missing from the instruction set #1352). Solidity 0.8.20 and later emitPUSH0by default, so a contract compiled with a current solc cannot be deployed at all.How
ForkEVMCompatis registered atMaxHeight(off by default) and the templates keep it at-1, so each chain opts in with a concrete height. Enabling it from genesis on an existing chain would rewrite historical execution.Fork on:
CREATEaddress =CreateAddress(executing account, its nonce). The caller nonce is incremented before any create snapshot and persisted in contract state, so it survives across transactions and failed creates. New contracts start at nonce 1 (EIP-161), an account with a nonce is no longer treated as non-existent, andCREATE/CREATE2returnErrContractAddressCollisionwhen the target already has a nonce or code. An account that holds code but no nonce record (deployed before the fork) is treated as nonce 1, so these contracts match Ethereum as well.CREATE/CREATE2forward 63/64 of the remaining gas (EIP-150), forward value with the same precision conversionCREATEuses, and roll back onErrCodeStoreOutOfGasinstead of keeping the account.PUSH0pushes zero andBASEFEEreturns zero, both at 2 gas. The chain has no base-fee mechanism.Fork off, execution is unchanged: the previous
CREATEaddress derivation, the Berlin instruction set, the gas constants and the refund handling are untouched.Address construction for the new path bypasses the chain33 address driver: a btc-format driver cannot parse a
0xhex string and produced an all-zero raw address.Testing
go test ./plugin/dapp/evm/...(bn256/cloudflarefails on macOS with adyld: missing LC_UUID load commanderror; the package does not depend on anything here)CREATEaddress matchingcrypto.CreateAddress, twice in one transaction; nonce persistence across transactions and executor instances; a failedCREATEstill consuming a nonceCREATE2collision returning zeroPUSH0/BASEFEEbeinginvalid opcodewhen off and executing when onCREATEandCREATE2, aCREATEfrom inside a constructor,CREATE2incrementing the caller nonce, and the pre-fork contract nonce ruleCREATEkeeps when onlyForkEVMCompatis on, andForkEVMCompatbeing present in the three shipped configsgo test ./plugin/dapp/evm/executor/ -shuffle=<seed>is order-independent; a pre-existing global address-driver leak fromquery_test.gowas fixed for that.Deployment note
The fork has to be enabled with a real height in the deployment repository; the templates here keep it off (
-1). Every existing chain configuration must listForkEVMCompatonce this release is deployed — the fork is registered in code, and a configuration that omits it fails the fork check at startup.ForkEVMTransferRevert. That fork rolls back the value attached to a failedCREATE, which this one alone does not do; the full Ethereum semantics need both.[exec.sub.evm] addressDriver="eth"for the deploy to land on the Ethereum address; the driver is still used by the pre-existing paths that do not create contracts.evmVersion=shanghaiwork. Cancun and later targets emitMCOPY/TLOAD/TSTORE, which this fork does not provide.Not covered
No gas metering changes: cold/warm access accounting, net
SSTOREmetering and EIP-3529 refunds are not part of this fork, so gas numbers differ from Ethereum for contracts that are sensitive to them.MCOPY,TLOAD/TSTORE,DIFFICULTY/PREVRANDAO, the precompile table and theSELFDESTRUCTpricing are unchanged.