fix: enable automatic upgrades on the server side (#1981)#1983
fix: enable automatic upgrades on the server side (#1981)#1983
Conversation
# What ❔ <!-- What are the changes this PR brings about? --> <!-- Example: This PR adds a PR template to the repo. --> <!-- (For bigger PRs adding more context is appreciated) --> ## Why ❔ <!-- Why are these changes done? What goal do they contribute to? What are the principles behind them? --> <!-- Example: PR templates ensure PR reviewers, observers, and future iterators are in context about the evolution of repos. --> ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. # What ❔ <!-- What are the changes this PR brings about? --> <!-- Example: This PR adds a PR template to the repo. --> <!-- (For bigger PRs adding more context is appreciated) --> ## Why ❔ <!-- Why are these changes done? What goal do they contribute to? What are the principles behind them? --> <!-- Example: PR templates ensure PR reviewers, observers, and future iterators are in context about the evolution of repos. --> ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 96116eaa79
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| function _onlyAdminOrChainTypeManagerOrUpgradeExecutor() internal view { | ||
| if (msg.sender != s.admin && msg.sender != s.chainTypeManager && !s.validators[msg.sender] && false) { // kl todo | ||
| revert Unauthorized(msg.sender); |
There was a problem hiding this comment.
Restore access control in upgrade executor check
The new onlyAdminOrChainTypeManagerOrUpgradeExecutor guard is effectively a no‑op because the condition includes && false, which makes the if unreachable. That means any address can pass the modifier, and since upgradeChainFromVersion now uses it, any caller can execute a pending upgrade as soon as the cut hash matches, bypassing the intended admin/chain-type-manager/upgrade-executor restriction and any timing controls. This allows unauthorized or premature upgrades whenever upgradeCutHash is set.
Useful? React with 👍 / 👎.
…s into kl/automatic-upgrades
e527e38 to
0262c7a
Compare
…s into kl/automatic-upgrades
…s into kl/automatic-upgrades
StanislavBreadless
left a comment
There was a problem hiding this comment.
also, we should add a test for upgrading via the validator timelock, etc
| @@ -140,4 +148,10 @@ interface IValidatorTimelock is IExecutor { | |||
| uint256 _processBatchTo, | |||
| bytes calldata _batchData | |||
| ) external; | |||
| /// @dev Make a call to the zkChain diamond contract to upgrade from a specific protocol version. | |||
There was a problem hiding this comment.
nit: should be a newline before new function declaration
| /// @param _cutData The diamond cut parameters that is executed in the upgrade | ||
| function upgradeChainFromVersion(uint256 _protocolVersion, Diamond.DiamondCutData calldata _cutData) external; | ||
| function upgradeChainFromVersion( | ||
| address _chainAddress, |
There was a problem hiding this comment.
I know that you have not yet worked on this change on the server side, but this is a breaking change for zkstack cli etc
| rotateCommitterRole: false, | ||
| rotateReverterRole: true, | ||
| rotateProverRole: true, | ||
| rotateExecutorRole: true |
There was a problem hiding this comment.
we never in this script set that the upgrader role is true, I am not sure it is usable for the platform team
There was a problem hiding this comment.
Tomasz tried it and he said it worked somehow
There was a problem hiding this comment.
most likely because he uses ValidatorTimelock.addValidator which sets all the roles
There was a problem hiding this comment.
We still need to rotate it here somehow
| @@ -140,4 +148,10 @@ interface IValidatorTimelock is IExecutor { | |||
| uint256 _processBatchTo, | |||
| bytes calldata _batchData | |||
| ) external; | |||
| /// @dev Make a call to the zkChain diamond contract to upgrade from a specific protocol version. | |||
| function upgradeChainFromVersion( | |||
There was a problem hiding this comment.
another small note:
- the interface is defined inside IAdmin.sol, but ValidatorTimelock does not inherit it.
- this introduces a risk that we may accidentally change the function signature and not notice it. the tests help, but whenever we have an opportunity to use compile time checks, we should do so
I think the best solutions are either:
- move this function to executor
- create a new small upgrade-only interface that will be inherited by both IAdmin and IValidatorTimelock
|
|
||
| /// @notice Checks that the message sender is an active admin | ||
| modifier onlyAdmin() { | ||
| _onlyAdmin(); |
There was a problem hiding this comment.
why did we introduce so many changes in this file?
…s into kl/automatic-upgrades
…s into kl/automatic-upgrades
…s into kl/automatic-upgrades
|
Coverage after merging kl/automatic-upgrades into draft-v31 will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
What ❔
enable automatic upgrades on the server side
Why ❔
Checklist
entries from PRs).
What ❔
Why ❔
Checklist