From b578604d4a251189d2fd72b6a58b5ddaa197965e Mon Sep 17 00:00:00 2001 From: benesjan Date: Mon, 29 Jan 2024 14:12:59 +0000 Subject: [PATCH 1/2] feat: removing redundant values from PrivateCircuitPublicInputs --- .../src/core/libraries/ConstantsGen.sol | 2 +- .../acir-simulator/src/acvm/deserialize.ts | 5 -- .../acir-simulator/src/acvm/serialize.ts | 3 - yarn-project/aztec-nr/aztec/src/context.nr | 9 +-- .../src/abis/__snapshots__/abis.test.ts.snap | 60 +++++++++---------- yarn-project/circuits.js/src/abis/abis.ts | 2 - yarn-project/circuits.js/src/constants.gen.ts | 2 +- .../src/structs/global_variables.ts | 9 +++ .../structs/private_circuit_public_inputs.ts | 19 +----- .../circuits.js/src/tests/factories.ts | 2 - .../src/integration_l1_publisher.test.ts | 5 +- .../crates/private-kernel-lib/src/common.nr | 4 +- .../src/abis/private_circuit_public_inputs.nr | 4 -- .../src/crates/types/src/constants.nr | 2 +- .../private_circuit_public_inputs_builder.nr | 8 --- .../src/type_conversion.ts | 2 - .../block_builder/solo_block_builder.test.ts | 2 +- .../src/sequencer/processed_tx.ts | 5 +- .../src/sequencer/public_processor.test.ts | 2 - .../src/sequencer/public_processor.ts | 16 ++--- .../src/sequencer/sequencer.test.ts | 7 ++- .../sequencer-client/src/sequencer/utils.ts | 5 +- 22 files changed, 69 insertions(+), 106 deletions(-) diff --git a/l1-contracts/src/core/libraries/ConstantsGen.sol b/l1-contracts/src/core/libraries/ConstantsGen.sol index 6bf33898baa..e306bb7dda3 100644 --- a/l1-contracts/src/core/libraries/ConstantsGen.sol +++ b/l1-contracts/src/core/libraries/ConstantsGen.sol @@ -80,7 +80,7 @@ library Constants { uint256 internal constant GET_NOTES_ORACLE_RETURN_LENGTH = 674; uint256 internal constant CALL_PRIVATE_FUNCTION_RETURN_SIZE = 210; uint256 internal constant PUBLIC_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = 98; - uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = 188; + uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = 186; uint256 internal constant COMMITMENTS_NUM_BYTES_PER_BASE_ROLLUP = 2048; uint256 internal constant NULLIFIERS_NUM_BYTES_PER_BASE_ROLLUP = 2048; uint256 internal constant PUBLIC_DATA_WRITES_NUM_BYTES_PER_BASE_ROLLUP = 1024; diff --git a/yarn-project/acir-simulator/src/acvm/deserialize.ts b/yarn-project/acir-simulator/src/acvm/deserialize.ts index a49f060e2e7..36288a1d6af 100644 --- a/yarn-project/acir-simulator/src/acvm/deserialize.ts +++ b/yarn-project/acir-simulator/src/acvm/deserialize.ts @@ -111,9 +111,6 @@ export function extractPrivateCircuitPublicInputs( EthAddress.fromField(witnessReader.readField()), ); - const chainId = witnessReader.readField(); - const version = witnessReader.readField(); - return new PrivateCircuitPublicInputs( callContext, argsHash, @@ -132,8 +129,6 @@ export function extractPrivateCircuitPublicInputs( unencryptedLogPreimagesLength, header, contractDeploymentData, - chainId, - version, ); } diff --git a/yarn-project/acir-simulator/src/acvm/serialize.ts b/yarn-project/acir-simulator/src/acvm/serialize.ts index f0ae6d1e284..aec27d42b73 100644 --- a/yarn-project/acir-simulator/src/acvm/serialize.ts +++ b/yarn-project/acir-simulator/src/acvm/serialize.ts @@ -152,9 +152,6 @@ export function toACVMPublicInputs(publicInputs: PrivateCircuitPublicInputs): AC ...toACVMHeader(publicInputs.historicalHeader), ...toACVMContractDeploymentData(publicInputs.contractDeploymentData), - - toACVMField(publicInputs.chainId), - toACVMField(publicInputs.version), ]; } diff --git a/yarn-project/aztec-nr/aztec/src/context.nr b/yarn-project/aztec-nr/aztec/src/context.nr index 9b3790a02a0..2f0b90952bf 100644 --- a/yarn-project/aztec-nr/aztec/src/context.nr +++ b/yarn-project/aztec-nr/aztec/src/context.nr @@ -159,7 +159,7 @@ impl PrivateContext { let encrypted_log_preimages_length = 0; let unencrypted_log_preimages_length = 0; - let priv_circuit_pub_inputs = PrivateCircuitPublicInputs { + PrivateCircuitPublicInputs { call_context: self.inputs.call_context, args_hash: self.args_hash, return_values: self.return_values.storage, @@ -177,10 +177,7 @@ impl PrivateContext { unencrypted_log_preimages_length: unencrypted_log_preimages_length, historical_header: self.historical_header, contract_deployment_data: self.inputs.contract_deployment_data, - chain_id: self.inputs.private_global_variables.chain_id, - version: self.inputs.private_global_variables.version, - }; - priv_circuit_pub_inputs + } } pub fn push_read_request(&mut self, read_request: Field) { @@ -350,8 +347,6 @@ impl PrivateContext { contract_address_salt : reader.read(), portal_contract_address : EthAddress::from_field(reader.read()), }, - chain_id: reader.read(), - version: reader.read(), }, is_execution_request: reader.read() as bool, }; diff --git a/yarn-project/circuits.js/src/abis/__snapshots__/abis.test.ts.snap b/yarn-project/circuits.js/src/abis/__snapshots__/abis.test.ts.snap index 68c1e02ab78..db9d3296c8c 100644 --- a/yarn-project/circuits.js/src/abis/__snapshots__/abis.test.ts.snap +++ b/yarn-project/circuits.js/src/abis/__snapshots__/abis.test.ts.snap @@ -55,41 +55,41 @@ Fr { exports[`abis compute private call stack item hash 1`] = ` Fr { - "asBigInt": 12187345511405217717040217531423286257305914329376428594135414078733109256018n, + "asBigInt": 3614117677866200196295775647283645866034430866159465163124756284278864628372n, "asBuffer": { "data": [ - 26, - 241, - 203, - 9, - 80, - 135, - 163, - 233, - 54, - 161, - 69, - 247, - 77, - 223, - 148, - 99, - 177, 7, - 65, + 253, 132, - 142, - 175, - 255, - 49, - 18, - 190, - 219, + 163, + 51, 83, - 245, - 1, - 95, - 82, + 155, + 154, + 228, + 18, + 207, + 110, + 93, + 174, + 199, + 175, + 193, + 169, + 85, + 175, + 9, + 250, + 126, + 101, + 186, + 177, + 176, + 91, + 76, + 64, + 74, + 148, ], "type": "Buffer", }, diff --git a/yarn-project/circuits.js/src/abis/abis.ts b/yarn-project/circuits.js/src/abis/abis.ts index bcf7d01e3db..3327978da74 100644 --- a/yarn-project/circuits.js/src/abis/abis.ts +++ b/yarn-project/circuits.js/src/abis/abis.ts @@ -537,8 +537,6 @@ function computePrivateInputsHash(input: PrivateCircuitPublicInputs) { input.unencryptedLogPreimagesLength.toBuffer(), ...(input.historicalHeader.toFieldArray().map(fr => fr.toBuffer()) as Buffer[]), computeContractDeploymentDataHash(input.contractDeploymentData).toBuffer(), - input.chainId.toBuffer(), - input.version.toBuffer(), ]; if (toHash.length != PRIVATE_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH) { throw new Error( diff --git a/yarn-project/circuits.js/src/constants.gen.ts b/yarn-project/circuits.js/src/constants.gen.ts index 6d2571f17ec..29e90d8a329 100644 --- a/yarn-project/circuits.js/src/constants.gen.ts +++ b/yarn-project/circuits.js/src/constants.gen.ts @@ -66,7 +66,7 @@ export const PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = 190; export const GET_NOTES_ORACLE_RETURN_LENGTH = 674; export const CALL_PRIVATE_FUNCTION_RETURN_SIZE = 210; export const PUBLIC_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = 98; -export const PRIVATE_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = 188; +export const PRIVATE_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = 186; export const COMMITMENTS_NUM_BYTES_PER_BASE_ROLLUP = 2048; export const NULLIFIERS_NUM_BYTES_PER_BASE_ROLLUP = 2048; export const PUBLIC_DATA_WRITES_NUM_BYTES_PER_BASE_ROLLUP = 1024; diff --git a/yarn-project/circuits.js/src/structs/global_variables.ts b/yarn-project/circuits.js/src/structs/global_variables.ts index fd353693a10..3cc3e134bdf 100644 --- a/yarn-project/circuits.js/src/structs/global_variables.ts +++ b/yarn-project/circuits.js/src/structs/global_variables.ts @@ -77,4 +77,13 @@ export class GlobalVariables { isEmpty(): boolean { return this.chainId.isZero() && this.version.isZero() && this.blockNumber.isZero() && this.timestamp.isZero(); } + + equals(other: GlobalVariables): boolean { + return ( + this.chainId.equals(other.chainId) && + this.version.equals(other.version) && + this.blockNumber.equals(other.blockNumber) && + this.timestamp.equals(other.timestamp) + ); + } } diff --git a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts index e16a2e4a68e..2e149531f7c 100644 --- a/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts +++ b/yarn-project/circuits.js/src/structs/private_circuit_public_inputs.ts @@ -101,15 +101,6 @@ export class PrivateCircuitPublicInputs { * Deployment data of contracts being deployed in this kernel iteration. */ public contractDeploymentData: ContractDeploymentData, - // TODO(#4256): Nuke the following 2 values --> they are in header now. - /** - * Chain Id of the instance. - */ - public chainId: Fr, - /** - * Version of the instance. - */ - public version: Fr, ) {} /** @@ -146,8 +137,6 @@ export class PrivateCircuitPublicInputs { reader.readObject(Fr), reader.readObject(Header), reader.readObject(ContractDeploymentData), - reader.readObject(Fr), - reader.readObject(Fr), ); } @@ -174,8 +163,6 @@ export class PrivateCircuitPublicInputs { Fr.ZERO, Header.empty(), ContractDeploymentData.empty(), - Fr.ZERO, - Fr.ZERO, ); } @@ -200,9 +187,7 @@ export class PrivateCircuitPublicInputs { this.encryptedLogPreimagesLength.isZero() && this.unencryptedLogPreimagesLength.isZero() && this.historicalHeader.isEmpty() && - this.contractDeploymentData.isEmpty() && - this.chainId.isZero() && - this.version.isZero() + this.contractDeploymentData.isEmpty() ); } @@ -230,8 +215,6 @@ export class PrivateCircuitPublicInputs { fields.unencryptedLogPreimagesLength, fields.historicalHeader, fields.contractDeploymentData, - fields.chainId, - fields.version, ] as const; } /** diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index 3770d632b8d..4e062aa7ac7 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -728,8 +728,6 @@ export function makePrivateCircuitPublicInputs(seed = 0): PrivateCircuitPublicIn unencryptedLogPreimagesLength: fr(seed + 0xc00), historicalHeader: makeHeader(seed + 0xd00, undefined), contractDeploymentData: makeContractDeploymentData(seed + 0xe00), - chainId: fr(seed + 0x1400), - version: fr(seed + 0x1500), }); } diff --git a/yarn-project/end-to-end/src/integration_l1_publisher.test.ts b/yarn-project/end-to-end/src/integration_l1_publisher.test.ts index 1812355b76c..169731a4719 100644 --- a/yarn-project/end-to-end/src/integration_l1_publisher.test.ts +++ b/yarn-project/end-to-end/src/integration_l1_publisher.test.ts @@ -153,9 +153,8 @@ describe('L1Publisher integration', () => { prevHeader = await buildInitialHeader(builderDb); }, 100_000); - const makeEmptyProcessedTx = async () => { - const tx = await makeEmptyProcessedTxFromHistoricalTreeRoots(prevHeader, new Fr(chainId), new Fr(config.version)); - return tx; + const makeEmptyProcessedTx = () => { + return makeEmptyProcessedTxFromHistoricalTreeRoots(prevHeader); }; const makeBloatedProcessedTx = async (seed = 0x1) => { diff --git a/yarn-project/noir-protocol-circuits/src/crates/private-kernel-lib/src/common.nr b/yarn-project/noir-protocol-circuits/src/crates/private-kernel-lib/src/common.nr index 3be4b547363..1db58fa075f 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/private-kernel-lib/src/common.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/private-kernel-lib/src/common.nr @@ -270,9 +270,9 @@ pub fn update_end_values(private_call: PrivateCallData, public_inputs: &mut Kern if msg_is_zero == false { let new_l2_to_l1_msgs = compute_l2_to_l1_hash( storage_contract_address, - private_call_public_inputs.version, + private_call_public_inputs.header.global_variables.version, portal_contract_address, - private_call_public_inputs.chain_id, + private_call_public_inputs.header.global_variables.chain_id, new_l2_to_l1_msgs[i] ); new_l2_to_l1_msgs_to_insert.push(new_l2_to_l1_msgs) diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/private_circuit_public_inputs.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/private_circuit_public_inputs.nr index 6439a66da6e..662a724ee91 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/private_circuit_public_inputs.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/private_circuit_public_inputs.nr @@ -88,8 +88,6 @@ impl Hash for PrivateCircuitPublicInputs { fields.push(self.unencrypted_log_preimages_length); fields.push_array(self.historical_header.serialize()); fields.push(self.contract_deployment_data.hash()); - fields.push(self.chain_id); - fields.push(self.version); assert_eq(fields.len(), PRIVATE_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH, "Incorrect number of input fields when hashing PrivateCircuitPublicInputs"); @@ -123,8 +121,6 @@ impl PrivateCircuitPublicInputs { fields.push(self.unencrypted_log_preimages_length); fields.push_array(self.historical_header.serialize()); fields.push_array(self.contract_deployment_data.serialize()); - fields.push(self.chain_id); - fields.push(self.version); assert_eq(fields.len(), PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH); diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/constants.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/constants.nr index 8a65c1d284c..8bb1cdf963e 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/types/src/constants.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/constants.nr @@ -112,7 +112,7 @@ global PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH: Field = 190; global GET_NOTES_ORACLE_RETURN_LENGTH: Field = 674; global CALL_PRIVATE_FUNCTION_RETURN_SIZE: Field = 210; global PUBLIC_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH: Field = 98; -global PRIVATE_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH: Field = 188; +global PRIVATE_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH: Field = 186; global COMMITMENTS_NUM_BYTES_PER_BASE_ROLLUP: Field = 2048; global NULLIFIERS_NUM_BYTES_PER_BASE_ROLLUP: Field = 2048; global PUBLIC_DATA_WRITES_NUM_BYTES_PER_BASE_ROLLUP: Field = 1024; diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/tests/private_circuit_public_inputs_builder.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/tests/private_circuit_public_inputs_builder.nr index 5617dcd970b..f59413aacca 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/types/src/tests/private_circuit_public_inputs_builder.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/tests/private_circuit_public_inputs_builder.nr @@ -52,9 +52,6 @@ struct PrivateCircuitPublicInputsBuilder { historical_header: Header, contract_deployment_data: ContractDeploymentData, - - chain_id: Field, - version: Field, } impl PrivateCircuitPublicInputsBuilder { @@ -102,8 +99,6 @@ impl PrivateCircuitPublicInputsBuilder { public_inputs.args_hash = args_hash; public_inputs.contract_deployment_data = contract_deployment_data; public_inputs.historical_header = fixtures::HEADER; - public_inputs.chain_id = 0; - public_inputs.version = 1; public_inputs } @@ -134,9 +129,6 @@ impl PrivateCircuitPublicInputsBuilder { historical_header: self.historical_header, contract_deployment_data: self.contract_deployment_data, - - chain_id: self.chain_id, - version: self.version, } } } diff --git a/yarn-project/noir-protocol-circuits/src/type_conversion.ts b/yarn-project/noir-protocol-circuits/src/type_conversion.ts index 4a493ff4d75..18c139582f1 100644 --- a/yarn-project/noir-protocol-circuits/src/type_conversion.ts +++ b/yarn-project/noir-protocol-circuits/src/type_conversion.ts @@ -621,8 +621,6 @@ export function mapPrivateCircuitPublicInputsToNoir( unencrypted_log_preimages_length: mapFieldToNoir(privateCircuitPublicInputs.unencryptedLogPreimagesLength), historical_header: mapHeaderToNoir(privateCircuitPublicInputs.historicalHeader), contract_deployment_data: mapContractDeploymentDataToNoir(privateCircuitPublicInputs.contractDeploymentData), - chain_id: mapFieldToNoir(privateCircuitPublicInputs.chainId), - version: mapFieldToNoir(privateCircuitPublicInputs.version), }; } diff --git a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts index 27f6e78a20b..f74bd3b2c9f 100644 --- a/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts +++ b/yarn-project/sequencer-client/src/block_builder/solo_block_builder.test.ts @@ -123,7 +123,7 @@ describe('sequencer/solo_block_builder', () => { const makeEmptyProcessedTx = async () => { const header = await buildInitialHeader(builderDb); - return makeEmptyProcessedTxFromHistoricalTreeRoots(header, chainId, version); + return makeEmptyProcessedTxFromHistoricalTreeRoots(header); }; // Updates the expectedDb trees based on the new commitments, contracts, and nullifiers from these txs diff --git a/yarn-project/sequencer-client/src/sequencer/processed_tx.ts b/yarn-project/sequencer-client/src/sequencer/processed_tx.ts index a78dd261c95..7c6ce6a5030 100644 --- a/yarn-project/sequencer-client/src/sequencer/processed_tx.ts +++ b/yarn-project/sequencer-client/src/sequencer/processed_tx.ts @@ -87,12 +87,9 @@ export async function makeProcessedTx( * Makes an empty tx from an empty kernel circuit public inputs. * @returns A processed empty tx. */ -export function makeEmptyProcessedTx(header: Header, chainId: Fr, version: Fr): Promise { +export function makeEmptyProcessedTx(header: Header): Promise { const emptyKernelOutput = PublicKernelPublicInputs.empty(); emptyKernelOutput.constants.header = header; - // TODO(#4256): The following two fields are most likely redundant now and should be removed. - emptyKernelOutput.constants.txContext.chainId = chainId; - emptyKernelOutput.constants.txContext.version = version; const emptyProof = makeEmptyProof(); const hash = new TxHash(Fr.ZERO.toBuffer()); diff --git a/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts b/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts index 5bb68a03ec3..889dc18ed4a 100644 --- a/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts +++ b/yarn-project/sequencer-client/src/sequencer/public_processor.test.ts @@ -83,7 +83,6 @@ describe('public_processor', () => { publicExecutor, publicKernel, publicProver, - GlobalVariables.empty(), Header.empty(), publicContractsDB, publicWorldStateDB, @@ -138,7 +137,6 @@ describe('public_processor', () => { publicExecutor, publicKernel, publicProver, - GlobalVariables.empty(), Header.empty(), publicContractsDB, publicWorldStateDB, diff --git a/yarn-project/sequencer-client/src/sequencer/public_processor.ts b/yarn-project/sequencer-client/src/sequencer/public_processor.ts index 3fcd01cf4dc..81674c16563 100644 --- a/yarn-project/sequencer-client/src/sequencer/public_processor.ts +++ b/yarn-project/sequencer-client/src/sequencer/public_processor.ts @@ -72,11 +72,16 @@ export class PublicProcessorFactory { * Creates a new instance of a PublicProcessor. * @param prevHeader - The header of the previous block. * @param globalVariables - The global variables for the block being processed. - * @param newContracts - Provides access to contract bytecode for public executions. * @returns A new instance of a PublicProcessor. */ public async create(prevHeader: Header | undefined, globalVariables: GlobalVariables): Promise { - prevHeader = prevHeader ?? (await buildInitialHeader(this.merkleTree)); + prevHeader = prevHeader ?? (await buildInitialHeader(this.merkleTree, globalVariables)); + + if (prevHeader && !prevHeader.globalVariables.equals(globalVariables)) { + throw new Error( + `Global variables mismatch: expected ${prevHeader.globalVariables.toString()}, got ${globalVariables.toString()}`, + ); + } const publicContractsDB = new ContractsDataSourcePublicDB(this.contractDataSource); const worldStatePublicDB = new WorldStatePublicDB(this.merkleTree); @@ -87,7 +92,6 @@ export class PublicProcessorFactory { publicExecutor, new RealPublicKernelCircuitSimulator(), new EmptyPublicProver(), - globalVariables, prevHeader, publicContractsDB, worldStatePublicDB, @@ -105,7 +109,6 @@ export class PublicProcessor { protected publicExecutor: PublicExecutor, protected publicKernel: PublicKernelCircuitSimulator, protected publicProver: PublicProver, - protected globalVariables: GlobalVariables, protected header: Header, protected publicContractsDB: ContractsDataSourcePublicDB, protected publicStateDB: PublicStateDB, @@ -153,8 +156,7 @@ export class PublicProcessor { * @returns A processed tx with empty data. */ public makeEmptyProcessedTx(): Promise { - const { chainId, version } = this.globalVariables; - return makeEmptyProcessedTx(this.header, chainId, version); + return makeEmptyProcessedTx(this.header); } protected async processTx(tx: Tx): Promise { @@ -210,7 +212,7 @@ export class PublicProcessor { while (executionStack.length) { const current = executionStack.pop()!; const isExecutionRequest = !isPublicExecutionResult(current); - const result = isExecutionRequest ? await this.publicExecutor.simulate(current, this.globalVariables) : current; + const result = isExecutionRequest ? await this.publicExecutor.simulate(current, this.header.globalVariables) : current; newUnencryptedFunctionLogs.push(result.unencryptedLogs); const functionSelector = result.execution.functionData.selector.toString(); this.log( diff --git a/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts b/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts index f3d94763f0e..8065a10bcf6 100644 --- a/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts +++ b/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts @@ -60,7 +60,12 @@ describe('sequencer', () => { publicProcessor = mock({ process: async txs => [await Promise.all(txs.map(tx => makeProcessedTx(tx))), []], - makeEmptyProcessedTx: () => makeEmptyProcessedTx(Header.empty(), chainId, version), + makeEmptyProcessedTx: () => { + const header = Header.empty(); + header.globalVariables.chainId = chainId; + + return makeEmptyProcessedTx(header); + } }); publicProcessorFactory = mock({ diff --git a/yarn-project/sequencer-client/src/sequencer/utils.ts b/yarn-project/sequencer-client/src/sequencer/utils.ts index eebff558fea..84d0255ba31 100644 --- a/yarn-project/sequencer-client/src/sequencer/utils.ts +++ b/yarn-project/sequencer-client/src/sequencer/utils.ts @@ -6,7 +6,8 @@ import { MerkleTreeOperations } from '@aztec/world-state'; * * TODO(#4148) Proper genesis state. If the state is empty, we allow anything for now. */ -export async function buildInitialHeader(db: MerkleTreeOperations) { +export async function buildInitialHeader(db: MerkleTreeOperations, globalVariables: GlobalVariables | undefined = undefined) { const state = await db.getStateReference(); - return new Header(AppendOnlyTreeSnapshot.empty(), Buffer.alloc(32, 0), state, GlobalVariables.empty()); + globalVariables = globalVariables ?? GlobalVariables.empty(); + return new Header(AppendOnlyTreeSnapshot.empty(), Buffer.alloc(32, 0), state, globalVariables); } From 64b4488b8ceec85eae181fddf27a6dbfc2f65fa3 Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 30 Jan 2024 09:03:55 +0000 Subject: [PATCH 2/2] fixes after rebase --- .../src/crates/private-kernel-lib/src/common.nr | 4 ++-- .../crates/types/src/abis/private_circuit_public_inputs.nr | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/yarn-project/noir-protocol-circuits/src/crates/private-kernel-lib/src/common.nr b/yarn-project/noir-protocol-circuits/src/crates/private-kernel-lib/src/common.nr index 1db58fa075f..d2a41dddd01 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/private-kernel-lib/src/common.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/private-kernel-lib/src/common.nr @@ -270,9 +270,9 @@ pub fn update_end_values(private_call: PrivateCallData, public_inputs: &mut Kern if msg_is_zero == false { let new_l2_to_l1_msgs = compute_l2_to_l1_hash( storage_contract_address, - private_call_public_inputs.header.global_variables.version, + private_call_public_inputs.historical_header.global_variables.version, portal_contract_address, - private_call_public_inputs.header.global_variables.chain_id, + private_call_public_inputs.historical_header.global_variables.chain_id, new_l2_to_l1_msgs[i] ); new_l2_to_l1_msgs_to_insert.push(new_l2_to_l1_msgs) diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/private_circuit_public_inputs.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/private_circuit_public_inputs.nr index 662a724ee91..049ed7449f4 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/private_circuit_public_inputs.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/abis/private_circuit_public_inputs.nr @@ -55,10 +55,6 @@ struct PrivateCircuitPublicInputs { historical_header: Header, contract_deployment_data: ContractDeploymentData, - - // TODO(#4256): This is now in header. Nuke this. - chain_id: Field, - version: Field, } impl Hash for PrivateCircuitPublicInputs {