Skip to content

Commit 0803964

Browse files
authored
feat!: rename Header to BlockHeader (#10372)
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.
1 parent f4ed66b commit 0803964

File tree

108 files changed

+518
-416
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+518
-416
lines changed

barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#define PUBLIC_INNER_CALL_REQUEST_LENGTH 13
3939
#define STATE_REFERENCE_LENGTH 8
4040
#define TOTAL_FEES_LENGTH 1
41-
#define HEADER_LENGTH 25
4241
#define PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH 867
4342
#define AVM_ACCUMULATED_DATA_LENGTH 318
4443
#define AVM_CIRCUIT_PUBLIC_INPUTS_LENGTH 1006

docs/docs/aztec/smart_contracts/functions/context.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,11 @@ The call context contains information about the current call being made:
6666
- 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.
6767
- 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.
6868

69-
### Header
69+
### Block Header
7070

71-
Another structure that is contained within the context is the Header object.
72-
In the private context this is a header of a block which used to generate proofs against.
73-
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.
71+
Another structure that is contained within the context is the `BlockHeader` object, which is the header of the block used to generate proofs against.
7472

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

7775
### Transaction Context
7876

docs/docs/migration_notes.md

+11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ keywords: [sandbox, aztec, notes, migration, updating, upgrading]
66

77
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.
88

9+
## TBD
10+
11+
### [aztec.nr] Renamed `Header` and associated helpers
12+
13+
The `Header` struct has been renamed to `BlockHeader`, and the `get_header()` family of functions have been similarly renamed to `get_block_header()`.
14+
15+
```diff
16+
- let header = context.get_header_at(block_number);
17+
+ let header = context.get_block_header_at(block_number);
18+
```
19+
920
## 0.66
1021

1122
### DEBUG env var is removed

l1-contracts/src/core/libraries/ConstantsGen.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ library Constants {
199199
uint256 internal constant TX_REQUEST_LENGTH = 12;
200200
uint256 internal constant TOTAL_FEES_LENGTH = 1;
201201
uint256 internal constant TOTAL_MANA_USED_LENGTH = 1;
202-
uint256 internal constant HEADER_LENGTH = 25;
202+
uint256 internal constant BLOCK_HEADER_LENGTH = 25;
203203
uint256 internal constant PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH = 739;
204204
uint256 internal constant PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH = 867;
205205
uint256 internal constant PRIVATE_CONTEXT_INPUTS_LENGTH = 38;

l1-contracts/src/core/libraries/RollupLibs/HeaderLib.sol

+3-3
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ library HeaderLib {
203203
fields[24] = bytes32(_header.totalManaUsed);
204204
// fail if the header structure has changed without updating this function
205205
require(
206-
fields.length == Constants.HEADER_LENGTH,
207-
Errors.HeaderLib__InvalidHeaderSize(Constants.HEADER_LENGTH, fields.length)
206+
fields.length == Constants.BLOCK_HEADER_LENGTH,
207+
Errors.HeaderLib__InvalidHeaderSize(Constants.BLOCK_HEADER_LENGTH, fields.length)
208208
);
209209

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

240240
return fields;

noir-projects/aztec-nr/aztec/src/context/inputs/private_context_inputs.nr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use dep::protocol_types::{
2-
abis::call_context::CallContext, header::Header, traits::Empty,
2+
abis::call_context::CallContext, block_header::BlockHeader, traits::Empty,
33
transaction::tx_context::TxContext,
44
};
55

66
// PrivateContextInputs are expected to be provided to each private function
77
// docs:start:private-context-inputs
88
pub struct PrivateContextInputs {
99
pub call_context: CallContext,
10-
pub historical_header: Header,
10+
pub historical_header: BlockHeader,
1111
pub tx_context: TxContext,
1212
pub start_side_effect_counter: u32,
1313
}
@@ -17,7 +17,7 @@ impl Empty for PrivateContextInputs {
1717
fn empty() -> Self {
1818
PrivateContextInputs {
1919
call_context: CallContext::empty(),
20-
historical_header: Header::empty(),
20+
historical_header: BlockHeader::empty(),
2121
tx_context: TxContext::empty(),
2222
start_side_effect_counter: 0 as u32,
2323
}

noir-projects/aztec-nr/aztec/src/context/private_context.nr

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ use crate::{
55
messaging::process_l1_to_l2_message,
66
oracle::{
77
arguments,
8+
block_header::get_block_header_at,
89
call_private_function::call_private_function_internal,
910
enqueue_public_function_call::{
1011
enqueue_public_function_call_internal, notify_set_min_revertible_side_effect_counter,
1112
set_public_teardown_function_call_internal,
1213
},
13-
header::get_header_at,
1414
key_validation_request::get_key_validation_request,
1515
returns::pack_returns,
1616
},
@@ -33,6 +33,7 @@ use dep::protocol_types::{
3333
validation_requests::{KeyValidationRequest, KeyValidationRequestAndGenerator},
3434
},
3535
address::{AztecAddress, EthAddress},
36+
block_header::BlockHeader,
3637
constants::{
3738
MAX_CONTRACT_CLASS_LOGS_PER_CALL, MAX_ENQUEUED_CALLS_PER_CALL,
3839
MAX_KEY_VALIDATION_REQUESTS_PER_CALL, MAX_L2_TO_L1_MSGS_PER_CALL,
@@ -41,7 +42,6 @@ use dep::protocol_types::{
4142
MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, MAX_PRIVATE_LOGS_PER_CALL,
4243
PRIVATE_LOG_SIZE_IN_FIELDS, PUBLIC_DISPATCH_SELECTOR,
4344
},
44-
header::Header,
4545
messaging::l2_to_l1_message::L2ToL1Message,
4646
traits::Empty,
4747
};
@@ -74,7 +74,7 @@ pub struct PrivateContext {
7474
// docs:end:private-context
7575

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

7979
pub private_logs: BoundedVec<PrivateLogData, MAX_PRIVATE_LOGS_PER_CALL>,
8080
pub contract_class_logs_hashes: BoundedVec<LogHash, MAX_CONTRACT_CLASS_LOGS_PER_CALL>,
@@ -157,14 +157,14 @@ impl PrivateContext {
157157

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

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

170170
pub fn set_return_hash(&mut self, returns_hasher: ArgsHasher) {
@@ -585,7 +585,7 @@ impl Empty for PrivateContext {
585585
public_call_requests: BoundedVec::new(),
586586
public_teardown_call_request: PublicCallRequest::empty(),
587587
l2_to_l1_msgs: BoundedVec::new(),
588-
historical_header: Header::empty(),
588+
historical_header: BlockHeader::empty(),
589589
private_logs: BoundedVec::new(),
590590
contract_class_logs_hashes: BoundedVec::new(),
591591
last_key_validation_requests: [Option::none(); NUM_KEY_TYPES],

noir-projects/aztec-nr/aztec/src/history/contract_inclusion.nr

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use dep::protocol_types::{
2-
address::AztecAddress, constants::DEPLOYER_CONTRACT_ADDRESS, hash::compute_siloed_nullifier,
3-
header::Header,
2+
address::AztecAddress, block_header::BlockHeader, constants::DEPLOYER_CONTRACT_ADDRESS,
3+
hash::compute_siloed_nullifier,
44
};
55

66
trait ProveContractDeployment {
7-
fn prove_contract_deployment(header: Header, contract_address: AztecAddress);
7+
fn prove_contract_deployment(header: BlockHeader, contract_address: AztecAddress);
88
}
99

10-
impl ProveContractDeployment for Header {
10+
impl ProveContractDeployment for BlockHeader {
1111
fn prove_contract_deployment(self, contract_address: AztecAddress) {
1212
// Compute deployment nullifier
1313
let nullifier =
@@ -18,10 +18,10 @@ impl ProveContractDeployment for Header {
1818
}
1919

2020
trait ProveContractNonDeployment {
21-
fn prove_contract_non_deployment(header: Header, contract_address: AztecAddress);
21+
fn prove_contract_non_deployment(header: BlockHeader, contract_address: AztecAddress);
2222
}
2323

24-
impl ProveContractNonDeployment for Header {
24+
impl ProveContractNonDeployment for BlockHeader {
2525
fn prove_contract_non_deployment(self, contract_address: AztecAddress) {
2626
// Compute deployment nullifier
2727
let nullifier =
@@ -34,10 +34,10 @@ impl ProveContractNonDeployment for Header {
3434
}
3535

3636
trait ProveContractInitialization {
37-
fn prove_contract_initialization(header: Header, contract_address: AztecAddress);
37+
fn prove_contract_initialization(header: BlockHeader, contract_address: AztecAddress);
3838
}
3939

40-
impl ProveContractInitialization for Header {
40+
impl ProveContractInitialization for BlockHeader {
4141
fn prove_contract_initialization(self, contract_address: AztecAddress) {
4242
// Compute initialization nullifier
4343
let nullifier = compute_siloed_nullifier(contract_address, contract_address.to_field());
@@ -47,10 +47,10 @@ impl ProveContractInitialization for Header {
4747
}
4848

4949
trait ProveContractNonInitialization {
50-
fn prove_contract_non_initialization(header: Header, contract_address: AztecAddress);
50+
fn prove_contract_non_initialization(header: BlockHeader, contract_address: AztecAddress);
5151
}
5252

53-
impl ProveContractNonInitialization for Header {
53+
impl ProveContractNonInitialization for BlockHeader {
5454
fn prove_contract_non_initialization(self, contract_address: AztecAddress) {
5555
// Compute initialization nullifier
5656
let nullifier = compute_siloed_nullifier(contract_address, contract_address.to_field());

noir-projects/aztec-nr/aztec/src/history/note_inclusion.nr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use dep::protocol_types::header::Header;
1+
use dep::protocol_types::block_header::BlockHeader;
22
use dep::protocol_types::merkle_tree::root::root_from_sibling_path;
33

44
use crate::{
@@ -7,12 +7,12 @@ use crate::{
77
};
88

99
trait ProveNoteInclusion {
10-
fn prove_note_inclusion<Note, let N: u32>(header: Header, note: Note)
10+
fn prove_note_inclusion<Note, let N: u32>(header: BlockHeader, note: Note)
1111
where
1212
Note: NoteInterface<N> + NullifiableNote;
1313
}
1414

15-
impl ProveNoteInclusion for Header {
15+
impl ProveNoteInclusion for BlockHeader {
1616
fn prove_note_inclusion<Note, let N: u32>(self, note: Note)
1717
where
1818
Note: NoteInterface<N> + NullifiableNote,

noir-projects/aztec-nr/aztec/src/history/note_validity.nr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
use crate::{context::PrivateContext, note::note_interface::{NoteInterface, NullifiableNote}};
22

3-
use dep::protocol_types::header::Header;
3+
use dep::protocol_types::block_header::BlockHeader;
44

55
trait ProveNoteValidity {
66
fn prove_note_validity<Note, let N: u32>(
7-
header: Header,
7+
header: BlockHeader,
88
note: Note,
99
context: &mut PrivateContext,
1010
)
1111
where
1212
Note: NoteInterface<N> + NullifiableNote;
1313
}
1414

15-
impl ProveNoteValidity for Header {
15+
impl ProveNoteValidity for BlockHeader {
1616
fn prove_note_validity<Note, let N: u32>(self, note: Note, context: &mut PrivateContext)
1717
where
1818
Note: NoteInterface<N> + NullifiableNote,

noir-projects/aztec-nr/aztec/src/history/nullifier_inclusion.nr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use dep::protocol_types::header::Header;
1+
use dep::protocol_types::block_header::BlockHeader;
22
use dep::protocol_types::merkle_tree::root::root_from_sibling_path;
33

44
use crate::{
@@ -8,10 +8,10 @@ use crate::{
88
};
99

1010
trait ProveNullifierInclusion {
11-
fn prove_nullifier_inclusion(header: Header, nullifier: Field);
11+
fn prove_nullifier_inclusion(header: BlockHeader, nullifier: Field);
1212
}
1313

14-
impl ProveNullifierInclusion for Header {
14+
impl ProveNullifierInclusion for BlockHeader {
1515
fn prove_nullifier_inclusion(self, nullifier: Field) {
1616
// 1) Get the membership witness of the nullifier
1717
let witness = unsafe {
@@ -39,15 +39,15 @@ impl ProveNullifierInclusion for Header {
3939

4040
trait ProveNoteIsNullified {
4141
fn prove_note_is_nullified<Note, let N: u32>(
42-
header: Header,
42+
header: BlockHeader,
4343
note: Note,
4444
context: &mut PrivateContext,
4545
)
4646
where
4747
Note: NoteInterface<N> + NullifiableNote;
4848
}
4949

50-
impl ProveNoteIsNullified for Header {
50+
impl ProveNoteIsNullified for BlockHeader {
5151
// docs:start:prove_note_is_nullified
5252
fn prove_note_is_nullified<Note, let N: u32>(self, note: Note, context: &mut PrivateContext)
5353
where

noir-projects/aztec-nr/aztec/src/history/nullifier_non_inclusion.nr

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ use crate::{
44
oracle::get_nullifier_membership_witness::get_low_nullifier_membership_witness,
55
};
66
use dep::protocol_types::{
7-
header::Header,
7+
block_header::BlockHeader,
88
utils::field::{full_field_greater_than, full_field_less_than},
99
};
1010
use dep::protocol_types::merkle_tree::root::root_from_sibling_path;
1111

1212
trait ProveNullifierNonInclusion {
13-
fn prove_nullifier_non_inclusion(header: Header, nullifier: Field);
13+
fn prove_nullifier_non_inclusion(header: BlockHeader, nullifier: Field);
1414
}
1515

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

5353
trait ProveNoteNotNullified {
5454
fn prove_note_not_nullified<Note, let N: u32>(
55-
header: Header,
55+
header: BlockHeader,
5656
note: Note,
5757
context: &mut PrivateContext,
5858
)
5959
where
6060
Note: NoteInterface<N> + NullifiableNote;
6161
}
6262

63-
impl ProveNoteNotNullified for Header {
63+
impl ProveNoteNotNullified for BlockHeader {
6464
// docs:start:prove_note_not_nullified
6565
fn prove_note_not_nullified<Note, let N: u32>(self, note: Note, context: &mut PrivateContext)
6666
where

noir-projects/aztec-nr/aztec/src/history/public_storage.nr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
use dep::protocol_types::{
2-
address::AztecAddress, constants::GENERATOR_INDEX__PUBLIC_LEAF_INDEX,
3-
hash::poseidon2_hash_with_separator, header::Header, utils::field::full_field_less_than,
2+
address::AztecAddress, block_header::BlockHeader, constants::GENERATOR_INDEX__PUBLIC_LEAF_INDEX,
3+
hash::poseidon2_hash_with_separator, utils::field::full_field_less_than,
44
};
55
use dep::protocol_types::merkle_tree::root::root_from_sibling_path;
66

77
use crate::oracle::get_public_data_witness::get_public_data_witness;
88

99
trait PublicStorageHistoricalRead {
1010
fn public_storage_historical_read(
11-
header: Header,
11+
header: BlockHeader,
1212
storage_slot: Field,
1313
contract_address: AztecAddress,
1414
) -> Field;
1515
}
1616

17-
impl PublicStorageHistoricalRead for Header {
17+
impl PublicStorageHistoricalRead for BlockHeader {
1818
fn public_storage_historical_read(
1919
self,
2020
storage_slot: Field,

0 commit comments

Comments
 (0)