Skip to content

Commit

Permalink
fix(synchroniser): Store most recent globals hash in the synchroniser…
Browse files Browse the repository at this point in the history
…, rather than fetching from the latest block (#1539)

fixes: AztecProtocol/aztec-packages#1537

Stores the most recent global variables hash within the synchroniser
rather than fetching it from the most recent block. This created a race
condition where the globals hash requested from the block was ahead of
the tree roots requested from the node.

As the tree roots were being requested from the node the synchroniser
was also behind.
  • Loading branch information
superstar0402 committed Aug 14, 2023
1 parent 201072b commit 736b5da
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions yarn-project/noir-libs/noir-aztec/src/abi.nr
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl ContractDeploymentData {
// PrivateContextInputs are expected to be provided to each private function
struct PrivateContextInputs {
call_context : CallContext,
block_data: ConstantHistoricBlockData,
block_data: HistoricBlockData,

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_data: ConstantHistoricBlockData,
block_data: HistoricBlockData,

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

struct ConstantHistoricBlockData {
struct HistoricBlockData {
private_data_tree_root : Field,
nullifier_tree_root : Field,
contract_tree_root : Field,
Expand All @@ -136,7 +136,7 @@ struct ConstantHistoricBlockData {
public_data_tree_root: Field,
}

impl ConstantHistoricBlockData {
impl HistoricBlockData {
// NOTE: this order must match the order in `private_circuit_public_inputs.hpp`
fn serialize(self) -> [Field; CONSTANT_HISTORIC_BLOCK_DATA_LENGTH] {
[
Expand All @@ -151,8 +151,8 @@ impl ConstantHistoricBlockData {
}
}

fn empty_block_data() -> ConstantHistoricBlockData {
ConstantHistoricBlockData{ 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() -> HistoricBlockData {
HistoricBlockData{ 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_data: ConstantHistoricBlockData,
block_data: HistoricBlockData,
contract_deployment_data: ContractDeploymentData,
chain_id: Field,
version: Field,
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_data: ConstantHistoricBlockData,
block_data: HistoricBlockData,
historic_public_data_tree_root: Field,
prover_address: Field,
}
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/noir-libs/noir-aztec/src/context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::abi::{
hash_args,
CallContext,
ContractDeploymentData,
ConstantHistoricBlockData,
HistoricBlockData,
FunctionData,
PrivateCircuitPublicInputs,
PublicCircuitPublicInputs,
Expand Down Expand Up @@ -247,7 +247,7 @@ impl Context {
unencrypted_logs_hash: arr_copy_slice(fields, [0; NUM_FIELDS_PER_SHA256], 44),
encrypted_log_preimages_length: fields[46],
unencrypted_log_preimages_length: fields[47],
block_data: ConstantHistoricBlockData {
block_data: HistoricBlockData {
// Must match order in `private_circuit_public_inputs.hpp`
private_data_tree_root : fields[48],
nullifier_tree_root : fields[49],
Expand Down

0 comments on commit 736b5da

Please sign in to comment.