Skip to content

Commit

Permalink
Add initialize2 for rollup to set state root (#641)
Browse files Browse the repository at this point in the history
Co-authored-by: Agnar Song <[email protected]>
  • Loading branch information
Kukoomomo and Agnar Song committed Nov 20, 2024
1 parent 278ac64 commit 375d1f0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions contracts/contracts/l1/rollup/Rollup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,15 @@ contract Rollup is IRollup, OwnableUpgradeable, PausableUpgradeable {
emit UpdateProofRewardPercent(0, _proofRewardPercent);
}

function initialize2(bytes32 _prevStateRoot) external reinitializer(2) {
require(_getInitializedVersion() == 2, "must have initialized!");
require(_prevStateRoot != bytes32(0), "can not set state root with bytes32(0)!");

if (committedStateRoots[lastCommittedBatchIndex] == bytes32(0)) {
committedStateRoots[lastCommittedBatchIndex] = _prevStateRoot;
}
}

/************************
* Restricted Functions *
************************/
Expand Down

0 comments on commit 375d1f0

Please sign in to comment.