Skip to content

Commit d1d3d50

Browse files
authored
refactor!: historical block -> anchor block (#17066)
Fixes #16026
2 parents bb87ea4 + 9fd0f3c commit d1d3d50

98 files changed

Lines changed: 5742 additions & 5715 deletions

File tree

Some content is hidden

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

docs/docs/developers/guides/smart_contracts/how_to_define_storage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ While `DelayedPublicMutable` state variables are much less leaky than the assert
415415

416416
### Choosing Delays
417417

418-
The `include_by_timestamp` transaction property will be set to a value close to the current timestamp plus the duration of the delay in seconds. The exact value depends on the historical block over which the private proof is constructed. For example, if current timestamp is `X` and a `DelayedPublicMutable` state variable has a delay of 3000 seconds, then transactions that read this value privately will set `include_by_timestamp` to a value close to 'X + 3000' (clients building proofs on older state will select a lower `include_by_timestamp`).
418+
The `include_by_timestamp` transaction property will be set to a value close to the current timestamp plus the duration of the delay in seconds. The exact value depends on the anchor block over which the private proof is constructed. For example, if current timestamp is `X` and a `DelayedPublicMutable` state variable has a delay of 3000 seconds, then transactions that read this value privately will set `include_by_timestamp` to a value close to 'X + 3000' (clients building proofs on older state will select a lower `include_by_timestamp`).
419419

420420
These delays can be changed during the contract lifetime as the application's needs evolve.
421421

docs/docs/migration_notes.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ As we prepare for a bigger `Wallet` interface refactor and the upcoming `WalletS
4949

5050
## [Aztec.nr]
5151

52+
### Historical block renamed as anchor block
53+
54+
A historical block term has been used as a term that denotes the block against which a private part of a tx has been executed.
55+
This name is ambiguous and for this reason we've introduce "anchor block".
56+
This naming change resulted in quite a few changes and if you've access private context's or utility context's block header you will need to update your code:
57+
58+
```diff
59+
- let header = context.get_block_header();
60+
+ let header = context.get_anchor_block_header();
61+
```diff
5262

5363
### PrivateMutable: replace / initialize_or_replace behaviour change
5464

docs/docs/protocol-specs/gas-and-fees/kernel-tracking.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class PrivateCircuitPublicInputs {
4141
+bool is_fee_payer
4242
+u32 min_revertible_side_effect_counter
4343
+Field public_teardown_function_hash
44-
+Header historical_header
44+
+Header anchor_block_header
4545
}
4646
PrivateCircuitPublicInputs --> TxContext
4747
PrivateCircuitPublicInputs --> Header
@@ -69,7 +69,7 @@ class PrivateAccumulatedData {
6969
}
7070
7171
class CombinedConstantData {
72-
+Header historical_header
72+
+Header anchor_block_header
7373
+TxContext tx_context
7474
+GlobalVariables global_variables
7575
}
@@ -163,7 +163,7 @@ It must:
163163

164164
- check that the `TxContext` provided as in the `TxRequest` input matches the `TxContext` in the `PrivateCallData`
165165
- copy the `TxContext` from the `TxRequest` to the `PrivateKernelCircuitPublicInputs.constants.tx_context`
166-
- copy the `Header` from the `PrivateCircuitPublicInputs` to the `PrivateKernelCircuitPublicInputs.constants.historical_header`
166+
- copy the `Header` from the `PrivateCircuitPublicInputs` to the `PrivateKernelCircuitPublicInputs.constants.anchor_block_header`
167167
- set the min_revertible_side_effect_counter if it is present in the `PrivateCallData`
168168
- set the `fee_payer` if the `is_fee_payer` flag is set in the `PrivateCircuitPublicInputs`
169169
- set the `public_teardown_function_hash` if it is present in the `PrivateCircuitPublicInputs`
@@ -304,7 +304,7 @@ PublicKernelCircuitPublicInputs --> PublicAccumulatedData
304304
PublicKernelCircuitPublicInputs --> CombinedConstantData
305305
306306
class CombinedConstantData {
307-
+Header historical_header
307+
+Header anchor_block_header
308308
+TxContext tx_context
309309
+GlobalVariables global_variables
310310
}
@@ -387,7 +387,7 @@ class CombinedAccumulatedData {
387387
CombinedAccumulatedData --> Gas
388388
389389
class PublicContextInputs {
390-
+Header historical_header
390+
+Header anchor_block_header
391391
+GlobalVariables public_global_variables
392392
+Gas gas_left
393393
+Field transaction_fee

docs/docs/protocol-specs/rollup-circuits/base-rollup.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,11 @@ class TxContext {
157157
TxContext *-- GasSettings : gas_settings
158158
159159
class CombinedConstantData {
160-
historical_header: Header
160+
anchor_block_header: Header
161161
tx_context: TxContext
162162
global_variables: GlobalVariables
163163
}
164-
CombinedConstantData *-- Header : historical_header
164+
CombinedConstantData *-- Header : anchor_block_header
165165
CombinedConstantData *-- TxContext : tx_context
166166
CombinedConstantData *-- GlobalVariables : global_variables
167167
@@ -204,7 +204,7 @@ class StateDiffHints {
204204
}
205205
206206
class BaseRollupInputs {
207-
historical_header_membership_witnesses: HeaderMembershipWitness
207+
anchor_block_header_membership_witnesses: HeaderMembershipWitness
208208
kernel_data: KernelData
209209
partial: PartialStateReference
210210
state_diff_hints: StateDiffHints
@@ -237,7 +237,7 @@ Fee structs and contract deployment structs will need to be revised, in line wit
237237
```python
238238
def BaseRollupCircuit(
239239
state_diff_hints: StateDiffHints,
240-
historical_header_membership_witnesses: HeaderMembershipWitness,
240+
anchor_block_header_membership_witnesses: HeaderMembershipWitness,
241241
kernel_data: KernelData,
242242
partial: PartialStateReference,
243243
constants: ConstantRollupData,
@@ -248,7 +248,7 @@ def BaseRollupCircuit(
248248
kernel_data,
249249
constants,
250250
public_data_tree_root,
251-
historical_header_membership_witnesses,
251+
anchor_block_header_membership_witnesses,
252252
)
253253

254254
note_hash_subtree = MerkleTree(kernel_data.public_inputs.end.note_hashes)
@@ -304,7 +304,7 @@ def kernel_checks(
304304
kernel: KernelData,
305305
constants: ConstantRollupData,
306306
public_data_tree_root: Fr,
307-
historical_header_membership_witness: HeaderMembershipWitness
307+
anchor_block_header_membership_witness: HeaderMembershipWitness
308308
) -> (Fr[2], Fr[], Fr):
309309
assert public_data_tree_root == kernel.public_inputs.end.start_public_data_root
310310
assert kernel.proof.verify(kernel.public_inputs)
@@ -317,9 +317,9 @@ def kernel_checks(
317317
assert len(kernel.public_inputs.end.public_call_stack) == 0
318318

319319
assert merkle_inclusion(
320-
kernel.constants.historical_header.hash(),
321-
kernel.constants.historical_header.global_variables.block_number,
322-
historical_header_membership_witness,
320+
kernel.constants.anchor_block_header.hash(),
321+
kernel.constants.anchor_block_header.global_variables.block_number,
322+
anchor_block_header_membership_witness,
323323
constants.last_archive
324324
)
325325

docs/docs/protocol-specs/rollup-circuits/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,11 @@ class TxContext {
281281
TxContext *-- GasSettings : gas_settings
282282
283283
class CombinedConstantData {
284-
historical_header: Header
284+
anchor_block_header: Header
285285
tx_context: TxContext
286286
global_variables: GlobalVariables
287287
}
288-
CombinedConstantData *-- Header : historical_header
288+
CombinedConstantData *-- Header : anchor_block_header
289289
CombinedConstantData *-- TxContext : tx_context
290290
CombinedConstantData *-- GlobalVariables : global_variables
291291
@@ -327,7 +327,7 @@ class StateDiffHints {
327327
}
328328
329329
class BaseRollupInputs {
330-
historical_header_membership_witnesses: HeaderMembershipWitness
330+
anchor_block_header_membership_witnesses: HeaderMembershipWitness
331331
kernel_data: KernelData
332332
partial: PartialStateReference
333333
state_diff_hints: StateDiffHints

docs/docs/protocol-specs/transactions/validity.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Mike review: If we have written definitions for the various kinds of "`data`" de
1313
- **Proof is valid**: The `proof` for the given public `data` should be valid according to a protocol-wide verification key for the final private kernel circuit.
1414
- **No duplicate nullifiers**: No `nullifier` in the transaction `data` should be already present in the nullifier tree.
1515
- **No pending private function calls**: The `data` private call stack should be empty.
16-
- **Valid historic data**: The tree roots in the block header of `data` must match the tree roots of a historical block in the chain.
16+
- **Valid anchor data**: The tree roots in the block header of `data` must match the tree roots of an anchor block in the chain.
1717
- **Maximum block number not exceeded**: The transaction must be included in a block with height no greater than the value specified in `maxBlockNum` within the transaction's `data`.
1818
- **Preimages must match commitments in `data`**: The expanded fields in the transaction object should match the commitments (hashes) to them in the public `data`.
1919
- The `encryptedLogs` should match the `encryptedLogsHash` and `encryptedLogPreimagesLength` in the transaction `data`.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use protocol_types::{
1010
#[derive(Eq)]
1111
pub struct PrivateContextInputs {
1212
pub call_context: CallContext,
13-
pub historical_header: BlockHeader,
13+
pub anchor_block_header: BlockHeader,
1414
pub tx_context: TxContext,
1515
pub start_side_effect_counter: u32,
1616
}
@@ -20,7 +20,7 @@ impl Empty for PrivateContextInputs {
2020
fn empty() -> Self {
2121
PrivateContextInputs {
2222
call_context: CallContext::empty(),
23-
historical_header: BlockHeader::empty(),
23+
anchor_block_header: BlockHeader::empty(),
2424
tx_context: TxContext::empty(),
2525
start_side_effect_counter: 0 as u32,
2626
}

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ pub struct PrivateContext {
193193
// docs:end:private-context
194194

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

198198
pub private_logs: BoundedVec<PrivateLogData, MAX_PRIVATE_LOGS_PER_CALL>,
199199
pub contract_class_logs_hashes: BoundedVec<Counted<LogHash>, MAX_CONTRACT_CLASS_LOGS_PER_CALL>,
@@ -206,8 +206,8 @@ pub struct PrivateContext {
206206

207207
impl PrivateContext {
208208
pub fn new(inputs: PrivateContextInputs, args_hash: Field) -> PrivateContext {
209-
let max_allowed_include_by_timestamp =
210-
inputs.historical_header.global_variables.timestamp + MAX_INCLUDE_BY_TIMESTAMP_DURATION;
209+
let max_allowed_include_by_timestamp = inputs.anchor_block_header.global_variables.timestamp
210+
+ MAX_INCLUDE_BY_TIMESTAMP_DURATION;
211211
PrivateContext {
212212
inputs,
213213
side_effect_counter: inputs.start_side_effect_counter + 1,
@@ -221,7 +221,7 @@ impl PrivateContext {
221221
key_validation_requests_and_generators: BoundedVec::new(),
222222
note_hashes: BoundedVec::new(),
223223
nullifiers: BoundedVec::new(),
224-
historical_header: inputs.historical_header,
224+
anchor_block_header: inputs.anchor_block_header,
225225
private_call_requests: BoundedVec::new(),
226226
public_call_requests: BoundedVec::new(),
227227
public_teardown_call_request: PublicCallRequest::empty(),
@@ -489,7 +489,7 @@ impl PrivateContext {
489489
/// private function is reading from.
490490
///
491491
/// A private function CANNOT read from the "current" block header,
492-
/// but must read from some historical block header, because as soon as
492+
/// but must read from some older block header, because as soon as
493493
/// private function execution begins (asynchronously, on a user's device),
494494
/// the public state of the chain (the "current state") will have progressed
495495
/// forward.
@@ -505,8 +505,8 @@ impl PrivateContext {
505505
/// from the mempool. Therefore, the chosen block header _must_ be one
506506
/// from within the last 24 hours.
507507
///
508-
pub fn get_block_header(self) -> BlockHeader {
509-
self.historical_header
508+
pub fn get_anchor_block_header(self) -> BlockHeader {
509+
self.anchor_block_header
510510
}
511511

512512
/// Returns the header of any historical block at or before the anchor
@@ -600,7 +600,7 @@ impl PrivateContext {
600600
contract_class_logs_hashes: ClaimedLengthArray::from_bounded_vec(
601601
self.contract_class_logs_hashes,
602602
),
603-
historical_header: self.historical_header,
603+
anchor_block_header: self.anchor_block_header,
604604
tx_context: self.inputs.tx_context,
605605
}
606606
}
@@ -993,7 +993,7 @@ impl PrivateContext {
993993
) {
994994
// docs:end:context_consume_l1_to_l2_message
995995
let nullifier = process_l1_to_l2_message(
996-
self.historical_header.state.l1_to_l2_message_tree.root,
996+
self.anchor_block_header.state.l1_to_l2_message_tree.root,
997997
self.this_address(),
998998
sender,
999999
self.chain_id(),
@@ -1698,7 +1698,7 @@ impl Empty for PrivateContext {
16981698
public_call_requests: BoundedVec::new(),
16991699
public_teardown_call_request: PublicCallRequest::empty(),
17001700
l2_to_l1_msgs: BoundedVec::new(),
1701-
historical_header: BlockHeader::empty(),
1701+
anchor_block_header: BlockHeader::empty(),
17021702
private_logs: BoundedVec::new(),
17031703
contract_class_logs_hashes: BoundedVec::new(),
17041704
last_key_validation_requests: [Option::none(); NUM_KEY_TYPES],

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ unconstrained fn succeeds_on_blocks_after_note_creation() {
77
let (env, retrieved_note) = test::create_note();
88

99
env.private_context_opts(
10-
PrivateContextOptions::new().at_historical_block_number(test::NOTE_CREATED_AT),
10+
PrivateContextOptions::new().at_anchor_block_number(test::NOTE_CREATED_AT),
1111
|context| {
1212
// docs:start:prove_note_inclusion
13-
let header = context.historical_header;
13+
let header = context.anchor_block_header;
1414
header.prove_note_inclusion(retrieved_note, test::NOTE_STORAGE_SLOT);
1515
// docs:end:prove_note_inclusion
1616
},
@@ -22,9 +22,9 @@ unconstrained fn fails_on_blocks_before_note_creation() {
2222
let (env, retrieved_note) = test::create_note();
2323

2424
env.private_context_opts(
25-
PrivateContextOptions::new().at_historical_block_number(test::NOTE_CREATED_AT - 1),
25+
PrivateContextOptions::new().at_anchor_block_number(test::NOTE_CREATED_AT - 1),
2626
|context| {
27-
let header = context.historical_header;
27+
let header = context.anchor_block_header;
2828
header.prove_note_inclusion(retrieved_note, test::NOTE_STORAGE_SLOT);
2929
},
3030
);

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ unconstrained fn fails_on_blocks_before_note_creation() {
88
let (env, retrieved_note) = test::create_note_and_nullify_it();
99

1010
env.private_context_opts(
11-
PrivateContextOptions::new().at_historical_block_number(test::NOTE_CREATED_AT - 1),
11+
PrivateContextOptions::new().at_anchor_block_number(test::NOTE_CREATED_AT - 1),
1212
|context| {
13-
let header = context.historical_header;
13+
let header = context.anchor_block_header;
1414
header.prove_note_validity(retrieved_note, test::NOTE_STORAGE_SLOT, context);
1515
},
1616
);
@@ -21,10 +21,10 @@ unconstrained fn succeeds_on_blocks_after_creation_and_before_nullification() {
2121
let (env, retrieved_note) = test::create_note_and_nullify_it();
2222

2323
env.private_context_opts(
24-
PrivateContextOptions::new().at_historical_block_number(test::NOTE_CREATED_AT),
24+
PrivateContextOptions::new().at_anchor_block_number(test::NOTE_CREATED_AT),
2525
|context| {
2626
// docs:start:prove_note_validity
27-
let header = context.historical_header;
27+
let header = context.anchor_block_header;
2828
header.prove_note_validity(retrieved_note, test::NOTE_STORAGE_SLOT, context);
2929
// docs:end:prove_note_validity
3030
},
@@ -36,9 +36,9 @@ unconstrained fn fails_on_blocks_after_note_nullification() {
3636
let (env, retrieved_note) = test::create_note_and_nullify_it();
3737

3838
env.private_context_opts(
39-
PrivateContextOptions::new().at_historical_block_number(test::NOTE_NULLIFIED_AT),
39+
PrivateContextOptions::new().at_anchor_block_number(test::NOTE_NULLIFIED_AT),
4040
|context| {
41-
let header = context.historical_header;
41+
let header = context.anchor_block_header;
4242
header.prove_note_validity(retrieved_note, test::NOTE_STORAGE_SLOT, context);
4343
},
4444
);

0 commit comments

Comments
 (0)