-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(root): root rollup native implementation wip (#128)
* intial root * feat: pass on snaphots * fix: update naming for consistency + extend root rollup logic * extend root test * fix: index
- Loading branch information
Showing
12 changed files
with
794 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
cpp/src/aztec3/circuits/abis/rollup/base/previous_rollup_data.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#pragma once | ||
#include "aztec3/circuits/abis/append_only_tree_snapshot.hpp" | ||
#include "aztec3/circuits/abis/membership_witness.hpp" | ||
#include "aztec3/circuits/abis/rollup/base/base_rollup_public_inputs.hpp" | ||
#include "aztec3/constants.hpp" | ||
#include <aztec3/utils/types/native_types.hpp> | ||
#include <aztec3/utils/types/circuit_types.hpp> | ||
#include <aztec3/utils/types/convert.hpp> | ||
#include <type_traits> | ||
|
||
namespace aztec3::circuits::abis { | ||
|
||
using aztec3::utils::types::CircuitTypes; | ||
using aztec3::utils::types::NativeTypes; | ||
using std::is_same; | ||
|
||
template <typename NCT> struct PreviousRollupData { | ||
BaseRollupPublicInputs<NCT> base_rollup_public_inputs; | ||
|
||
NativeTypes::Proof proof; | ||
std::shared_ptr<NativeTypes::VK> vk; | ||
NativeTypes::uint32 vk_index; | ||
MembershipWitness<NCT, ROLLUP_VK_TREE_HEIGHT> vk_sibling_path; | ||
|
||
bool operator==(PreviousRollupData<NCT> const&) const = default; | ||
}; | ||
|
||
template <typename NCT> void read(uint8_t const*& it, PreviousRollupData<NCT>& obj) | ||
{ | ||
using serialize::read; | ||
|
||
read(it, obj.base_rollup_public_inputs); | ||
read(it, obj.proof); | ||
read(it, obj.vk); | ||
read(it, obj.vk_index); | ||
read(it, obj.vk_sibling_path); | ||
}; | ||
|
||
template <typename NCT> void write(std::vector<uint8_t>& buf, PreviousRollupData<NCT> const& obj) | ||
{ | ||
using serialize::write; | ||
|
||
write(buf, obj.base_rollup_public_inputs); | ||
write(buf, obj.proof); | ||
write(buf, *obj.vk); | ||
write(buf, obj.vk_index); | ||
write(buf, obj.vk_sibling_path); | ||
}; | ||
|
||
template <typename NCT> std::ostream& operator<<(std::ostream& os, PreviousRollupData<NCT> const& obj) | ||
{ | ||
return os << "merge_rollup_public_inputs: " << obj.base_rollup_public_inputs << "\n" | ||
<< "proof: " << obj.proof << "\n" | ||
<< "vk: " << obj.vk << "\n" | ||
<< "vk_index: " << obj.vk_index << "\n" | ||
<< "vk_sibling_path: " << obj.vk_sibling_path << "\n"; | ||
}; | ||
|
||
} // namespace aztec3::circuits::abis |
54 changes: 54 additions & 0 deletions
54
cpp/src/aztec3/circuits/abis/rollup/root/root_rollup_inputs.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
|
||
#pragma once | ||
#include "aztec3/circuits/abis/append_only_tree_snapshot.hpp" | ||
#include "aztec3/circuits/abis/rollup/base/previous_rollup_data.hpp" | ||
#include "aztec3/constants.hpp" | ||
#include <aztec3/utils/types/native_types.hpp> | ||
#include <aztec3/utils/types/circuit_types.hpp> | ||
#include <aztec3/utils/types/convert.hpp> | ||
#include <ostream> | ||
|
||
namespace aztec3::circuits::abis { | ||
|
||
using aztec3::utils::types::CircuitTypes; | ||
using aztec3::utils::types::NativeTypes; | ||
|
||
template <typename NCT> struct RootRollupInputs { | ||
typedef typename NCT::fr fr; | ||
|
||
// All below are shared between the base and merge rollups | ||
std::array<PreviousRollupData<NCT>, 2> previous_rollup_data; | ||
|
||
std::array<fr, PRIVATE_DATA_TREE_ROOTS_TREE_HEIGHT> new_historic_private_data_tree_root_sibling_path; | ||
std::array<fr, CONTRACT_TREE_ROOTS_TREE_HEIGHT> new_historic_contract_tree_root_sibling_path; | ||
|
||
bool operator==(RootRollupInputs<NCT> const&) const = default; | ||
}; | ||
|
||
template <typename NCT> void read(uint8_t const*& it, RootRollupInputs<NCT>& obj) | ||
{ | ||
using serialize::read; | ||
|
||
read(it, obj.previous_rollup_data); | ||
read(it, obj.new_historic_private_data_tree_roots); | ||
read(it, obj.new_historic_contract_tree_roots); | ||
}; | ||
|
||
template <typename NCT> void write(std::vector<uint8_t>& buf, RootRollupInputs<NCT> const& obj) | ||
{ | ||
using serialize::write; | ||
|
||
write(buf, obj.previous_rollup_data); | ||
write(buf, obj.new_historic_private_data_tree_roots); | ||
write(buf, obj.new_historic_contract_tree_roots); | ||
}; | ||
|
||
template <typename NCT> std::ostream& operator<<(std::ostream& os, RootRollupInputs<NCT> const& obj) | ||
{ | ||
return os << "previous_rollup_data: " << obj.previous_rollup_data << "\n" | ||
<< "new_historic_private_data_tree_roots: " << obj.new_historic_private_data_tree_roots << "\n" | ||
<< "new_historic_contract_tree_roots: " << obj.new_historic_contract_tree_roots << "\n"; | ||
} | ||
|
||
} // namespace aztec3::circuits::abis |
97 changes: 97 additions & 0 deletions
97
cpp/src/aztec3/circuits/abis/rollup/root/root_rollup_public_inputs.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
|
||
#pragma once | ||
#include "aztec3/circuits/abis/append_only_tree_snapshot.hpp" | ||
#include <aztec3/utils/types/native_types.hpp> | ||
#include <aztec3/utils/types/circuit_types.hpp> | ||
#include <aztec3/utils/types/convert.hpp> | ||
#include <ostream> | ||
|
||
namespace aztec3::circuits::abis { | ||
|
||
using aztec3::utils::types::CircuitTypes; | ||
using aztec3::utils::types::NativeTypes; | ||
|
||
template <typename NCT> struct RootRollupPublicInputs { | ||
typedef typename NCT::fr fr; | ||
typedef typename NCT::AggregationObject AggregationObject; | ||
|
||
// All below are shared between the base and merge rollups | ||
AggregationObject end_aggregation_object; | ||
|
||
AppendOnlyTreeSnapshot<NCT> start_private_data_tree_snapshot; | ||
AppendOnlyTreeSnapshot<NCT> end_private_data_tree_snapshot; | ||
|
||
AppendOnlyTreeSnapshot<NCT> start_nullifier_tree_snapshot; | ||
AppendOnlyTreeSnapshot<NCT> end_nullifier_tree_snapshot; | ||
|
||
AppendOnlyTreeSnapshot<NCT> start_contract_tree_snapshot; | ||
AppendOnlyTreeSnapshot<NCT> end_contract_tree_snapshot; | ||
|
||
AppendOnlyTreeSnapshot<NCT> start_tree_of_historic_private_data_tree_roots_snapshot; | ||
AppendOnlyTreeSnapshot<NCT> end_tree_of_historic_private_data_tree_roots_snapshot; | ||
|
||
AppendOnlyTreeSnapshot<NCT> start_tree_of_historic_contract_tree_roots_snapshot; | ||
AppendOnlyTreeSnapshot<NCT> end_tree_of_historic_contract_tree_roots_snapshot; | ||
|
||
std::array<fr, 2> calldata_hash; | ||
|
||
bool operator==(RootRollupPublicInputs<NCT> const&) const = default; | ||
}; | ||
|
||
template <typename NCT> void read(uint8_t const*& it, RootRollupPublicInputs<NCT>& obj) | ||
{ | ||
using serialize::read; | ||
|
||
read(it, obj.end_aggregation_object); | ||
read(it, obj.start_private_data_tree_snapshot); | ||
read(it, obj.end_private_data_tree_snapshot); | ||
read(it, obj.start_nullifier_tree_snapshot); | ||
read(it, obj.end_nullifier_tree_snapshot); | ||
read(it, obj.start_contract_tree_snapshot); | ||
read(it, obj.end_contract_tree_snapshot); | ||
read(it, obj.start_tree_of_historic_private_data_tree_roots_snapshot); | ||
read(it, obj.end_tree_of_historic_private_data_tree_roots_snapshot); | ||
read(it, obj.start_tree_of_historic_contract_tree_roots_snapshot); | ||
read(it, obj.end_tree_of_historic_contract_tree_roots_snapshot); | ||
read(it, obj.calldata_hash); | ||
}; | ||
|
||
template <typename NCT> void write(std::vector<uint8_t>& buf, RootRollupPublicInputs<NCT> const& obj) | ||
{ | ||
using serialize::write; | ||
|
||
write(buf, obj.end_aggregation_object); | ||
write(buf, obj.start_private_data_tree_snapshot); | ||
write(buf, obj.end_private_data_tree_snapshot); | ||
write(buf, obj.start_nullifier_tree_snapshot); | ||
write(buf, obj.end_nullifier_tree_snapshot); | ||
write(buf, obj.start_contract_tree_snapshot); | ||
write(buf, obj.end_contract_tree_snapshot); | ||
write(buf, obj.start_tree_of_historic_private_data_tree_roots_snapshot); | ||
write(buf, obj.end_tree_of_historic_private_data_tree_roots_snapshot); | ||
write(buf, obj.start_tree_of_historic_contract_tree_roots_snapshot); | ||
write(buf, obj.end_tree_of_historic_contract_tree_roots_snapshot); | ||
write(buf, obj.calldata_hash); | ||
}; | ||
|
||
template <typename NCT> std::ostream& operator<<(std::ostream& os, RootRollupPublicInputs<NCT> const& obj) | ||
{ | ||
return os << "end_aggregation_object: " << obj.end_aggregation_object << "\n" | ||
<< "start_private_data_tree_snapshot: " << obj.start_private_data_tree_snapshot << "\n" | ||
<< "end_private_data_tree_snapshot: " << obj.end_private_data_tree_snapshot << "\n" | ||
<< "start_nullifier_tree_snapshot: " << obj.start_nullifier_tree_snapshot << "\n" | ||
<< "end_nullifier_tree_snapshot: " << obj.end_nullifier_tree_snapshot << "\n" | ||
<< "start_contract_tree_snapshot: " << obj.start_contract_tree_snapshot << "\n" | ||
<< "end_contract_tree_snapshot: " << obj.end_contract_tree_snapshot << "\n" | ||
<< "start_tree_of_historic_private_data_tree_roots_snapshot: " | ||
<< obj.start_tree_of_historic_private_data_tree_roots_snapshot << "\n" | ||
<< "end_tree_of_historic_private_data_tree_roots_snapshot: " | ||
<< obj.end_tree_of_historic_private_data_tree_roots_snapshot << "\n" | ||
<< "start_tree_of_historic_contract_tree_roots_snapshot: " | ||
<< obj.start_tree_of_historic_contract_tree_roots_snapshot << "\n" | ||
<< "end_tree_of_historic_contract_tree_roots_snapshot: " | ||
<< obj.end_tree_of_historic_contract_tree_roots_snapshot << "\n" | ||
<< "calldata_hash: " << obj.calldata_hash << "\n"; | ||
}; | ||
|
||
} // namespace aztec3::circuits::abis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
barretenberg_module( | ||
aztec3_circuits_rollup | ||
aztec3_circuits_kernel | ||
barretenberg | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.