Pre-mainnet hardening: repoint owner check, shared hold-check helper, pinned remappings #19

Merged
Taskuler-bot merged 5 commits from feat/premainnet-hardening into main 2026-11-17 03:20:12 +00:00
Member

Base main. #17 is merged (2404283), so this was retargeted. Pre-mainnet suggestions from Security's PR #17 re-review (v2) and its #19 re-review (2026-11-16): no High/Medium/Low; Info-D/E/F fixed at d790cbb. Info-G and Info-H are added in 5b929ef and 77c2b5e, which are not reviewed yet. Do not merge until reviewed.

Bytecode: only 5aa3adb is byte-identical to #17, metadata included. 9b06cd1, d790cbb, 5b929ef and 77c2b5e change BuilderBonus's executable code. All other contracts, TaskulerMarket included, are byte-identical to #17 at every commit. Sepolia runs 8610085 (#20), so a BuilderBonus redeploy will be needed after this merges for the changes to take effect on testnet.

Changes

  • Info-D (shared-owner invariant on repoints): scheduleRepoint and executeRepoint now revert OwnerMismatch() unless the target Market's owner() equals BuilderBonus's owner(). The check runs at both steps, so ownership drifting apart during the 48-hour delay blocks the repoint. A missing or malformed owner() answer counts as a mismatch. It guards against mistakes; a contract that reports a false owner is still bounded as described in KI-14.
  • Info-E (one gas-check helper): the gas-capped isHeld call (the InsufficientGas guard plus staticcall{gas: HOLD_CHECK_GAS}) is now one internal helper, _holdProbe, used by _firstHold and ignoreBrokenMarketHolds. The threshold is an internal constant, HOLD_CHECK_MIN_GAS (55,793), with the same value as before. No ABI change. This does change BuilderBonus's executable bytecode (code layout); the runtime stays 15,366 B. Security measured the gas edges of ignoreBrokenMarketHolds and withdraw and found them identical to 7a41b38, to the gas unit.
  • Info-F (reproducible metadata): foundry.toml now lists all three remappings and sets auto_detect_remappings = false. At 5aa3adb, a clean build gives exactly the same creation and runtime bytecode, metadata hash included, for every contract in src/, compared with #17. Security also reproduced all 11 deployed b19f21d contracts with the pinned config.
  • Info-G (owner check hardening): _requireSameOwner now does the following:
    • calls owner() with exactly OWNER_CHECK_GAS (50,000), reverting InsufficientGas if less than OWNER_CHECK_MIN_GAS is left;
    • copies at most one word of return data;
    • treats any return size other than 32 bytes as OwnerMismatch, as do a revert, a gas burner and dirty high bits.
  • Info-H (constructor): the BuilderBonus constructor calls _requireSameOwner(market_), so the initial Market must report BuilderBonus's owner too, whatever the deploy script.

ABI (BuilderBonus)

  • New error: OwnerMismatch() 0xa8c81623. No new functions or events. The constructor (Info-H) and scheduleRepoint/executeRepoint can also revert InsufficientGas() from the owner check (Info-G).

Tests

  • test_ScheduleRepointRequiresSameOwner: a different owner, no owner(), and a two-word owner() all revert OwnerMismatch; the same owner passes.
  • test_ExecuteRepointRechecksOwner: the Market owner moves during the delay, so execute reverts; once BuilderBonus's owner moves too, it executes.
  • test_ExecuteRepointBlockedAfterBonusOwnerMoves: BuilderBonus's owner moves alone, so execute reverts.
  • test_OwnerCheckGasCappedAndSizeChecked (Info-G): a gas burner, a 30 KB return, dirty high bits, an empty return and a revert all give OwnerMismatch for under 120k gas; 60k forwarded gives InsufficientGas; a clean answer passes.
  • test_ConstructorRequiresSameOwner (Info-H): a Market reporting another owner, or a governance that isn't the genuine Market's owner, makes the constructor revert OwnerMismatch; the matching owner deploys.
  • The test fake Markets now report the shared owner (setOwner(safe)) so the existing repoint scenarios still run.
  • Full forge test with the fork RPC set: 353 passed, 0 failed, 0 skipped.

Size

BuilderBonus is 15,518 B (9,058 B margin). TaskulerMarket is unchanged at 24,146 B (430 B margin). Every other contract's bytecode is unchanged.

Docs

  • KI-14 and runbook section 5: the constructor and repoints enforce the shared owner, so finish moving both owners before executing.
  • README (repoint section; remappings pinned), THREAT-MODEL (repoint bounds), AUDIT-SCOPE (owner powers; total 3254/2140).
Base `main`. #17 is merged (`2404283`), so this was retargeted. Pre-mainnet suggestions from Security's PR #17 re-review (v2) and its #19 re-review (2026-11-16): no High/Medium/Low; Info-D/E/F fixed at `d790cbb`. Info-G and Info-H are added in `5b929ef` and `77c2b5e`, which are not reviewed yet. Do not merge until reviewed. **Bytecode:** only `5aa3adb` is byte-identical to #17, metadata included. `9b06cd1`, `d790cbb`, `5b929ef` and `77c2b5e` change BuilderBonus's executable code. All other contracts, TaskulerMarket included, are byte-identical to #17 at every commit. Sepolia runs `8610085` (#20), so a BuilderBonus redeploy will be needed after this merges for the changes to take effect on testnet. ## Changes - **Info-D (shared-owner invariant on repoints):** `scheduleRepoint` and `executeRepoint` now revert `OwnerMismatch()` unless the target Market's `owner()` equals BuilderBonus's `owner()`. The check runs at both steps, so ownership drifting apart during the 48-hour delay blocks the repoint. A missing or malformed `owner()` answer counts as a mismatch. It guards against mistakes; a contract that reports a false owner is still bounded as described in KI-14. - **Info-E (one gas-check helper):** the gas-capped `isHeld` call (the `InsufficientGas` guard plus `staticcall{gas: HOLD_CHECK_GAS}`) is now one internal helper, `_holdProbe`, used by `_firstHold` and `ignoreBrokenMarketHolds`. The threshold is an internal constant, `HOLD_CHECK_MIN_GAS` (55,793), with the same value as before. No ABI change. This **does change BuilderBonus's executable bytecode** (code layout); the runtime stays 15,366 B. Security measured the gas edges of `ignoreBrokenMarketHolds` and `withdraw` and found them identical to 7a41b38, to the gas unit. - **Info-F (reproducible metadata):** `foundry.toml` now lists all three remappings and sets `auto_detect_remappings = false`. At `5aa3adb`, a clean build gives exactly the same creation and runtime bytecode, metadata hash included, for every contract in `src/`, compared with #17. Security also reproduced all 11 deployed b19f21d contracts with the pinned config. - **Info-G (owner check hardening):** `_requireSameOwner` now does the following: - calls `owner()` with exactly `OWNER_CHECK_GAS` (50,000), reverting `InsufficientGas` if less than `OWNER_CHECK_MIN_GAS` is left; - copies at most one word of return data; - treats any return size other than 32 bytes as `OwnerMismatch`, as do a revert, a gas burner and dirty high bits. - **Info-H (constructor):** the BuilderBonus constructor calls `_requireSameOwner(market_)`, so the initial Market must report BuilderBonus's owner too, whatever the deploy script. ## ABI (BuilderBonus) - New error: `OwnerMismatch()` `0xa8c81623`. No new functions or events. The constructor (Info-H) and `scheduleRepoint`/`executeRepoint` can also revert `InsufficientGas()` from the owner check (Info-G). ## Tests - `test_ScheduleRepointRequiresSameOwner`: a different owner, no `owner()`, and a two-word `owner()` all revert `OwnerMismatch`; the same owner passes. - `test_ExecuteRepointRechecksOwner`: the Market owner moves during the delay, so execute reverts; once BuilderBonus's owner moves too, it executes. - `test_ExecuteRepointBlockedAfterBonusOwnerMoves`: BuilderBonus's owner moves alone, so execute reverts. - `test_OwnerCheckGasCappedAndSizeChecked` (Info-G): a gas burner, a 30 KB return, dirty high bits, an empty return and a revert all give `OwnerMismatch` for under 120k gas; 60k forwarded gives `InsufficientGas`; a clean answer passes. - `test_ConstructorRequiresSameOwner` (Info-H): a Market reporting another owner, or a governance that isn't the genuine Market's owner, makes the constructor revert `OwnerMismatch`; the matching owner deploys. - The test fake Markets now report the shared owner (`setOwner(safe)`) so the existing repoint scenarios still run. - Full `forge test` with the fork RPC set: **353 passed, 0 failed, 0 skipped**. ## Size BuilderBonus is 15,518 B (9,058 B margin). TaskulerMarket is unchanged at 24,146 B (430 B margin). Every other contract's bytecode is unchanged. ## Docs - KI-14 and runbook section 5: the constructor and repoints enforce the shared owner, so finish moving both owners before executing. - README (repoint section; remappings pinned), THREAT-MODEL (repoint bounds), AUDIT-SCOPE (owner powers; total 3254/2140).
scheduleRepoint and executeRepoint revert OwnerMismatch unless the target's
owner() is BuilderBonus's owner. Tests for schedule, execute re-check and
ownership moves; docs updated.
Taskuler-bot changed target branch from feat/revoked-hold-ignore to main 2026-11-16 20:00:29 +00:00
george approved these changes 2026-11-17 03:13:51 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
taskuler/contracts!19
No description provided.