Skip to content

Commit

Permalink
feat!: rename Header to BlockHeader (#10372)
Browse files Browse the repository at this point in the history
I found this name quite confusing since there are lots of headers (note
headers, log headers, etc.), and so this seemed like an obvious
improvement. I also renamed the generic-looking methods (e.g.
`getHeader()`) where appropriate.
  • Loading branch information
nventuro authored Dec 7, 2024
1 parent f4ed66b commit 0803964
Show file tree
Hide file tree
Showing 108 changed files with 518 additions and 416 deletions.
1 change: 0 additions & 1 deletion barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#define PUBLIC_INNER_CALL_REQUEST_LENGTH 13
#define STATE_REFERENCE_LENGTH 8
#define TOTAL_FEES_LENGTH 1
#define HEADER_LENGTH 25
#define PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH 867
#define AVM_ACCUMULATED_DATA_LENGTH 318
#define AVM_CIRCUIT_PUBLIC_INPUTS_LENGTH 1006
Expand Down
8 changes: 3 additions & 5 deletions docs/docs/aztec/smart_contracts/functions/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,11 @@ The call context contains information about the current call being made:
- is_delegate_call: Denotes whether the current call is a delegate call. If true, then the storage contract address will be the address of the sender.
- is_static_call: This will be set if and only if the current call is a static call. In a static call, state changing altering operations are not allowed.

### Header
### Block Header

Another structure that is contained within the context is the Header object.
In the private context this is a header of a block which used to generate proofs against.
In the public context this header is set by sequencer (sequencer executes public calls) and it is set to 1 block before the block in which the transaction is included.
Another structure that is contained within the context is the `BlockHeader` object, which is the header of the block used to generate proofs against.

#include_code header /noir-projects/noir-protocol-circuits/crates/types/src/header.nr rust
#include_code block-header /noir-projects/noir-protocol-circuits/crates/types/src/block_header.nr rust

### Transaction Context

Expand Down
11 changes: 11 additions & 0 deletions docs/docs/migration_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ keywords: [sandbox, aztec, notes, migration, updating, upgrading]

Aztec is in full-speed development. Literally every version breaks compatibility with the previous ones. This page attempts to target errors and difficulties you might encounter when upgrading, and how to resolve them.

## TBD

### [aztec.nr] Renamed `Header` and associated helpers

The `Header` struct has been renamed to `BlockHeader`, and the `get_header()` family of functions have been similarly renamed to `get_block_header()`.

```diff
- let header = context.get_header_at(block_number);
+ let header = context.get_block_header_at(block_number);
```

## 0.66

### DEBUG env var is removed
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 @@ -199,7 +199,7 @@ library Constants {
uint256 internal constant TX_REQUEST_LENGTH = 12;
uint256 internal constant TOTAL_FEES_LENGTH = 1;
uint256 internal constant TOTAL_MANA_USED_LENGTH = 1;
uint256 internal constant HEADER_LENGTH = 25;
uint256 internal constant BLOCK_HEADER_LENGTH = 25;
uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 739;
uint256 internal constant PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = 867;
uint256 internal constant PRIVATE_CONTEXT_INPUTS_LENGTH = 38;
Expand Down
6 changes: 3 additions & 3 deletions l1-contracts/src/core/libraries/RollupLibs/HeaderLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ library HeaderLib {
fields[24] = bytes32(_header.totalManaUsed);
// fail if the header structure has changed without updating this function
require(
fields.length == Constants.HEADER_LENGTH,
Errors.HeaderLib__InvalidHeaderSize(Constants.HEADER_LENGTH, fields.length)
fields.length == Constants.BLOCK_HEADER_LENGTH,
Errors.HeaderLib__InvalidHeaderSize(Constants.BLOCK_HEADER_LENGTH, fields.length)
);

return fields;
Expand Down Expand Up @@ -234,7 +234,7 @@ library HeaderLib {
// When we verify root proofs, this method can be removed => no need for separate named error
require(
fields.length == Constants.GLOBAL_VARIABLES_LENGTH,
Errors.HeaderLib__InvalidHeaderSize(Constants.HEADER_LENGTH, fields.length)
Errors.HeaderLib__InvalidHeaderSize(Constants.BLOCK_HEADER_LENGTH, fields.length)
);

return fields;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use dep::protocol_types::{
abis::call_context::CallContext, header::Header, traits::Empty,
abis::call_context::CallContext, block_header::BlockHeader, traits::Empty,
transaction::tx_context::TxContext,
};

// PrivateContextInputs are expected to be provided to each private function
// docs:start:private-context-inputs
pub struct PrivateContextInputs {
pub call_context: CallContext,
pub historical_header: Header,
pub historical_header: BlockHeader,
pub tx_context: TxContext,
pub start_side_effect_counter: u32,
}
Expand All @@ -17,7 +17,7 @@ impl Empty for PrivateContextInputs {
fn empty() -> Self {
PrivateContextInputs {
call_context: CallContext::empty(),
historical_header: Header::empty(),
historical_header: BlockHeader::empty(),
tx_context: TxContext::empty(),
start_side_effect_counter: 0 as u32,
}
Expand Down
14 changes: 7 additions & 7 deletions noir-projects/aztec-nr/aztec/src/context/private_context.nr
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ use crate::{
messaging::process_l1_to_l2_message,
oracle::{
arguments,
block_header::get_block_header_at,
call_private_function::call_private_function_internal,
enqueue_public_function_call::{
enqueue_public_function_call_internal, notify_set_min_revertible_side_effect_counter,
set_public_teardown_function_call_internal,
},
header::get_header_at,
key_validation_request::get_key_validation_request,
returns::pack_returns,
},
Expand All @@ -33,6 +33,7 @@ use dep::protocol_types::{
validation_requests::{KeyValidationRequest, KeyValidationRequestAndGenerator},
},
address::{AztecAddress, EthAddress},
block_header::BlockHeader,
constants::{
MAX_CONTRACT_CLASS_LOGS_PER_CALL, MAX_ENQUEUED_CALLS_PER_CALL,
MAX_KEY_VALIDATION_REQUESTS_PER_CALL, MAX_L2_TO_L1_MSGS_PER_CALL,
Expand All @@ -41,7 +42,6 @@ use dep::protocol_types::{
MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, MAX_PRIVATE_LOGS_PER_CALL,
PRIVATE_LOG_SIZE_IN_FIELDS, PUBLIC_DISPATCH_SELECTOR,
},
header::Header,
messaging::l2_to_l1_message::L2ToL1Message,
traits::Empty,
};
Expand Down Expand Up @@ -74,7 +74,7 @@ pub struct PrivateContext {
// docs:end:private-context

// Header of a block whose state is used during private execution (not the block the transaction is included in).
pub historical_header: Header,
pub historical_header: BlockHeader,

pub private_logs: BoundedVec<PrivateLogData, MAX_PRIVATE_LOGS_PER_CALL>,
pub contract_class_logs_hashes: BoundedVec<LogHash, MAX_CONTRACT_CLASS_LOGS_PER_CALL>,
Expand Down Expand Up @@ -157,14 +157,14 @@ impl PrivateContext {

// Returns the header of a block whose state is used during private execution (not the block the transaction is
// included in).
pub fn get_header(self) -> Header {
pub fn get_block_header(self) -> BlockHeader {
self.historical_header
}

// Returns the header of an arbitrary block whose block number is less than or equal to the block number
// of historical header.
pub fn get_header_at(self, block_number: u32) -> Header {
get_header_at(block_number, self)
pub fn get_block_header_at(self, block_number: u32) -> BlockHeader {
get_block_header_at(block_number, self)
}

pub fn set_return_hash(&mut self, returns_hasher: ArgsHasher) {
Expand Down Expand Up @@ -585,7 +585,7 @@ impl Empty for PrivateContext {
public_call_requests: BoundedVec::new(),
public_teardown_call_request: PublicCallRequest::empty(),
l2_to_l1_msgs: BoundedVec::new(),
historical_header: Header::empty(),
historical_header: BlockHeader::empty(),
private_logs: BoundedVec::new(),
contract_class_logs_hashes: BoundedVec::new(),
last_key_validation_requests: [Option::none(); NUM_KEY_TYPES],
Expand Down
20 changes: 10 additions & 10 deletions noir-projects/aztec-nr/aztec/src/history/contract_inclusion.nr
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use dep::protocol_types::{
address::AztecAddress, constants::DEPLOYER_CONTRACT_ADDRESS, hash::compute_siloed_nullifier,
header::Header,
address::AztecAddress, block_header::BlockHeader, constants::DEPLOYER_CONTRACT_ADDRESS,
hash::compute_siloed_nullifier,
};

trait ProveContractDeployment {
fn prove_contract_deployment(header: Header, contract_address: AztecAddress);
fn prove_contract_deployment(header: BlockHeader, contract_address: AztecAddress);
}

impl ProveContractDeployment for Header {
impl ProveContractDeployment for BlockHeader {
fn prove_contract_deployment(self, contract_address: AztecAddress) {
// Compute deployment nullifier
let nullifier =
Expand All @@ -18,10 +18,10 @@ impl ProveContractDeployment for Header {
}

trait ProveContractNonDeployment {
fn prove_contract_non_deployment(header: Header, contract_address: AztecAddress);
fn prove_contract_non_deployment(header: BlockHeader, contract_address: AztecAddress);
}

impl ProveContractNonDeployment for Header {
impl ProveContractNonDeployment for BlockHeader {
fn prove_contract_non_deployment(self, contract_address: AztecAddress) {
// Compute deployment nullifier
let nullifier =
Expand All @@ -34,10 +34,10 @@ impl ProveContractNonDeployment for Header {
}

trait ProveContractInitialization {
fn prove_contract_initialization(header: Header, contract_address: AztecAddress);
fn prove_contract_initialization(header: BlockHeader, contract_address: AztecAddress);
}

impl ProveContractInitialization for Header {
impl ProveContractInitialization for BlockHeader {
fn prove_contract_initialization(self, contract_address: AztecAddress) {
// Compute initialization nullifier
let nullifier = compute_siloed_nullifier(contract_address, contract_address.to_field());
Expand All @@ -47,10 +47,10 @@ impl ProveContractInitialization for Header {
}

trait ProveContractNonInitialization {
fn prove_contract_non_initialization(header: Header, contract_address: AztecAddress);
fn prove_contract_non_initialization(header: BlockHeader, contract_address: AztecAddress);
}

impl ProveContractNonInitialization for Header {
impl ProveContractNonInitialization for BlockHeader {
fn prove_contract_non_initialization(self, contract_address: AztecAddress) {
// Compute initialization nullifier
let nullifier = compute_siloed_nullifier(contract_address, contract_address.to_field());
Expand Down
6 changes: 3 additions & 3 deletions noir-projects/aztec-nr/aztec/src/history/note_inclusion.nr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use dep::protocol_types::header::Header;
use dep::protocol_types::block_header::BlockHeader;
use dep::protocol_types::merkle_tree::root::root_from_sibling_path;

use crate::{
Expand All @@ -7,12 +7,12 @@ use crate::{
};

trait ProveNoteInclusion {
fn prove_note_inclusion<Note, let N: u32>(header: Header, note: Note)
fn prove_note_inclusion<Note, let N: u32>(header: BlockHeader, note: Note)
where
Note: NoteInterface<N> + NullifiableNote;
}

impl ProveNoteInclusion for Header {
impl ProveNoteInclusion for BlockHeader {
fn prove_note_inclusion<Note, let N: u32>(self, note: Note)
where
Note: NoteInterface<N> + NullifiableNote,
Expand Down
6 changes: 3 additions & 3 deletions noir-projects/aztec-nr/aztec/src/history/note_validity.nr
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
use crate::{context::PrivateContext, note::note_interface::{NoteInterface, NullifiableNote}};

use dep::protocol_types::header::Header;
use dep::protocol_types::block_header::BlockHeader;

trait ProveNoteValidity {
fn prove_note_validity<Note, let N: u32>(
header: Header,
header: BlockHeader,
note: Note,
context: &mut PrivateContext,
)
where
Note: NoteInterface<N> + NullifiableNote;
}

impl ProveNoteValidity for Header {
impl ProveNoteValidity for BlockHeader {
fn prove_note_validity<Note, let N: u32>(self, note: Note, context: &mut PrivateContext)
where
Note: NoteInterface<N> + NullifiableNote,
Expand Down
10 changes: 5 additions & 5 deletions noir-projects/aztec-nr/aztec/src/history/nullifier_inclusion.nr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use dep::protocol_types::header::Header;
use dep::protocol_types::block_header::BlockHeader;
use dep::protocol_types::merkle_tree::root::root_from_sibling_path;

use crate::{
Expand All @@ -8,10 +8,10 @@ use crate::{
};

trait ProveNullifierInclusion {
fn prove_nullifier_inclusion(header: Header, nullifier: Field);
fn prove_nullifier_inclusion(header: BlockHeader, nullifier: Field);
}

impl ProveNullifierInclusion for Header {
impl ProveNullifierInclusion for BlockHeader {
fn prove_nullifier_inclusion(self, nullifier: Field) {
// 1) Get the membership witness of the nullifier
let witness = unsafe {
Expand Down Expand Up @@ -39,15 +39,15 @@ impl ProveNullifierInclusion for Header {

trait ProveNoteIsNullified {
fn prove_note_is_nullified<Note, let N: u32>(
header: Header,
header: BlockHeader,
note: Note,
context: &mut PrivateContext,
)
where
Note: NoteInterface<N> + NullifiableNote;
}

impl ProveNoteIsNullified for Header {
impl ProveNoteIsNullified for BlockHeader {
// docs:start:prove_note_is_nullified
fn prove_note_is_nullified<Note, let N: u32>(self, note: Note, context: &mut PrivateContext)
where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ use crate::{
oracle::get_nullifier_membership_witness::get_low_nullifier_membership_witness,
};
use dep::protocol_types::{
header::Header,
block_header::BlockHeader,
utils::field::{full_field_greater_than, full_field_less_than},
};
use dep::protocol_types::merkle_tree::root::root_from_sibling_path;

trait ProveNullifierNonInclusion {
fn prove_nullifier_non_inclusion(header: Header, nullifier: Field);
fn prove_nullifier_non_inclusion(header: BlockHeader, nullifier: Field);
}

impl ProveNullifierNonInclusion for Header {
impl ProveNullifierNonInclusion for BlockHeader {
fn prove_nullifier_non_inclusion(self, nullifier: Field) {
// 1) Get the membership witness of a low nullifier of the nullifier
let witness = unsafe {
Expand Down Expand Up @@ -52,15 +52,15 @@ impl ProveNullifierNonInclusion for Header {

trait ProveNoteNotNullified {
fn prove_note_not_nullified<Note, let N: u32>(
header: Header,
header: BlockHeader,
note: Note,
context: &mut PrivateContext,
)
where
Note: NoteInterface<N> + NullifiableNote;
}

impl ProveNoteNotNullified for Header {
impl ProveNoteNotNullified for BlockHeader {
// docs:start:prove_note_not_nullified
fn prove_note_not_nullified<Note, let N: u32>(self, note: Note, context: &mut PrivateContext)
where
Expand Down
8 changes: 4 additions & 4 deletions noir-projects/aztec-nr/aztec/src/history/public_storage.nr
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
use dep::protocol_types::{
address::AztecAddress, constants::GENERATOR_INDEX__PUBLIC_LEAF_INDEX,
hash::poseidon2_hash_with_separator, header::Header, utils::field::full_field_less_than,
address::AztecAddress, block_header::BlockHeader, constants::GENERATOR_INDEX__PUBLIC_LEAF_INDEX,
hash::poseidon2_hash_with_separator, utils::field::full_field_less_than,
};
use dep::protocol_types::merkle_tree::root::root_from_sibling_path;

use crate::oracle::get_public_data_witness::get_public_data_witness;

trait PublicStorageHistoricalRead {
fn public_storage_historical_read(
header: Header,
header: BlockHeader,
storage_slot: Field,
contract_address: AztecAddress,
) -> Field;
}

impl PublicStorageHistoricalRead for Header {
impl PublicStorageHistoricalRead for BlockHeader {
fn public_storage_historical_read(
self,
storage_slot: Field,
Expand Down
Loading

0 comments on commit 0803964

Please sign in to comment.