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

L1 to L2 messaging fixes #471

Merged
merged 5 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ RootRollupPublicInputs root_rollup_circuit(DummyComposer& composer, RootRollupIn
rootRollupInputs.new_l1_to_l2_message_tree_root_sibling_path,
empty_l1_to_l2_subtree_root,
l1_to_l2_subtree_root,
L1_TO_L2_MSG_SUBTREE_INCLUSION_CHECK_DEPTH,
L1_TO_L2_MSG_SUBTREE_DEPTH,
"l1 to l2 message tree insertion");

// Update the historic l1 to l2 data tree
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/circuits.js/src/structs/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ export const CONTRACT_TREE_HEIGHT = 4;
export const PRIVATE_DATA_TREE_HEIGHT = 8;
export const PUBLIC_DATA_TREE_HEIGHT = 254;
export const NULLIFIER_TREE_HEIGHT = 8;
export const NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP = 16;
export const L1_TO_L2_MESSAGES_TREE_HEIGHT = 8;
export const L1_TO_L2_MESSAGES_ROOTS_TREE_HEIGHT = 8;
export const L1_TO_L2_MESSAGES_SUBTREE_INSERTION_HEIGHT = 4;
export const L1_TO_L2_MESSAGES_SUBTREE_HEIGHT = Math.ceil(Math.log2(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP));
export const L1_TO_L2_MESSAGES_SIBLING_PATH_LENGTH = L1_TO_L2_MESSAGES_TREE_HEIGHT - L1_TO_L2_MESSAGES_SUBTREE_HEIGHT;

export const PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT = 8;
export const CONTRACT_TREE_ROOTS_TREE_HEIGHT = 8;
export const ROLLUP_VK_TREE_HEIGHT = 8;

export const FUNCTION_SELECTOR_NUM_BYTES = 4;

export const NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP = 16;
4 changes: 2 additions & 2 deletions yarn-project/circuits.js/src/structs/rollup/root_rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AppendOnlyTreeSnapshot } from './append_only_tree_snapshot.js';
import {
CONTRACT_TREE_ROOTS_TREE_HEIGHT,
L1_TO_L2_MESSAGES_ROOTS_TREE_HEIGHT,
L1_TO_L2_MESSAGES_SUBTREE_INSERTION_HEIGHT,
L1_TO_L2_MESSAGES_SIBLING_PATH_LENGTH,
NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT,
} from '../constants.js';
Expand All @@ -27,7 +27,7 @@ export class RootRollupInputs {
) {
assertLength(this, 'newHistoricPrivateDataTreeRootSiblingPath', PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT);
assertLength(this, 'newHistoricContractDataTreeRootSiblingPath', CONTRACT_TREE_ROOTS_TREE_HEIGHT);
assertLength(this, 'newL1ToL2MessageTreeRootSiblingPath', L1_TO_L2_MESSAGES_SUBTREE_INSERTION_HEIGHT);
assertLength(this, 'newL1ToL2MessageTreeRootSiblingPath', L1_TO_L2_MESSAGES_SIBLING_PATH_LENGTH);
assertLength(this, 'newHistoricL1ToL2MessageTreeRootSiblingPath', L1_TO_L2_MESSAGES_ROOTS_TREE_HEIGHT);
assertLength(this, 'newL1ToL2Messages', NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
}
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/circuits.js/src/tests/factories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import {
KERNEL_PRIVATE_CALL_STACK_LENGTH,
KERNEL_PUBLIC_CALL_STACK_LENGTH,
L1_TO_L2_MESSAGES_ROOTS_TREE_HEIGHT,
L1_TO_L2_MESSAGES_SUBTREE_INSERTION_HEIGHT,
NEW_L2_TO_L1_MSGS_LENGTH,
NEW_COMMITMENTS_LENGTH,
NEW_NULLIFIERS_LENGTH,
Expand All @@ -67,6 +66,7 @@ import {
STATE_READS_LENGTH,
STATE_TRANSITIONS_LENGTH,
VK_TREE_HEIGHT,
L1_TO_L2_MESSAGES_SIBLING_PATH_LENGTH,
} from '../structs/constants.js';
import { FunctionData } from '../structs/function_data.js';
import { MembershipWitness } from '../structs/membership_witness.js';
Expand Down Expand Up @@ -468,7 +468,7 @@ export function makeRootRollupInputs(seed = 0) {
range(PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT, 0x2000).map(fr),
range(CONTRACT_TREE_ROOTS_TREE_HEIGHT, 0x2100).map(fr),
range(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, 0x2100).map(fr),
range(L1_TO_L2_MESSAGES_SUBTREE_INSERTION_HEIGHT, 0x2100).map(fr),
range(L1_TO_L2_MESSAGES_SIBLING_PATH_LENGTH, 0x2100).map(fr),
range(L1_TO_L2_MESSAGES_ROOTS_TREE_HEIGHT, 0x2100).map(fr),
makeAppendOnlyTreeSnapshot(seed + 0x2200),
makeAppendOnlyTreeSnapshot(seed + 0x2300),
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/end-to-end/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"clean": "rm -rf ./dest .tsbuildinfo",
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
"formatting:fix": "run -T prettier -w ./src",
"test": "DEBUG='aztec:' NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --runInBand --passWithNoTests --testTimeout=15000",
"test": "DEBUG='aztec:*' NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --runInBand --passWithNoTests --testTimeout=15000",
"test:integration": "concurrently -k -s first -c reset,dim -n test,anvil \"yarn test:integration:run\" \"anvil\"",
"test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --config jest.integration.config.json"
},
Expand Down Expand Up @@ -55,4 +55,4 @@
"!*.test.*"
],
"types": "./dest/index.d.ts"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
CONTRACT_TREE_ROOTS_TREE_HEIGHT,
CircuitsWasm,
ConstantBaseRollupData,
L1_TO_L2_MESSAGES_SUBTREE_INSERTION_HEIGHT,
L1_TO_L2_MESSAGES_SUBTREE_HEIGHT,
MembershipWitness,
MergeRollupInputs,
NULLIFIER_TREE_HEIGHT,
Expand Down Expand Up @@ -425,7 +425,7 @@ export class SoloBlockBuilder implements BlockBuilder {
);
const newL1ToL2MessageTreeRootSiblingPath = await this.getSubtreeSiblingPath(
MerkleTreeId.L1_TO_L2_MESSAGES_TREE,
L1_TO_L2_MESSAGES_SUBTREE_INSERTION_HEIGHT,
L1_TO_L2_MESSAGES_SUBTREE_HEIGHT,
);

// Get tree snapshots
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ describe('server_world_state_synchroniser', () => {
.map((_, index) => getMockBlock(index, [Buffer.alloc(32, index)]));
// sync the server
await server.start();
// there are 3 data trees updated
expect(merkleTreeDb.appendLeaves).toHaveBeenCalledTimes(totalBlocks * 3);
// there are 4 data trees updated
expect(merkleTreeDb.appendLeaves).toHaveBeenCalledTimes(totalBlocks * 4);
// and 2 root trees
expect(merkleTreeDb.updateHistoricRootsTrees).toHaveBeenCalledTimes(totalBlocks);
// there should be a call to append to the contract tree for each block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ export class ServerWorldStateSynchroniser implements WorldStateSynchroniser {
l2Block.endTreeOfHistoricPrivateDataTreeRootsSnapshot.root,
MerkleTreeId.PRIVATE_DATA_TREE_ROOTS_TREE,
),
compareRoot(l2Block.endL1ToL2MessageTreeSnapshot.root, MerkleTreeId.L1_TO_L2_MESSAGES_TREE),
compareRoot(
l2Block.endTreeOfHistoricL1ToL2MessageTreeRootsSnapshot.root,
MerkleTreeId.L1_TO_L2_MESSAGES_ROOTS_TREE,
),
]);
const ourBlock = rootChecks.every(x => x);
if (ourBlock) {
Expand All @@ -155,6 +160,7 @@ export class ServerWorldStateSynchroniser implements WorldStateSynchroniser {
[MerkleTreeId.CONTRACT_TREE, l2Block.newContracts],
[MerkleTreeId.NULLIFIER_TREE, l2Block.newNullifiers],
[MerkleTreeId.PRIVATE_DATA_TREE, l2Block.newCommitments],
[MerkleTreeId.L1_TO_L2_MESSAGES_TREE, l2Block.newL1ToL2Messages],
] as const) {
await this.merkleTreeDb.appendLeaves(
tree,
Expand Down