Skip to content

Get start time from parameter registry#254

Draft
neekolas wants to merge 6 commits intomainfrom
01-27-get_start_time_from_parameter_registry
Draft

Get start time from parameter registry#254
neekolas wants to merge 6 commits intomainfrom
01-27-get_start_time_from_parameter_registry

Conversation

@neekolas
Copy link
Collaborator

@neekolas neekolas commented Jan 28, 2026

TL;DR

Added a new parameter to control when rate changes take effect in the RateRegistry contract.

What changed?

  • Added a new parameter key xmtp.rateRegistry.ratesInEffectAfter to the RateRegistry
  • Modified the rate update mechanism to use this timestamp instead of the current block timestamp
  • Added the Arbitrum bridging submodule
  • Updated the _setRateRegistryStartingRates() function to include the new parameter
  • Added validation for the new parameter in the rate update process
  • Updated tests to verify the new functionality

How to test?

  1. Run the existing test suite to verify that the rate registry functionality works with the new parameter
  2. Test specifically the test_updateRates_ratesInEffectAfterOutOfTypeBounds test case to ensure proper validation
  3. Deploy locally using the updated DeployLocal.s.sol script and verify that rates are set with the correct effective timestamp

Why make this change?

This change allows for more flexible control over when rate changes take effect, rather than always using the current block timestamp. This is particularly useful for coordinating rate changes across different systems or for scheduling future rate updates, providing better predictability and control over the rate change process.

@octane-security-app
Copy link

Summary by Octane

New Contracts

No new contracts were added.

Updated Contracts

  • RateRegistry.sol: Added a start time parameter to track when rate changes are effective and adjusted validation for rate changes accordingly.

🔗 Commit Hash: 26d9c35

@coderabbitai
Copy link

coderabbitai bot commented Jan 28, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 01-27-get_start_time_from_parameter_registry

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@macroscopeapp
Copy link

macroscopeapp bot commented Jan 28, 2026

Use parameter registry key IRateRegistry.ratesInEffectAfterParameterKey to set and emit rate start time in RateRegistry.updateRates and validate in DeployLocalScripts

Switch RateRegistry.updateRates to read start time from xmtp.rateRegistry.ratesInEffectAfter and extend IRateRegistry.RatesUpdated with uint64 startTime; update deploy scripts to set/verify the parameter and adjust tests for the new event field.

📍Where to Start

Start with updateRates in src/settlement-chain/RateRegistry.sol, then review the event changes in src/settlement-chain/interfaces/IRateRegistry.sol and the deploy script updates in script/DeployLocal.s.sol.

Changes since #254 opened

  • Added start time validation to RateRegistry.updateRates method to enforce strictly increasing start times [4f4c67c]
  • Added unit tests verifying start time validation behavior in RateRegistry.updateRates [4f4c67c]

Macroscope summarized e23e41d.

@neekolas neekolas force-pushed the 01-27-get_start_time_from_parameter_registry branch from 26d9c35 to 4aef029 Compare January 28, 2026 00:30
@github-actions
Copy link

github-actions bot commented Jan 28, 2026

Changes to gas cost

Generated at commit: 4dc40b6994e5841330697aadf4ab30618102959d, compared to commit: 253037f388b24abce932af96e4391d2693db781e

🧾 Summary (20% most significant diffs)

Contract Method Avg (+/-) %
Proxy __setPauseStatus
fallback
initialize()
initialize(address[])
+14,757 ❌
+147,551,986 ❌
-12,175 ✅
+65,884 ❌
+84.60%
+26109.39%
-15.76%
+132.88%

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
Proxy 105,099 (0) __getSequenceId
__mint
__setMaxPayloadSize
__setMinPayloadSize
__setPauseStatus
__setPayloadBootstrapper
__setSequenceId
adminParameterKey
contractName
fallback
implementation
initialize()
initialize(address[])
maxPayloadSize
migrate
migratorParameterKey
minPayloadSizeParameterKey
name
parameterRegistry
paused
pausedParameterKey
symbol
version
682 (0)
56,427 (0)
821 (0)
804 (0)
826 (0)
48,465 (-228)
7,332 (0)
5,264 (-45)
5,264 (-1)
5,005 (+34)
5,100 (-45)
28,489 (-1)
29,075 (-20,271)
7,140 (0)
28,601 (-740)
5,242 (-68)
5,308 (0)
7,987 (-62)
5,005 (-23)
7,148 (-32)
5,285 (-67)
7,999 (-45)
5,231 (-56)
0.00%
0.00%
0.00%
0.00%
0.00%
-0.47%
0.00%
-0.85%
-0.02%
+0.68%
-0.87%
-0.00%
-41.08%
0.00%
-2.52%
-1.28%
0.00%
-0.77%
-0.46%
-0.45%
-1.25%
-0.56%
-1.06%
6,098 (+216)
63,294 (+1,284)
18,537 (+8,046)
15,181 (+4,785)
32,201 (+14,757)
48,617 (-76)
26,036 (+240)
5,285 (-24)
5,294 (0)
148,117,116 (+147,551,986)
5,144 (-19)
65,055 (-12,175)
115,466 (+65,884)
7,176 (+14)
32,684 (-85)
5,308 (-15)
5,315 (+7)
8,018 (-31)
5,035 (-9)
7,166 (-25)
5,331 (-21)
8,021 (-23)
5,286 (-23)
+3.67%
+2.07%
+76.69%
+46.03%
+84.60%
-0.16%
+0.93%
-0.45%
0.00%
+26109.39%
-0.37%
-15.76%
+132.88%
+0.20%
-0.26%
-0.28%
+0.13%
-0.39%
-0.18%
-0.35%
-0.39%
-0.29%
-0.43%
7,182 (0)
56,439 (0)
821 (0)
804 (0)
48,430 (+47,582)
48,693 (0)
27,232 (0)
5,285 (-24)
5,287 (0)
48,852 (+16,859)
5,145 (-22)
50,056 (-45,677)
124,407 (+74,825)
7,185 (+23)
33,581 (-28)
5,311 (-19)
5,308 (0)
8,018 (-31)
5,028 (-16)
7,169 (-22)
5,335 (-17)
8,021 (-23)
5,281 (-28)
0.00%
0.00%
0.00%
0.00%
+5611.08%
0.00%
0.00%
-0.45%
0.00%
+52.70%
-0.43%
-47.71%
+150.91%
+0.32%
-0.08%
-0.36%
0.00%
-0.39%
-0.32%
-0.31%
-0.32%
-0.29%
-0.53%
7,182 (0)
73,527 (0)
48,425 (0)
48,408 (0)
48,525 (+73)
48,693 (0)
31,336 (0)
5,309 (0)
5,336 (+6)
2,861,555,004 (0)
5,179 (0)
145,712 (+49,979)
124,407 (+74,588)
7,185 (0)
37,542 (+35)
5,378 (+48)
5,330 (+22)
8,049 (0)
5,061 (0)
7,202 (0)
5,352 (0)
8,044 (0)
5,331 (0)
0.00%
0.00%
0.00%
0.00%
+0.15%
0.00%
0.00%
0.00%
+0.11%
0.00%
0.00%
+52.21%
+149.72%
0.00%
+0.09%
+0.90%
+0.41%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
12 (+2)
52 (+6)
33 (+7)
29 (+5)
61 (+29)
9 (+3)
23 (+1)
4 (+3)
14 (+11)
58 (-16,004)
15 (+12)
540 (+450)
32 (+30)
5 (+3)
50 (+45)
14 (+11)
3 (+1)
2 (+1)
20 (+16)
17 (+15)
7 (+5)
2 (+1)
14 (+11)
GenericEIP1967Migrator 121,763 (0) fallback 1,330 (0) 0.00% 3,430 (+350) +11.36% 4,130 (0) 0.00% 4,130 (0) 0.00% 8 (0)
RateRegistryHarness 1,287,888 (+74,888) __getAllRates
__pushRates
congestionFeeParameterKey
initialize
migrate
storageFeeParameterKey
updateRates
2,613 (-22)
10,219 (0)
472 (-22)
2,674 (0)
3,450 (+23)
495 (+23)
972 (0)
-0.83%
0.00%
-4.45%
0.00%
+0.67%
+4.87%
0.00%
12,159 (-22)
11,273 (+182)
472 (-22)
23,415 (+128)
6,877 (+23)
495 (+23)
22,422 (+607)
-0.18%
+1.64%
-4.45%
+0.55%
+0.34%
+4.87%
+2.78%
9,771 (+2,364)
10,219 (0)
472 (-22)
24,184 (0)
7,704 (+23)
495 (+23)
11,152 (+7,925)
+31.92%
0.00%
-4.45%
0.00%
+0.30%
+4.87%
+245.58%
26,480 (-22)
67,119 (0)
472 (-22)
24,184 (0)
11,624 (+23)
495 (+23)
74,293 (+1,201)
-0.08%
0.00%
-4.45%
0.00%
+0.20%
+4.87%
+1.64%
4 (+1)
1,030 (+3)
1 (0)
28 (+4)
5 (0)
1 (0)
11 (+4)
FactoryHarness 1,305,322 (0) deployProxy 2,735 (0) 0.00% 953,805,841 (-4) -0.00% 102,602 (0) 0.00% 2,861,360,028 (-12) -0.00% 6 (0)
RateRegistryUpgrader 4,720,653 (+73,032)
DepositSplitterHarness 683,558 (-12)
IdentityUpdateBroadcasterHarness 1,544,336 (+12)
ParameterKeysHarness 644,733 (+12)
PayerRegistryHarness 3,394,439 (-12)
SequentialMerkleProofsHarness 947,726 (-12)
SettlementChainParameterRegistryHarness 1,149,810 (+12)

@github-actions
Copy link

github-actions bot commented Jan 28, 2026

LCOV of commit 4f4c67c during Solidity #676

Summary coverage rate:
  lines......: 99.9% (1340 of 1341 lines)
  functions..: 100.0% (383 of 383 functions)
  branches...: no data found

Files changed coverage rate:
                                                           |Lines       |Functions  |Branches    
  Filename                                                 |Rate     Num|Rate    Num|Rate     Num
  ===============================================================================================
  src/settlement-chain/RateRegistry.sol                    |29.0%     62| 0.0%    18|    -      0

@octane-security-app
Copy link

Overview

Octane AI analysis has finished. No vulnerabilities were found. Cheers! 🎉🎉🎉


🔗 Commit Hash: 26d9c35

@neekolas neekolas force-pushed the 01-27-get_start_time_from_parameter_registry branch 2 times, most recently from f9be91b to 94d1a95 Compare January 29, 2026 17:57
@neekolas neekolas force-pushed the 01-27-get_start_time_from_parameter_registry branch from 94d1a95 to 8af46e4 Compare January 30, 2026 21:09
neekolas and others added 2 commits February 3, 2026 08:38
Slither 0.11.5 introduced a new reentrancy-balance detector that flags
a pre-existing pattern in DistributionManager._makeWithdrawableAmount().
Tracked in #258.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Collaborator

@KevinSmall KevinSmall left a comment

Choose a reason for hiding this comment

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

lgtm, some minor comments

uint64 startTime_ = RegistryParameters.getUint64Parameter(parameterRegistry, ratesInEffectAfterParameterKey());

uint64 startTime_ = uint64(block.timestamp);
_revertIfNoRateChange(messageFee_, storageFee_, congestionFee_, targetRatePerMinute_);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want a change in just the startTime_ to count as a valid change? At present if we changed just the startTime_ it'd count as "no rate change" here, and the transaction would revert. Which might be fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great question. I initially had it in the calculation and Octane made some very good points.

The concern is that if the startTime moved ahead of other parameters and updateRates got called you could end up with duplicate rates (old parameters new start time). And then when it did get called again you would end up with two rates that have the same start time.

);

_revertIfNoRateChange(messageFee_, storageFee_, congestionFee_, targetRatePerMinute_);
uint64 startTime_ = RegistryParameters.getUint64Parameter(parameterRegistry, ratesInEffectAfterParameterKey());
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might be overkill to add this in, but we could add validation here to see if startTime_ were set to something unexpected, like in the past?
If we can, I'd favor trusting our admin process to get it right, and keep contract simple.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The one validation that seems the most important is that the start time of the new rates is after the start time of the previous rates. The nodes will reject out of order rate changes, but it would be nice to cut them off at the source.

@neekolas neekolas force-pushed the 01-27-get_start_time_from_parameter_registry branch from da81345 to e23e41d Compare February 4, 2026 17:01
@@ -1,4 +1,4 @@
{
"detectors_to_exclude": "",
"detectors_to_exclude": "reentrancy-balance",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I forgot to mention, we could drop this change if we wanted.
Another PR pinned slither in CI and so the CI error has gone away.

Ensure new rate start times are strictly increasing to prevent
out-of-order rate entries. Validation is skipped on first update
when the rates array is empty.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

/// @inheritdoc IIdentified
function version() external pure returns (string memory version_) {
return "1.0.0";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return "1.0.1";

Oops, I forgot about the version bump

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