Timelock refactor - #172
Draft
JohnChangUK wants to merge 1 commit into
Draft
Conversation
Soroban Contract Test Coverage91.82% line coverage — 18068 / 19677 lines hit
Per-Contract Breakdown
Full file-level coverage report |
There was a problem hiding this comment.
Pull request overview
Refactors the Stellar timelock contract to a v2 model with exact role capabilities, permissionless execution of ready operations, self-administration via internal dispatch (to avoid Soroban re-entry), and target-scoped function blocking. This aligns timelock operation authorization with committed operation content rather than the transaction sender, and updates hashing/encoding plus downstream interface/bindings accordingly.
Changes:
- Introduces canonical
{target,function,args_xdr}calls with new length-prefixed hashing and an explicit batch domain separator (encoding.rs). - Reworks access control to exact roles (no admin-or-role fallback), self-admin-only ADMIN, and sharded role storage keys.
- Adds target-scoped function blocking and propagates ABI changes through Rust interfaces and Go bindings.
Reviewed changes
Copilot reviewed 10 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| contracts/timelock/src/types.rs | Updates on-chain types: new Call shape, new storage keys, target-scoped BlockedFunction. |
| contracts/timelock/src/test.rs | Rewrites tests to cover v2 semantics (self-admin, permissionless execute, target-scoped blocking, new call encoding). |
| contracts/timelock/src/storage.rs | Implements sharded persistent storage model and revised TTL bump behavior. |
| contracts/timelock/src/roles.rs | Replaces role-or-admin checks with exact roles + unknown-role rejection; updates role CRUD helpers. |
| contracts/timelock/src/lib.rs | Implements v2 authorization model, permissionless execute_batch, internal self-admin dispatch, and new blocking APIs. |
| contracts/timelock/src/events.rs | Updates event payloads to match {target,function,args_hash} and new block/unblock events. |
| contracts/timelock/src/error.rs | Adds new error codes for v2 (unknown role, invalid target, args XDR errors, empty batch, etc.). |
| contracts/timelock/src/encoding.rs | Adds call/batch hashing, call validation, and golden vector tests for deterministic IDs. |
| contracts/timelock/Cargo.toml | Moves stellar-strkey to dev-dependencies (used only in tests). |
| contracts/common/interfaces/src/timelock.rs | Updates shared interface/types to match new ABI and error/event shapes. |
| bindings/contracts/timelock/types.go | Updates generated Go types for new Call/BlockedFunction and new error codes. |
| bindings/contracts/timelock/client.go | Updates generated Go client methods for ABI changes (initialize, execute_batch, blocking APIs, etc.). |
Files not reviewed (2)
- bindings/contracts/timelock/client.go: Generated file
- bindings/contracts/timelock/types.go: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…n of ready operations, self-administration, and target-scoped function blocking.
JohnChangUK
force-pushed
the
feat/stellar-mcms-v2-timelock
branch
from
August 2, 2026 19:38
d044ad5 to
18fa08e
Compare
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.
Summary
Moves the timelock to exact role capabilities, permissionless execution of ready operations, self-administration, and target-scoped function blocking.
Key changes
encoding.rsadded:DOMAIN_TIMELOCK_BATCH_STELLAR, length-prefixed call/batch hashing,validate_call, empty batch rejected.require_role_or_adminremoved → exactrequire_role:schedule_batch→PROPOSER,cancel→CANCELLER,bypasser_execute_batch→BYPASSER, admin ops→ADMIN; newvalidate_rolerejects unknown roles.initializedrops bothadminandexecutors; ADMIN granted only toenv.current_contract_address()so no EOA ever holds it;EXECUTOR_ROLEdeleted.execute_batchdrops itscallerargument — anyone may execute a ready operation; authorization is the committed operation, not the sender. DONE persisted before the first external call and rolls back on failure.execute_calldispatches self-targeted admin calls internally (execute_self_admin) because Soroban forbids contract re-entry; argument layout mirrors the public ABI so proposal encoding and operation hashing are unchanged. Unsupported self-calls fail withUnsupportedSelfCall.Callreshaped{to,data}→{target,function,args_xdr}; blocking becomes target-scopedBlockedFunction {target,function}.get_op_timestampno longer extends TTL.