Skip to content

Commit

Permalink
2117 - address feedback of David
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanmon committed Sep 12, 2023
1 parent 46340db commit 1916038
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ template <typename NCT> struct RootRollupInputs {

// inputs required to process l1 to l2 messages
std::array<fr, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP> new_l1_to_l2_messages{};
std::array<fr, L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH> new_l1_to_l2_message_tree_root_sibling_path{};
std::array<fr, L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH> new_l1_to_l2_messages_tree_root_sibling_path{};

AppendOnlyTreeSnapshot<NCT> start_l1_to_l2_message_tree_snapshot{};
AppendOnlyTreeSnapshot<NCT> start_l1_to_l2_messages_tree_snapshot{};

// inputs required to add the block hash
AppendOnlyTreeSnapshot<NCT> start_historic_blocks_tree_snapshot{};
Expand All @@ -31,8 +31,8 @@ template <typename NCT> struct RootRollupInputs {
// For serialization, update with new fields
MSGPACK_FIELDS(previous_rollup_data,
new_l1_to_l2_messages,
new_l1_to_l2_message_tree_root_sibling_path,
start_l1_to_l2_message_tree_snapshot,
new_l1_to_l2_messages_tree_root_sibling_path,
start_l1_to_l2_messages_tree_snapshot,
start_historic_blocks_tree_snapshot,
new_historic_blocks_tree_sibling_path);
bool operator==(RootRollupInputs<NCT> const&) const = default;
Expand Down
5 changes: 5 additions & 0 deletions circuits/cpp/src/aztec3/circuits/rollup/merge/.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class merge_rollup_tests : public ::testing::Test {
protected:
static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../barretenberg/cpp/srs_db/ignition"); }

// TODO(1998): uncomment once https://github.com/AztecProtocol/aztec-packages/issues/1998 is solved and
// use new pattern such as call_func_and_wrapper from test_helper.hpp

// static void run_cbind(MergeRollupInputs& merge_rollup_inputs,
// BaseOrMergeRollupPublicInputs& expected_public_inputs,
// bool compare_pubins = true)
Expand Down Expand Up @@ -299,6 +302,8 @@ TEST_F(merge_rollup_tests, native_merge_cbind)

ASSERT_FALSE(builder.failed());
BaseOrMergeRollupPublicInputs ignored_public_inputs;

// TODO(1998): see above
// run_cbind(inputs, ignored_public_inputs, false);
}
} // namespace aztec3::circuits::rollup::merge::native_merge_rollup_circuit
5 changes: 5 additions & 0 deletions circuits/cpp/src/aztec3/circuits/rollup/root/.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class root_rollup_tests : public ::testing::Test {
protected:
static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../barretenberg/cpp/srs_db/ignition"); }

// TODO(1998): uncomment once https://github.com/AztecProtocol/aztec-packages/issues/1998 is solved and
// use new pattern such as call_func_and_wrapper from test_helper.hpp

// static void run_cbind(RootRollupInputs& root_rollup_inputs,
// RootRollupPublicInputs& expected_public_inputs,
// bool compare_pubins = true)
Expand Down Expand Up @@ -149,6 +152,7 @@ TEST_F(root_rollup_tests, native_check_block_hashes_empty_blocks)

EXPECT_FALSE(builder.failed());

// TODO(1998): see above
// run_cbind(inputs, outputs, true);
}

Expand Down Expand Up @@ -300,6 +304,7 @@ TEST_F(root_rollup_tests, native_root_missing_nullifier_logic)

EXPECT_FALSE(builder.failed());

// TODO(1998): see above
// run_cbind(rootRollupInputs, outputs, true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ RootRollupPublicInputs root_rollup_circuit(DummyBuilder& builder, RootRollupInpu
const auto empty_l1_to_l2_subtree_root = components::calculate_empty_tree_root(L1_TO_L2_MSG_SUBTREE_HEIGHT);
auto new_l1_to_l2_messages_tree_snapshot = components::insert_subtree_to_snapshot_tree(
builder,
rootRollupInputs.start_l1_to_l2_message_tree_snapshot,
rootRollupInputs.new_l1_to_l2_message_tree_root_sibling_path,
rootRollupInputs.start_l1_to_l2_messages_tree_snapshot,
rootRollupInputs.new_l1_to_l2_messages_tree_root_sibling_path,
empty_l1_to_l2_subtree_root,
l1_to_l2_subtree_root,
L1_TO_L2_MSG_SUBTREE_HEIGHT,
Expand Down Expand Up @@ -138,7 +138,7 @@ RootRollupPublicInputs root_rollup_circuit(DummyBuilder& builder, RootRollupInpu
.end_contract_tree_snapshot = right.end_contract_tree_snapshot,
.start_public_data_tree_root = left.start_public_data_tree_root,
.end_public_data_tree_root = right.end_public_data_tree_root,
.start_l1_to_l2_messages_tree_snapshot = rootRollupInputs.start_l1_to_l2_message_tree_snapshot,
.start_l1_to_l2_messages_tree_snapshot = rootRollupInputs.start_l1_to_l2_messages_tree_snapshot,
.end_l1_to_l2_messages_tree_snapshot = new_l1_to_l2_messages_tree_snapshot,
.start_historic_blocks_tree_snapshot = rootRollupInputs.start_historic_blocks_tree_snapshot,
.end_historic_blocks_tree_snapshot = end_historic_blocks_tree_snapshot,
Expand Down
4 changes: 2 additions & 2 deletions circuits/cpp/src/aztec3/circuits/rollup/test_utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ RootRollupInputs get_root_rollup_inputs(utils::DummyBuilder& builder,
RootRollupInputs rootRollupInputs = {
.previous_rollup_data = get_previous_rollup_data(builder, std::move(kernel_data)),
.new_l1_to_l2_messages = l1_to_l2_messages,
.new_l1_to_l2_message_tree_root_sibling_path = l1_to_l2_tree_sibling_path,
.start_l1_to_l2_message_tree_snapshot = start_l1_to_l2_msg_tree_snapshot,
.new_l1_to_l2_messages_tree_root_sibling_path = l1_to_l2_tree_sibling_path,
.start_l1_to_l2_messages_tree_snapshot = start_l1_to_l2_msg_tree_snapshot,
.start_historic_blocks_tree_snapshot = start_historic_blocks_tree_snapshot,
.new_historic_blocks_tree_sibling_path = blocks_tree_sibling_path,
};
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec-rpc/src/synchroniser/synchroniser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export class Synchroniser {
block.endPrivateDataTreeSnapshot.root,
block.endNullifierTreeSnapshot.root,
block.endContractTreeSnapshot.root,
block.endL1ToL2MessageTreeSnapshot.root,
block.endL1ToL2MessagesTreeSnapshot.root,
block.endHistoricBlocksTreeSnapshot.root,
Fr.ZERO, // todo: private kernel vk tree root
block.endPublicDataTreeRoot,
Expand Down
28 changes: 14 additions & 14 deletions yarn-project/circuits.js/src/cbind/circuits.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2579,8 +2579,8 @@ export function fromMergeRollupInputs(o: MergeRollupInputs): MsgpackMergeRollupI
interface MsgpackRootRollupInputs {
previous_rollup_data: Tuple<MsgpackPreviousRollupData, 2>;
new_l1_to_l2_messages: Tuple<Buffer, 16>;
new_l1_to_l2_message_tree_root_sibling_path: Tuple<Buffer, 12>;
start_l1_to_l2_message_tree_snapshot: MsgpackAppendOnlyTreeSnapshot;
new_l1_to_l2_messages_tree_root_sibling_path: Tuple<Buffer, 12>;
start_l1_to_l2_messages_tree_snapshot: MsgpackAppendOnlyTreeSnapshot;
start_historic_blocks_tree_snapshot: MsgpackAppendOnlyTreeSnapshot;
new_historic_blocks_tree_sibling_path: Tuple<Buffer, 16>;
}
Expand All @@ -2592,11 +2592,11 @@ export function toRootRollupInputs(o: MsgpackRootRollupInputs): RootRollupInputs
if (o.new_l1_to_l2_messages === undefined) {
throw new Error('Expected new_l1_to_l2_messages in RootRollupInputs deserialization');
}
if (o.new_l1_to_l2_message_tree_root_sibling_path === undefined) {
throw new Error('Expected new_l1_to_l2_message_tree_root_sibling_path in RootRollupInputs deserialization');
if (o.new_l1_to_l2_messages_tree_root_sibling_path === undefined) {
throw new Error('Expected new_l1_to_l2_messages_tree_root_sibling_path in RootRollupInputs deserialization');
}
if (o.start_l1_to_l2_message_tree_snapshot === undefined) {
throw new Error('Expected start_l1_to_l2_message_tree_snapshot in RootRollupInputs deserialization');
if (o.start_l1_to_l2_messages_tree_snapshot === undefined) {
throw new Error('Expected start_l1_to_l2_messages_tree_snapshot in RootRollupInputs deserialization');
}
if (o.start_historic_blocks_tree_snapshot === undefined) {
throw new Error('Expected start_historic_blocks_tree_snapshot in RootRollupInputs deserialization');
Expand All @@ -2607,8 +2607,8 @@ export function toRootRollupInputs(o: MsgpackRootRollupInputs): RootRollupInputs
return new RootRollupInputs(
mapTuple(o.previous_rollup_data, (v: MsgpackPreviousRollupData) => toPreviousRollupData(v)),
mapTuple(o.new_l1_to_l2_messages, (v: Buffer) => Fr.fromBuffer(v)),
mapTuple(o.new_l1_to_l2_message_tree_root_sibling_path, (v: Buffer) => Fr.fromBuffer(v)),
toAppendOnlyTreeSnapshot(o.start_l1_to_l2_message_tree_snapshot),
mapTuple(o.new_l1_to_l2_messages_tree_root_sibling_path, (v: Buffer) => Fr.fromBuffer(v)),
toAppendOnlyTreeSnapshot(o.start_l1_to_l2_messages_tree_snapshot),
toAppendOnlyTreeSnapshot(o.start_historic_blocks_tree_snapshot),
mapTuple(o.new_historic_blocks_tree_sibling_path, (v: Buffer) => Fr.fromBuffer(v)),
);
Expand All @@ -2621,11 +2621,11 @@ export function fromRootRollupInputs(o: RootRollupInputs): MsgpackRootRollupInpu
if (o.newL1ToL2Messages === undefined) {
throw new Error('Expected newL1ToL2Messages in RootRollupInputs serialization');
}
if (o.newL1ToL2MessageTreeRootSiblingPath === undefined) {
throw new Error('Expected newL1ToL2MessageTreeRootSiblingPath in RootRollupInputs serialization');
if (o.newL1ToL2MessagesTreeRootSiblingPath === undefined) {
throw new Error('Expected newL1ToL2MessagesTreeRootSiblingPath in RootRollupInputs serialization');
}
if (o.startL1ToL2MessageTreeSnapshot === undefined) {
throw new Error('Expected startL1ToL2MessageTreeSnapshot in RootRollupInputs serialization');
if (o.startL1ToL2MessagesTreeSnapshot === undefined) {
throw new Error('Expected startL1ToL2MessagesTreeSnapshot in RootRollupInputs serialization');
}
if (o.startHistoricBlocksTreeSnapshot === undefined) {
throw new Error('Expected startHistoricBlocksTreeSnapshot in RootRollupInputs serialization');
Expand All @@ -2636,10 +2636,10 @@ export function fromRootRollupInputs(o: RootRollupInputs): MsgpackRootRollupInpu
return {
previous_rollup_data: mapTuple(o.previousRollupData, (v: PreviousRollupData) => fromPreviousRollupData(v)),
new_l1_to_l2_messages: mapTuple(o.newL1ToL2Messages, (v: Fr) => toBuffer(v)),
new_l1_to_l2_message_tree_root_sibling_path: mapTuple(o.newL1ToL2MessageTreeRootSiblingPath, (v: Fr) =>
new_l1_to_l2_messages_tree_root_sibling_path: mapTuple(o.newL1ToL2MessagesTreeRootSiblingPath, (v: Fr) =>
toBuffer(v),
),
start_l1_to_l2_message_tree_snapshot: fromAppendOnlyTreeSnapshot(o.startL1ToL2MessageTreeSnapshot),
start_l1_to_l2_messages_tree_snapshot: fromAppendOnlyTreeSnapshot(o.startL1ToL2MessagesTreeSnapshot),
start_historic_blocks_tree_snapshot: fromAppendOnlyTreeSnapshot(o.startHistoricBlocksTreeSnapshot),
new_historic_blocks_tree_sibling_path: mapTuple(o.newHistoricBlocksTreeSiblingPath, (v: Fr) => toBuffer(v)),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ sibling_path: [ 0x1120 0x1121 0x1122 0x1123 0x1124 0x1125 0x1126 0x1127 ]
]
new_l1_to_l2_messages: [ 0x2100 0x2101 0x2102 0x2103 0x2104 0x2105 0x2106 0x2107 0x2108 0x2109 0x210a 0x210b 0x210c 0x210d 0x210e 0x210f ]
new_l1_to_l2_message_tree_root_sibling_path: [ 0x2100 0x2101 0x2102 0x2103 0x2104 0x2105 0x2106 0x2107 0x2108 0x2109 0x210a 0x210b ]
start_l1_to_l2_message_tree_snapshot: root: 0x2200
new_l1_to_l2_messages_tree_root_sibling_path: [ 0x2100 0x2101 0x2102 0x2103 0x2104 0x2105 0x2106 0x2107 0x2108 0x2109 0x210a 0x210b ]
start_l1_to_l2_messages_tree_snapshot: root: 0x2200
next_available_leaf_index: 8704
start_historic_blocks_tree_snapshot: root: 0x2200
Expand Down
8 changes: 4 additions & 4 deletions yarn-project/circuits.js/src/structs/rollup/root_rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ export class RootRollupInputs {
/**
* Sibling path of the new L1 to L2 message tree root.
*/
public newL1ToL2MessageTreeRootSiblingPath: Tuple<Fr, typeof L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH>,
public newL1ToL2MessagesTreeRootSiblingPath: Tuple<Fr, typeof L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH>,
/**
* Snapshot of the L1 to L2 message tree at the start of the rollup.
*/
public startL1ToL2MessageTreeSnapshot: AppendOnlyTreeSnapshot,
public startL1ToL2MessagesTreeSnapshot: AppendOnlyTreeSnapshot,
/**
* Snapshot of the historic block roots tree at the start of the rollup.
*/
Expand All @@ -58,8 +58,8 @@ export class RootRollupInputs {
return [
fields.previousRollupData,
fields.newL1ToL2Messages,
fields.newL1ToL2MessageTreeRootSiblingPath,
fields.startL1ToL2MessageTreeSnapshot,
fields.newL1ToL2MessagesTreeRootSiblingPath,
fields.startL1ToL2MessagesTreeSnapshot,
fields.startHistoricBlocksTreeSnapshot,
fields.newHistoricBlocksTreeSiblingPath,
] as const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ describe('sequencer/solo_block_builder', () => {
endContractTreeSnapshot: rootRollupOutput.endContractTreeSnapshot,
startPublicDataTreeRoot: rootRollupOutput.startPublicDataTreeRoot,
endPublicDataTreeRoot: rootRollupOutput.endPublicDataTreeRoot,
startL1ToL2MessageTreeSnapshot: rootRollupOutput.startL1ToL2MessagesTreeSnapshot,
endL1ToL2MessageTreeSnapshot: rootRollupOutput.endL1ToL2MessagesTreeSnapshot,
startL1ToL2MessagesTreeSnapshot: rootRollupOutput.startL1ToL2MessagesTreeSnapshot,
endL1ToL2MessagesTreeSnapshot: rootRollupOutput.endL1ToL2MessagesTreeSnapshot,
startHistoricBlocksTreeSnapshot: rootRollupOutput.startHistoricBlocksTreeSnapshot,
endHistoricBlocksTreeSnapshot: rootRollupOutput.endHistoricBlocksTreeSnapshot,
newCommitments,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class SoloBlockBuilder implements BlockBuilder {
endNullifierTreeSnapshot,
endContractTreeSnapshot,
endPublicDataTreeRoot,
endL1ToL2MessagesTreeSnapshot: endL1ToL2MessageTreeSnapshot,
endL1ToL2MessagesTreeSnapshot,
endHistoricBlocksTreeSnapshot,
} = circuitsOutput;

Expand Down Expand Up @@ -150,8 +150,8 @@ export class SoloBlockBuilder implements BlockBuilder {
endContractTreeSnapshot,
startPublicDataTreeRoot: startPublicDataTreeSnapshot.root,
endPublicDataTreeRoot,
startL1ToL2MessageTreeSnapshot,
endL1ToL2MessageTreeSnapshot,
startL1ToL2MessagesTreeSnapshot: startL1ToL2MessageTreeSnapshot,
endL1ToL2MessagesTreeSnapshot,
startHistoricBlocksTreeSnapshot,
endHistoricBlocksTreeSnapshot,
newCommitments,
Expand Down Expand Up @@ -438,20 +438,20 @@ export class SoloBlockBuilder implements BlockBuilder {
return path.toFieldArray();
};

const newL1ToL2MessageTreeRootSiblingPathArray = await this.getSubtreeSiblingPath(
const newL1ToL2MessagesTreeRootSiblingPathArray = await this.getSubtreeSiblingPath(
MerkleTreeId.L1_TO_L2_MESSAGES_TREE,
L1_TO_L2_MSG_SUBTREE_HEIGHT,
);

const newL1ToL2MessageTreeRootSiblingPath = makeTuple(
const newL1ToL2MessagesTreeRootSiblingPath = makeTuple(
L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH,
i =>
i < newL1ToL2MessageTreeRootSiblingPathArray.length ? newL1ToL2MessageTreeRootSiblingPathArray[i] : Fr.ZERO,
i < newL1ToL2MessagesTreeRootSiblingPathArray.length ? newL1ToL2MessagesTreeRootSiblingPathArray[i] : Fr.ZERO,
0,
);

// Get tree snapshots
const startL1ToL2MessageTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.L1_TO_L2_MESSAGES_TREE);
const startL1ToL2MessagesTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.L1_TO_L2_MESSAGES_TREE);

// Get historic block tree roots
const startHistoricBlocksTreeSnapshot = await this.getTreeSnapshot(MerkleTreeId.BLOCKS_TREE);
Expand All @@ -466,8 +466,8 @@ export class SoloBlockBuilder implements BlockBuilder {
return RootRollupInputs.from({
previousRollupData,
newL1ToL2Messages,
newL1ToL2MessageTreeRootSiblingPath,
startL1ToL2MessageTreeSnapshot,
newL1ToL2MessagesTreeRootSiblingPath,
startL1ToL2MessagesTreeSnapshot,
startHistoricBlocksTreeSnapshot,
newHistoricBlocksTreeSiblingPath,
});
Expand Down
Loading

0 comments on commit 1916038

Please sign in to comment.