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 authored Nov 20, 2024
1 parent c56fb93 commit 5eafefe
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bindings/bin/rollup_deployed.hex

Large diffs are not rendered by default.

25 changes: 23 additions & 2 deletions bindings/bindings/rollup.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bindings/bindings/rollup_more.go

Large diffs are not rendered by default.

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 5eafefe

Please sign in to comment.