Repository navigation
test-setup: deploy SimpleTest at a CREATE2 address so keyed runs stop redeploying it - #520
alexshchur wants to merge 4 commits into
Conversation
|
|
Vercel previews (commit
|
eab3a0b to
ce1cdb8
Compare
…tries Every keyed CI run redeployed SimpleTest on the three testnets since #390 changed its bytecode: setup.mjs compared the compiled bytecode hash with the committed deployments.json, CI never wrote the new entry back, and one of the redeploys failed the Base Sepolia job before any test ran. The committed registries were a copy of chain state that only a human could refresh. The chain is now the only source of truth. Where the deterministic CREATE2 deployer has code (the testnets), SimpleTest lives at an address computed from the bytecode: setup skips when that address has code, deploys otherwise, and a failed send still counts when the code is there afterwards. Chains without the deployer (staging, local CoFHE) keep forge create; they reset anyway. Setup writes what it found or deployed to deployments.local.json, which is not committed and which tsup inlines for the tests of this checkout. The values the decrypt tests read follow the same rule. Setup stores them as its own account and pins the resulting handles in the same local file, read at the block of its own transaction; it skips while the TaskManager's ACL still allows the pinned handles for that account. The tests use the pinned handles, since the fixture is shared and other suites overwrite it while a handle stays decryptable. primaryTestChainRegistry.json and stagingTestChainRegistry.json go, along with the coupling to whichever key last ran setup. The test-live jobs run setup for Arbitrum Sepolia before the tests, like the matrix jobs do.
ce1cdb8 to
edec486
Compare
architect-dev
left a comment
There was a problem hiding this comment.
Looks great, removing the deployments.json is great (btw .memories/testing.md needs to be updated to prevent drift). One issue is that test-live now runs the setup, which can cause nonce collisions.
There was a problem hiding this comment.
Comments in this file need to be updated (read-only removed etc).
We should extract test-setup out to its own step that is depended on by both test-live and integration / matrix tests. Adding setup to the test-live opens the chance for nonce collision as the test-setup is being run concurrently for the live / integration tests.
…bs read its record test-live ran setup on Arbitrum Sepolia at the same time as the Arbitrum matrix leg, with the same key, and failed on a nonce collision. Setup now runs only in the fixtures jobs, in the concurrency group of the matrix leg of the same testnet, and hands deployments.local.json to the test jobs as an artifact. test-live is read-only again.
… deployments.local.json
Goal
A keyed CI run should, on its own: detect that
SimpleTest's bytecode changed, deploy it if so, and otherwise reuse the contract already on the chain. No registry to keep in sync, no dependency on who deployed last, nothing a human has to refresh.Why it didn't
setup.mjsdecided "deploy or not" by comparing the compiled bytecode hash with the committedtest/setup/src/deployments.json. #390 changed the bytecode and CI never writes that file back, so since then every keyed run redeployedSimpleTeston Ethereum, Arbitrum and Base Sepolia, and on 2026-11-09 one of those deploys failed on Base Sepolia (run 42641443056) before any test ran. The stored values had the same shape:primaryTestChainRegistry.jsonpinned handles that only the account that ran setup could read, sotest-livedepended on a human running setup with CI's own key and committing.Change
The chain is the only source of truth; the committed registries are gone.
0x4e59b44847b379578588920cA78FbF26c0B4956C, detected withcast code),SimpleTestlives at an address computed from a fixed salt and its bytecode. Setup skips when that address has code, deploys through the deployer otherwise, and treats a failed send as success when the code is there afterwards (another run got there first). The deployer beingmsg.senderat construction is harmless:SimpleTesthas no constructor and no owner.deployments.local.json, gitignored, and tsup inlines it into the bundle of this checkout. A checkout where setup has not run has no addresses and the live suites say so.storedValue(42) andpublicValue(7) as its account and pins the resulting handles in the same local file, read at the block of its own transaction. The decrypt tests use the pinned handles. The fixture is shared and the matrix suites overwrite it, but a handle stays decryptable after the contract moves on, so this is the one thing the tests cannot read live from the chain. Setup skips the step while the TaskManager's ACL still allows the pinned handles for this account, so a developer's checkout stores once; a fresh runner stores on each run (two transactions).Test fixturesjob, one leg per testnet. Each leg uploads itsdeployments.local.jsonas an artifact; the live suite and the matrix leg of that testnet wait for it and download the file before they build. Setup sends transactions from the test account, and so does the matrix leg, so the fixtures leg sits in the same concurrency group as the matrix leg of its testnet and the two never overlap, within a run or across runs. The live suite only reads, as before this PR. An earlier version of this PR ran setup insidetest-liveas well; that collided with the Arbitrum matrix leg on the account's nonce (run 43429024574).forge create, recorded in the same local file. They reset periodically, so a fresh runner deploys there once per run.A keyed run, before and after
Before:
forge build→ hash differs from the committed entry →forge create→ address written to the runner only → values stored again → tests. Three deploys per run, and a failed deploy fails the job.After, in the fixtures job:
forge build→ the CREATE2 address has code → skip → store the two values and pin their handles → upload the record. Then the test jobs download it and run. The first run after a bytecode change deploys once per chain; every later run only reads the chain, apart from the two value stores on Arbitrum. (This PR's CI runs showed exactly this: the first deployed on all three chains, the next ones logged a skip.)Gaps that remain
forge createaddress lives only in the checkout's local file. Installing the CREATE2 deployer there would fix it, but its presigned legacy transaction may be rejected by those nodes and would have to be redone after every reset. Left as is; those chains are ephemeral.publicValue. Pinning at store time is the fix; it is also what the old committed registry was doing, minus the commit.simpleTestAbi.tsis still a committed file generated from the contract. Unchanged here.Notes
cd test/setup && pnpm test: 18 tests with stubbedcast/forge, no network, covering both deploy paths, the value store and its ACL-gated reuse, and the address derivation againstcast create2.@cofhe/test-setupis private.