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
46
53
65 WorldStateStatusSummary(WorldStateStatusSummary&& other) noexcept { *this = std::move(other); }
66
68 {
69 if (this != &other) {
70 *this = other;
71 }
72 return *this;
73 }
74
76
78
85
86 friend std::ostream& operator<<(std::ostream& os, const WorldStateStatusSummary& status)
87 {
88 os << "unfinalizedBlockNumber: " << status.unfinalizedBlockNumber
89 << ", finalizedBlockNumber: " << status.finalizedBlockNumber
90 << ", oldestHistoricalBlock: " << status.oldestHistoricalBlock
91 << ", treesAreSynched: " << status.treesAreSynched;
92 return os;
93 }
94};
95
102
104
105 WorldStateDBStats() = default;
106 WorldStateDBStats(const TreeDBStats& noteHashStats,
107 const TreeDBStats& messageStats,
108 const TreeDBStats& archiveStats,
109 const TreeDBStats& publicDataStats,
110 const TreeDBStats& nullifierStats)
111 : noteHashTreeStats(noteHashStats)
112 , messageTreeStats(messageStats)
113 , archiveTreeStats(archiveStats)
114 , publicDataTreeStats(publicDataStats)
115 , nullifierTreeStats(nullifierStats)
116 {}
117 WorldStateDBStats(const WorldStateDBStats& other) = default;
118 WorldStateDBStats(WorldStateDBStats&& other) noexcept { *this = std::move(other); }
119
121 {
122 if (this != &other) {
123 noteHashTreeStats = std::move(other.noteHashTreeStats);
124 messageTreeStats = std::move(other.messageTreeStats);
125 archiveTreeStats = std::move(other.archiveTreeStats);
126 publicDataTreeStats = std::move(other.publicDataTreeStats);
127 nullifierTreeStats = std::move(other.nullifierTreeStats);
128 }
129 return *this;
130 }
131
133
140
142
143 friend std::ostream& operator<<(std::ostream& os, const WorldStateDBStats& stats)
144 {
145 os << "Note hash tree stats " << stats.noteHashTreeStats << ", Message tree stats " << stats.messageTreeStats
146 << ", Archive tree stats " << stats.archiveTreeStats << ", Public Data tree stats "
147 << stats.publicDataTreeStats << ", Nullifier tree stats " << stats.nullifierTreeStats;
148 return os;
149 }
150};
151
158
160
161 WorldStateMeta() = default;
162 WorldStateMeta(const TreeMeta& noteHashMeta,
163 const TreeMeta& messageMeta,
164 const TreeMeta& archiveMeta,
165 const TreeMeta& publicDataMeta,
166 const TreeMeta& nullifierMeta)
167 : noteHashTreeMeta(noteHashMeta)
168 , messageTreeMeta(messageMeta)
169 , archiveTreeMeta(archiveMeta)
170 , publicDataTreeMeta(publicDataMeta)
171 , nullifierTreeMeta(nullifierMeta)
172 {}
173 WorldStateMeta(const WorldStateMeta& other) = default;
174 WorldStateMeta(WorldStateMeta&& other) noexcept { *this = std::move(other); }
175
177 {
178 if (this != &other) {
179 noteHashTreeMeta = std::move(other.noteHashTreeMeta);
180 messageTreeMeta = std::move(other.messageTreeMeta);
181 archiveTreeMeta = std::move(other.archiveTreeMeta);
182 publicDataTreeMeta = std::move(other.publicDataTreeMeta);
183 nullifierTreeMeta = std::move(other.nullifierTreeMeta);
184 }
185 return *this;
186 }
187
188 ~WorldStateMeta() = default;
189
190 bool operator==(const WorldStateMeta& other) const
191 {
195 }
196
197 WorldStateMeta& operator=(const WorldStateMeta& other) = default;
198
199 friend std::ostream& operator<<(std::ostream& os, const WorldStateMeta& stats)
200 {
201 os << "Note hash tree meta " << stats.noteHashTreeMeta << ", Message tree meta " << stats.messageTreeMeta
202 << ", Archive tree meta " << stats.archiveTreeMeta << ", Public Data tree meta " << stats.publicDataTreeMeta
203 << ", Nullifier tree meta " << stats.nullifierTreeMeta;
204 return os;
205 }
206};
207
212
214
224 WorldStateStatusFull(WorldStateStatusFull&& other) noexcept { *this = std::move(other); }
225
227 {
228 if (this != &other) {
229 summary = std::move(other.summary);
230 dbStats = std::move(other.dbStats);
231 meta = std::move(other.meta);
232 }
233 return *this;
234 }
235
237
239
240 bool operator==(const WorldStateStatusFull& other) const
241 {
242 return summary == other.summary && dbStats == other.dbStats && meta == other.meta;
243 }
244
245 friend std::ostream& operator<<(std::ostream& os, const WorldStateStatusFull& status)
246 {
247 os << "Summary: " << status.summary << ", DB Stats " << status.dbStats << ", Meta " << status.meta;
248 return os;
249 }
250};
251} // namespace bb::world_state
#define MSGPACK_FIELDS(...)
Definition msgpack.hpp:121
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:120
WorldStateDBStats(const TreeDBStats &noteHashStats, const TreeDBStats &messageStats, const TreeDBStats &archiveStats, const TreeDBStats &publicDataStats, const TreeDBStats &nullifierStats)
Definition types.hpp:106
bool operator==(const WorldStateDBStats &other) const
Definition types.hpp:134
MSGPACK_FIELDS(noteHashTreeStats, messageTreeStats, archiveTreeStats, publicDataTreeStats, nullifierTreeStats)
WorldStateDBStats(WorldStateDBStats &&other) noexcept
Definition types.hpp:118
friend std::ostream & operator<<(std::ostream &os, const WorldStateDBStats &stats)
Definition types.hpp:143
WorldStateDBStats(const WorldStateDBStats &other)=default
friend std::ostream & operator<<(std::ostream &os, const WorldStateMeta &stats)
Definition types.hpp:199
WorldStateMeta & operator=(WorldStateMeta &&other) noexcept
Definition types.hpp:176
MSGPACK_FIELDS(noteHashTreeMeta, messageTreeMeta, archiveTreeMeta, publicDataTreeMeta, nullifierTreeMeta)
WorldStateMeta(WorldStateMeta &&other) noexcept
Definition types.hpp:174
bool operator==(const WorldStateMeta &other) const
Definition types.hpp:190
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:162
static WorldStateRevision committed()
Definition types.hpp:41
bool operator==(const WorldStateRevision &other) const =default
static WorldStateRevision uncommitted()
Definition types.hpp:42
bool operator==(const WorldStateStatusFull &other) const
Definition types.hpp:240
WorldStateStatusFull(const WorldStateStatusSummary &summary, const WorldStateDBStats &dbStats, const WorldStateMeta &meta)
Definition types.hpp:216
WorldStateStatusFull(WorldStateStatusFull &&other) noexcept
Definition types.hpp:224
WorldStateStatusSummary summary
Definition types.hpp:209
WorldStateStatusFull & operator=(const WorldStateStatusFull &other)=default
friend std::ostream & operator<<(std::ostream &os, const WorldStateStatusFull &status)
Definition types.hpp:245
MSGPACK_FIELDS(summary, dbStats, meta)
WorldStateStatusFull & operator=(WorldStateStatusFull &&other) noexcept
Definition types.hpp:226
WorldStateStatusFull(const WorldStateStatusFull &other)=default
friend std::ostream & operator<<(std::ostream &os, const WorldStateStatusSummary &status)
Definition types.hpp:86
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:55
WorldStateStatusSummary(WorldStateStatusSummary &&other) noexcept
Definition types.hpp:65
WorldStateStatusSummary & operator=(WorldStateStatusSummary &&other) noexcept
Definition types.hpp:67
bool operator==(const WorldStateStatusSummary &other) const
Definition types.hpp:79