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

Align block structure with yellow paper #3533

Closed
20 of 21 tasks
Tracked by #3826
LHerskind opened this issue Dec 4, 2023 · 4 comments
Closed
20 of 21 tasks
Tracked by #3826

Align block structure with yellow paper #3533

LHerskind opened this issue Dec 4, 2023 · 4 comments
Assignees
Labels
T-tracking Type: Tracking Issue. This contains tasklists.

Comments

@LHerskind
Copy link
Contributor

LHerskind commented Dec 4, 2023

The block as defined currently is very hard to follow. It uses different names all over the place to refer to the same things. We should use structs when possible, and be more consistent in the naming.

For example, the L2Block don't explicitly define the block header, so the BlockHeader in typescript is not consistent with the actual block. It is only the "after" half of it.

Instead, we must update it to match what is described in the yellow-paper.

@LHerskind
Copy link
Contributor Author

The blocksTreeRoot also is a bad name, hence it is not actually a tree of blocks, but a tree of StateContext from the above definitions (almost).

It should either be renamed, or consist of commitments to the actual blocks.

Our apis which are mostly used for building the header should also be altered to return a StateReference instead and header building should be more easily exposed to the PXE.

@LHerskind LHerskind added this to A3 Dec 5, 2023
@github-project-automation github-project-automation bot moved this to Todo in A3 Dec 5, 2023
@LHerskind
Copy link
Contributor Author

LHerskind commented Dec 5, 2023

From discussion earlier, we came up with a few structs and hopefully some better naming:

// Base rollup only change part of the state
interface PartialStateReference {
    noteHashTreeRoot: Snapshot;
    nullifierTreeRoot: Snapshot;
    contractTreeRoot: Snapshot;
    publicDataTreeRoot: Fr;
};

// StateRoot = H(StateReference)
// Tree of StateRoots = Archive
interface StateReference {
    ...partialStateReference;
    privateKernelVkTreeRoot: Snapshot;
    l1ToL2MessageTreeRoot: Snapshot; 
    archiveRoot: Fr; // Before insertion of this leaf
    globalVariablesHash: H(GlobalVariables);
};

interface CombinedConstantData {
    historical_state: StateReference; // old header
    context: TxContext;
};

interface BlockHeader {
    parent: StateRoot;
    state: StateReference;
    globalVariables: GlobalVariables;
}

interface Block {
    header: BlockHeader;
    content: Content;
}

Further, there are some cleanup to do regarding global variables which have multiple variations in noir which makes it hard to follow.

@LHerskind
Copy link
Contributor Author

As mentioned in #3564 it will also be useful to expose the block number as part of the state reference to make historic access easier. Practically, this could be done by not providing a globalVariablesHash but actually provide the global variables, that way we can just read them directly, and as we are not in the getting all the juice out of the circuits state, this seems like a valid route to make it easier to understand what is going on and build.

@LHerskind LHerskind changed the title Refactor the block structure Align block structure with yellow paper Jan 3, 2024
@LHerskind LHerskind added the T-tracking Type: Tracking Issue. This contains tasklists. label Jan 18, 2024
@LHerskind LHerskind added this to the Execution Environment milestone Jan 22, 2024
@LHerskind
Copy link
Contributor Author

Closing this as its subtasks have been addressed.

@github-project-automation github-project-automation bot moved this from Todo to Done in A3 Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-tracking Type: Tracking Issue. This contains tasklists.
Projects
Archived in project
Development

No branches or pull requests

2 participants