From 1b902f663349198aa8f9b3a22663b5c8adc0d442 Mon Sep 17 00:00:00 2001 From: just-mitch <68168980+just-mitch@users.noreply.github.com> Date: Tue, 8 Oct 2024 11:03:26 +0100 Subject: [PATCH] feat: parameterize circuit epoch duration (#9050) --- l1-contracts/src/core/Rollup.sol | 20 +++++++------- l1-contracts/src/core/interfaces/IRollup.sol | 4 +-- .../src/core/libraries/ConstantsGen.sol | 4 +-- l1-contracts/test/Rollup.t.sol | 3 ++- ...block_root_or_block_merge_public_inputs.nr | 13 +++++---- .../block_root/block_root_rollup_inputs.nr | 4 +-- .../empty_block_root_rollup_inputs.nr | 3 ++- .../crates/rollup-lib/src/components.nr | 8 +++--- .../src/root/root_rollup_public_inputs.nr | 3 ++- .../crates/types/src/constants.nr | 7 +++-- yarn-project/circuits.js/src/constants.gen.ts | 4 +-- .../circuits.js/src/scripts/constants.in.ts | 4 +++ ...block_root_or_block_merge_public_inputs.ts | 5 ++-- .../src/structs/rollup/root_rollup.ts | 5 ++-- .../circuits.js/src/tests/factories.ts | 5 ++-- .../end-to-end/src/spartan/smoke.test.ts | 27 ++++++++++--------- .../src/type_conversion.ts | 5 ++-- .../src/publisher/l1-publisher.ts | 5 ++-- 18 files changed, 75 insertions(+), 54 deletions(-) diff --git a/l1-contracts/src/core/Rollup.sol b/l1-contracts/src/core/Rollup.sol index e1600ec0dd4..4d6048db7b1 100644 --- a/l1-contracts/src/core/Rollup.sol +++ b/l1-contracts/src/core/Rollup.sol @@ -227,7 +227,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup { function submitEpochRootProof( uint256 _epochSize, bytes32[7] calldata _args, - bytes32[64] calldata _fees, + bytes32[] calldata _fees, bytes calldata _aggregationObject, bytes calldata _proof ) external override(IRollup) { @@ -241,7 +241,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup { tips.provenBlockNumber = endBlockNumber; - for (uint256 i = 0; i < 32; i++) { + for (uint256 i = 0; i < Constants.AZTEC_EPOCH_DURATION; i++) { address coinbase = address(uint160(uint256(publicInputs[9 + i * 2]))); uint256 fees = uint256(publicInputs[10 + i * 2]); @@ -470,7 +470,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup { function getEpochProofPublicInputs( uint256 _epochSize, bytes32[7] calldata _args, - bytes32[64] calldata _fees, + bytes32[] calldata _fees, bytes calldata _aggregationObject ) public view override(IRollup) returns (bytes32[] memory) { uint256 previousBlockNumber = tips.provenBlockNumber; @@ -528,7 +528,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup { // end_timestamp: u64, // end_block_number: Field, // out_hash: Field, - // fees: [FeeRecipient; 32], + // fees: [FeeRecipient; Constants.AZTEC_EPOCH_DURATION], // vk_tree_root: Field, // prover_id: Field // } @@ -562,16 +562,18 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup { // out_hash: root of this epoch's l2 to l1 message tree publicInputs[8] = _args[5]; - // fees[9-72]: array of recipient-value pairs - for (uint256 i = 0; i < 64; i++) { + uint256 feesLength = Constants.AZTEC_EPOCH_DURATION * 2; + // fees[9 to (9+feesLength-1)]: array of recipient-value pairs + for (uint256 i = 0; i < feesLength; i++) { publicInputs[9 + i] = _fees[i]; } + uint256 feesEnd = 9 + feesLength; // vk_tree_root - publicInputs[73] = vkTreeRoot; + publicInputs[feesEnd] = vkTreeRoot; // prover_id: id of current epoch's prover - publicInputs[74] = _args[6]; + publicInputs[feesEnd + 1] = _args[6]; // the block proof is recursive, which means it comes with an aggregation object // this snippet copies it into the public inputs needed for verification @@ -582,7 +584,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup { assembly { part := calldataload(add(_aggregationObject.offset, mul(i, 32))) } - publicInputs[i + 75] = part; + publicInputs[i + feesEnd + 2] = part; } return publicInputs; diff --git a/l1-contracts/src/core/interfaces/IRollup.sol b/l1-contracts/src/core/interfaces/IRollup.sol index 6aa9f616938..1ed780fdd90 100644 --- a/l1-contracts/src/core/interfaces/IRollup.sol +++ b/l1-contracts/src/core/interfaces/IRollup.sol @@ -55,7 +55,7 @@ interface IRollup { function submitEpochRootProof( uint256 _epochSize, bytes32[7] calldata _args, - bytes32[64] calldata _fees, + bytes32[] calldata _fees, bytes calldata _aggregationObject, bytes calldata _proof ) external; @@ -110,7 +110,7 @@ interface IRollup { function getEpochProofPublicInputs( uint256 _epochSize, bytes32[7] calldata _args, - bytes32[64] calldata _fees, + bytes32[] calldata _fees, bytes calldata _aggregationObject ) external view returns (bytes32[] memory); function computeTxsEffectsHash(bytes calldata _body) external pure returns (bytes32); diff --git a/l1-contracts/src/core/libraries/ConstantsGen.sol b/l1-contracts/src/core/libraries/ConstantsGen.sol index 91a9ca5a958..c2d73fb50cd 100644 --- a/l1-contracts/src/core/libraries/ConstantsGen.sol +++ b/l1-contracts/src/core/libraries/ConstantsGen.sol @@ -210,9 +210,9 @@ library Constants { uint256 internal constant KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 663; uint256 internal constant CONSTANT_ROLLUP_DATA_LENGTH = 12; uint256 internal constant BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH = 29; - uint256 internal constant BLOCK_ROOT_OR_BLOCK_MERGE_PUBLIC_INPUTS_LENGTH = 91; uint256 internal constant FEE_RECIPIENT_LENGTH = 2; - uint256 internal constant ROOT_ROLLUP_PUBLIC_INPUTS_LENGTH = 75; + uint256 internal constant BLOCK_ROOT_OR_BLOCK_MERGE_PUBLIC_INPUTS_LENGTH = 123; + uint256 internal constant ROOT_ROLLUP_PUBLIC_INPUTS_LENGTH = 107; uint256 internal constant GET_NOTES_ORACLE_RETURN_LENGTH = 674; uint256 internal constant NOTE_HASHES_NUM_BYTES_PER_BASE_ROLLUP = 2048; uint256 internal constant NULLIFIERS_NUM_BYTES_PER_BASE_ROLLUP = 2048; diff --git a/l1-contracts/test/Rollup.t.sol b/l1-contracts/test/Rollup.t.sol index 150b0c1030d..2c1366a9e6d 100644 --- a/l1-contracts/test/Rollup.t.sol +++ b/l1-contracts/test/Rollup.t.sol @@ -865,7 +865,8 @@ contract RollupTest is DecoderBase { _proverId ]; - bytes32[64] memory fees; + bytes32[] memory fees = new bytes32[](Constants.AZTEC_EPOCH_DURATION * 2); + fees[0] = bytes32(uint256(uint160(_feeRecipient))); fees[1] = bytes32(_feeAmount); diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/block_root_or_block_merge_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/block_root_or_block_merge_public_inputs.nr index 231f83001ba..f85f8d567f4 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/block_root_or_block_merge_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/abis/block_root_or_block_merge_public_inputs.nr @@ -1,6 +1,6 @@ use dep::types::{ abis::{append_only_tree_snapshot::AppendOnlyTreeSnapshot, global_variables::GlobalVariables}, - constants::{BLOCK_ROOT_OR_BLOCK_MERGE_PUBLIC_INPUTS_LENGTH, FEE_RECIPIENT_LENGTH}, + constants::{AZTEC_EPOCH_DURATION, BLOCK_ROOT_OR_BLOCK_MERGE_PUBLIC_INPUTS_LENGTH, FEE_RECIPIENT_LENGTH}, traits::{Empty, Serialize, Deserialize}, utils::reader::Reader, address::EthAddress }; @@ -44,7 +44,7 @@ pub struct BlockRootOrBlockMergePublicInputs { start_global_variables: GlobalVariables, // Global variables for the first block in the range end_global_variables: GlobalVariables, // Global variables for the last block in the range out_hash: Field, // Merkle node of the L2-to-L1 messages merkle roots in the block range - fees: [FeeRecipient; 32], // Concatenation of all coinbase and fees for the block range + fees: [FeeRecipient; AZTEC_EPOCH_DURATION], // Concatenation of all coinbase and fees for the block range vk_tree_root: Field, // Root of allowed vk tree prover_id: Field, // TODO(#7346): Temporarily added prover_id while we verify block-root proofs on L1 } @@ -65,7 +65,7 @@ impl Empty for BlockRootOrBlockMergePublicInputs { start_global_variables: GlobalVariables::empty(), end_global_variables: GlobalVariables::empty(), out_hash: 0, - fees: [FeeRecipient::empty(); 32], + fees: [FeeRecipient::empty(); AZTEC_EPOCH_DURATION], vk_tree_root: 0, prover_id: 0 } @@ -98,7 +98,7 @@ impl Serialize for BlockRootOrBl fields.extend_from_array(self.start_global_variables.serialize()); fields.extend_from_array(self.end_global_variables.serialize()); fields.push(self.out_hash as Field); - for i in 0..32 { + for i in 0..AZTEC_EPOCH_DURATION { fields.extend_from_array(self.fees[i].serialize()); } fields.push(self.vk_tree_root as Field); @@ -120,7 +120,10 @@ impl Deserialize for BlockRootOr start_global_variables: reader.read_struct(GlobalVariables::deserialize), end_global_variables: reader.read_struct(GlobalVariables::deserialize), out_hash: reader.read(), - fees: reader.read_struct_array(FeeRecipient::deserialize, [FeeRecipient::empty(); 32]), + fees: reader.read_struct_array( + FeeRecipient::deserialize, + [FeeRecipient::empty(); AZTEC_EPOCH_DURATION] + ), vk_tree_root: reader.read(), prover_id: reader.read() }; diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/block_root_rollup_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/block_root_rollup_inputs.nr index 5124e5316ff..ed197f5e7f9 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/block_root_rollup_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/block_root_rollup_inputs.nr @@ -9,7 +9,7 @@ use parity_lib::{root::root_rollup_parity_input::RootRollupParityInput}; use types::{ abis::{append_only_tree_snapshot::AppendOnlyTreeSnapshot}, constants::{ - NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, L1_TO_L2_MSG_SUBTREE_HEIGHT, + AZTEC_EPOCH_DURATION, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, L1_TO_L2_MSG_SUBTREE_HEIGHT, L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, ARCHIVE_HEIGHT, BASE_ROLLUP_INDEX, MERGE_ROLLUP_INDEX }, header::Header, content_commitment::ContentCommitment, @@ -133,7 +133,7 @@ impl BlockRootRollupInputs { 0 ); - let mut fee_arr = [FeeRecipient::empty(); 32]; + let mut fee_arr = [FeeRecipient::empty(); AZTEC_EPOCH_DURATION]; fee_arr[0] = FeeRecipient { recipient: left.constants.global_variables.coinbase, value: total_fees }; BlockRootOrBlockMergePublicInputs { diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/empty_block_root_rollup_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/empty_block_root_rollup_inputs.nr index ecff942e975..248b1c5051e 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/empty_block_root_rollup_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/block_root/empty_block_root_rollup_inputs.nr @@ -1,5 +1,6 @@ use crate::abis::block_root_or_block_merge_public_inputs::BlockRootOrBlockMergePublicInputs; use types::{abis::{append_only_tree_snapshot::AppendOnlyTreeSnapshot, global_variables::GlobalVariables}}; +use types::constants::AZTEC_EPOCH_DURATION; use crate::abis::block_root_or_block_merge_public_inputs::FeeRecipient; pub struct EmptyBlockRootRollupInputs { @@ -21,7 +22,7 @@ impl EmptyBlockRootRollupInputs { start_global_variables: self.global_variables, end_global_variables: self.global_variables, out_hash: 0, // out_hash is ignored when merging if the block proof is padding - fees: [FeeRecipient::empty(); 32], + fees: [FeeRecipient::empty(); AZTEC_EPOCH_DURATION], vk_tree_root: self.vk_tree_root, prover_id: self.prover_id } diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr index 85e3debb8d1..6f195d69df8 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr @@ -10,7 +10,7 @@ use dep::types::{ }, merkle_tree::VariableMerkleTree, constants::{ - MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, + AZTEC_EPOCH_DURATION, MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, MAX_L2_TO_L1_MSGS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, MAX_UNENCRYPTED_LOGS_PER_TX }, utils::{arrays::{array_length, array_merge}}, @@ -117,10 +117,12 @@ pub fn accumulate_fees(left: BaseOrMergeRollupPublicInputs, right: BaseOrMergeRo pub fn accumulate_blocks_fees( left: BlockRootOrBlockMergePublicInputs, right: BlockRootOrBlockMergePublicInputs -) -> [FeeRecipient; 32] { +) -> [FeeRecipient; AZTEC_EPOCH_DURATION] { let left_len = array_length(left.fees); let right_len = array_length(right.fees); - assert(left_len + right_len <= 32, "too many fee payment structs accumulated in rollup"); + assert( + left_len + right_len <= AZTEC_EPOCH_DURATION, "too many fee payment structs accumulated in rollup" + ); // TODO(Miranda): combine fees with same recipient depending on rollup structure // Assuming that the final rollup tree (block root -> block merge -> root) has max 32 leaves (TODO: constrain in root), then // in the worst case, we would be checking the left 16 values (left_len = 16) against the right 16 (right_len = 16). diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_public_inputs.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_public_inputs.nr index 9b43483ab1a..bd8d7524952 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_public_inputs.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/root/root_rollup_public_inputs.nr @@ -1,4 +1,5 @@ use dep::types::abis::append_only_tree_snapshot::AppendOnlyTreeSnapshot; +use dep::types::constants::AZTEC_EPOCH_DURATION; use crate::abis::block_root_or_block_merge_public_inputs::FeeRecipient; pub struct RootRollupPublicInputs { @@ -10,7 +11,7 @@ pub struct RootRollupPublicInputs { end_timestamp: u64, end_block_number: Field, out_hash: Field, - fees: [FeeRecipient; 32], + fees: [FeeRecipient; AZTEC_EPOCH_DURATION], vk_tree_root: Field, prover_id: Field, } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr index df4d56124b0..2f86635ef9c 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr @@ -289,11 +289,10 @@ global CONSTANT_ROLLUP_DATA_LENGTH: u32 = APPEND_ONLY_TREE_SNAPSHOT_LENGTH + 1 + // + 5 for rollup_type, height_in_block_tree, txs_effects_hash, out_hash, accumulated_fees global BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH: u32 = CONSTANT_ROLLUP_DATA_LENGTH + PARTIAL_STATE_REFERENCE_LENGTH + PARTIAL_STATE_REFERENCE_LENGTH + 5; -// + 64 for 32 * FeeRecipient { recipient, value }, + 4 for previous_block_hash, end_block_hash, out_hash, vk_tree_root + 1 temporarily for prover_id -global BLOCK_ROOT_OR_BLOCK_MERGE_PUBLIC_INPUTS_LENGTH: u32 = 2 * APPEND_ONLY_TREE_SNAPSHOT_LENGTH + 2 * GLOBAL_VARIABLES_LENGTH + 69; - +// + 5 for previous_block_hash, end_block_hash, out_hash, vk_tree_root, and (temporary) prover_id global FEE_RECIPIENT_LENGTH: u32 = 2; -global ROOT_ROLLUP_PUBLIC_INPUTS_LENGTH: u32 = 2 * APPEND_ONLY_TREE_SNAPSHOT_LENGTH + 7 + 32 * FEE_RECIPIENT_LENGTH; +global BLOCK_ROOT_OR_BLOCK_MERGE_PUBLIC_INPUTS_LENGTH: u32 = 2 * APPEND_ONLY_TREE_SNAPSHOT_LENGTH + 2 * GLOBAL_VARIABLES_LENGTH + AZTEC_EPOCH_DURATION * FEE_RECIPIENT_LENGTH + 5; +global ROOT_ROLLUP_PUBLIC_INPUTS_LENGTH: u32 = 2 * APPEND_ONLY_TREE_SNAPSHOT_LENGTH + 7 + AZTEC_EPOCH_DURATION * FEE_RECIPIENT_LENGTH; global GET_NOTES_ORACLE_RETURN_LENGTH: u32 = 674; global NOTE_HASHES_NUM_BYTES_PER_BASE_ROLLUP: u32 = 32 * MAX_NOTE_HASHES_PER_TX; diff --git a/yarn-project/circuits.js/src/constants.gen.ts b/yarn-project/circuits.js/src/constants.gen.ts index 521c7201aad..2ba48c08245 100644 --- a/yarn-project/circuits.js/src/constants.gen.ts +++ b/yarn-project/circuits.js/src/constants.gen.ts @@ -192,9 +192,9 @@ export const VM_CIRCUIT_PUBLIC_INPUTS_LENGTH = 2471; export const KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 663; export const CONSTANT_ROLLUP_DATA_LENGTH = 12; export const BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH = 29; -export const BLOCK_ROOT_OR_BLOCK_MERGE_PUBLIC_INPUTS_LENGTH = 91; export const FEE_RECIPIENT_LENGTH = 2; -export const ROOT_ROLLUP_PUBLIC_INPUTS_LENGTH = 75; +export const BLOCK_ROOT_OR_BLOCK_MERGE_PUBLIC_INPUTS_LENGTH = 123; +export const ROOT_ROLLUP_PUBLIC_INPUTS_LENGTH = 107; export const GET_NOTES_ORACLE_RETURN_LENGTH = 674; export const NOTE_HASHES_NUM_BYTES_PER_BASE_ROLLUP = 2048; export const NULLIFIERS_NUM_BYTES_PER_BASE_ROLLUP = 2048; diff --git a/yarn-project/circuits.js/src/scripts/constants.in.ts b/yarn-project/circuits.js/src/scripts/constants.in.ts index 8580b48e8ba..17748e0f71b 100644 --- a/yarn-project/circuits.js/src/scripts/constants.in.ts +++ b/yarn-project/circuits.js/src/scripts/constants.in.ts @@ -333,6 +333,8 @@ function parseNoirFile(fileContent: string): ParsedContent { function evaluateExpressions(expressions: [string, string][]): { [key: string]: string } { const constants: { [key: string]: string } = {}; + const knownBigInts = ['AZTEC_EPOCH_DURATION', 'FEE_RECIPIENT_LENGTH']; + // Create JS expressions. It is not as easy as just evaluating the expression! // We basically need to convert everything to BigInts, otherwise things don't fit. // However, (1) the bigints need to be initialized from strings; (2) everything needs to @@ -352,6 +354,8 @@ function evaluateExpressions(expressions: [string, string][]): { [key: string]: .split(' ') // ...and then we convert each term to a BigInt if it is a number. .map(term => (isNaN(+term) ? term : `BigInt('${term}')`)) + // .. also, we convert the known bigints to BigInts. + .map(term => (knownBigInts.includes(term) ? `BigInt(${term})` : term)) // We join the terms back together. .join(' '); return `var ${name} = ${guardedRhs};`; diff --git a/yarn-project/circuits.js/src/structs/rollup/block_root_or_block_merge_public_inputs.ts b/yarn-project/circuits.js/src/structs/rollup/block_root_or_block_merge_public_inputs.ts index 48293c44896..64020e2ac8c 100644 --- a/yarn-project/circuits.js/src/structs/rollup/block_root_or_block_merge_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/rollup/block_root_or_block_merge_public_inputs.ts @@ -3,6 +3,7 @@ import { Fr } from '@aztec/foundation/fields'; import { BufferReader, type Tuple, serializeToBuffer, serializeToFields } from '@aztec/foundation/serialize'; import { type FieldsOf } from '@aztec/foundation/types'; +import { AZTEC_EPOCH_DURATION } from '../../constants.gen.js'; import { GlobalVariables } from '../global_variables.js'; import { AppendOnlyTreeSnapshot } from './append_only_tree_snapshot.js'; @@ -43,7 +44,7 @@ export class BlockRootOrBlockMergePublicInputs { /** * The summed `transaction_fee`s and recipients of the constituent blocks. */ - public fees: Tuple, + public fees: Tuple, /** * Root of the verification key tree. */ @@ -69,7 +70,7 @@ export class BlockRootOrBlockMergePublicInputs { reader.readObject(GlobalVariables), reader.readObject(GlobalVariables), Fr.fromBuffer(reader), - reader.readArray(32, FeeRecipient), + reader.readArray(AZTEC_EPOCH_DURATION, FeeRecipient), Fr.fromBuffer(reader), Fr.fromBuffer(reader), ); diff --git a/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts b/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts index f33487e2378..337a3175079 100644 --- a/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts +++ b/yarn-project/circuits.js/src/structs/rollup/root_rollup.ts @@ -2,6 +2,7 @@ import { Fr } from '@aztec/foundation/fields'; import { BufferReader, type Tuple, serializeToBuffer, serializeToFields } from '@aztec/foundation/serialize'; import { type FieldsOf } from '@aztec/foundation/types'; +import { AZTEC_EPOCH_DURATION } from '../../constants.gen.js'; import { AppendOnlyTreeSnapshot } from './append_only_tree_snapshot.js'; import { FeeRecipient } from './block_root_or_block_merge_public_inputs.js'; import { PreviousRollupBlockData } from './previous_rollup_block_data.js'; @@ -94,7 +95,7 @@ export class RootRollupPublicInputs { public endTimestamp: Fr, public endBlockNumber: Fr, public outHash: Fr, - public fees: Tuple, + public fees: Tuple, public vkTreeRoot: Fr, public proverId: Fr, ) {} @@ -141,7 +142,7 @@ export class RootRollupPublicInputs { Fr.fromBuffer(reader), Fr.fromBuffer(reader), Fr.fromBuffer(reader), - reader.readArray(32, FeeRecipient), + reader.readArray(AZTEC_EPOCH_DURATION, FeeRecipient), Fr.fromBuffer(reader), Fr.fromBuffer(reader), ); diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index 537c24c0bcb..24535a46d7d 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -15,6 +15,7 @@ import { import { SchnorrSignature } from '../barretenberg/index.js'; import { ARCHIVE_HEIGHT, + AZTEC_EPOCH_DURATION, AppendOnlyTreeSnapshot, AvmCircuitInputs, AvmContractInstanceHint, @@ -985,7 +986,7 @@ export function makeBlockRootOrBlockMergeRollupPublicInputs( globalVariables ?? makeGlobalVariables(seed + 0x501), globalVariables ?? makeGlobalVariables(seed + 0x502), fr(seed + 0x600), - makeTuple(32, () => makeFeeRecipient(seed), 0x700), + makeTuple(AZTEC_EPOCH_DURATION, () => makeFeeRecipient(seed), 0x700), fr(seed + 0x800), fr(seed + 0x900), ); @@ -1128,7 +1129,7 @@ export function makeRootRollupPublicInputs(seed = 0): RootRollupPublicInputs { fr(seed + 0x600), fr(seed + 0x700), fr(seed + 0x800), - makeTuple(32, () => makeFeeRecipient(seed), 0x900), + makeTuple(AZTEC_EPOCH_DURATION, () => makeFeeRecipient(seed), 0x900), fr(seed + 0x100), fr(seed + 0x200), ); diff --git a/yarn-project/end-to-end/src/spartan/smoke.test.ts b/yarn-project/end-to-end/src/spartan/smoke.test.ts index 867c4ff1688..6a497a1b634 100644 --- a/yarn-project/end-to-end/src/spartan/smoke.test.ts +++ b/yarn-project/end-to-end/src/spartan/smoke.test.ts @@ -1,5 +1,9 @@ import { type PXE, createCompatibleClient } from '@aztec/aztec.js'; import { createDebugLogger } from '@aztec/foundation/log'; +import { RollupAbi } from '@aztec/l1-artifacts'; + +import { createPublicClient, getAddress, getContract, http } from 'viem'; +import { foundry } from 'viem/chains'; const { PXE_URL } = process.env; if (!PXE_URL) { @@ -20,12 +24,12 @@ describe('sample test', () => { expect(info.enr).toMatch(/^enr:-/); }); - /** - * Leaving this test commented out because it requires the ethereum node - * to be running and forwarded, e.g. - * kubectl port-forward -n smoke service/spartan-aztec-network-ethereum 8545:8545 + // Leaving this test skipped commented out because it requires the ethereum node + // to be running and forwarded, e.g. + // kubectl port-forward -n smoke service/spartan-aztec-network-ethereum 8545:8545 + // also because it assumes foundry. - it('should be able to get rollup info', async () => { + it.skip('should be able to get rollup info', async () => { const info = await pxe.getNodeInfo(); const publicClient = createPublicClient({ chain: foundry, @@ -41,12 +45,11 @@ describe('sample test', () => { // eslint-disable-next-line @typescript-eslint/no-unused-vars const [pendingBlockNum, pendingArchive, provenBlockNum, provenArchive, myArchive, provenEpochNumber] = await rollupContract.read.status([60n]); - console.log('pendingBlockNum', pendingBlockNum.toString()); - console.log('pendingArchive', pendingArchive.toString()); - console.log('provenBlockNum', provenBlockNum.toString()); - console.log('provenArchive', provenArchive.toString()); - console.log('myArchive', myArchive.toString()); - console.log('provenEpochNumber', provenEpochNumber.toString()); + // console.log('pendingBlockNum', pendingBlockNum.toString()); + // console.log('pendingArchive', pendingArchive.toString()); + // console.log('provenBlockNum', provenBlockNum.toString()); + // console.log('provenArchive', provenArchive.toString()); + // console.log('myArchive', myArchive.toString()); + // console.log('provenEpochNumber', provenEpochNumber.toString()); }); - */ }); diff --git a/yarn-project/noir-protocol-circuits-types/src/type_conversion.ts b/yarn-project/noir-protocol-circuits-types/src/type_conversion.ts index bf45467ac82..0ef38b37192 100644 --- a/yarn-project/noir-protocol-circuits-types/src/type_conversion.ts +++ b/yarn-project/noir-protocol-circuits-types/src/type_conversion.ts @@ -1,4 +1,5 @@ import { + AZTEC_EPOCH_DURATION, AppendOnlyTreeSnapshot, AztecAddress, BaseOrMergeRollupPublicInputs, @@ -2215,7 +2216,7 @@ export function mapBlockRootOrBlockMergePublicInputsFromNoir( mapGlobalVariablesFromNoir(blockRootOrBlockMergePublicInputs.start_global_variables), mapGlobalVariablesFromNoir(blockRootOrBlockMergePublicInputs.end_global_variables), mapFieldFromNoir(blockRootOrBlockMergePublicInputs.out_hash), - mapTupleFromNoir(blockRootOrBlockMergePublicInputs.fees, 32, mapFeeRecipientFromNoir), + mapTupleFromNoir(blockRootOrBlockMergePublicInputs.fees, AZTEC_EPOCH_DURATION, mapFeeRecipientFromNoir), mapFieldFromNoir(blockRootOrBlockMergePublicInputs.vk_tree_root), mapFieldFromNoir(blockRootOrBlockMergePublicInputs.prover_id), ); @@ -2390,7 +2391,7 @@ export function mapRootRollupPublicInputsFromNoir( mapFieldFromNoir(rootRollupPublicInputs.end_timestamp), mapFieldFromNoir(rootRollupPublicInputs.end_block_number), mapFieldFromNoir(rootRollupPublicInputs.out_hash), - mapTupleFromNoir(rootRollupPublicInputs.fees, 32, mapFeeRecipientFromNoir), + mapTupleFromNoir(rootRollupPublicInputs.fees, AZTEC_EPOCH_DURATION, mapFeeRecipientFromNoir), mapFieldFromNoir(rootRollupPublicInputs.vk_tree_root), mapFieldFromNoir(rootRollupPublicInputs.prover_id), ); diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index c6275bc877b..e79986c70a7 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -9,6 +9,7 @@ import { import { type L1PublishBlockStats, type L1PublishProofStats } from '@aztec/circuit-types/stats'; import { AGGREGATION_OBJECT_LENGTH, + AZTEC_EPOCH_DURATION, ETHEREUM_SLOT_DURATION, EthAddress, type FeeRecipient, @@ -116,7 +117,7 @@ export type L1SubmitEpochProofArgs = { endTimestamp: Fr; outHash: Fr; proverId: Fr; - fees: Tuple; + fees: Tuple; proof: Proof; }; @@ -601,7 +602,7 @@ export class L1Publisher { args.publicInputs.outHash.toString(), args.publicInputs.proverId.toString(), ], - makeTuple(64, i => + makeTuple(AZTEC_EPOCH_DURATION * 2, i => i % 2 === 0 ? args.publicInputs.fees[i / 2].recipient.toField().toString() : args.publicInputs.fees[(i - 1) / 2].value.toString(),