Skip to content

fix(contracts): Validate deploy script parameters - #576

Merged
ebma merged 19 commits into
mainfrom
fix/governance-require-canceller
Oct 25, 2026
Merged

ebma merged 19 commits into
mainfrom
fix/governance-require-canceller

Conversation

@ebma

@ebma ebma commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

What

Both deploy scripts validate every parameter before broadcasting, so a misconfigured environment stops before anything is deployed.

Deploy.s.sol (migration)

  • MAX_ISSUANCE must match the fixed supply.
  • EARLIEST_SWEEP_TS must be given in seconds and, on Base mainnet, lie at least 30 days after the deployment.
  • On Base mainnet the bootstrap admin must be a Safe with at least two signers.

DeployGovernance.s.sol

  • PEN_TOKEN must be the vault's token (VAULT_ADDRESS is required).
  • The timelock delay and the voting windows have lower and upper bounds, and the quorum floor and fraction must be meaningful.
  • TIMELOCK_CANCELLER is required: a dedicated Safe with at least two signers, distinct from the guardian, the token and the vault. It receives CANCELLER_ROLE.

TEST_DEPLOY=true relaxes the multisig and floor checks for testnet drills and is refused on Base mainnet.

Testing

  • forge test: 45 tests, covering every refusal and the production paths on Base mainnet's chain id.
  • The Base Sepolia rehearsal scripts set the test values they need.

ebma added 19 commits October 21, 2026 16:53
Once a queued operation's delay has passed anyone may execute it, and OZ
Governor lets only the proposer cancel before voting starts. Without a
canceller nobody could veto a passed proposal during the delay, so the
script now refuses to deploy without TIMELOCK_CANCELLER. The Base Sepolia
governance rehearsal passes its guardian as canceller and checks the role.
…ript

MAX_ISSUANCE and EARLIEST_SWEEP_TS cannot be changed once the token and
vault exist. The script now refuses an issuance other than 150M PEN in
18-decimal units and a sweep floor that is not a future unix time in
seconds within the next two years, so a units slip fails before anything
is broadcast.

It also broadcasts explicitly as msg.sender, the address it already
hands the interim admin role to, and returns the deployed contracts.
That leaves forge script behaviour unchanged and lets a Foundry test run
the script itself: the new test covers each refusal and the happy path.
Most governance parameters are fixed at deploy or can only be changed by
a proposal through the governor being deployed, so the script now checks
each one before broadcasting:

- PEN_TOKEN must be the token of the new VAULT_ADDRESS
- TIMELOCK_DELAY is 48h to 30 days; VOTING_DELAY and VOTING_PERIOD are
  at most 30 days, checked before narrowing to the governor's types
- PROPOSAL_THRESHOLD and QUORUM_FLOOR are 18-decimal units between 1 PEN
  and the total supply, so a whole-PEN figure is refused
- TIMELOCK_CANCELLER must not be the deployer and must have code

TEST_DEPLOY=true admits the shorter delay, a codeless canceller and a
zero floor that testnet drills use, and is refused on Base mainnet. The
Base Sepolia rehearsal sets it and passes the vault address.

The script broadcasts as msg.sender and returns the deployed contracts,
so a Foundry test now runs it: each refusal, the drill override, and the
role wiring (the deployer keeps no timelock role, the canceller holds
CANCELLER_ROLE).
…overnor tests

The canceller is meant to be a dedicated Safe, separate from the pause
guardian, so the governor test fixture now grants CANCELLER_ROLE to its
own address instead of the guardian's. The Base Sepolia drill keeps
reusing its guardian key for the role and now says so.
Having code on the chain is true of any contract, so the governance
deploy script now asks the canceller for its Safe threshold instead:
getThreshold() must succeed and return a non-zero value, and an EIP-7702
delegated EOA is refused whatever it delegates to. The canceller must
also not be PEN_TOKEN, VAULT_ADDRESS or the vault's guardian.

TEST_DEPLOY keeps admitting a canceller that is not a Safe and the
guardian key, which the testnet drills reuse. The deploy test now uses a
stub that answers getThreshold() and covers each refusal.
VOTING_DELAY and VOTING_PERIOD only had an upper bound, so days entered
as seconds produced a governor with a vote of a few seconds. The deploy
script now requires a voting delay of at least one hour and a voting
period of at least one day. TEST_DEPLOY admits the shorter drill
windows, which the deploy test now runs.
The canceller check in the governance deploy refused every non-Safe
with the same message, including a Safe with threshold 0 and an EIP-7702
delegated EOA, where getThreshold() had answered. It now names the
reason: no code on this chain, a delegated EOA, getThreshold() failing
or answering anything but one word, or a threshold of 0. The deploy test
covers each refusal, including short and long getThreshold() answers.
…igners

A 1-of-n canceller Safe is a single key holding a veto over every queued
proposal. The governance deploy now refuses a canceller whose Safe
threshold is below 2 unless TEST_DEPLOY is set.
…deploy

With QUORUM_FRACTION=0 the governor's quorum stays at the permanent
floor however much PEN circulates. The governance deploy now refuses 0
unless TEST_DEPLOY is set, which the drills use with drill-scale voting
power.
The scripts read their parameters from the process-wide environment and
forge runs test functions in parallel. Both scripts are about to read
TEST_DEPLOY, so their cases now share one test function instead of two
that could race on it.
The migration deploy handed vault admin to whatever ADMIN_SAFE named. It
now refuses an address without code on the chain and an EIP-7702
delegated EOA. TEST_DEPLOY, refused on Base mainnet as in the governance
deploy, admits a plain key for testnet drills and local runs; the Anvil
and Base Sepolia harnesses set it.
The migration deploy accepted any future EARLIEST_SWEEP_TS, so a value
an hour or two ahead from a drill environment would have been fixed in
the vault for good. It now requires the floor to lie at least 30 days
after the deploy block unless TEST_DEPLOY is set; 2027-03-01 still
passes for a deploy up to 2027-01-30.
The drill wrote its parameters to the run manifest with JSON.stringify,
which throws on the BigInt quorum floor, so a run aborted after its last
check and exited non-zero.
@ebma ebma changed the title fix(contracts): Require a timelock canceller in the governance deploy fix(contracts): Validate deploy script parameters Oct 23, 2026
@ebma
ebma merged commit c44034e into main Oct 25, 2026
7 checks passed
@ebma
ebma deleted the fix/governance-require-canceller branch October 25, 2026 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant