|
1 | | -!!! warning |
2 | | - Coming soon. |
| 1 | +--- |
| 2 | +comments: true |
| 3 | +--- |
| 4 | + |
| 5 | +Transactions flowing through the system reach the smart contract environment after one of two contract call use-cases: |
| 6 | + |
| 7 | +- Sequence batches requests coming from the sequencer component in the node. |
| 8 | +- Verifying batches requests coming from the aggregator component in the node. |
| 9 | + |
| 10 | +This section focuses on the verification workflow. |
| 11 | + |
| 12 | +The sequence diagram below shows the verification workflow for rollup stacks and/or the AggLayer calling the `verifyBatchesTrustedAggregator(...)` function on the rollup manager. |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | +## `verifyBatchesTrustedAggregator(rollupID, pendingStateNum, initNumBatch, finalNewBatch, newLocalExitRoot, newStateRoot, beneficiary, proof)` |
| 17 | + |
| 18 | +This function is called on the `PolygonRollupManager` contract. |
| 19 | + |
| 20 | +The zkEVM node aggregator, or the AggLayer, calls the [`verifyBatchesTrustedAggregator`](https://github.com/0xPolygonHermez/zkevm-contracts/blob/b2a62e6af5738366e7494e8312184b1d6fdf287c/contracts/v2/PolygonRollupManager.sol#L921) function on the [`PolygonRollupManager.sol`](https://github.com/0xPolygonHermez/zkevm-contracts/blob/feature/etrog/contracts/v2/PolygonRollupManager.sol) contract. |
| 21 | + |
| 22 | +The function creates a rollup data storage object with the data provided by the caller, which it first verifies by sending it to the helper function [`_verifyAndRewardBatches`](https://github.com/0xPolygonHermez/zkevm-contracts/blob/b2a62e6af5738366e7494e8312184b1d6fdf287c/contracts/v2/PolygonRollupManager.sol#L977). |
| 23 | + |
| 24 | +This internal function calculates the inputSnark bytes value, which is a `(SHA256 % "RFIELD")` calculation on the input data, and uses this value to verify the proof by calling `rollup.verifier.verifyProof(proof, [inputSnark])` on an `IVerifierRollup` interface implementation. |
| 25 | + |
| 26 | +!!! note |
| 27 | + Using a `verifier` variable on the rollup object means the verifier implementation can be customized in the future. |
| 28 | + |
| 29 | +Next, in the `_verifyAndRewardBatches` helper function, the code reverts if the proof does not verify successfully. Otherwise, the code pays POL rewards to the beneficiary. |
| 30 | + |
| 31 | +The function then updates the state and calls `rollup.rollupContract.onVerifyBatches(...)`, which is a callback into the rollup consensus contract, allowing for customizable behavior. `onVerifyBatches(...)` takes the new state root and final batch, and emits a `VerifyBatches(...)` event. |
| 32 | + |
| 33 | +The command flow returns to the `verifyBatchesTrustedAggregator` function which consolidates and updates the state with the `newStateRoot` and the new `localExitRoot` and calls the `updateExitRoot(...)` function on the `GlobalExitRootManager` contract passing the rollup's updated exit root. |
0 commit comments