Skip to content

Commit 44a33a1

Browse files
refactor!: include_by_timestamp -> expiration_timestamp (#20536)
As agreed upon on [slack](https://aztecprotocol.slack.com/archives/C060PU5R327/p1770842346067929) the `include_by_timestamp` name was strange so I am renaming it.
2 parents d8c49fc + 942a535 commit 44a33a1

File tree

114 files changed

+658
-668
lines changed

Some content is hidden

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

114 files changed

+658
-668
lines changed

docs/docs-developers/docs/aztec-nr/framework-description/functions/context.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ The return values are a set of values that are returned from an applications exe
9595
```rust
9696
return_values : BoundedVec\<Field, RETURN_VALUES_LENGTH\>,
9797
```
98-
## Include By Timestamp
98+
## Expiration Timestamp
9999

100-
Some data structures impose time constraints, e.g. they may make it so that a value can only be changed after a certain delay. Interacting with these in private involves creating proofs that are only valid as long as they are included before a certain future point in time. To achieve this, the `set_include_by_timestamp` function can be used to set this property:
100+
Some data structures impose time constraints, e.g. they may make it so that a value can only be changed after a certain delay. Interacting with these in private involves creating proofs that are only valid as long as they are included before a certain future point in time. To achieve this, the `set_expiration_timestamp` function can be used to set this property:
101101

102-
#include_code include-by-timestamp /noir-projects/aztec-nr/aztec/src/context/private_context.nr rust
102+
#include_code expiration-timestamp /noir-projects/aztec-nr/aztec/src/context/private_context.nr rust
103103

104104
A transaction that sets this value will never be included in a block with a timestamp larger than the requested value, since it would be considered invalid. This can also be used to make transactions automatically expire after some time if not included.
105105

docs/docs-developers/docs/aztec-nr/framework-description/state_variables.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ It is sometimes necessary to read public mutable state in private. For example,
170170

171171
`DelayedPublicMutable` is the same as a `PublicMutable` in that it is a public value that can be read and written, but with a caveat: writes only take effect _after some time delay_. These delays are configurable, but they're typically on the order of a couple hours, if not days, making this state variable unsuitable for actions that must be executed immediately - such as an emergency shutdown. It is these very delays that enable private contract functions to _read the current value of a public state variable_, which is otherwise typically impossible.
172172

173-
The existence of minimum delays means that a private function that reads a public value at an anchor block has a guarantee that said historical value will remain the current value until _at least_ some time in the future - before the delay elapses. As long as the transaction gets included in a block before that time (by using the `include_by_timestamp` tx property), the read value is valid.
173+
The existence of minimum delays means that a private function that reads a public value at an anchor block has a guarantee that said historical value will remain the current value until _at least_ some time in the future - before the delay elapses. As long as the transaction gets included in a block before that time (by using the `expiration_timestamp` tx property), the read value is valid.
174174

175175
#### Declaration
176176

@@ -191,7 +191,7 @@ Returns the current value in a public, private or utility execution context.
191191
#include_code get_current_value /noir-projects/noir-contracts/contracts/app/auth_contract/src/main.nr rust
192192

193193
:::warning Privacy Consideration
194-
Reading `DelayedPublicMutable` in private sets the `include_by_timestamp` property, which may reveal timing information. Choose delays that align with common values to maximize privacy sets.
194+
Reading `DelayedPublicMutable` in private sets the `expiration_timestamp` property, which may reveal timing information. Choose delays that align with common values to maximize privacy sets.
195195
:::
196196

197197
#### `get_scheduled_value`

docs/docs-developers/docs/resources/migration_notes.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ Aztec is in active development. Each version may introduce breaking changes that
99

1010
## TBD
1111

12+
### [Protocol] `include_by_timestamp` renamed to `expiration_timestamp`
13+
14+
The `include_by_timestamp` field has been renamed to `expiration_timestamp` across the protocol to better convey its meaning.
15+
**Noir:**
16+
17+
```diff
18+
- context.set_tx_include_by_timestamp(123456789);
19+
+ context.set_expiration_timestamp(123456789);
20+
```
21+
1222
### [CLI] Dockerless CLI Installation
1323

1424
The Aztec CLI is now installed without Docker. The installation command has changed:

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

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ use crate::protocol::{
3535
address::{AztecAddress, EthAddress},
3636
constants::{
3737
CONTRACT_CLASS_LOG_SIZE_IN_FIELDS, MAX_CONTRACT_CLASS_LOGS_PER_CALL, MAX_ENQUEUED_CALLS_PER_CALL,
38-
MAX_INCLUDE_BY_TIMESTAMP_DURATION, MAX_KEY_VALIDATION_REQUESTS_PER_CALL, MAX_L2_TO_L1_MSGS_PER_CALL,
39-
MAX_NOTE_HASH_READ_REQUESTS_PER_CALL, MAX_NOTE_HASHES_PER_CALL, MAX_NULLIFIER_READ_REQUESTS_PER_CALL,
40-
MAX_NULLIFIERS_PER_CALL, MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, MAX_PRIVATE_LOGS_PER_CALL,
38+
MAX_KEY_VALIDATION_REQUESTS_PER_CALL, MAX_L2_TO_L1_MSGS_PER_CALL, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL,
39+
MAX_NOTE_HASHES_PER_CALL, MAX_NULLIFIER_READ_REQUESTS_PER_CALL, MAX_NULLIFIERS_PER_CALL,
40+
MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, MAX_PRIVATE_LOGS_PER_CALL, MAX_TX_LIFETIME,
4141
NULL_MSG_SENDER_CONTRACT_ADDRESS, PRIVATE_LOG_SIZE_IN_FIELDS,
4242
},
4343
hash::poseidon2_hash,
@@ -148,7 +148,7 @@ pub struct PrivateContext {
148148
pub args_hash: Field,
149149
pub return_hash: Field,
150150

151-
pub include_by_timestamp: u64,
151+
pub expiration_timestamp: u64,
152152

153153
pub(crate) note_hash_read_requests: BoundedVec<Scoped<Counted<Field>>, MAX_NOTE_HASH_READ_REQUESTS_PER_CALL>,
154154
pub(crate) nullifier_read_requests: BoundedVec<Scoped<Counted<Field>>, MAX_NULLIFIER_READ_REQUESTS_PER_CALL>,
@@ -180,16 +180,14 @@ pub struct PrivateContext {
180180

181181
impl PrivateContext {
182182
pub fn new(inputs: PrivateContextInputs, args_hash: Field) -> PrivateContext {
183-
let max_allowed_include_by_timestamp =
184-
inputs.anchor_block_header.global_variables.timestamp + MAX_INCLUDE_BY_TIMESTAMP_DURATION;
185183
PrivateContext {
186184
inputs,
187185
side_effect_counter: inputs.start_side_effect_counter + 1,
188186
min_revertible_side_effect_counter: 0,
189187
is_fee_payer: false,
190188
args_hash,
191189
return_hash: 0,
192-
include_by_timestamp: max_allowed_include_by_timestamp,
190+
expiration_timestamp: inputs.anchor_block_header.global_variables.timestamp + MAX_TX_LIFETIME,
193191
note_hash_read_requests: BoundedVec::new(),
194192
nullifier_read_requests: BoundedVec::new(),
195193
key_validation_requests_and_generators: BoundedVec::new(),
@@ -430,7 +428,7 @@ impl PrivateContext {
430428
///
431429
/// # Advanced
432430
/// * All private functions of a tx read from the same anchor block header.
433-
/// * The protocol asserts that the `include_by_timestamp` of every tx is at most 24 hours beyond the timestamp of
431+
/// * The protocol asserts that the `expiration_timestamp` of every tx is at most 24 hours beyond the timestamp of
434432
/// the tx's chosen anchor block header. This enables the network's nodes to safely prune old txs from the mempool.
435433
/// Therefore, the chosen block header _must_ be one from within the last 24 hours.
436434
///
@@ -496,7 +494,7 @@ impl PrivateContext {
496494
returns_hash: self.return_hash,
497495
min_revertible_side_effect_counter: self.min_revertible_side_effect_counter,
498496
is_fee_payer: self.is_fee_payer,
499-
include_by_timestamp: self.include_by_timestamp,
497+
expiration_timestamp: self.expiration_timestamp,
500498
note_hash_read_requests: ClaimedLengthArray::from_bounded_vec(self.note_hash_read_requests),
501499
nullifier_read_requests: ClaimedLengthArray::from_bounded_vec(self.nullifier_read_requests),
502500
key_validation_requests_and_generators: ClaimedLengthArray::from_bounded_vec(
@@ -598,11 +596,11 @@ impl PrivateContext {
598596
/// This expiry timestamp is publicly visible. See the "Advanced" section for privacy concerns.
599597
///
600598
/// # Arguments
601-
/// * `include_by_timestamp` - Unix timestamp (seconds) deadline for inclusion. The include-by timestamp of this tx
599+
/// * `expiration_timestamp` - Unix timestamp (seconds) deadline for inclusion. The include-by timestamp of this tx
602600
/// will be _at most_ the timestamp specified.
603601
///
604602
/// # Advanced
605-
/// * If multiple functions set differing `include_by_timestamp`s, the kernel circuits will set it to be the
603+
/// * If multiple functions set differing `expiration_timestamp`s, the kernel circuits will set it to be the
606604
/// _minimum_ of the two. This ensures the tx expiry requirements of all functions in the tx are met.
607605
/// * Rollup circuits will reject expired txs.
608606
/// * The protocol enforces that all transactions must be included within 24 hours of their chosen anchor block's
@@ -617,10 +615,10 @@ impl PrivateContext {
617615
/// will need to be discussed. Wallets that deviate from a standard might accidentally reveal which wallet each
618616
/// transaction originates from.
619617
///
620-
// docs:start:include-by-timestamp
621-
pub fn set_include_by_timestamp(&mut self, include_by_timestamp: u64) {
622-
// docs:end:include-by-timestamp
623-
self.include_by_timestamp = std::cmp::min(self.include_by_timestamp, include_by_timestamp);
618+
// docs:start:expiration-timestamp
619+
pub fn set_expiration_timestamp(&mut self, expiration_timestamp: u64) {
620+
// docs:end:expiration-timestamp
621+
self.expiration_timestamp = std::cmp::min(self.expiration_timestamp, expiration_timestamp);
624622
}
625623

626624
/// Asserts that a note has been created.
@@ -1460,7 +1458,7 @@ impl Empty for PrivateContext {
14601458
is_fee_payer: false,
14611459
args_hash: 0,
14621460
return_hash: 0,
1463-
include_by_timestamp: 0,
1461+
expiration_timestamp: 0,
14641462
note_hash_read_requests: BoundedVec::new(),
14651463
nullifier_read_requests: BoundedVec::new(),
14661464
key_validation_requests_and_generators: BoundedVec::new(),

noir-projects/aztec-nr/aztec/src/state_vars/delayed_public_mutable.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ where
189189

190190
// We prevent this transaction from being included in any timestamp after the time horizon, ensuring that the
191191
// historical public value matches the current one, since it can only change after the horizon.
192-
self.context.set_include_by_timestamp(time_horizon);
192+
self.context.set_expiration_timestamp(time_horizon);
193193

194194
value_change.get_current_at(anchor_timestamp)
195195
}

noir-projects/aztec-nr/aztec/src/state_vars/delayed_public_mutable/test.nr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ unconstrained fn get_current_value_in_private_initial() {
229229

230230
assert_eq(state_var.get_current_value(), zeroed());
231231
assert_eq(
232-
context.include_by_timestamp,
232+
context.expiration_timestamp,
233233
context.get_anchor_block_header().global_variables.timestamp + TEST_INITIAL_DELAY,
234234
);
235235
});
@@ -251,7 +251,7 @@ unconstrained fn get_current_value_in_private_before_change() {
251251
let state_var = in_private(context);
252252

253253
assert_eq(state_var.get_current_value(), MockStruct::empty());
254-
assert_eq(context.include_by_timestamp, timestamp_of_change - 1);
254+
assert_eq(context.expiration_timestamp, timestamp_of_change - 1);
255255
});
256256
}
257257

@@ -275,10 +275,10 @@ unconstrained fn get_current_value_in_private_immediately_before_change() {
275275

276276
let state_var = in_private(context);
277277

278-
// Note that this transaction would never be valid since the include_by_timestamp is the same as the anchor
278+
// Note that this transaction would never be valid since the expiration_timestamp is the same as the anchor
279279
// block's timestamp, i.e. in the past.
280280
assert_eq(state_var.get_current_value(), MockStruct::empty());
281-
assert_eq(context.include_by_timestamp, timestamp_of_change - 1);
281+
assert_eq(context.expiration_timestamp, timestamp_of_change - 1);
282282
});
283283
}
284284

@@ -304,7 +304,7 @@ unconstrained fn get_current_value_in_private_at_change() {
304304

305305
assert_eq(state_var.get_current_value(), new_value);
306306
assert_eq(
307-
context.include_by_timestamp,
307+
context.expiration_timestamp,
308308
context.get_anchor_block_header().global_variables.timestamp + TEST_INITIAL_DELAY,
309309
);
310310
});
@@ -332,7 +332,7 @@ unconstrained fn get_current_value_in_private_after_change() {
332332

333333
assert_eq(state_var.get_current_value(), new_value);
334334
assert_eq(
335-
context.include_by_timestamp,
335+
context.expiration_timestamp,
336336
context.get_anchor_block_header().global_variables.timestamp + TEST_INITIAL_DELAY,
337337
);
338338
});
@@ -361,7 +361,7 @@ unconstrained fn get_current_value_in_private_with_non_initial_delay() {
361361
let state_var = in_private(context);
362362

363363
assert_eq(state_var.get_current_value(), new_value);
364-
assert_eq(context.include_by_timestamp, historical_timestamp + new_delay);
364+
assert_eq(context.expiration_timestamp, historical_timestamp + new_delay);
365365
});
366366
}
367367

noir-projects/noir-contracts/contracts/protocol/aztec_sublib/src/context/private_context.nr

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use crate::protocol::{
2929
address::{AztecAddress, EthAddress},
3030
constants::{
3131
CONTRACT_CLASS_LOG_SIZE_IN_FIELDS, MAX_CONTRACT_CLASS_LOGS_PER_CALL,
32-
MAX_ENQUEUED_CALLS_PER_CALL, MAX_INCLUDE_BY_TIMESTAMP_DURATION, MAX_L2_TO_L1_MSGS_PER_CALL,
32+
MAX_ENQUEUED_CALLS_PER_CALL, MAX_TX_LIFETIME, MAX_L2_TO_L1_MSGS_PER_CALL,
3333
MAX_NULLIFIER_READ_REQUESTS_PER_CALL, MAX_NULLIFIERS_PER_CALL,
3434
MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, MAX_PRIVATE_LOGS_PER_CALL,
3535
NULL_MSG_SENDER_CONTRACT_ADDRESS, PRIVATE_LOG_SIZE_IN_FIELDS,
@@ -54,7 +54,7 @@ pub struct PrivateContext {
5454
pub args_hash: Field,
5555
pub return_hash: Field,
5656

57-
pub include_by_timestamp: u64,
57+
pub expiration_timestamp: u64,
5858

5959
pub nullifier_read_requests: BoundedVec<Scoped<Counted<Field>>, MAX_NULLIFIER_READ_REQUESTS_PER_CALL>,
6060

@@ -77,16 +77,15 @@ pub struct PrivateContext {
7777

7878
impl PrivateContext {
7979
pub fn new(inputs: PrivateContextInputs, args_hash: Field) -> PrivateContext {
80-
let max_allowed_include_by_timestamp = inputs.anchor_block_header.global_variables.timestamp
81-
+ MAX_INCLUDE_BY_TIMESTAMP_DURATION;
8280
PrivateContext {
8381
inputs,
8482
side_effect_counter: inputs.start_side_effect_counter + 1,
8583
min_revertible_side_effect_counter: 0,
8684
is_fee_payer: false,
8785
args_hash,
8886
return_hash: 0,
89-
include_by_timestamp: max_allowed_include_by_timestamp,
87+
expiration_timestamp: inputs.anchor_block_header.global_variables.timestamp
88+
+ MAX_TX_LIFETIME,
9089
nullifier_read_requests: BoundedVec::new(),
9190
nullifiers: BoundedVec::new(),
9291
anchor_block_header: inputs.anchor_block_header,
@@ -161,7 +160,7 @@ impl PrivateContext {
161160
returns_hash: self.return_hash,
162161
min_revertible_side_effect_counter: self.min_revertible_side_effect_counter,
163162
is_fee_payer: self.is_fee_payer,
164-
include_by_timestamp: self.include_by_timestamp,
163+
expiration_timestamp: self.expiration_timestamp,
165164
note_hash_read_requests: ClaimedLengthArray::empty(), // Not used by protocol contracts
166165
nullifier_read_requests: ClaimedLengthArray::from_bounded_vec(
167166
self.nullifier_read_requests,
@@ -214,8 +213,8 @@ impl PrivateContext {
214213
}
215214

216215
/// Sets a deadline for when this transaction must be included in a block.
217-
pub fn set_include_by_timestamp(&mut self, include_by_timestamp: u64) {
218-
self.include_by_timestamp = std::cmp::min(self.include_by_timestamp, include_by_timestamp);
216+
pub fn set_expiration_timestamp(&mut self, expiration_timestamp: u64) {
217+
self.expiration_timestamp = std::cmp::min(self.expiration_timestamp, expiration_timestamp);
219218
}
220219

221220
/// Pushes a new nullifier. Used by class_registry and instance_registry.
@@ -402,7 +401,7 @@ impl Empty for PrivateContext {
402401
is_fee_payer: false,
403402
args_hash: 0,
404403
return_hash: 0,
405-
include_by_timestamp: 0,
404+
expiration_timestamp: 0,
406405
nullifier_read_requests: BoundedVec::new(),
407406
nullifiers: BoundedVec::new(),
408407
private_call_requests: BoundedVec::new(),

noir-projects/noir-contracts/contracts/protocol/aztec_sublib/src/state_vars/delayed_public_mutable.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ where
164164
let time_horizon = value_change.get_time_horizon(anchor_timestamp, effective_minimum_delay);
165165

166166
// We prevent this transaction from being included in any timestamp after the time horizon.
167-
self.context.set_include_by_timestamp(time_horizon);
167+
self.context.set_expiration_timestamp(time_horizon);
168168

169169
value_change.get_current_at(anchor_timestamp)
170170
}

noir-projects/noir-contracts/contracts/test/test_contract/src/main.nr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ pub contract Test {
121121
}
122122

123123
#[external("private")]
124-
fn set_include_by_timestamp(include_by_timestamp: u64, make_tx_hybrid: bool) {
125-
self.context.set_include_by_timestamp(include_by_timestamp);
124+
fn set_expiration_timestamp(expiration_timestamp: u64, make_tx_hybrid: bool) {
125+
self.context.set_expiration_timestamp(expiration_timestamp);
126126

127127
if make_tx_hybrid {
128128
self.enqueue_self.dummy_public_call()

noir-projects/noir-protocol-circuits/ABOUT.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Validator:
9696
- Asserts equality (between the tx and current chain) of the chain_id, version, vk_tree_root, protocol_contracts_hash.
9797
- Asserts that the tx's chosen gas prices are sufficiently high, relative to the block's minimum requirements.
9898
- Asserts that the tx doesn't exceed the L2 gas limit.
99-
- Asserts that the tx's `include_by_timestamp` hasn't already passed, relative to the block's timestamp.
99+
- Asserts that the tx's `expiration_timestamp` hasn't already passed, relative to the block's timestamp.
100100
- Hashes the `contract_class_log_fields` and compares them against the tx's claimed contract class log hash.
101101

102102
Composer:
@@ -177,7 +177,7 @@ Validator:
177177
- Asserts equality (between the tx and current chain) of the chain_id, version, vk_tree_root, protocol_contracts_hash.
178178
- Asserts that the tx's chosen gas prices are sufficiently high, relative to the block's minimum requirements.
179179
- Asserts that the tx doesn't exceed the L2 gas limit.
180-
- Asserts that the tx's `include_by_timestamp` hasn't already passed, relative to the block's timestamp.
180+
- Asserts that the tx's `expiration_timestamp` hasn't already passed, relative to the block's timestamp.
181181

182182
Composer `.finish()`:
183183
- **Appends the tx effects to the next available position of a blob.**

0 commit comments

Comments
 (0)