test(credible-block): live-anvil scripts for credible block guard upgrades - #94
Merged
makemake-kbo merged 3 commits intoJul 27, 2026
Conversation
…rades
Add an examples/credible-block project that exercises CredibleBlockGuard's
onlyCredibleBlock modifier against a live anvil node, covering the one thing the
vm.roll/vm.prank unit tests cannot: a builder's credible-block marker tx and a
guarded tx landing in the same block (a bundle).
- CredibleRegistry.sol: minimal ICredibleRegistry with a single immutable builder
- GuardedCounter.sol: concrete guard consumer standing in for an upgraded contract
- test-credible-upgrades.sh: seeds anvil + a builder, then verifies
1) credible block - bundled [marker, guarded] both succeed
2) non-credible - guarded tx alone reverts (NonCredibleBlock)
3) fail-open - guarded tx passes only once the builder set is silent
past failOpenBlockThreshold
- foundry.toml: add [profile.credible-block]
makemake-kbo
requested review from
fredo,
lean-apple and
mateo-mro
as code owners
July 24, 2026 12:12
mateo-mro
reviewed
Jul 24, 2026
Refuse to run if the RPC port is already answering before launch, and fail fast if the anvil child exits before becoming ready, instead of adopting (and snapshotting/reverting/disabling automine on) another node.
mateo-mro
reviewed
Jul 24, 2026
…lock in Case 2 Address review on PR #94: - fix stale script header claiming the registry has an admin/whitelist; it takes one immutable builder in the constructor - seed a credible block before Case 2's non-credible check so a small FAIL_OPEN_THRESHOLD override cannot trip fail-open (lastCredibleBlock==0) and report a false failure - use the absolute GitHub URL for the production credible-registry link
mateo-mro
approved these changes
Jul 24, 2026
makemake-kbo
deleted the
makemake/eng-4069-featstd-create-test-scripts-for-testing-contract-updates
branch
July 27, 2026 09:30
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.
What
Adds an
examples/credible-blockproject with scripts to test Credible Layer contract upgrades against a live anvil node.The existing forge unit tests fake block state with
vm.roll/vm.prank. That covers the guard's decision logic but cannot reproduce the one thing that only exists on a real chain: a builder's credible-block marker transaction and a guarded transaction landing in the same block (a bundle). These scripts seed a real node and drive mining manually to test exactly that.Contents
src/CredibleRegistry.sol— minimalICredibleRegistry: a single immutable builder (set at construction) can mark the current block credible. Trimmed to the least required to exercise the guard; the production registry additionally has a timelocked admin, builder whitelist, and timestamp slot-binding.src/GuardedCounter.sol— a concreteCredibleBlockGuardconsumer standing in for an upgraded credible-layer contract (bump()isonlyCredibleBlock).script/test-credible-upgrades.sh— boots anvil (fifo mempool ordering), deploys the registry + a builder we control + the guard, then verifies three cases.foundry.toml— new[profile.credible-block].Cases verified (all pass)
[markCurrentBlockCredible, bump]into one block (automine off +cast send --async+ singleevm_mine); both succeed, counter increments.bump()with no marker reverts withNonCredibleBlock(); counter unchanged.> failOpenBlockThresholdblocks,bump()passes again (and still reverts at the boundary, gap == threshold).Running
Requires
anvil,cast,forge,jq. Exits non-zero on any failed check. Seeexamples/credible-block/README.mdfor details.