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

Conversation

Maddiaa0
Copy link
Member

@Maddiaa0 Maddiaa0 commented Aug 1, 2023

Description

closes: #1163

Now the blocks tree baseline is added, we can remove the old historic blocks trees

This Pr:

  • Deletes the historic roots trees for private data, contracts and l1 to l2 messages
  • Removes all checks from smart contract / rollups, in a previous pr the block hash check was added
  • Add a way for rpc server to recalculate the previous block hash. (this is in progress)
  • Add getBlock (singular, it was annoying getting an array when i only need one)

Base automatically changed from md/blocks-tree-circuits to master August 2, 2023 14:29
Copy link
Contributor

@LHerskind LHerskind left a comment

Choose a reason for hiding this comment

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

Minor stuff, mainly around a typo in a name and to create issues for some todos. Otherwise good to me.

using fr = typename NCT::fr;
using boolean = typename NCT::boolean;

// Private data
fr private_data_tree_root = 0;
fr nullifier_tree_root = 0;
fr contract_tree_root = 0;
fr l1_to_l2_messages_tree_root = 0;
fr blocks_tree_root = 0;
fr private_kernel_vk_tree_root = 0; // TODO: future enhancement
Copy link
Contributor

Choose a reason for hiding this comment

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

@dbanks12 or @iAmMichaelConnor I guess the todo here is one of yours? Can one of you create an issue for it?

privateKernelVkTreeRoot: Fr.ZERO,
// TODO: work out how to get the previous globals hash in here
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there an issue for this?

import { computeGlobalsHash } from '@aztec/circuits.js/abis';
import { MerkleTreeOperations } from '@aztec/world-state';

/**
* Fetches the private, nullifier, contract tree and l1 to l2 messages tree roots from a given db and assembles a CombinedHistoricTreeRoots object.
*/
export async function getConstantBlockHashData(
export async function getconstantHistoricBlockData(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should probably be getConstantHistoricBlockData

@@ -86,7 +86,7 @@ export class PublicProcessor {
protected publicProver: PublicProver,
protected contractDataSource: ContractDataSource,
protected globalVariables: GlobalVariables,
protected blockHashData: ConstantBlockHashData,
protected blockHashData: ConstantHistoricBlockData,
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe better to rename to not refer to hash in some names but not others?

privateKernelVkTreeRoot: Fr.ZERO,

// TODO: work out how to get the previous globals hash in here
prevGlobalVariablesHash: Fr.ZERO,
Copy link
Contributor

Choose a reason for hiding this comment

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

As earlier, should this have an issue?

Copy link
Member Author

Choose a reason for hiding this comment

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

turns out im both cases we no longer needed this method as i had injected it in higher up. Have delet

@@ -223,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 COMMITMENT_TREES_ROOTS_LENGTH = 5;
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?

@@ -166,7 +165,7 @@ export class AcirSimulator {
abi,
AztecAddress.ZERO,
EthAddress.ZERO,
PrivateHistoricTreeRoots.empty(),
ConstantHistoricBlockData.empty(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this a better name that something like HistoricBlockDataTreeRoots (like its predecessor)?

Copy link
Member Author

@Maddiaa0 Maddiaa0 Aug 8, 2023

Choose a reason for hiding this comment

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

It's no longer just roots, as the global variables are included within it. Finding the right name for it has been difficult, Ive flipped it around a few times. But im open to changing it again as its important to get right.
@iAmMichaelConnor do you have any suggestions?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I suppose this can be thought of as a block header cant it?

Copy link
Contributor

@LHerskind LHerskind left a comment

Choose a reason for hiding this comment

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

If you add the issues as pointed out, looks good to me.

@@ -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

// 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.

@Maddiaa0 Maddiaa0 enabled auto-merge (squash) August 9, 2023 10:00
@Maddiaa0 Maddiaa0 merged commit ac935e1 into master Aug 9, 2023
1 check passed
@Maddiaa0 Maddiaa0 deleted the md/blocks-tree-use-blocks-tree branch August 9, 2023 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

feat(blocks_tree): refactor - replace historic trees with blocks tree
3 participants