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: Sync from L1 #1224

Open
drspacemn opened this issue Oct 26, 2023 · 3 comments
Open

feat: Sync from L1 #1224

drspacemn opened this issue Oct 26, 2023 · 3 comments
Labels
enhancement New feature or request stale

Comments

@drspacemn
Copy link
Contributor

drspacemn commented Oct 26, 2023

Enable Madara to Sync it's state from L1.

As Starknet is a Validity Rollup on top of an L1 (Ethereum) we can query the base chain to retrieve all of the information needed to recompute the last proved state of Starknet.

The information needed to recompute the state is known as a StateDiff and it includes pertinent changes to the Starknet State per block:

  • deployed contracts
  • storage updates
  • declared(+deprecated) classes
  • nonce updates
  • replaced classes

This information is encoded by the Starknet OS as calldata, encoding defined here. This calldata is PUBLISHED AND LOGGED to the L1 Core Contracts and checked against the verifier's fact registry in the following function updateState

    /**
      Updates the state of the StarkNet, based on a proof of the
      StarkNet OS that the state transition is valid.

      Arguments:
        programOutput - The main part of the StarkNet OS program output.
        data_availability_fact - An encoding of the on-chain data associated
        with the 'programOutput'.
    */
    function updateState(
        uint256[] calldata programOutput,
        uint256 onchainDataHash,
        uint256 onchainDataSize
    ) external onlyOperator {

Each state update is tied to a Fact which is a hash represents the output of the StarknetOS and its program hash and serves as an attestation of the block verification(simple fact hash example). These facts can be registered as mulitple MemoryPages in the verifier fact registry.

Syncing

The implementation will involve(w/ python examples):

@drspacemn drspacemn added the enhancement New feature or request label Oct 26, 2023
Copy link

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.
Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a 👍
Because this issue is marked as stale, it will be closed and locked in 7 days if no further activity occurs.
Thank you for your contributions!

@github-actions github-actions bot added the stale label Nov 26, 2023
@jerrybaoo
Copy link

Our team has essentially implemented this feature. This is our PR: #1296

Copy link

github-actions bot commented Jan 6, 2024

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.
Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a 👍
Because this issue is marked as stale, it will be closed and locked in 7 days if no further activity occurs.
Thank you for your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale
Projects
None yet
Development

No branches or pull requests

2 participants