Forge script: replay all 45 §5.1 EVM deploy steps with BSC address parity (dry run PASS/FAIL) #121
Labels
No labels
agent:implement
agent:ready
backend
bug
cannot-reproduce
confirmed
desktop
docs
documentation
duplicate
enhancement
feature
frontend
good first issue
help wanted
high-risk
in-review
invalid
mobile
needs-triage
P0-critical
P1-high
P2-medium
P3-low
qa
QA
question
ready
report
responsive
security
security-escalate
smart-contract
solana
tablet
test-pass
ux
wallet-issue
wallet:keplr
wallet:metamask
wallet:station
wallet:walletconnect
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-bridge-monorepo#121
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implement a Foundry
forge scriptthat replays the canonical 45-transaction BSC deployer sequence (seedocs/deployment-megaeth.md§5.1) on any new EVM chain so contract addresses match BSC / opBNB parity. The deliverable must include a dry-run path that prints predicted addresses and ends with an unambiguous PASS or FAIL versus the frozen BSC golden set.Related:
docs/deployment-megaeth.md§5.1–5.3,docs/export-transaction-list-1777384911253.csv,docs/reference/bsc-deployer-transaction-export-sample.csv,packages/contracts-evm/broadcast/Deploy.s.sol/56/run-latest.json, existingpackages/contracts-evm/script/Deploy.s.sol.Problem statement
Operators today must manually: recover per-tx nonces from BSC, align the target chain deployer nonce to
N0, run multipleforge script/caststeps in order, and verify withcast compute-address/ receipts. This is error-prone (wrong nonce, extra txs, wrong order) and cannot be rolled back without a new deployer. A single orchestrated script with simulation + PASS/FAIL reduces operational risk.In-scope behavior
THIS_CHAIN_ID/CHAIN_IDENTIFIER, wrapped native / chain-specific env already used byDeploy.s.soland deployment docs.simulate/vm.startBroadcastskipped); output must include expected addresses after each material step and a final gate: all compared addresses equal BSC references → PASS; any mismatch → FAIL with step index, nonce, expected vs actual (or predicted vs golden).Recommendations — script design and repo layout
Architecture
script/EvmParityReplay.s.sol) with a small public API:runDryCheck(),runBroadcast()(or onerun()+vm.envBool("DRY_RUN")) so CI and operators share one code path.library BscParityGoldenwithaddressconstants + step metadata (nonce, optional tx hash for docs only).script/bsc-parity-replay.jsonconsumed viavm.readFile+stdJsonin Foundry (easier for 45 rows; keep schema versioned).executeStep(uint8 i)so ordering is auditable in code review (not one 2000-line function).Deploy.s.sol(or shared internal libraries) instead of duplicating bytecode deployment details. IfDeploy.s.solcannot be called safely in sequence, extract shared internal deploy helpers intoscript/libraries/orsrc/as appropriate with minimal surface change.contractAddress); simulation must still assert child contract addresses (logs,eth_getTransactionReceiptparity in script viavm.recordLogs/ known interface, or static prediction from salt + init code if deterministic).vm.getNonce(deployer) == N0at entry; first line of broadcast moderequirethis; dry run may usevm.setNoncein test only—document that production dry run uses fork + prank or pure prediction without mutating mainnet state.scripts/evm/parity-replay.shthat exports env, runsforge script ... --sig runDryCheckvsrunBroadcast, forwards--rpc-url,--slow,--legacy, etc.Dry run implementation (pick a coherent approach)
forge scriptagainst an empty or fresh account on a local fork withvm.setNonce(deployer, N0)only in test/fork context, then run all steps and scrape created addresses from receipts (if Foundry exposes them) or from return values / storage.CREATE,cast compute-address-equivalent in Solidity (CREATEaddress from nonce); for CREATE2,vm.computeCreate2Address; for step 40, document required assertions against logs or a one-time golden map for internal addresses from BSC receipts.reverton mismatch or a bash wrapper greppingPASS/FAIL).Safety
--slow/ confirmation flags per org policy; never silently skip steps.requireforWETH/ chain id /THIS_CHAIN_IDvsblock.chainidwhere applicable (mirrorDeploy.s.sol).Implementation checklist
PARITY_CHECK: PASSorPARITY_CHECK: FAIL(machine-readable).Deploy.s.sol/deployment-guide.md(DEPLOYER,ADMIN_ADDRESS,THIS_CHAIN_ID,CHAIN_IDENTIFIER,WETH_ADDRESS, etc.).test/BscParityReplayDryRun.t.sol) that runs dry check on a fork and asserts PASS (CI guard against regressions).N0=0; partial replay e.g.N0=39for step 40 only—script must document which entrypoints are supported.Verification and QA checklist
vm.setNonce/ fresh account: PASS if logic is chain-agnostic aside from env.cast tx/cast receipton BSC for the tx hashes in §5.1.Documentation checklist (deliver with MR; may be short additions to existing runbooks)
forge scriptcommand, required env, example output showing PASS).Acceptance criteria (must all be true to close)
N0alignment documented in runbook/issue).Canonical references (BSC deployer sequence)
0xD699EbC6930F593f0725D2a7dC58ACC65b41a08e(from §5.1 verification snippet).docs/deployment-megaeth.md§5.1 table.0x12fedd29e71f66157e985aa1aaae434253e39a22.Out of scope (unless explicitly expanded)
cast sendloop; script documents prerequisitecast nonce == N0).changed the description
mentioned in commit
a9a99a38b8GL-121 implemented (merged to
main)Summary
packages/contracts-evm/script/bsc-parity-golden.json— 45 steps, EOACREATEaddresses from BSC receipts + tx hashes (source:docs/export-transaction-list-1777384911253.csv).EvmParityReplay.runDryCheck— prints per-step expected vsvm.computeCreateAddress; ends withPARITY_CHECK: PASSor revertsPARITY_CHECK: FAIL.runBroadcastHead(nonces 0–17),runBroadcastFaucet19(nonce 19),runBroadcastTail(from nonce 20) — reusesDeploy.deployAll+ guard/Create3/factory pattern; outer step 18 remains manual Nick CREATE2 (documented in runbook).BscParityReplayDryRun.t.sol.docs/deployment-megaeth.md§5.x;docs/deployment-guide.md§4.2a;skills/agent-evm-bsc-parity-replay.md;scripts/evm/parity-replay.sh.Invariants (documented in golden JSON)
eoaCreatedContractmust matchvm.computeCreateAddress(historicalDeployer, nonce).ENTRY_NONCE/TAIL_ENTRY_NONCEfor partial replay.FactoryTokenCl8yBridgedScriptsalt); verify on fork post-broadcast.Checklist for @brouie
cd packages/contracts-evm && forge test --match-contract BscParityReplayDryRun -vv→ PASS.DEPLOYER_ADDRESS=0xD699EbC6930F593f0725D2a7dC58ACC65b41a08e forge script script/EvmParityReplay.s.sol:EvmParityReplay --sig runDryCheck -vvv→ ends withPARITY_CHECK: PASS.bsc-parity-golden.jsontxHashvs BscScan).docs/deployment-megaeth.md§5.3 — confirm manual step 18 process is acceptable for your ops flow.runBroadcastTail, confirm guard/factory wiring; dry check intentionally skips CREATE3 factory equality to README row.Issue left open per instructions.
mentioned in issue #122
marked this issue as related to #122