Skip to content
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

feat: storage mirror root registry #10

Merged
merged 4 commits into from
Nov 21, 2023
Merged

Conversation

0xOneTony
Copy link
Member

🤖 Linear

Closes SAF-30, SAF-31, SAF-32

Copy link

linear bot commented Nov 20, 2023

SAF-30 StorageMirrorRootRegistry

This contract should accept and store storageRoots of the StorageMirror contract in L1.

SAF-31 StorageMirrorRootRegistry Tests & Docs

  • 100% unit test
  • Natspec comments

SAF-32 StorageMirrorRootRegistry Contract

  • Should store an immutable address of the StorageMirror address in L1, that is needed for the verification
  • Should have a mapping(L1BlockNumber => verifiedStorageRoot) verifiedStorageMirrorStorageRoots that will store all verified storage roots of L1 at a specific block.
  • Has a function queryL1BlockHeader(blockNumber) that should query a magical oracle that will return the L1 Block Header at a specific block. This is gonna be used to check against the proposed root by an off chain agent.
  • Has a function proposeAndVerifyStorageMirrorStorageRoot(rewardNonce, blockNumber, storageRoot, MPTproof), this function should call the queryL1StateRoot at the provided block number and then call the Verifier contract and verifyStorageMirrorStorageRoot(storageRoot, MPTproof, blockheader) to verify if the StorageMirror storageRoot is part of the state tree. If it is then save it in the verifiedStorageMirrorStorageRoots mapping. ⚠️ The payment for the verification should happen after the verification is successful but inside the Verifier module
  • VerifiedStorageMirrorStorageRoot(uint256 homeChainBlockNumber, bytes32 storageRoot) will emit after a proposeAndVerifyStorageMirrorStorageRoot call

@0xOneTony 0xOneTony marked this pull request as ready for review November 21, 2023 11:31
VERIFIER_MODULE.extractStorageMirrorStorageRoot(_blockHeader, _accountProof);

latestVerifiedStorageMirrorStorageRoot = _latestVerifiedStorageMirrorStorageRoot;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After thinking more about it, i thinks its good UX to save the block number as well so a new searcher who wasnt previously subscribed to the events knows what the latest verified block was easily, it makes the operation slightly more expensive but i think its good UX for searchers,everything else looks good.

Copy link
Contributor

@excaliborr excaliborr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm!

@0xOneTony 0xOneTony merged commit 8e55d38 into dev Nov 21, 2023
5 checks passed
@0xOneTony 0xOneTony deleted the feat/storage-mirror-root-registry branch November 21, 2023 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants