Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
types.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <utility>
5#include <variant>
6
13
14namespace bb::world_state {
15
16using namespace bb::crypto::merkle_tree;
17
25
26const uint64_t CANONICAL_FORK_ID = 0;
27const uint64_t NUM_TREES = 5;
28
29std::string getMerkleTreeName(MerkleTreeId id);
30
32using StateReference = std::unordered_map<MerkleTreeId, TreeStateReference>;
33
44
51
63 WorldStateStatusSummary(WorldStateStatusSummary&& other) noexcept { *this = std::move(other); }
64
66 {
67 if (this != &other) {
68 *this = other;
69 }
70 return *this;
71 }
72
74
76
83
84 friend std::ostream& operator<<(std::ostream& os, const WorldStateStatusSummary& status)
85 {
86 os << "unfinalizedBlockNumber: " << status.unfinalizedBlockNumber
87 << ", finalizedBlockNumber: " << status.finalizedBlockNumber
88 << ", oldestHistoricalBlock: " << status.oldestHistoricalBlock
89 << ", treesAreSynched: " << status.treesAreSynched;
90 return os;
91 }
92};
93
100
102
103 WorldStateDBStats() = default;
104 WorldStateDBStats(const TreeDBStats& noteHashStats,
105 const TreeDBStats& messageStats,
106 const TreeDBStats& archiveStats,
107 const TreeDBStats& publicDataStats,
108 const TreeDBStats& nullifierStats)
109 : noteHashTreeStats(noteHashStats)
110 , messageTreeStats(messageStats)
111 , archiveTreeStats(archiveStats)
112 , publicDataTreeStats(publicDataStats)
113 , nullifierTreeStats(nullifierStats)
114 {}
115 WorldStateDBStats(const WorldStateDBStats& other) = default;
116 WorldStateDBStats(WorldStateDBStats&& other) noexcept { *this = std::move(other); }
117
119 {
120 if (this != &other) {
121 noteHashTreeStats = std::move(other.noteHashTreeStats);
122 messageTreeStats = std::move(other.messageTreeStats);
123 archiveTreeStats = std::move(other.archiveTreeStats);
124 publicDataTreeStats = std::move(other.publicDataTreeStats);
125 nullifierTreeStats = std::move(other.nullifierTreeStats);
126 }
127 return *this;
128 }
129
131
138
140
141 friend std::ostream& operator<<(std::ostream& os, const WorldStateDBStats& stats)
142 {
143 os << "Note hash tree stats " << stats.noteHashTreeStats << ", Message tree stats " << stats.messageTreeStats
144 << ", Archive tree stats " << stats.archiveTreeStats << ", Public Data tree stats "
145 << stats.publicDataTreeStats << ", Nullifier tree stats " << stats.nullifierTreeStats;
146 return os;
147 }
148};
149
156
158
159 WorldStateMeta() = default;
160 WorldStateMeta(const TreeMeta& noteHashMeta,
161 const TreeMeta& messageMeta,
162 const TreeMeta& archiveMeta,
163 const TreeMeta& publicDataMeta,
164 const TreeMeta& nullifierMeta)
165 : noteHashTreeMeta(noteHashMeta)
166 , messageTreeMeta(messageMeta)
167 , archiveTreeMeta(archiveMeta)
168 , publicDataTreeMeta(publicDataMeta)
169 , nullifierTreeMeta(nullifierMeta)
170 {}
171 WorldStateMeta(const WorldStateMeta& other) = default;
172 WorldStateMeta(WorldStateMeta&& other) noexcept { *this = std::move(other); }
173
175 {
176 if (this != &other) {
177 noteHashTreeMeta = std::move(other.noteHashTreeMeta);
178 messageTreeMeta = std::move(other.messageTreeMeta);
179 archiveTreeMeta = std::move(other.archiveTreeMeta);
180 publicDataTreeMeta = std::move(other.publicDataTreeMeta);
181 nullifierTreeMeta = std::move(other.nullifierTreeMeta);
182 }
183 return *this;
184 }
185
186 ~WorldStateMeta() = default;
187
188 bool operator==(const WorldStateMeta& other) const
189 {
193 }
194
195 WorldStateMeta& operator=(const WorldStateMeta& other) = default;
196
197 friend std::ostream& operator<<(std::ostream& os, const WorldStateMeta& stats)
198 {
199 os << "Note hash tree meta " << stats.noteHashTreeMeta << ", Message tree meta " << stats.messageTreeMeta
200 << ", Archive tree meta " << stats.archiveTreeMeta << ", Public Data tree meta " << stats.publicDataTreeMeta
201 << ", Nullifier tree meta " << stats.nullifierTreeMeta;
202 return os;
203 }
204};
205
210
212
222 WorldStateStatusFull(WorldStateStatusFull&& other) noexcept { *this = std::move(other); }
223
225 {
226 if (this != &other) {
227 summary = std::move(other.summary);
228 dbStats = std::move(other.dbStats);
229 meta = std::move(other.meta);
230 }
231 return *this;
232 }
233
235
237
238 bool operator==(const WorldStateStatusFull& other) const
239 {
240 return summary == other.summary && dbStats == other.dbStats && meta == other.meta;
241 }
242
243 friend std::ostream& operator<<(std::ostream& os, const WorldStateStatusFull& status)
244 {
245 os << "Summary: " << status.summary << ", DB Stats " << status.dbStats << ", Meta " << status.meta;
246 return os;
247 }
248};
249} // namespace bb::world_state
#define MSGPACK_FIELDS(...)
Definition msgpack.hpp:118
uint32_t block_number_t
Definition types.hpp:19
@ L1_TO_L2_MESSAGE_TREE
Definition types.hpp:22
std::pair< bb::fr, bb::crypto::merkle_tree::index_t > TreeStateReference
Definition types.hpp:31
const uint64_t CANONICAL_FORK_ID
Definition types.hpp:26
std::string getMerkleTreeName(MerkleTreeId id)
Definition types.cpp:6
std::unordered_map< MerkleTreeId, TreeStateReference > StateReference
Definition types.hpp:32
const uint64_t NUM_TREES
Definition types.hpp:27
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
WorldStateDBStats & operator=(const WorldStateDBStats &other)=default
WorldStateDBStats & operator=(WorldStateDBStats &&other) noexcept
Definition types.hpp:118
WorldStateDBStats(const TreeDBStats &noteHashStats, const TreeDBStats &messageStats, const TreeDBStats &archiveStats, const TreeDBStats &publicDataStats, const TreeDBStats &nullifierStats)
Definition types.hpp:104
bool operator==(const WorldStateDBStats &other) const
Definition types.hpp:132
MSGPACK_FIELDS(noteHashTreeStats, messageTreeStats, archiveTreeStats, publicDataTreeStats, nullifierTreeStats)
WorldStateDBStats(WorldStateDBStats &&other) noexcept
Definition types.hpp:116
friend std::ostream & operator<<(std::ostream &os, const WorldStateDBStats &stats)
Definition types.hpp:141
WorldStateDBStats(const WorldStateDBStats &other)=default
friend std::ostream & operator<<(std::ostream &os, const WorldStateMeta &stats)
Definition types.hpp:197
WorldStateMeta & operator=(WorldStateMeta &&other) noexcept
Definition types.hpp:174
MSGPACK_FIELDS(noteHashTreeMeta, messageTreeMeta, archiveTreeMeta, publicDataTreeMeta, nullifierTreeMeta)
WorldStateMeta(WorldStateMeta &&other) noexcept
Definition types.hpp:172
bool operator==(const WorldStateMeta &other) const
Definition types.hpp:188
WorldStateMeta(const WorldStateMeta &other)=default
WorldStateMeta & operator=(const WorldStateMeta &other)=default
WorldStateMeta(const TreeMeta &noteHashMeta, const TreeMeta &messageMeta, const TreeMeta &archiveMeta, const TreeMeta &publicDataMeta, const TreeMeta &nullifierMeta)
Definition types.hpp:160
static WorldStateRevision committed()
Definition types.hpp:41
static WorldStateRevision uncommitted()
Definition types.hpp:42
bool operator==(const WorldStateStatusFull &other) const
Definition types.hpp:238
WorldStateStatusFull(const WorldStateStatusSummary &summary, const WorldStateDBStats &dbStats, const WorldStateMeta &meta)
Definition types.hpp:214
WorldStateStatusFull(WorldStateStatusFull &&other) noexcept
Definition types.hpp:222
WorldStateStatusSummary summary
Definition types.hpp:207
WorldStateStatusFull & operator=(const WorldStateStatusFull &other)=default
friend std::ostream & operator<<(std::ostream &os, const WorldStateStatusFull &status)
Definition types.hpp:243
MSGPACK_FIELDS(summary, dbStats, meta)
WorldStateStatusFull & operator=(WorldStateStatusFull &&other) noexcept
Definition types.hpp:224
WorldStateStatusFull(const WorldStateStatusFull &other)=default
friend std::ostream & operator<<(std::ostream &os, const WorldStateStatusSummary &status)
Definition types.hpp:84
MSGPACK_FIELDS(unfinalizedBlockNumber, finalizedBlockNumber, oldestHistoricalBlock, treesAreSynched)
WorldStateStatusSummary(const WorldStateStatusSummary &other)=default
WorldStateStatusSummary & operator=(const WorldStateStatusSummary &other)=default
WorldStateStatusSummary(const index_t &unfinalizedBlockNumber, const index_t &finalizedBlockNumber, const index_t &oldestHistoricBlock, bool treesAreSynched)
Definition types.hpp:53
WorldStateStatusSummary(WorldStateStatusSummary &&other) noexcept
Definition types.hpp:63
WorldStateStatusSummary & operator=(WorldStateStatusSummary &&other) noexcept
Definition types.hpp:65
bool operator==(const WorldStateStatusSummary &other) const
Definition types.hpp:77