Skip to content

feat: add TimeLock contract with queue/execute/cancel#5

Merged
oliv3rdrt merged 1 commit into
mainfrom
feat/timelock-contract
May 17, 2026
Merged

feat: add TimeLock contract with queue/execute/cancel#5
oliv3rdrt merged 1 commit into
mainfrom
feat/timelock-contract

Conversation

@oliv3rdrt

Copy link
Copy Markdown
Owner

Summary

  • src/TimeLock.sol: minimal admin-gated timelock. queue records an eta, execute calls the target once block.timestamp >= eta, cancel invalidates an entry. Operation id = keccak256(target, value, data, salt) so the same call can be queued more than once via distinct salts.
  • All revert paths use custom errors (NotAdmin, AlreadyQueued, NotQueued, TooEarly, CallFailed).
  • test/TimeLock.t.sol: 7 unit + 1 fuzz test using vm.warp to exercise the timing edges. Executes against Counter to keep the target trivial.

Test plan

  • forge test --match-contract TimeLockTest - 8/8 pass (1000 fuzz runs)
  • forge test - 41/41, no regressions

Single-admin timelock used to practice vm.warp timing tests. Custom
errors throughout (NotAdmin / AlreadyQueued / NotQueued / TooEarly /
CallFailed). Operation ID hashes (target, value, data, salt) so the same
call can be queued multiple times via distinct salts.
@oliv3rdrt

Copy link
Copy Markdown
Owner Author

Reviewed - the salt-in-id design avoids the 'same call can never be queued twice' footgun. Tests cover the queue/execute/cancel happy paths plus all four custom-error reverts. Merging.

@oliv3rdrt oliv3rdrt merged commit 813a8eb into main May 17, 2026
@oliv3rdrt oliv3rdrt deleted the feat/timelock-contract branch May 17, 2026 11:30
oliv3rdrt added a commit that referenced this pull request Jun 27, 2026
Single-admin timelock used to practice vm.warp timing tests. Custom
errors throughout (NotAdmin / AlreadyQueued / NotQueued / TooEarly /
CallFailed). Operation ID hashes (target, value, data, salt) so the same
call can be queued multiple times via distinct salts.

Co-authored-by: Oliver Anyanwu <oliver.anyanwu@aol.com>
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