-
Notifications
You must be signed in to change notification settings - Fork 623
chore: Provider exits #25492
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
Merged
Merged
chore: Provider exits #25492
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4d44011
chore: Add provider exits
Rumata888 7a7fd03
refactor: name attester withdrawals consistently
Rumata888 ec42603
minor changes
Rumata888 bc3b598
chore: renumber attester exit labs patches
Rumata888 0e4c298
feat: add batched attester exits
Rumata888 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
93 changes: 93 additions & 0 deletions
93
l1-contracts/src/core/libraries/rollup/AttesterExitExtLib.sol
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // Copyright 2026 Aztec Labs. | ||
| pragma solidity >=0.8.27; | ||
|
|
||
| import {Errors} from "@aztec/core/libraries/Errors.sol"; | ||
| import {Signature, SignatureLib} from "@aztec/shared/libraries/SignatureLib.sol"; | ||
| import {Timestamp} from "@aztec/shared/libraries/TimeMath.sol"; | ||
| import {CoordinationSignatureLib} from "./CoordinationSignatureLib.sol"; | ||
| import {StakingLib, AttesterExitLimitState, AttesterExitAuthorization} from "./StakingLib.sol"; | ||
|
|
||
| /// @notice External attester-exit functions separated to keep rollup libraries within the contract size limit. | ||
| /// @dev Library calls execute against the calling rollup's staking storage. | ||
| library AttesterExitExtLib { | ||
| using SignatureLib for Signature; | ||
|
|
||
| bytes32 internal constant ATTESTER_EXIT_TYPEHASH = keccak256("AttesterExit(address attester,uint256 deadline)"); | ||
|
|
||
| /// @notice Initiates an exit for a position controlled by the calling attester. | ||
| function initiateWithdrawByAttester(address _attester) external { | ||
| StakingLib.initiateWithdrawByAttester(_attester); | ||
| } | ||
|
|
||
| /// @notice Initiates an attester exit authorized by an EIP-712 signature. | ||
| /// @param _authorization The signed exit authorization. | ||
| function initiateWithdrawByAttesterWithSignature(AttesterExitAuthorization calldata _authorization) external { | ||
| _authorize(_authorization); | ||
| StakingLib.initiateWithdrawByAttesterWithSignature(_authorization.attester); | ||
| } | ||
|
|
||
| /// @notice Initiates multiple attester exits authorized by EIP-712 signatures. | ||
| /// @param _authorizations The signed exit authorizations to execute atomically. | ||
| function initiateWithdrawByAttesterBatch(AttesterExitAuthorization[] calldata _authorizations) external { | ||
| uint256 exitCount = _authorizations.length; | ||
| require(exitCount > 0, Errors.Staking__EmptyAttesterExitBatch()); | ||
|
|
||
| StakingLib.checkAttesterExitInstance(); | ||
| StakingLib.consumeAttesterExitAllowance(exitCount); | ||
|
|
||
| for (uint256 i = 0; i < exitCount;) { | ||
| AttesterExitAuthorization calldata authorization = _authorizations[i]; | ||
| _authorize(authorization); | ||
| StakingLib.initiateWithdrawByAttesterBatchItem(authorization.attester); | ||
| unchecked { | ||
| ++i; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// @notice Initiates as many authorized attester exits as the current limit permits. | ||
| /// @param _authorizations The ordered signed exit authorizations. | ||
| /// @return exitCount The number of authorizations processed from the start of the array. | ||
| function initiateWithdrawByAttesterBatchUpToLimit(AttesterExitAuthorization[] calldata _authorizations) | ||
| external | ||
| returns (uint256 exitCount) | ||
| { | ||
| uint256 requestedExitCount = _authorizations.length; | ||
| require(requestedExitCount > 0, Errors.Staking__EmptyAttesterExitBatch()); | ||
|
|
||
| StakingLib.checkAttesterExitInstance(); | ||
| exitCount = StakingLib.consumeAttesterExitAllowanceUpTo(requestedExitCount); | ||
|
|
||
| for (uint256 i = 0; i < exitCount;) { | ||
| AttesterExitAuthorization calldata authorization = _authorizations[i]; | ||
| _authorize(authorization); | ||
| StakingLib.initiateWithdrawByAttesterBatchItem(authorization.attester); | ||
| unchecked { | ||
| ++i; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// @notice Returns the current window used to count attester exits. | ||
| function getAttesterExitWindow() external view returns (Timestamp) { | ||
| return StakingLib.getAttesterExitWindow(); | ||
| } | ||
|
|
||
| /// @notice Returns attester-exit capacity for the calling rollup. | ||
| /// @dev canExit does not establish eligibility of an individual position. | ||
| function getAttesterExitLimitState() external view returns (AttesterExitLimitState memory) { | ||
| return StakingLib.getAttesterExitLimitState(); | ||
| } | ||
|
|
||
| function _authorize(AttesterExitAuthorization calldata _authorization) private view { | ||
| require( | ||
| block.timestamp <= _authorization.deadline, | ||
| Errors.Staking__AttesterExitAuthorizationExpired(_authorization.deadline, block.timestamp) | ||
| ); | ||
|
|
||
| bytes32 structHash = keccak256(abi.encode(ATTESTER_EXIT_TYPEHASH, _authorization.attester, _authorization.deadline)); | ||
| bytes32 digest = CoordinationSignatureLib.toTypedDataHash(structHash); | ||
| _authorization.signature.verify(_authorization.attester, digest); | ||
| } | ||
| } | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Ah, the gas savings that matter