From 237415749e23fb3da48e3bfb8a66c90b69cf33ea Mon Sep 17 00:00:00 2001 From: benesjan Date: Mon, 4 Dec 2023 16:05:11 +0000 Subject: [PATCH] renaming state provider --- .../circuits/abis/historic_block_data.hpp | 139 ------------------ yarn-project/types/src/interfaces/index.ts | 2 +- ...ate_provider.ts => state_info_provider.ts} | 0 3 files changed, 1 insertion(+), 140 deletions(-) delete mode 100644 circuits/cpp/src/aztec3/circuits/abis/historic_block_data.hpp rename yarn-project/types/src/interfaces/{state_provider.ts => state_info_provider.ts} (100%) diff --git a/circuits/cpp/src/aztec3/circuits/abis/historic_block_data.hpp b/circuits/cpp/src/aztec3/circuits/abis/historic_block_data.hpp deleted file mode 100644 index 7d07d16fe0a5..000000000000 --- a/circuits/cpp/src/aztec3/circuits/abis/historic_block_data.hpp +++ /dev/null @@ -1,139 +0,0 @@ -#pragma once - -#include "aztec3/circuits/abis/append_only_tree_snapshot.hpp" -#include "aztec3/circuits/abis/global_variables.hpp" -#include "aztec3/circuits/hash.hpp" -#include "aztec3/utils/types/circuit_types.hpp" -#include "aztec3/utils/types/convert.hpp" -#include "aztec3/utils/types/native_types.hpp" - -#include - -#include - -namespace aztec3::circuits::abis { - -using aztec3::utils::types::CircuitTypes; -using aztec3::utils::types::NativeTypes; -using std::is_same; - -template struct BlockHeader { - using fr = typename NCT::fr; - using boolean = typename NCT::boolean; - - // Private data - fr note_hash_tree_root = 0; - fr nullifier_tree_root = 0; - fr contract_tree_root = 0; - fr l1_to_l2_messages_tree_root = 0; - fr blocks_tree_root = 0; - fr private_kernel_vk_tree_root = 0; // TODO: future enhancement - - // Public data - fr public_data_tree_root = 0; - fr global_variables_hash = 0; - - // for serialization, update with new fields - MSGPACK_FIELDS(note_hash_tree_root, - nullifier_tree_root, - contract_tree_root, - l1_to_l2_messages_tree_root, - blocks_tree_root, - private_kernel_vk_tree_root, - public_data_tree_root, - global_variables_hash); - - boolean operator==(BlockHeader const& other) const - { - return note_hash_tree_root == other.note_hash_tree_root && nullifier_tree_root == other.nullifier_tree_root && - contract_tree_root == other.contract_tree_root && - l1_to_l2_messages_tree_root == other.l1_to_l2_messages_tree_root && - blocks_tree_root == other.blocks_tree_root && - private_kernel_vk_tree_root == other.private_kernel_vk_tree_root && - public_data_tree_root == other.public_data_tree_root && - global_variables_hash == other.global_variables_hash; - }; - - template void assert_is_zero() - { - static_assert((std::is_same, NCT>::value)); - - note_hash_tree_root.assert_is_zero(); - nullifier_tree_root.assert_is_zero(); - contract_tree_root.assert_is_zero(); - l1_to_l2_messages_tree_root.assert_is_zero(); - blocks_tree_root.assert_is_zero(); - private_kernel_vk_tree_root.assert_is_zero(); - public_data_tree_root.assert_is_zero(); - global_variables_hash.assert_is_zero(); - } - - template BlockHeader> to_circuit_type(Builder& builder) const - { - static_assert((std::is_same::value)); - - // Capture the circuit builder: - auto to_ct = [&](auto& e) { return aztec3::utils::types::to_ct(builder, e); }; - - BlockHeader> data = { - to_ct(note_hash_tree_root), to_ct(nullifier_tree_root), to_ct(contract_tree_root), - to_ct(l1_to_l2_messages_tree_root), to_ct(blocks_tree_root), to_ct(private_kernel_vk_tree_root), - to_ct(public_data_tree_root), to_ct(global_variables_hash), - }; - - return data; - }; - - template BlockHeader to_native_type() const - { - static_assert(std::is_same, NCT>::value); - auto to_nt = [&](auto& e) { return aztec3::utils::types::to_nt(e); }; - - BlockHeader data = { - to_nt(note_hash_tree_root), to_nt(nullifier_tree_root), to_nt(contract_tree_root), - to_nt(l1_to_l2_messages_tree_root), to_nt(blocks_tree_root), to_nt(private_kernel_vk_tree_root), - to_nt(public_data_tree_root), to_nt(global_variables_hash), - }; - - return data; - }; - - void set_public() - { - static_assert(!(std::is_same::value)); - - note_hash_tree_root.set_public(); - nullifier_tree_root.set_public(); - contract_tree_root.set_public(); - l1_to_l2_messages_tree_root.set_public(); - blocks_tree_root.set_public(); - private_kernel_vk_tree_root.set_public(); - public_data_tree_root.set_public(); - global_variables_hash.set_public(); - } - - std::array to_array() const - { - return { note_hash_tree_root, - nullifier_tree_root, - contract_tree_root, - l1_to_l2_messages_tree_root, - blocks_tree_root, // TODO(#3441) Note private_kernel_vk_tree_root, is not included yet as - // it is not present in noir, - public_data_tree_root, - global_variables_hash }; - } - - - fr hash() - { - return compute_block_hash(global_variables_hash, - note_hash_tree_root, - nullifier_tree_root, - contract_tree_root, - l1_to_l2_messages_tree_root, - public_data_tree_root); - } -}; - -} // namespace aztec3::circuits::abis diff --git a/yarn-project/types/src/interfaces/index.ts b/yarn-project/types/src/interfaces/index.ts index f351287cab22..e0cbc82677c1 100644 --- a/yarn-project/types/src/interfaces/index.ts +++ b/yarn-project/types/src/interfaces/index.ts @@ -1,4 +1,4 @@ -export * from './state_provider.js'; +export * from './state_info_provider.js'; export * from './hasher.js'; export * from './aztec-node.js'; export * from './pxe.js'; diff --git a/yarn-project/types/src/interfaces/state_provider.ts b/yarn-project/types/src/interfaces/state_info_provider.ts similarity index 100% rename from yarn-project/types/src/interfaces/state_provider.ts rename to yarn-project/types/src/interfaces/state_info_provider.ts