-
Notifications
You must be signed in to change notification settings - Fork 383
Cleanup PolygonPessimisticConsensus 1 #575
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
Draft
alrevuelta
wants to merge
1
commit into
develop
Choose a base branch
from
polpesconsensus-clean1
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,6 @@ import "./lib/PolygonTransparentProxy.sol"; | |
| import "./lib/PolygonAccessControlUpgradeable.sol"; | ||
| import "./lib/LegacyZKEVMStateVariables.sol"; | ||
| import "./lib/PolygonConstantsBase.sol"; | ||
| import "./interfaces/IPolygonPessimisticConsensus.sol"; | ||
| import "./interfaces/ISP1Verifier.sol"; | ||
| import "./interfaces/IAgglayerManager.sol"; | ||
| import "./interfaces/IAggchainBase.sol"; | ||
|
|
@@ -528,10 +527,7 @@ contract AgglayerManager is | |
|
|
||
| uint32 rollupTypeID = ++rollupTypeCount; | ||
|
|
||
| if (rollupVerifierType == VerifierType.Pessimistic) { | ||
| // No genesis on pessimistic rollups | ||
| if (genesis != bytes32(0)) revert InvalidRollupType(); | ||
| } else if (rollupVerifierType == VerifierType.ALGateway) { | ||
| if (rollupVerifierType == VerifierType.ALGateway) { | ||
| // Those params should be zero for ALGateway rollup types | ||
| if ( | ||
| verifier != address(0) || | ||
|
|
@@ -778,14 +774,7 @@ contract AgglayerManager is | |
| rollup.rollupVerifierType = rollupVerifierType; | ||
|
|
||
| // Check verifier type | ||
| if (rollupVerifierType == VerifierType.Pessimistic) { | ||
| rollup.programVKey = programVKey; | ||
| rollup.lastPessimisticRoot = initPessimisticRoot; | ||
| rollup.lastLocalExitRoot = initRoot; | ||
| if (verifier.code.length == 0) { | ||
| revert InvalidVerifierAddress(); | ||
| } | ||
| } else if (rollupVerifierType == VerifierType.ALGateway) { | ||
|
Comment on lines
-781
to
-788
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. the condition if (rollupVerifierType == VerifierType.Pessimistic) { |
||
| if (rollupVerifierType == VerifierType.ALGateway) { | ||
| if ( | ||
| verifier != address(0) || | ||
| forkID != 0 || | ||
|
|
@@ -990,11 +979,11 @@ contract AgglayerManager is | |
| revert AllSequencedMustBeVerified(); | ||
| } | ||
|
|
||
| // NewRollupType must be pessimistic or ALGateway | ||
| // NewRollupType must be ALGateway | ||
| require( | ||
| rollupTypeMap[newRollupTypeID].rollupVerifierType != | ||
| VerifierType.StateTransition, | ||
| NewRollupTypeMustBePessimisticOrALGateway() | ||
| rollupTypeMap[newRollupTypeID].rollupVerifierType == | ||
| VerifierType.ALGateway, | ||
| InvalidRollupType() | ||
| ); | ||
|
|
||
| // Add rollupID to migration mapping | ||
|
|
@@ -1312,14 +1301,6 @@ contract AgglayerManager is | |
| revert StateTransitionChainsNotAllowed(); | ||
| } | ||
|
|
||
| // Not aggchainData for VerifierType.Pessimistic | ||
| if ( | ||
| rollup.rollupVerifierType == VerifierType.Pessimistic && | ||
| aggchainData.length != 0 | ||
| ) { | ||
| revert AggchainDataMustBeZeroForPessimisticVerifierType(); | ||
| } | ||
|
|
||
| // Check l1InfoTreeLeafCount has a valid l1InfoTreeRoot | ||
| bytes32 l1InfoRoot = globalExitRootManager.l1InfoRootMap( | ||
| l1InfoTreeLeafCount | ||
|
|
@@ -1361,23 +1342,14 @@ contract AgglayerManager is | |
| aggchainData | ||
| ); | ||
|
|
||
| if (rollup.rollupVerifierType == VerifierType.ALGateway) { | ||
| // Verify proof. The pessimistic proof selector is attached at the first 4 bytes of the proof | ||
| // proof[0:4]: 4 bytes selector pp | ||
| // proof[4:8]: 4 bytes selector SP1 verifier | ||
| // proof[8:]: proof | ||
| aggLayerGateway.verifyPessimisticProof( | ||
| inputPessimisticBytes, | ||
| proof | ||
| ); | ||
| } else { | ||
| // Verify proof | ||
| ISP1Verifier(rollup.verifier).verifyProof( | ||
| rollup.programVKey, | ||
| inputPessimisticBytes, | ||
| proof | ||
| ); | ||
| } | ||
| // Verify proof. The pessimistic proof selector is attached at the first 4 bytes of the proof | ||
| // proof[0:4]: 4 bytes selector pp | ||
| // proof[4:8]: 4 bytes selector SP1 verifier | ||
| // proof[8:]: proof | ||
| aggLayerGateway.verifyPessimisticProof( | ||
| inputPessimisticBytes, | ||
| proof | ||
| ); | ||
|
|
||
| // Update aggregation parameters | ||
| lastAggregationTimestamp = uint64(block.timestamp); | ||
|
|
@@ -1413,13 +1385,11 @@ contract AgglayerManager is | |
| msg.sender | ||
| ); | ||
|
|
||
| if (rollup.rollupVerifierType == VerifierType.ALGateway) { | ||
| // Allow chains to manage customData | ||
| // Callback to the rollup address | ||
| IAggchainBase(rollup.rollupContract).onVerifyPessimistic( | ||
| aggchainData | ||
| ); | ||
| } | ||
| // Allow chains to manage customData | ||
| // Callback to the rollup address | ||
| IAggchainBase(rollup.rollupContract).onVerifyPessimistic( | ||
| aggchainData | ||
| ); | ||
| } | ||
|
|
||
| //////////////////////// | ||
|
|
@@ -1660,35 +1630,18 @@ contract AgglayerManager is | |
| bytes32 newPessimisticRoot, | ||
| bytes calldata aggchainData | ||
| ) internal view returns (bytes memory inputPessimisticBytes) { | ||
| // Different consensusHash and encoding if the rollup is ALGateway or pessimistic | ||
| if (rollup.rollupVerifierType == VerifierType.ALGateway) { | ||
| bytes32 aggchainHash = IAggchainBase(rollup.rollupContract) | ||
| .getAggchainHash(aggchainData); | ||
| bytes32 aggchainHash = IAggchainBase(rollup.rollupContract) | ||
| .getAggchainHash(aggchainData); | ||
|
|
||
| inputPessimisticBytes = abi.encodePacked( | ||
| rollup.lastLocalExitRoot, | ||
| rollup.lastPessimisticRoot, | ||
| l1InfoTreeRoot, | ||
| rollupID, | ||
| aggchainHash, | ||
| newLocalExitRoot, | ||
| newPessimisticRoot | ||
| ); | ||
| } else { | ||
| bytes32 consensusHash = IPolygonPessimisticConsensus( | ||
| address(rollup.rollupContract) | ||
| ).getConsensusHash(); | ||
|
|
||
| inputPessimisticBytes = abi.encodePacked( | ||
| rollup.lastLocalExitRoot, | ||
| rollup.lastPessimisticRoot, | ||
| l1InfoTreeRoot, | ||
| rollupID, | ||
| consensusHash, | ||
| newLocalExitRoot, | ||
| newPessimisticRoot | ||
| ); | ||
| } | ||
| inputPessimisticBytes = abi.encodePacked( | ||
| rollup.lastLocalExitRoot, | ||
| rollup.lastPessimisticRoot, | ||
| l1InfoTreeRoot, | ||
| rollupID, | ||
| aggchainHash, | ||
| newLocalExitRoot, | ||
| newPessimisticRoot | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
after those lines fix comment:
// unreachable code since solidity enforces the enum input rollupVerifierType to be one of the enum values