Skip to content

Commit

Permalink
upgraded
Browse files Browse the repository at this point in the history
  • Loading branch information
invocamanman committed Jun 29, 2023
1 parent 96b4acd commit f2eacbc
Show file tree
Hide file tree
Showing 7 changed files with 523 additions and 8 deletions.
4 changes: 2 additions & 2 deletions compiled-contracts/PolygonZkEVM.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions compiled-contracts/PolygonZkEVMMock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions compiled-contracts/PolygonZkEVMTimelock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/PolygonZkEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@ contract PolygonZkEVM is
bytes32 newLocalExitRoot,
bytes32 newStateRoot,
bytes32[24] calldata proof
) internal view {
) internal view virtual {
bytes32 oldStateRoot;

// Use pending state if specified, otherwise use consolidated state
Expand Down
39 changes: 39 additions & 0 deletions contracts/mainnetUpgraded/PolygonZkEVMUpgraded.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ contract PolygonZkEVMUpgraded is PolygonZkEVM {
*/
error VersionAlreadyUpdated();

/**
* @dev Thrown when try to proof a non deterministic state using a verified batch from previous forkIDs
*/
error InitBatchMustMatchCurrentForkID();

/**
* @notice Update version of the zkEVM
* @param _versionString New version string
Expand All @@ -63,4 +68,38 @@ contract PolygonZkEVMUpgraded is PolygonZkEVM {
lastBatchBeforeUpgrade = lastVerifiedBatch;
emit UpdateZkEVMVersion(lastVerifiedBatch, forkID, _versionString);
}

/**
* @notice Internal function that proves a different state root given the same batches to verify
* @param initPendingStateNum Init pending state, 0 if consolidated state is used
* @param finalPendingStateNum Final pending state, that will be used to compare with the newStateRoot
* @param initNumBatch Batch which the aggregator starts the verification
* @param finalNewBatch Last batch aggregator intends to verify
* @param newLocalExitRoot New local exit root once the batch is processed
* @param newStateRoot New State root once the batch is processed
* @param proof fflonk proof
*/
function _proveDistinctPendingState(
uint64 initPendingStateNum,
uint64 finalPendingStateNum,
uint64 initNumBatch,
uint64 finalNewBatch,
bytes32 newLocalExitRoot,
bytes32 newStateRoot,
bytes32[24] calldata proof
) internal view override {
if (initNumBatch < lastBatchBeforeUpgrade) {
revert InitBatchMustMatchCurrentForkID();
}

super._proveDistinctPendingState(
initPendingStateNum,
finalPendingStateNum,
initNumBatch,
finalNewBatch,
newLocalExitRoot,
newStateRoot,
proof
);
}
}
26 changes: 26 additions & 0 deletions docs/mainnetUpgraded/PolygonZkEVMUpgraded.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,29 @@ Update version of the zkEVM
| :--- | :--- | :------------------------------------------------------------------- |
|`_versionString` | string | New version string

### _proveDistinctPendingState
```solidity
function _proveDistinctPendingState(
uint64 initPendingStateNum,
uint64 finalPendingStateNum,
uint64 initNumBatch,
uint64 finalNewBatch,
bytes32 newLocalExitRoot,
bytes32 newStateRoot,
bytes32[24] proof
) internal
```
Internal function that proves a different state root given the same batches to verify


#### Parameters:
| Name | Type | Description |
| :--- | :--- | :------------------------------------------------------------------- |
|`initPendingStateNum` | uint64 | Init pending state, 0 if consolidated state is used
|`finalPendingStateNum` | uint64 | Final pending state, that will be used to compare with the newStateRoot
|`initNumBatch` | uint64 | Batch which the aggregator starts the verification
|`finalNewBatch` | uint64 | Last batch aggregator intends to verify
|`newLocalExitRoot` | bytes32 | New local exit root once the batch is processed
|`newStateRoot` | bytes32 | New State root once the batch is processed
|`proof` | bytes32[24] | fflonk proof

Loading

0 comments on commit f2eacbc

Please sign in to comment.