Skip to content

Commit

Permalink
Merging palla/split-protocol-contracts into ad/ci2.5+blobs+/palla/spl…
Browse files Browse the repository at this point in the history
…it-protocol-contracts
  • Loading branch information
ludamad committed Dec 16, 2024
2 parents 179bb2f + b0096dd commit 33ede6e
Show file tree
Hide file tree
Showing 193 changed files with 1,729 additions and 1,379 deletions.
2 changes: 1 addition & 1 deletion .noir-sync-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e88deaf4890a3c6d6af8b0760e952d10573c004d
f337992de96ef656681ebfc96a30c2c9c9b82a70
10 changes: 9 additions & 1 deletion docs/docs/migration_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ 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.

## 0.68.0

### Noir contracts package no longer exposes artifacts as default export

To reduce loading times, the package `@aztec/noir-contracts.js` no longer exposes all artifacts as its default export. Instead, it exposes a `ContractNames` variable with the list of all contract names available. To import a given artifact, use the corresponding export, such as `@aztec/noir-contracts.js/FPC`.

## 0.67.0

### L2 Gas limit of 6M enforced for public portion of TX
Expand All @@ -24,10 +30,11 @@ The `Header` struct has been renamed to `BlockHeader`, and the `get_header()` fa
### Outgoing Events removed

Previously, every event which was emitted included:

- Incoming Header (to convey the app contract address to the recipient)
- Incoming Ciphertext (to convey the note contents to the recipient)
- Outgoing Header (served as a backup, to convey the app contract address to the "outgoing viewer" - most likely the sender)
- Outgoing Ciphertext (served as a backup, encrypting the summetric key of the incoming ciphertext to the "outgoing viewer" - most likely the sender)
- Outgoing Ciphertext (served as a backup, encrypting the symmetric key of the incoming ciphertext to the "outgoing viewer" - most likely the sender)

The latter two have been removed from the `.emit()` functions, so now only an Incoming Header and Incoming Ciphertext will be emitted.

Expand All @@ -43,6 +50,7 @@ The `getOutgoingNotes` function is removed from the PXE interface.
Some aztec.nr library methods' arguments are simplified to remove an `outgoing_viewer` parameter. E.g. `ValueNote::increment`, `ValueNote::decrement`, `ValueNote::decrement_by_at_most`, `EasyPrivateUint::add`, `EasyPrivateUint::sub`.

Further changes are planned, so that:

- Outgoing ciphertexts (or any kind of abstract ciphertext) can be emitted by a contract, and on the other side discovered and then processed by the contract.
- Headers will be removed, due to the new tagging scheme.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ use dep::types::{
log_hash::ScopedLogHash,
note_hash::ScopedNoteHash,
nullifier::ScopedNullifier,
private_log::{PrivateLog, PrivateLogData},
public_call_request::PublicCallRequest,
side_effect::{Counted, scoped::Scoped},
side_effect::Counted,
},
messaging::l2_to_l1_message::ScopedL2ToL1Message,
utils::arrays::{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::abis::constant_rollup_data::ConstantRollupData;
use dep::types::{
abis::sponge_blob::SpongeBlob,
abis::{constant_rollup_data::ConstantRollupData, sponge_blob::SpongeBlob},
constants::BASE_OR_MERGE_PUBLIC_INPUTS_LENGTH,
partial_state_reference::PartialStateReference,
traits::{Deserialize, Empty, Serialize},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub(crate) mod constant_rollup_data;
pub(crate) mod base_or_merge_rollup_public_inputs;
pub(crate) mod block_root_or_block_merge_public_inputs;
pub(crate) mod previous_rollup_data;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::abis::constant_rollup_data::ConstantRollupData;
use types::abis::combined_constant_data::CombinedConstantData;
use types::abis::{
combined_constant_data::CombinedConstantData, constant_rollup_data::ConstantRollupData,
};

pub(crate) fn validate_combined_constant_data(
constants: CombinedConstantData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@ pub(crate) mod constants;
pub(crate) mod fees;
pub(crate) mod nullifier_tree;
pub(crate) mod public_data_tree;

mod private_tube_data_validator;
mod public_tube_data_validator;
pub(crate) mod validate_tube_data;

pub(crate) use private_tube_data_validator::PrivateTubeDataValidator;
pub(crate) use public_tube_data_validator::PublicTubeDataValidator;
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use super::validate_tube_data::validate_max_fees_per_gas;
use dep::types::abis::{constant_rollup_data::ConstantRollupData, tube::PrivateTubeData};

pub struct PrivateTubeDataValidator {
pub data: PrivateTubeData,
}

// TODO: Move relevant verifications here.
impl PrivateTubeDataValidator {
pub fn new(data: PrivateTubeData) -> Self {
PrivateTubeDataValidator { data }
}

pub fn verify_proof<let N: u32>(self, _allowed_previous_circuits: [u32; N]) {
if !dep::std::runtime::is_unconstrained() {
self.data.verify();
// TODO(#7410)
// self.data.vk_data.validate_in_vk_tree(self.data.public_inputs.constants.vk_tree_root, allowed_previous_circuits);
}
}

pub fn validate_with_rollup_data(self, constants: ConstantRollupData) {
validate_max_fees_per_gas(
self.data.public_inputs.constants.tx_context.gas_settings.max_fees_per_gas,
constants.global_variables.gas_fees,
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use super::validate_tube_data::validate_max_fees_per_gas;
use dep::types::abis::{constant_rollup_data::ConstantRollupData, tube::PublicTubeData};

pub struct PublicTubeDataValidator {
pub data: PublicTubeData,
}

// TODO: Move relevant verifications here.
impl PublicTubeDataValidator {
pub fn new(data: PublicTubeData) -> Self {
PublicTubeDataValidator { data }
}

pub fn verify_proof(self) {
if !dep::std::runtime::is_unconstrained() {
self.data.verify();
// TODO(#7410)
// self.tube_data.vk_data.validate_in_vk_tree(self.tube_data.public_inputs.constants.vk_tree_root, ALLOWED_PREVIOUS_CIRCUITS);
}
}

pub fn validate_with_rollup_data(self, constants: ConstantRollupData) {
validate_max_fees_per_gas(
self.data.public_inputs.constants.tx_context.gas_settings.max_fees_per_gas,
constants.global_variables.gas_fees,
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use dep::types::abis::gas_fees::GasFees;

pub fn validate_max_fees_per_gas(max_fees_per_gas: GasFees, gas_fees: GasFees) {
assert(
!max_fees_per_gas.fee_per_da_gas.lt(gas_fees.fee_per_da_gas),
"da gas is higher than the maximum specified by the tx",
);
assert(
!max_fees_per_gas.fee_per_l2_gas.lt(gas_fees.fee_per_l2_gas),
"l2 gas is higher than the maximum specified by the tx",
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub(crate) mod components;
pub(crate) mod state_diff_hints;
mod private_base_rollup;
mod public_base_rollup;
mod tests;

pub use crate::abis::base_or_merge_rollup_public_inputs::BaseOrMergeRollupPublicInputs;
pub use private_base_rollup::PrivateBaseRollupInputs;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
use crate::{
abis::{
base_or_merge_rollup_public_inputs::{BASE_ROLLUP_TYPE, BaseOrMergeRollupPublicInputs},
constant_rollup_data::ConstantRollupData,
},
abis::base_or_merge_rollup_public_inputs::{BASE_ROLLUP_TYPE, BaseOrMergeRollupPublicInputs},
base::{
components::{
archive::perform_archive_membership_check, constants::validate_combined_constant_data,
fees::compute_fee_payer_fee_juice_balance_leaf_slot,
nullifier_tree::nullifier_tree_batch_insert, public_data_tree::public_data_tree_insert,
nullifier_tree::nullifier_tree_batch_insert, PrivateTubeDataValidator,
public_data_tree::public_data_tree_insert,
},
state_diff_hints::PrivateBaseStateDiffHints,
},
components::{append_tx_effects_for_blob, compute_kernel_out_hash},
};
use dep::types::{
abis::{
append_only_tree_snapshot::AppendOnlyTreeSnapshot,
append_only_tree_snapshot::AppendOnlyTreeSnapshot, constant_rollup_data::ConstantRollupData,
nullifier_leaf_preimage::NullifierLeafPreimage, public_data_write::PublicDataWrite,
sponge_blob::SpongeBlob, tube::PrivateTubeData,
},
constants::{
ARCHIVE_HEIGHT, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX, NOTE_HASH_SUBTREE_HEIGHT,
TUBE_VK_INDEX,
},
data::{hash::compute_public_data_tree_value, public_data_hint::PublicDataHint},
hash::silo_l2_to_l1_message,
Expand All @@ -32,7 +31,7 @@ use dep::types::{
traits::is_empty,
};

// global ALLOWED_PREVIOUS_CIRCUITS: [u32; 2] = [PRIVATE_KERNEL_EMPTY_INDEX, TUBE_VK_INDEX];
global ALLOWED_PREVIOUS_CIRCUITS: [u32; 1] = [TUBE_VK_INDEX];

pub struct PrivateBaseRollupInputs {
tube_data: PrivateTubeData,
Expand All @@ -55,10 +54,14 @@ impl PrivateBaseRollupInputs {
}

pub fn execute(self) -> BaseOrMergeRollupPublicInputs {
if !dep::std::runtime::is_unconstrained() {
self.tube_data.verify();
// TODO(#7410)
// self.tube_data.vk_data.validate_in_vk_tree(self.tube_data.public_inputs.constants.vk_tree_root, ALLOWED_PREVIOUS_CIRCUITS);
// TODO(#10311): There should be an empty base rollup.
// There's at least 1 nullifier for a tx. So gas_used won't be empty if the previous circuit is private_tail.
let is_empty_tube = self.tube_data.public_inputs.gas_used.is_empty();

let tube_data_validator = PrivateTubeDataValidator::new(self.tube_data);
tube_data_validator.verify_proof(ALLOWED_PREVIOUS_CIRCUITS);
if !is_empty_tube {
tube_data_validator.validate_with_rollup_data(self.constants);
}

let transaction_fee = self.compute_transaction_fee();
Expand Down Expand Up @@ -223,10 +226,7 @@ impl PrivateBaseRollupInputs {

mod tests {
use crate::{
abis::{
base_or_merge_rollup_public_inputs::BaseOrMergeRollupPublicInputs,
constant_rollup_data::ConstantRollupData,
},
abis::base_or_merge_rollup_public_inputs::BaseOrMergeRollupPublicInputs,
base::{
components::fees::compute_fee_payer_fee_juice_balance_leaf_slot,
private_base_rollup::PrivateBaseRollupInputs,
Expand All @@ -239,7 +239,8 @@ mod tests {
use dep::types::{
abis::{
accumulated_data::CombinedAccumulatedData,
append_only_tree_snapshot::AppendOnlyTreeSnapshot, gas::Gas, gas_fees::GasFees,
append_only_tree_snapshot::AppendOnlyTreeSnapshot,
constant_rollup_data::ConstantRollupData, gas::Gas, gas_fees::GasFees,
kernel_circuit_public_inputs::KernelCircuitPublicInputs,
nullifier_leaf_preimage::NullifierLeafPreimage, public_data_write::PublicDataWrite,
sponge_blob::SpongeBlob,
Expand Down Expand Up @@ -887,6 +888,8 @@ mod tests {
builder.tube_data.set_gas_used(100, 200);
builder.constants.global_variables.gas_fees.fee_per_da_gas = 1;
builder.constants.global_variables.gas_fees.fee_per_l2_gas = 1;
builder.tube_data.tx_context.gas_settings.max_fees_per_gas.fee_per_da_gas = 1;
builder.tube_data.tx_context.gas_settings.max_fees_per_gas.fee_per_l2_gas = 1;
let tx_fee = builder.compute_transaction_fee();
// builder.transaction_fee = tx_fee;
builder.tube_data.append_note_hashes_with_logs(NUM_NOTES);
Expand Down Expand Up @@ -1118,6 +1121,7 @@ mod tests {

// Set gas
builder.tube_data.gas_used = gas_used;
builder.tube_data.tx_context.gas_settings.max_fees_per_gas = gas_fees;
builder.constants.global_variables.gas_fees = gas_fees;

// Set fee payer
Expand Down Expand Up @@ -1167,6 +1171,7 @@ mod tests {

// Set gas
builder.tube_data.gas_used = gas_used;
builder.tube_data.tx_context.gas_settings.max_fees_per_gas = gas_fees;
builder.constants.global_variables.gas_fees = gas_fees;

// Set fee payer
Expand Down Expand Up @@ -1197,6 +1202,7 @@ mod tests {

// Set gas
builder.tube_data.gas_used = gas_used;
builder.tube_data.tx_context.gas_settings.max_fees_per_gas = gas_fees;
builder.constants.global_variables.gas_fees = gas_fees;

// Set fee payer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
use crate::{
abis::{
base_or_merge_rollup_public_inputs::{BASE_ROLLUP_TYPE, BaseOrMergeRollupPublicInputs},
constant_rollup_data::ConstantRollupData,
},
abis::base_or_merge_rollup_public_inputs::{BASE_ROLLUP_TYPE, BaseOrMergeRollupPublicInputs},
base::{
components::{
archive::perform_archive_membership_check, constants::validate_combined_constant_data,
nullifier_tree::nullifier_tree_batch_insert, public_data_tree::public_data_tree_insert,
PublicTubeDataValidator,
},
state_diff_hints::PublicBaseStateDiffHints,
},
Expand All @@ -18,6 +16,7 @@ use dep::types::{
append_only_tree_snapshot::AppendOnlyTreeSnapshot,
avm_circuit_public_inputs::AvmProofData,
combined_constant_data::CombinedConstantData,
constant_rollup_data::ConstantRollupData,
log_hash::ScopedLogHash,
nullifier_leaf_preimage::NullifierLeafPreimage,
public_data_write::PublicDataWrite,
Expand Down Expand Up @@ -92,11 +91,9 @@ impl PublicBaseRollupInputs {
}

pub fn execute(self) -> BaseOrMergeRollupPublicInputs {
if !dep::std::runtime::is_unconstrained() {
self.tube_data.verify();
// TODO(#7410)
// self.tube_data.vk_data.validate_in_vk_tree([TUBE_VK_INDEX]);
}
let tube_data_validator = PublicTubeDataValidator::new(self.tube_data);
tube_data_validator.verify_proof();
tube_data_validator.validate_with_rollup_data(self.constants);

// Warning: Fake verification! TODO(#8470)
// if !dep::std::runtime::is_unconstrained() {
Expand Down Expand Up @@ -263,10 +260,7 @@ impl PublicBaseRollupInputs {

mod tests {
use crate::{
abis::{
base_or_merge_rollup_public_inputs::BaseOrMergeRollupPublicInputs,
constant_rollup_data::ConstantRollupData,
},
abis::base_or_merge_rollup_public_inputs::BaseOrMergeRollupPublicInputs,
base::{
public_base_rollup::PublicBaseRollupInputs, state_diff_hints::PublicBaseStateDiffHints,
},
Expand All @@ -278,6 +272,7 @@ mod tests {
abis::{
accumulated_data::CombinedAccumulatedData,
append_only_tree_snapshot::AppendOnlyTreeSnapshot,
constant_rollup_data::ConstantRollupData,
nullifier_leaf_preimage::NullifierLeafPreimage, public_data_write::PublicDataWrite,
sponge_blob::SpongeBlob,
},
Expand All @@ -298,7 +293,11 @@ mod tests {
merkle_tree::MembershipWitness,
messaging::l2_to_l1_message::ScopedL2ToL1Message,
partial_state_reference::PartialStateReference,
tests::{fixture_builder::FixtureBuilder, fixtures, merkle_tree_utils::NonEmptyMerkleTree},
tests::{
fixture_builder::FixtureBuilder,
fixtures::{self, merkle_tree::generate_full_sha_tree},
merkle_tree_utils::NonEmptyMerkleTree,
},
traits::{Empty, is_empty},
utils::{
arrays::{array_concat, get_sorted_tuple::get_sorted_tuple},
Expand Down Expand Up @@ -1070,9 +1069,7 @@ mod tests {
);

// Since we fill the tree completely, we know to expect a full tree as below
let expected_tree = dep::types::merkle_tree::variable_merkle_tree::tests::generate_full_sha_tree(
siloed_l2_to_l1_msgs.storage(),
);
let expected_tree = generate_full_sha_tree(siloed_l2_to_l1_msgs.storage());
assert_eq(out_hash, expected_tree.get_root());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mod private_tube_data_validator_builder;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
mod validate_with_rollup_data;

use crate::base::components::PrivateTubeDataValidator;
use dep::types::tests::fixture_builder::FixtureBuilder;

pub struct PrivateTubeDataValidatorBuilder {
pub tube_data: FixtureBuilder,
pub rollup_data: FixtureBuilder,
}

impl PrivateTubeDataValidatorBuilder {
pub fn new() -> Self {
PrivateTubeDataValidatorBuilder {
tube_data: FixtureBuilder::new(),
rollup_data: FixtureBuilder::new(),
}
}

pub fn validate_with_rollup_data(self) {
let tube_data = self.tube_data.to_private_tube_data();
let rollup_data = self.rollup_data.to_constant_rollup_data();
PrivateTubeDataValidator::new(tube_data).validate_with_rollup_data(rollup_data);
}
}
Loading

0 comments on commit 33ede6e

Please sign in to comment.