Skip to content

Timelock refactor - #172

Draft
JohnChangUK wants to merge 1 commit into
feat/stellar-mcms-v2-contractfrom
feat/stellar-mcms-v2-timelock
Draft

Timelock refactor#172
JohnChangUK wants to merge 1 commit into
feat/stellar-mcms-v2-contractfrom
feat/stellar-mcms-v2-timelock

Conversation

@JohnChangUK

Copy link
Copy Markdown
Contributor

Summary

Moves the timelock to exact role capabilities, permissionless execution of ready operations, self-administration, and target-scoped function blocking.

  • Makes ADMIN a policy-only capability held by the Timelock itself

Key changes

  • encoding.rs added: DOMAIN_TIMELOCK_BATCH_STELLAR, length-prefixed call/batch hashing, validate_call, empty batch rejected.
  • require_role_or_admin removed → exact require_role: schedule_batch→PROPOSER, cancel→CANCELLER, bypasser_execute_batch→BYPASSER, admin ops→ADMIN; new validate_role rejects unknown roles.
  • initialize drops both admin and executors; ADMIN granted only to env.current_contract_address() so no EOA ever holds it; EXECUTOR_ROLE deleted.
  • execute_batch drops its caller argument — 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_call dispatches 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 with UnsupportedSelfCall.
  • Call reshaped {to,data}{target,function,args_xdr}; blocking becomes target-scoped BlockedFunction {target,function}.
  • Role storage sharded into per-account keys; get_op_timestamp no longer extends TTL.

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

Soroban Contract Test Coverage

91.82% line coverage — 18068 / 19677 lines hit

Metric Hit Total Coverage
Lines 18068 19677 91.82%
Functions 1203 1559 77.16%
Regions 33302 35993 92.52%

Per-Contract Breakdown

Contract Lines (Hit / Total) Line Cov Funcs (Hit / Total) Func Cov
other 18068 / 19677 91.8% 1203 / 1559 77.2%
Full file-level coverage report
Filename                                                 Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ccip-ramp-registry/src/lib.rs                                188                75    60.11%           8                 3    62.50%         104                41    60.58%           0                 0         -
ccip-ramp-registry/src/test.rs                               214                 0   100.00%           5                 0   100.00%         128                 0   100.00%           0                 0         -
ccip-ramp-registry/src/types.rs                               83                11    86.75%          17                 6    64.71%          83                11    86.75%           0                 0         -
ccvs/committee-verifier/src/lib.rs                           588                54    90.82%          26                 2    92.31%         382                10    97.38%           0                 0         -
ccvs/committee-verifier/src/test.rs                         1300                25    98.08%          48                 2    95.83%         587                13    97.79%           0                 0         -
ccvs/committee-verifier/src/types.rs                          17                 8    52.94%           6                 5    16.67%          14                 7    50.00%           0                 0         -
ccvs/versioned-verifier-resolver/src/lib.rs                  287                21    92.68%          14                 1    92.86%         162                 4    97.53%           0                 0         -
ccvs/versioned-verifier-resolver/src/test.rs                 680                 9    98.68%          20                 0   100.00%         359                 3    99.16%           0                 0         -
ccvs/versioned-verifier-resolver/src/types.rs                 89                 6    93.26%          16                 4    75.00%          83                 4    95.18%           0                 0         -
common/authorization/src/allowlist.rs                        167                51    69.46%          12                 4    66.67%         110                40    63.64%           0                 0         -
common/authorization/src/lib.rs                              426                27    93.66%          16                 0   100.00%         277                16    94.22%           0                 0         -
common/authorization/src/ownable.rs                          102                13    87.25%           9                 1    88.89%          62                 6    90.32%           0                 0         -
common/authorization/src/test.rs                            1195                 0   100.00%          57                 0   100.00%         462                 0   100.00%           0                 0         -
common/guard/src/initializable.rs                             30                 1    96.67%           4                 0   100.00%          22                 1    95.45%           0                 0         -
common/guard/src/lib.rs                                       32                 1    96.88%           4                 0   100.00%          22                 0   100.00%           0                 0         -
common/guard/src/test.rs                                     101                 0   100.00%           8                 0   100.00%          47                 0   100.00%           0                 0         -
common/helpers/src/curse_checkable.rs                        103                24    76.70%           6                 1    83.33%          56                12    78.57%           0                 0         -
common/helpers/src/map_updater.rs                             94                15    84.04%           7                 3    57.14%          39                 8    79.49%           0                 0         -
common/helpers/src/soroban_invoke.rs                         277                 7    97.47%          12                 0   100.00%         115                 1    99.13%           0                 0         -
common/interfaces/src/ccip_receiver.rs                         8                 8     0.00%           8                 8     0.00%           8                 8     0.00%           0                 0         -
common/interfaces/src/committee_verifier.rs                   13                13     0.00%          13                13     0.00%          13                13     0.00%           0                 0         -
common/interfaces/src/fee_quoter.rs                           17                17     0.00%          17                17     0.00%          17                17     0.00%           0                 0         -
common/interfaces/src/offramp.rs                              11                11     0.00%          11                11     0.00%          11                11     0.00%           0                 0         -
common/interfaces/src/onramp.rs                                9                 9     0.00%           9                 9     0.00%           9                 9     0.00%           0                 0         -
common/interfaces/src/ramp_registry.rs                         5                 5     0.00%           5                 5     0.00%           5                 5     0.00%           0                 0         -
common/interfaces/src/rmn_proxy.rs                             6                 6     0.00%           6                 6     0.00%           6                 6     0.00%           0                 0         -
common/interfaces/src/router.rs                                9                 9     0.00%           9                 9     0.00%           9                 9     0.00%           0                 0         -
common/interfaces/src/siloed_lock_release_pool.rs             21                21     0.00%          21                21     0.00%          21                21     0.00%           0                 0         -
common/interfaces/src/token_admin_registry.rs                  8                 8     0.00%           8                 8     0.00%           8                 8     0.00%           0                 0         -
common/interfaces/src/token_lock_box.rs                        6                 6     0.00%           6                 6     0.00%           6                 6     0.00%           0                 0         -
common/interfaces/src/token_pool.rs                           11                11     0.00%          11                11     0.00%          11                11     0.00%           0                 0         -
common/interfaces/src/versioned_verifier_resolver.rs          10                10     0.00%          10                10     0.00%          10                10     0.00%           0                 0         -
common/message/src/lib.rs                                    586                41    93.00%          28                 4    85.71%         298                 9    96.98%           0                 0         -
common/message/src/test.rs                                   641                 2    99.69%          28                 0   100.00%         323                 0   100.00%           0                 0         -
common/pool/src/decimals.rs                                  109                10    90.83%           6                 0   100.00%          76                 3    96.05%           0                 0         -
common/pool/src/finality_codec.rs                             52                 1    98.08%           3                 0   100.00%          41                 0   100.00%           0                 0         -
common/pool/src/lib.rs                                       460                31    93.26%          32                 1    96.88%         409                26    93.64%           0                 0         -
common/pool/src/rate_limit.rs                                180                 7    96.11%           9                 0   100.00%         145                 3    97.93%           0                 0         -
common/pool/src/types.rs                                      20                14    30.00%          16                14    12.50%          30                14    53.33%           0                 0         -
common/signature/src/config.rs                                44                12    72.73%           6                 2    66.67%          28                 5    82.14%           0                 0         -
common/signature/src/quorum.rs                                68                 1    98.53%           2                 0   100.00%          44                 1    97.73%           0                 0         -
common/signature/src/scheme.rs                                45                 0   100.00%           2                 0   100.00%          29                 0   100.00%           0                 0         -
cre/forwarder/src/error.rs                                     8                 3    62.50%           1                 0   100.00%           8                 3    62.50%           0                 0         -
cre/forwarder/src/lib.rs                                     462                24    94.81%          18                 0   100.00%         318                 7    97.80%           0                 0         -
cre/forwarder/src/test.rs                                   2886                14    99.51%         128                 2    98.44%        1204                 8    99.34%           0                 0         -
cre/forwarder/src/types.rs                                    62                 6    90.32%          10                 6    40.00%          36                 6    83.33%           0                 0         -
cre/test/read_fixture/src/lib.rs                             125               125     0.00%          33                33     0.00%         103               103     0.00%           0                 0         -
cre/test/receiver/src/lib.rs                                  53                53     0.00%           5                 5     0.00%          26                26     0.00%           0                 0         -
cre/test/rejecting_receiver/src/lib.rs                         3                 3     0.00%           1                 1     0.00%           8                 8     0.00%           0                 0         -
fee-quoter/src/lib.rs                                        771               164    78.73%          20                 3    85.00%         527               100    81.02%           0                 0         -
fee-quoter/src/test.rs                                       861                 0   100.00%          17                 0   100.00%         427                 0   100.00%           0                 0         -
fee-quoter/src/types.rs                                       13                13     0.00%          13                13     0.00%          13                13     0.00%           0                 0         -
mcms/src/constants.rs                                         10                 0   100.00%           2                 0   100.00%           6                 0   100.00%           0                 0         -
mcms/src/crypto.rs                                           202                 3    98.51%           7                 0   100.00%         109                 2    98.17%           0                 0         -
mcms/src/encoding.rs                                         328                 8    97.56%          15                 0   100.00%         196                 3    98.47%           0                 0         -
mcms/src/error.rs                                              8                 3    62.50%           1                 0   100.00%           8                 3    62.50%           0                 0         -
mcms/src/lib.rs                                              715                54    92.45%          17                 0   100.00%         511                23    95.50%           0                 0         -
mcms/src/test.rs                                            2439                39    98.40%          71                 2    97.18%        1150                16    98.61%           0                 0         -
mcms/src/types.rs                                             10                10     0.00%          10                10     0.00%          10                10     0.00%           0                 0         -
offramp/src/lib.rs                                           729               400    45.13%          23                 8    65.22%         473               224    52.64%           0                 0         -
offramp/src/test.rs                                          890                 0   100.00%          28                 0   100.00%         363                 0   100.00%           0                 0         -
offramp/src/types.rs                                          21                 9    57.14%           6                 5    16.67%          17                 7    58.82%           0                 0         -
onramp/src/lib.rs                                           1181               149    87.38%          27                 2    92.59%         739                61    91.75%           0                 0         -
onramp/src/test.rs                                          1591                 4    99.75%          37                 0   100.00%         708                 4    99.44%           0                 0         -
onramp/src/types.rs                                           23                 9    60.87%           6                 5    16.67%          19                 7    63.16%           0                 0         -
pools/burn-mint-pool/src/lib.rs                              390               107    72.56%          28                 9    67.86%         282                55    80.50%           0                 0         -
pools/burn-mint-pool/src/test.rs                            2671                24    99.10%          56                 5    91.07%        1744                55    96.85%           0                 0         -
pools/lock-release-pool/src/lib.rs                           404               100    75.25%          28                 8    71.43%         288                48    83.33%           0                 0         -
pools/lock-release-pool/src/test.rs                         2330                24    98.97%          55                 5    90.91%        1524                55    96.39%           0                 0         -
pools/siloed-lock-release-pool/src/lib.rs                    556               196    64.75%          38                17    55.26%         384               123    67.97%           0                 0         -
pools/siloed-lock-release-pool/src/test.rs                  1303                12    99.08%          38                 2    94.74%         695                18    97.41%           0                 0         -
pools/token-lock-box/src/lib.rs                              197                17    91.37%          13                 1    92.31%         113                 2    98.23%           0                 0         -
pools/token-lock-box/src/test.rs                             257                 0   100.00%           7                 0   100.00%          73                 0   100.00%           0                 0         -
registry/src/lib.rs                                            8                 0   100.00%           1                 0   100.00%           3                 0   100.00%           0                 0         -
registry/src/test.rs                                          27                 0   100.00%           1                 0   100.00%          11                 0   100.00%           0                 0         -
rmn_proxy/src/lib.rs                                          66                12    81.82%           5                 1    80.00%          34                 3    91.18%           0                 0         -
rmn_proxy/src/test.rs                                        279                 0   100.00%          11                 0   100.00%          91                 0   100.00%           0                 0         -
rmn_remote/src/lib.rs                                        302                26    91.39%          16                 1    93.75%         171                10    94.15%           0                 0         -
rmn_remote/src/test.rs                                       393                 0   100.00%          14                 0   100.00%         133                 0   100.00%           0                 0         -
router/src/lib.rs                                            593                87    85.33%          18                 1    94.44%         374                43    88.50%           0                 0         -
router/src/test.rs                                          1186                 0   100.00%          29                 0   100.00%         497                 0   100.00%           0                 0         -
router/src/test_panic_receiver.rs                              5                 0   100.00%           2                 0   100.00%           5                 0   100.00%           0                 0         -
router/src/types.rs                                            3                 3     0.00%           3                 3     0.00%           3                 3     0.00%           0                 0         -
timelock/src/encoding.rs                                     329                 3    99.09%          15                 0   100.00%         182                 1    99.45%           0                 0         -
timelock/src/error.rs                                          6                 2    66.67%           1                 0   100.00%           6                 2    66.67%           0                 0         -
timelock/src/lib.rs                                          679               261    61.56%          33                11    66.67%         382               132    65.45%           0                 0         -
timelock/src/roles.rs                                         82                30    63.41%           7                 2    71.43%          62                21    66.13%           0                 0         -
timelock/src/storage.rs                                      227                51    77.53%          14                 1    92.86%         124                22    82.26%           0                 0         -
timelock/src/test.rs                                         798                13    98.37%          24                 0   100.00%         296                 0   100.00%           0                 0         -
timelock/src/types.rs                                          4                 4     0.00%           4                 4     0.00%           4                 4     0.00%           0                 0         -
token-admin-registry/src/lib.rs                              368                23    93.75%          18                 1    94.44%         257                 4    98.44%           0                 0         -
token-admin-registry/src/test.rs                             825                 0   100.00%          21                 0   100.00%         287                 0   100.00%           0                 0         -
token-admin-registry/src/types.rs                              2                 2     0.00%           2                 2     0.00%           2                 2     0.00%           0                 0         -
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                      35993              2691    92.52%        1559               356    77.16%       19677              1609    91.82%           0                 0         -```

</details>

> Commit `18fa08e8` | [Full CI run](https://github.com/smartcontractkit/chainlink-stellar/actions/runs/30763825691)

<!-- Sticky Pull Request Commentcontract-coverage -->

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread contracts/timelock/src/storage.rs
…n of ready

operations, self-administration, and target-scoped function blocking.
@JohnChangUK
JohnChangUK force-pushed the feat/stellar-mcms-v2-timelock branch from d044ad5 to 18fa08e Compare August 2, 2026 19:38
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.

2 participants