-
Notifications
You must be signed in to change notification settings - Fork 6
Get start time from parameter registry #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
8af46e4
a5e2483
9639eb4
5827a11
e23e41d
4f4c67c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,52 +1,52 @@ | ||
| { | ||
| "name": "@xmtp/smart-contracts", | ||
| "version": "0.5.6", | ||
| "description": "XMTP Smart Contracts", | ||
| "author": "Ephemera Engineering Team <eng@ephemerahq.com>", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/xmtp/smart-contracts.git" | ||
| }, | ||
| "bugs": { | ||
| "url": "https://github.com/xmtp/smart-contracts/issues" | ||
| }, | ||
| "homepage": "https://github.com/xmtp/smart-contracts#readme", | ||
| "scripts": { | ||
| "build": "forge build", | ||
| "clean": "forge clean", | ||
| "coverage": "forge coverage --no-match-coverage '(script|test)' --gas-limit 3000000000 --report lcov && lcov --ignore-errors inconsistent --extract lcov.info --rc branch_coverage=1 --rc derive_function_end_line=0 -o lcov.info 'src/*' && genhtml --ignore-errors inconsistent lcov.info --rc branch_coverage=1 --rc derive_function_end_line=0 -o coverage", | ||
| "gas-report": "forge test --fuzz-seed 10101 --gas-report --gas-limit 3000000000 > gasreport.ansi", | ||
| "doc": "forge doc --serve --port 4000", | ||
| "lint-staged": "lint-staged", | ||
| "prettier": "prettier --write 'script/**/*' 'src/**/*' 'test/**/*' 'config/**/*' 'environments/**/*'", | ||
| "prettier-check": "prettier --check 'script/**/*' 'src/**/*' 'test/**/*' 'config/**/*' 'environments/**/*'", | ||
| "slither": "rm -rf output.sarif && forge build --build-info --skip '*/test/**' --skip '*/script/**' --force && slither --exclude low-level-calls --sarif output.sarif --compile-force-framework foundry --ignore-compile --config-file slither.config.json --fail-high .", | ||
| "solhint": "solhint -f stylish 'src/**/*.sol'", | ||
| "solhint-fix": "solhint --fix 'src/**/*.sol'", | ||
| "test": "forge test", | ||
| "anvil": "anvil", | ||
| "gen-anvil-state": "./dev/gen-anvil-state", | ||
| "gen-artifacts": "./dev/gen-artifacts", | ||
| "deploy-local": "./dev/deploy-local", | ||
| "check-deployments-local": "./dev/check-local-deployment" | ||
| }, | ||
| "devDependencies": { | ||
| "@arbitrum/sdk": "^4.0.4", | ||
| "@ethersproject/bignumber": "^5.8.0", | ||
| "@fireblocks/fireblocks-json-rpc": "^0.2.2", | ||
| "dotenv": "^16.5.0", | ||
| "ethers": "5.8.0", | ||
| "lint-staged": "^15.5.2", | ||
| "prettier": "^3.5.3", | ||
| "prettier-plugin-solidity": "^1.4.3", | ||
| "solhint": "^5.1.0", | ||
| "solhint-plugin-prettier": "^0.1.0" | ||
| }, | ||
| "engines": { | ||
| "node": ">=23" | ||
| }, | ||
| "files": [ | ||
| "src/**", | ||
| "out/**" | ||
| ] | ||
| "name": "@xmtp/smart-contracts", | ||
| "version": "0.5.6", | ||
| "description": "XMTP Smart Contracts", | ||
| "author": "Ephemera Engineering Team <eng@ephemerahq.com>", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/xmtp/smart-contracts.git" | ||
| }, | ||
| "bugs": { | ||
| "url": "https://github.com/xmtp/smart-contracts/issues" | ||
| }, | ||
| "homepage": "https://github.com/xmtp/smart-contracts#readme", | ||
| "scripts": { | ||
| "build": "forge build", | ||
| "clean": "forge clean", | ||
| "coverage": "forge coverage --no-match-coverage '(script|test)' --gas-limit 3000000000 --report lcov && lcov --ignore-errors inconsistent --extract lcov.info --rc branch_coverage=1 --rc derive_function_end_line=0 -o lcov.info 'src/*' && genhtml --ignore-errors inconsistent lcov.info --rc branch_coverage=1 --rc derive_function_end_line=0 -o coverage", | ||
| "gas-report": "forge test --fuzz-seed 10101 --gas-report --gas-limit 3000000000 > gasreport.ansi", | ||
| "doc": "forge doc --serve --port 4000", | ||
| "lint-staged": "lint-staged", | ||
| "prettier": "prettier --write 'script/**/*' 'src/**/*' 'test/**/*' 'config/**/*' 'environments/**/*'", | ||
| "prettier-check": "prettier --check 'script/**/*' 'src/**/*' 'test/**/*' 'config/**/*' 'environments/**/*'", | ||
| "slither": "rm -rf output.sarif && forge build --build-info --skip '*/test/**' --skip '*/script/**' --force && slither --exclude low-level-calls --sarif output.sarif --compile-force-framework foundry --ignore-compile --config-file slither.config.json --fail-high .", | ||
| "solhint": "solhint -f stylish 'src/**/*.sol'", | ||
| "solhint-fix": "solhint --fix 'src/**/*.sol'", | ||
| "test": "forge test", | ||
| "anvil": "anvil", | ||
| "gen-anvil-state": "./dev/gen-anvil-state", | ||
| "gen-artifacts": "./dev/gen-artifacts", | ||
| "deploy-local": "./dev/deploy-local", | ||
| "check-deployments-local": "./dev/check-local-deployment" | ||
| }, | ||
| "devDependencies": { | ||
| "@arbitrum/sdk": "^4.0.4", | ||
| "@ethersproject/bignumber": "^5.8.0", | ||
| "@fireblocks/fireblocks-json-rpc": "^0.2.2", | ||
| "dotenv": "^16.5.0", | ||
| "ethers": "5.8.0", | ||
| "lint-staged": "^15.5.2", | ||
| "prettier": "^3.5.3", | ||
| "prettier-plugin-solidity": "^1.4.3", | ||
| "solhint": "^5.1.0", | ||
| "solhint-plugin-prettier": "^0.1.0" | ||
| }, | ||
| "engines": { | ||
| "node": ">=23" | ||
| }, | ||
| "files": [ | ||
| "src/**", | ||
| "out/**" | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| { | ||
| "detectors_to_exclude": "", | ||
| "detectors_to_exclude": "reentrancy-balance", | ||
| "filter_paths": "lib" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,13 +80,14 @@ contract RateRegistry is IRateRegistry, Migratable, Initializable { | |
| targetRatePerMinuteParameterKey() | ||
| ); | ||
|
|
||
| _revertIfNoRateChange(messageFee_, storageFee_, congestionFee_, targetRatePerMinute_); | ||
| uint64 startTime_ = RegistryParameters.getUint64Parameter(parameterRegistry, ratesInEffectAfterParameterKey()); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
|
||
| uint64 startTime_ = uint64(block.timestamp); | ||
| _revertIfNoRateChange(messageFee_, storageFee_, congestionFee_, targetRatePerMinute_); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want a change in just the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| _revertIfInvalidStartTime(startTime_); | ||
|
|
||
| $.allRates.push(Rates(messageFee_, storageFee_, congestionFee_, targetRatePerMinute_, startTime_)); | ||
|
|
||
| emit RatesUpdated(messageFee_, storageFee_, congestionFee_, targetRatePerMinute_); | ||
| emit RatesUpdated(messageFee_, storageFee_, congestionFee_, targetRatePerMinute_, startTime_); | ||
| } | ||
|
|
||
| /// @inheritdoc IMigratable | ||
|
|
@@ -117,6 +118,11 @@ contract RateRegistry is IRateRegistry, Migratable, Initializable { | |
| return "xmtp.rateRegistry.targetRatePerMinute"; | ||
| } | ||
|
|
||
| /// @inheritdoc IRateRegistry | ||
| function ratesInEffectAfterParameterKey() public pure returns (string memory key_) { | ||
| return "xmtp.rateRegistry.ratesInEffectAfter"; | ||
| } | ||
|
|
||
| /// @inheritdoc IRateRegistry | ||
| function migratorParameterKey() public pure returns (string memory key_) { | ||
| return "xmtp.rateRegistry.migrator"; | ||
|
|
@@ -181,4 +187,15 @@ contract RateRegistry is IRateRegistry, Migratable, Initializable { | |
| revert NoChange(); | ||
| } | ||
| } | ||
|
|
||
| /// @dev Reverts if the start time is not strictly greater than the last start time. | ||
| function _revertIfInvalidStartTime(uint64 startTime_) internal view { | ||
| RateRegistryStorage storage $ = _getRateRegistryStorage(); | ||
|
|
||
| if ($.allRates.length == 0) return; | ||
|
|
||
| uint64 lastStartTime_ = $.allRates[$.allRates.length - 1].startTime; | ||
|
|
||
| if (startTime_ <= lastStartTime_) revert InvalidStartTime(startTime_, lastStartTime_); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
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.