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

refactor(blocks tree): remove historic roots trees #1355

Merged
merged 72 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
8553fa0
feat: add blocks tree data to l2 block
Maddiaa0 Jul 25, 2023
4580093
feat: use constants to represent offsets
Maddiaa0 Jul 25, 2023
1991a57
chore: forge fmt
Maddiaa0 Jul 25, 2023
e0808b8
fix: linter
Maddiaa0 Jul 25, 2023
98692dd
fix: stub circuit output for the meantime
Maddiaa0 Jul 26, 2023
2942f95
feat: add naive block hash calculations to root rollup circuit
Maddiaa0 Jul 26, 2023
e8f9fbc
Merge branch 'master' into md/blocks-tree-circuits
Maddiaa0 Jul 27, 2023
376e71a
temp
Maddiaa0 Jul 27, 2023
9403830
Merge branch 'master' into md/blocks-tree-circuits
Maddiaa0 Jul 31, 2023
7520217
fix: update snapshot
Maddiaa0 Jul 31, 2023
3c9422c
feat: include block hash calcs in sequencer
Maddiaa0 Jul 31, 2023
de68edd
fix: make calculate block hash a cbind
Maddiaa0 Jul 31, 2023
520b9a6
Merge branch 'master' into md/blocks-tree-circuits
Maddiaa0 Jul 31, 2023
55fbd5f
feat: add block tree checking in ts
Maddiaa0 Aug 1, 2023
f1d9fc7
clean
Maddiaa0 Aug 1, 2023
3ae5a4d
lint
Maddiaa0 Aug 1, 2023
011a150
review comments
Maddiaa0 Aug 1, 2023
830721f
Merge branch 'master' into md/blocks-tree-circuits
Maddiaa0 Aug 1, 2023
035c41f
fix: include generator indices
Maddiaa0 Aug 1, 2023
5340a79
lint
Maddiaa0 Aug 1, 2023
d9bda7b
update snapshot
Maddiaa0 Aug 1, 2023
455058a
fix: remove references to block num in factories
Maddiaa0 Aug 2, 2023
515bb60
Merge branch 'master' into md/blocks-tree-circuits
Maddiaa0 Aug 2, 2023
03cc42e
feat: read trees against historic block root
Maddiaa0 Aug 1, 2023
3670fac
feat: remove other checks from the base rollup
Maddiaa0 Aug 1, 2023
e0129f8
feat: update ts and snapshot
Maddiaa0 Aug 1, 2023
acd2413
feat: remove old tree checks in base rollup
Maddiaa0 Aug 1, 2023
2bc675f
fix
Maddiaa0 Aug 2, 2023
1b8be8c
fix: get previous globals in transactions
Maddiaa0 Aug 2, 2023
c464ec2
feat: remove old historic trees from the smart contract
Maddiaa0 Aug 2, 2023
1357179
fix: update decoder test
Maddiaa0 Aug 2, 2023
2167ae9
fix: lint
Maddiaa0 Aug 2, 2023
727fec6
Merge branch 'master' into md/blocks-tree-use-blocks-tree
Maddiaa0 Aug 2, 2023
9ee98d5
feat: I have become death, destroyer of worlds
Maddiaa0 Aug 2, 2023
2885d55
i have become lint, hater of self
Maddiaa0 Aug 2, 2023
ce67250
ive only gone n done it again
Maddiaa0 Aug 2, 2023
0195792
fix: update snappyshootys
Maddiaa0 Aug 2, 2023
3a268e2
Merge branch 'master' into md/blocks-tree-use-blocks-tree
Maddiaa0 Aug 2, 2023
9f66593
tune
Maddiaa0 Aug 3, 2023
468bac0
clean: fix cbind naming, remove unused constants
Maddiaa0 Aug 3, 2023
99adca0
Merge branch 'master' into md/blocks-tree-use-blocks-tree
Maddiaa0 Aug 3, 2023
77ec737
post merge constants gen
Maddiaa0 Aug 3, 2023
e769526
fix: cleanup pass 1
Maddiaa0 Aug 4, 2023
acf17be
refactor: historic roots -> block hash data
Maddiaa0 Aug 4, 2023
f072420
refactor: update snapshots
Maddiaa0 Aug 4, 2023
956bfdd
refactor: trees
Maddiaa0 Aug 4, 2023
96ba6de
refactor: block hash data
Maddiaa0 Aug 4, 2023
4f124e3
hmmm, lint so good... gang gang, hmmm, lint so good
Maddiaa0 Aug 4, 2023
8edb2d9
Merge branch 'master' into md/blocks-tree-use-blocks-tree
Maddiaa0 Aug 4, 2023
85b6b01
minor fix
Maddiaa0 Aug 4, 2023
751d6df
we snapshot, we are a good boy mama
Maddiaa0 Aug 4, 2023
ce5a6be
lint so good, hmmm, lint so gooood
Maddiaa0 Aug 4, 2023
b3fcccc
refactor: processor && fix public tests
Maddiaa0 Aug 4, 2023
f065629
fix: serialise
Maddiaa0 Aug 4, 2023
8034c95
fix: missed test updates
Maddiaa0 Aug 7, 2023
f8ce11e
fix: reinstate circuits test
Maddiaa0 Aug 7, 2023
50ff634
Merge branch 'master' into md/blocks-tree-use-blocks-tree
Maddiaa0 Aug 7, 2023
cb3f80c
fix: recompile aztec js account contracts
Maddiaa0 Aug 7, 2023
a681273
refactor: rename historic block hash data and remove nested private t…
Maddiaa0 Aug 7, 2023
ae967ae
refactor: rename in ts
Maddiaa0 Aug 7, 2023
4a0f15a
cleanup
Maddiaa0 Aug 7, 2023
862a553
Merge branch 'master' into md/blocks-tree-use-blocks-tree
Maddiaa0 Aug 7, 2023
c0c5526
chore: update snapshot
Maddiaa0 Aug 7, 2023
1f102a5
minor rename
Maddiaa0 Aug 8, 2023
02d4e85
review fixes
Maddiaa0 Aug 8, 2023
8468b2e
Merge branch 'master' into md/blocks-tree-use-blocks-tree
Maddiaa0 Aug 8, 2023
deefe17
fmt
Maddiaa0 Aug 8, 2023
9210bf9
chore(fmt): formatting 2; electric boogaloo
Maddiaa0 Aug 8, 2023
5882121
Merge branch 'master' into md/blocks-tree-use-blocks-tree
Maddiaa0 Aug 8, 2023
2cfa1eb
fix: final review comments
Maddiaa0 Aug 9, 2023
f4f22e3
Merge branch 'master' into md/blocks-tree-use-blocks-tree
Maddiaa0 Aug 9, 2023
81dd1f3
merge fix
Maddiaa0 Aug 9, 2023
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 circuits/cpp/src/aztec3/circuits/abis/packers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct ConstantsPacker {
MAX_NOTES_PER_PAGE,
VIEW_NOTE_ORACLE_RETURN_LENGTH,
CALL_CONTEXT_LENGTH,
BLOCK_HASH_DATA_LENGTH,
BLOCK_DATA_LENGTH,
FUNCTION_DATA_LENGTH,
CONTRACT_DEPLOYMENT_DATA_LENGTH,
PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH,
Expand Down
8 changes: 4 additions & 4 deletions circuits/cpp/src/aztec3/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ constexpr size_t MAX_NOTES_PER_PAGE = 10;
constexpr size_t VIEW_NOTE_ORACLE_RETURN_LENGTH = MAX_NOTES_PER_PAGE * (MAX_NOTE_FIELDS_LENGTH + 1) + 2;

constexpr size_t CALL_CONTEXT_LENGTH = 6;
constexpr size_t BLOCK_HASH_DATA_LENGTH = 7;
constexpr size_t BLOCK_DATA_LENGTH = 7;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you write a comment here so that if people add any more trees to the block tree, they can easily find this and remember to update it?

constexpr size_t FUNCTION_DATA_LENGTH = 4;
constexpr size_t CONTRACT_DEPLOYMENT_DATA_LENGTH = 6;

Expand All @@ -232,14 +232,14 @@ constexpr size_t PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH =
+ RETURN_VALUES_LENGTH + MAX_READ_REQUESTS_PER_CALL + MAX_NEW_COMMITMENTS_PER_CALL +
2 * MAX_NEW_NULLIFIERS_PER_CALL + MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL +
MAX_NEW_L2_TO_L1_MSGS_PER_CALL + NUM_FIELDS_PER_SHA256 + NUM_FIELDS_PER_SHA256 + 2 // + 2 for logs preimage lengths
+ BLOCK_HASH_DATA_LENGTH + CONTRACT_DEPLOYMENT_DATA_LENGTH + 2; // + 2 for chain_id and version
+ BLOCK_DATA_LENGTH + CONTRACT_DEPLOYMENT_DATA_LENGTH + 2; // + 2 for chain_id and version

constexpr size_t PRIVATE_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH =
1 + 1 // call_context_hash + args_hash
+ RETURN_VALUES_LENGTH + MAX_READ_REQUESTS_PER_CALL + MAX_NEW_COMMITMENTS_PER_CALL +
2 * MAX_NEW_NULLIFIERS_PER_CALL + MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL +
MAX_NEW_L2_TO_L1_MSGS_PER_CALL + NUM_FIELDS_PER_SHA256 + NUM_FIELDS_PER_SHA256 + 2 // + 2 for logs preimage lengths
+ BLOCK_HASH_DATA_LENGTH + 3; // + 3 for contract_deployment_data.hash(), chain_id, version
+ BLOCK_DATA_LENGTH + 3; // + 3 for contract_deployment_data.hash(), chain_id, version

constexpr size_t CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH = 3;
constexpr size_t CONTRACT_STORAGE_READ_LENGTH = 2;
Expand All @@ -251,7 +251,7 @@ constexpr size_t PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH =
MAX_PUBLIC_DATA_READS_PER_CALL * CONTRACT_STORAGE_READ_LENGTH + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL +
MAX_NEW_COMMITMENTS_PER_CALL + MAX_NEW_NULLIFIERS_PER_CALL + MAX_NEW_L2_TO_L1_MSGS_PER_CALL +
NUM_FIELDS_PER_SHA256 + 1 + // + 1 for unencrypted logs preimage length
BLOCK_HASH_DATA_LENGTH + 2; // + 2 for chain_id and version
BLOCK_DATA_LENGTH + 2; // + 2 for chain_id and version

constexpr size_t PUBLIC_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH =
2 + RETURN_VALUES_LENGTH + // + 1 for args_hash + 1 call_context.hash
Expand Down
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 @@ -65,7 +65,7 @@ library Constants {
uint256 internal constant MAX_NOTES_PER_PAGE = 10;
uint256 internal constant VIEW_NOTE_ORACLE_RETURN_LENGTH = 212;
uint256 internal constant CALL_CONTEXT_LENGTH = 6;
uint256 internal constant BLOCK_HASH_DATA_LENGTH = 7;
uint256 internal constant BLOCK_DATA_LENGTH = 7;
uint256 internal constant FUNCTION_DATA_LENGTH = 4;
uint256 internal constant CONTRACT_DEPLOYMENT_DATA_LENGTH = 6;
uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 58;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('Private Execution test suite', () => {
let circuitsWasm: CircuitsWasm;
let oracle: MockProxy<DBOracle>;
let acirSimulator: AcirSimulator;
let blockHashData = ConstantHistoricBlockData.empty();
let blockData = ConstantHistoricBlockData.empty();
let logger: DebugLogger;

const defaultContractAddress = AztecAddress.random();
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('Private Execution test suite', () => {
abi,
functionData.isConstructor ? AztecAddress.ZERO : contractAddress,
EthAddress.ZERO,
blockHashData,
blockData,
);
};

Expand All @@ -125,10 +125,10 @@ describe('Private Execution test suite', () => {

// Update root.
const newRoot = trees[name].getRoot(false);
const prevRoots = blockHashData.toBuffer();
const prevRoots = blockData.toBuffer();
const rootIndex = name === 'privateData' ? 0 : 32 * 3;
const newRoots = Buffer.concat([prevRoots.subarray(0, rootIndex), newRoot, prevRoots.subarray(rootIndex + 32)]);
blockHashData = ConstantHistoricBlockData.fromBuffer(newRoots);
blockData = ConstantHistoricBlockData.fromBuffer(newRoots);

return trees[name];
};
Expand Down
3 changes: 2 additions & 1 deletion yarn-project/acir-simulator/src/client/simulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class AcirSimulator {
* @param contractAddress - The address of the contract.
* @param portalContractAddress - The address of the portal contract.
* @param constantHistoricBlockData - Block data containing historic roots.
* @returns The return values of the function.
* @param aztecNode - The AztecNode instance.
*/
public async runUnconstrained(
request: FunctionCall,
Expand All @@ -101,6 +101,7 @@ export class AcirSimulator {
contractAddress: AztecAddress,
portalContractAddress: EthAddress,
constantHistoricBlockData: ConstantHistoricBlockData,
aztecNode?: AztecNode,
) {
if (entryPointABI.functionType !== FunctionType.UNCONSTRAINED) {
throw new Error(`Cannot run ${entryPointABI.functionType} function as constrained`);
Expand Down
8 changes: 1 addition & 7 deletions yarn-project/acir-simulator/src/public/db.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ConstantHistoricBlockData, EthAddress } from '@aztec/circuits.js';
import { EthAddress } from '@aztec/circuits.js';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { Fr } from '@aztec/foundation/fields';

Expand Down Expand Up @@ -71,10 +71,4 @@ export interface CommitmentsDB {
* @returns - The Commitment data oracle object
*/
getCommitmentOracle(address: AztecAddress, commitment: Fr): Promise<CommitmentDataOracleInputs>;

/**
* Gets the current historic block data from the merkle db.
* @returns the previous blocks roots and global variables hash.
*/
getHistoricBlockData(): ConstantHistoricBlockData;
}
13 changes: 4 additions & 9 deletions yarn-project/acir-simulator/src/public/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class PublicExecutor {
private readonly stateDb: PublicStateDB,
private readonly contractsDb: PublicContractsDB,
private readonly commitmentsDb: CommitmentsDB,
private readonly blockHashData: ConstantHistoricBlockData,
private readonly blockData: ConstantHistoricBlockData,

private log = createDebugLogger('aztec:simulator:public-executor'),
) {}
Expand All @@ -60,12 +60,7 @@ export class PublicExecutor {
const acir = await this.contractsDb.getBytecode(execution.contractAddress, selector);
if (!acir) throw new Error(`Bytecode not found for ${execution.contractAddress.toString()}:${selectorHex}`);

const initialWitness = getInitialWitness(
execution.args,
execution.callContext,
this.blockHashData,
globalVariables,
);
const initialWitness = getInitialWitness(execution.args, execution.callContext, this.blockData, globalVariables);
const storageActions = new ContractStorageActionsCollector(this.stateDb, execution.contractAddress);
const newCommitments: Fr[] = [];
const newL2ToL1Messages: Fr[] = [];
Expand All @@ -87,14 +82,14 @@ export class PublicExecutor {
},
getL1ToL2Message: async ([msgKey]) => {
const messageInputs = await this.commitmentsDb.getL1ToL2Message(fromACVMField(msgKey));
return toAcvmL1ToL2MessageLoadOracleInputs(messageInputs, this.blockHashData.l1ToL2MessagesTreeRoot);
return toAcvmL1ToL2MessageLoadOracleInputs(messageInputs, this.blockData.l1ToL2MessagesTreeRoot);
}, // l1 to l2 messages in public contexts TODO: https://github.com/AztecProtocol/aztec-packages/issues/616
getCommitment: async ([commitment]) => {
const commitmentInputs = await this.commitmentsDb.getCommitmentOracle(
execution.contractAddress,
fromACVMField(commitment),
);
return toAcvmCommitmentLoadOracleInputs(commitmentInputs, this.blockHashData.privateDataTreeRoot);
return toAcvmCommitmentLoadOracleInputs(commitmentInputs, this.blockData.privateDataTreeRoot);
},
storageRead: async ([slot], [numberOfElements]) => {
const startStorageSlot = fromACVMField(slot);
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/acir-simulator/src/public/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('ACIR public execution simulator', () => {
let publicContracts: MockProxy<PublicContractsDB>;
let commitmentsDb: MockProxy<CommitmentsDB>;
let executor: PublicExecutor;
let blockHashData: ConstantHistoricBlockData;
let blockData: ConstantHistoricBlockData;

beforeAll(async () => {
circuitsWasm = await CircuitsWasm.get();
Expand All @@ -48,8 +48,8 @@ describe('ACIR public execution simulator', () => {
publicContracts = mock<PublicContractsDB>();
commitmentsDb = mock<CommitmentsDB>();

blockHashData = ConstantHistoricBlockData.empty();
executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, blockHashData);
blockData = ConstantHistoricBlockData.empty();
executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, blockData);
}, 10000);

describe('PublicToken contract', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ export class AztecRPCServer implements AztecRPC {
contractAddress,
portalContract,
constantHistoricBlockData,
this.node,
);
this.log('Unconstrained simulation completed!');

Expand Down
19 changes: 1 addition & 18 deletions yarn-project/aztec-rpc/src/simulator_oracle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { CommitmentDataOracleInputs, DBOracle, MessageLoadOracleInputs } from '@
import {
AztecAddress,
CircuitsWasm,
ConstantHistoricBlockData,
EthAddress,
Fr,
PartialContractAddress,
Expand All @@ -11,7 +10,7 @@ import {
} from '@aztec/circuits.js';
import { siloCommitment } from '@aztec/circuits.js/abis';
import { FunctionAbi } from '@aztec/foundation/abi';
import { DataCommitmentProvider, KeyStore, L1ToL2MessageProvider, MerkleTreeId } from '@aztec/types';
import { DataCommitmentProvider, KeyStore, L1ToL2MessageProvider } from '@aztec/types';

import { ContractDataOracle } from '../contract_data_oracle/index.js';
import { Database } from '../database/index.js';
Expand Down Expand Up @@ -101,20 +100,4 @@ export class SimulatorOracle implements DBOracle {
index,
});
}

getHistoricBlockData(): ConstantHistoricBlockData {
const roots = this.db.getTreeRoots();

return ConstantHistoricBlockData.from({
privateKernelVkTreeRoot: Fr.ZERO,
// TODO: work out how to get the previous globals hash in here
prevGlobalVariablesHash: Fr.ZERO,
privateDataTreeRoot: roots[MerkleTreeId.PRIVATE_DATA_TREE],
contractTreeRoot: roots[MerkleTreeId.CONTRACT_TREE],
nullifierTreeRoot: roots[MerkleTreeId.NULLIFIER_TREE],
l1ToL2MessagesTreeRoot: roots[MerkleTreeId.L1_TO_L2_MESSAGES_TREE],
blocksTreeRoot: roots[MerkleTreeId.BLOCKS_TREE],
publicDataTreeRoot: roots[MerkleTreeId.PUBLIC_DATA_TREE],
});
}
}
2 changes: 1 addition & 1 deletion yarn-project/aztec.js/src/abis/ecdsa_account_contract.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion yarn-project/circuits.js/src/cbind/constants.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const GET_NOTE_ORACLE_RETURN_LENGTH = 23;
export const MAX_NOTES_PER_PAGE = 10;
export const VIEW_NOTE_ORACLE_RETURN_LENGTH = 212;
export const CALL_CONTEXT_LENGTH = 6;
export const BLOCK_HASH_DATA_LENGTH = 7;
export const BLOCK_DATA_LENGTH = 7;
export const FUNCTION_DATA_LENGTH = 4;
export const CONTRACT_DEPLOYMENT_DATA_LENGTH = 6;
export const PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 58;
Expand Down
6 changes: 3 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 @@ -25,9 +25,9 @@ import {
L1Publisher,
SoloBlockBuilder,
WasmRollupCircuitSimulator,
getConstantHistoricBlockData,
getL1Publisher,
getVerificationKeys,
getconstantHistoricBlockData,
makeEmptyProcessedTx as makeEmptyProcessedTxFromHistoricTreeRoots,
makeProcessedTx,
} from '@aztec/sequencer-client';
Expand Down Expand Up @@ -155,7 +155,7 @@ describe('L1Publisher integration', () => {
}, 100_000);

const makeEmptyProcessedTx = async () => {
const historicTreeRoots = await getconstantHistoricBlockData(builderDb, prevGlobals);
const historicTreeRoots = await getConstantHistoricBlockData(builderDb, prevGlobals);
const tx = await makeEmptyProcessedTxFromHistoricTreeRoots(
historicTreeRoots,
new Fr(config.chainId),
Expand All @@ -169,7 +169,7 @@ describe('L1Publisher integration', () => {
const kernelOutput = KernelCircuitPublicInputs.empty();
kernelOutput.constants.txContext.chainId = fr(config.chainId);
kernelOutput.constants.txContext.version = fr(config.version);
kernelOutput.constants.blockData = await getconstantHistoricBlockData(builderDb, prevGlobals);
kernelOutput.constants.blockData = await getConstantHistoricBlockData(builderDb, prevGlobals);
kernelOutput.end.publicDataUpdateRequests = makeTuple(
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
i => new PublicDataUpdateRequest(fr(i), fr(0), fr(i + 10)),
Expand Down
30 changes: 15 additions & 15 deletions yarn-project/noir-libs/noir-aztec/src/abi.nr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::constants_gen::{
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL,
MAX_PUBLIC_DATA_READS_PER_CALL,
GENERATOR_INDEX__FUNCTION_ARGS,
BLOCK_HASH_DATA_LENGTH,
BLOCK_DATA_LENGTH,
CONTRACT_DEPLOYMENT_DATA_LENGTH,
CALL_CONTEXT_LENGTH,
PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH,
Expand Down Expand Up @@ -84,7 +84,7 @@ impl ContractDeploymentData {
// PrivateContextInputs are expected to be provided to each private function
struct PrivateContextInputs {
call_context : CallContext,
block_hash_data: BlockHashData,
block_data: ConstantBlockData,

contract_deployment_data: ContractDeploymentData,

Expand All @@ -94,7 +94,7 @@ struct PrivateContextInputs {
// PublicContextInputs are expected to be provided to each public function
struct PublicContextInputs {
call_context: CallContext,
block_hash_data: BlockHashData,
block_data: ConstantBlockData,

public_global_variables: PublicGlobalVariables,
}
Expand Down Expand Up @@ -126,7 +126,7 @@ impl CallContext {
}
}

struct BlockHashData {
struct ConstantBlockData {
private_data_tree_root : Field,
nullifier_tree_root : Field,
contract_tree_root : Field,
Expand All @@ -136,9 +136,9 @@ struct BlockHashData {
public_data_tree_root: Field,
}

impl BlockHashData {
impl ConstantBlockData {
// NOTE: this order must match the order in `private_circuit_public_inputs.hpp`
fn serialize(self) -> [Field; BLOCK_HASH_DATA_LENGTH] {
fn serialize(self) -> [Field; BLOCK_DATA_LENGTH] {
[
self.private_data_tree_root,
self.nullifier_tree_root,
Expand All @@ -151,8 +151,8 @@ impl BlockHashData {
}
}

fn empty_block_hash_data() -> BlockHashData {
BlockHashData{ private_data_tree_root: 0, nullifier_tree_root: 0, contract_tree_root: 0, l1_to_l2_messages_tree_root: 0, blocks_tree_root: 0, prev_global_variables_hash: 0, public_data_tree_root: 0 }
fn empty_block_data() -> ConstantBlockData {
ConstantBlockData{ private_data_tree_root: 0, nullifier_tree_root: 0, contract_tree_root: 0, l1_to_l2_messages_tree_root: 0, blocks_tree_root: 0, prev_global_variables_hash: 0, public_data_tree_root: 0 }
}

struct FunctionData {
Expand Down Expand Up @@ -190,7 +190,7 @@ struct PrivateCircuitPublicInputs {
unencrypted_logs_hash: [Field; NUM_FIELDS_PER_SHA256],
encrypted_log_preimages_length: Field,
unencrypted_log_preimages_length: Field,
block_hash_data: BlockHashData,
block_data: ConstantBlockData,
contract_deployment_data: ContractDeploymentData,
chain_id: Field,
version: Field,
Expand All @@ -213,7 +213,7 @@ impl PrivateCircuitPublicInputs {
fields.push_array(self.unencrypted_logs_hash);
fields.push(self.encrypted_log_preimages_length);
fields.push(self.unencrypted_log_preimages_length);
fields.push_array(self.block_hash_data.serialize());
fields.push_array(self.block_data.serialize());
fields.push(self.contract_deployment_data.hash());
fields.push(self.chain_id);
fields.push(self.version);
Expand All @@ -236,7 +236,7 @@ impl PrivateCircuitPublicInputs {
fields.push_array(self.unencrypted_logs_hash);
fields.push(self.encrypted_log_preimages_length);
fields.push(self.unencrypted_log_preimages_length);
fields.push_array(self.block_hash_data.serialize());
fields.push_array(self.block_data.serialize());
fields.push_array(self.contract_deployment_data.serialize());
fields.push(self.chain_id);
fields.push(self.version);
Expand Down Expand Up @@ -296,7 +296,7 @@ struct PublicCircuitPublicInputs {
new_l2_to_l1_msgs: [Field; crate::abi::MAX_NEW_L2_TO_L1_MSGS_PER_CALL],
unencrypted_logs_hash: [Field; NUM_FIELDS_PER_SHA256],
unencrypted_log_preimages_length: Field,
block_hash_data: BlockHashData, // TODO: This is not present in cpp or ts, do we need to include it?
block_data: ConstantBlockData, // TODO: This is not present in cpp or ts, do we need to include it?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still a todo? If so can you add issue for it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer a todo, however i will change the name to match exactly

historic_public_data_tree_root: Field,
prover_address: Field,
}
Expand All @@ -319,8 +319,8 @@ impl PublicCircuitPublicInputs {
inputs.push_array(self.new_nullifiers);
inputs.push_array(self.new_l2_to_l1_msgs);

// We do not include block_hash_data since it's not in the cpp hash
// inputs.push(self.block_hash_data.hash());
// We do not include block_data since it's not in the cpp hash
// inputs.push(self.block_data.hash());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add an issue for this, should be handled instead of just living as comment in here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


inputs.push_array(self.unencrypted_logs_hash);
inputs.push(self.unencrypted_log_preimages_length);
Expand All @@ -347,7 +347,7 @@ impl PublicCircuitPublicInputs {
fields.push_array(self.new_l2_to_l1_msgs);
fields.push_array(self.unencrypted_logs_hash);
fields.push(self.unencrypted_log_preimages_length);
fields.push_array(self.block_hash_data.serialize());
fields.push_array(self.block_data.serialize());
fields.push(self.historic_public_data_tree_root);
fields.push(self.prover_address);
fields.storage
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/noir-libs/noir-aztec/src/constants_gen.nr
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ global GET_NOTE_ORACLE_RETURN_LENGTH: comptime Field = 23;
global MAX_NOTES_PER_PAGE: comptime Field = 10;
global VIEW_NOTE_ORACLE_RETURN_LENGTH: comptime Field = 212;
global CALL_CONTEXT_LENGTH: comptime Field = 6;
global BLOCK_HASH_DATA_LENGTH: comptime Field = 7;
global BLOCK_DATA_LENGTH: comptime Field = 7;
global FUNCTION_DATA_LENGTH: comptime Field = 4;
global CONTRACT_DEPLOYMENT_DATA_LENGTH: comptime Field = 6;
global PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH: comptime Field = 58;
Expand Down
Loading