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

feat: removing redundant values from PrivateCircuitPublicInputs #4255

Closed
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
2 changes: 1 addition & 1 deletion l1-contracts/src/core/libraries/ConstantsGen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 0 additions & 5 deletions yarn-project/acir-simulator/src/acvm/deserialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ export function extractPrivateCircuitPublicInputs(
EthAddress.fromField(witnessReader.readField()),
);

const chainId = witnessReader.readField();
const version = witnessReader.readField();

return new PrivateCircuitPublicInputs(
callContext,
argsHash,
Expand All @@ -132,8 +129,6 @@ export function extractPrivateCircuitPublicInputs(
unencryptedLogPreimagesLength,
header,
contractDeploymentData,
chainId,
version,
);
}

Expand Down
3 changes: 0 additions & 3 deletions yarn-project/acir-simulator/src/acvm/serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,6 @@ export function toACVMPublicInputs(publicInputs: PrivateCircuitPublicInputs): AC
...toACVMHeader(publicInputs.historicalHeader),

...toACVMContractDeploymentData(publicInputs.contractDeploymentData),

toACVMField(publicInputs.chainId),
toACVMField(publicInputs.version),
];
}

Expand Down
9 changes: 2 additions & 7 deletions yarn-project/aztec-nr/aztec/src/context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down Expand Up @@ -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,
};
Expand Down
60 changes: 30 additions & 30 deletions yarn-project/circuits.js/src/abis/__snapshots__/abis.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down
2 changes: 0 additions & 2 deletions yarn-project/circuits.js/src/abis/abis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/circuits.js/src/constants.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions yarn-project/circuits.js/src/structs/global_variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {}

/**
Expand Down Expand Up @@ -146,8 +137,6 @@ export class PrivateCircuitPublicInputs {
reader.readObject(Fr),
reader.readObject(Header),
reader.readObject(ContractDeploymentData),
reader.readObject(Fr),
reader.readObject(Fr),
);
}

Expand All @@ -174,8 +163,6 @@ export class PrivateCircuitPublicInputs {
Fr.ZERO,
Header.empty(),
ContractDeploymentData.empty(),
Fr.ZERO,
Fr.ZERO,
);
}

Expand All @@ -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()
);
}

Expand Down Expand Up @@ -230,8 +215,6 @@ export class PrivateCircuitPublicInputs {
fields.unencryptedLogPreimagesLength,
fields.historicalHeader,
fields.contractDeploymentData,
fields.chainId,
fields.version,
] as const;
}
/**
Expand Down
2 changes: 0 additions & 2 deletions yarn-project/circuits.js/src/tests/factories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
});
}

Expand Down
5 changes: 2 additions & 3 deletions yarn-project/end-to-end/src/integration_l1_publisher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.historical_header.global_variables.version,
portal_contract_address,
private_call_public_inputs.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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -88,8 +84,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");

Expand Down Expand Up @@ -123,8 +117,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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ struct PrivateCircuitPublicInputsBuilder {
historical_header: Header,

contract_deployment_data: ContractDeploymentData,

chain_id: Field,
version: Field,
}

impl PrivateCircuitPublicInputsBuilder {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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,
}
}
}
2 changes: 0 additions & 2 deletions yarn-project/noir-protocol-circuits/src/type_conversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions yarn-project/sequencer-client/src/sequencer/processed_tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ProcessedTx> {
export function makeEmptyProcessedTx(header: Header): Promise<ProcessedTx> {
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ describe('public_processor', () => {
publicExecutor,
publicKernel,
publicProver,
GlobalVariables.empty(),
Header.empty(),
publicContractsDB,
publicWorldStateDB,
Expand Down Expand Up @@ -138,7 +137,6 @@ describe('public_processor', () => {
publicExecutor,
publicKernel,
publicProver,
GlobalVariables.empty(),
Header.empty(),
publicContractsDB,
publicWorldStateDB,
Expand Down
Loading
Loading