@@ -39,6 +39,7 @@ WorldState::WorldState(uint64_t thread_pool_size,
3939 const std::unordered_map<MerkleTreeId, uint32_t >& tree_heights,
4040 const std::unordered_map<MerkleTreeId, index_t >& tree_prefill,
4141 const std::vector<PublicDataLeafValue>& prefilled_public_data,
42+ const std::vector<bb::fr>& prefilled_nullifiers,
4243 uint32_t initial_header_generator_point,
4344 uint64_t genesis_timestamp,
4445 bool ephemeral)
@@ -51,7 +52,7 @@ WorldState::WorldState(uint64_t thread_pool_size,
5152{
5253 // We set the max readers to be high, at least the number of given threads or the default if higher
5354 uint64_t maxReaders = std::max (thread_pool_size, DEFAULT_MIN_NUMBER_OF_READERS );
54- create_canonical_fork (data_dir, map_size, prefilled_public_data, maxReaders, ephemeral);
55+ create_canonical_fork (data_dir, map_size, prefilled_public_data, prefilled_nullifiers, maxReaders, ephemeral);
5556 try {
5657 attempt_tree_resync ();
5758 } catch (std::exception& e) {
@@ -73,6 +74,7 @@ WorldState::WorldState(uint64_t thread_pool_size,
7374 tree_heights,
7475 tree_prefill,
7576 std::vector<PublicDataLeafValue>(),
77+ std::vector<bb::fr>(),
7678 initial_header_generator_point,
7779 genesis_timestamp,
7880 ephemeral)
@@ -84,6 +86,7 @@ WorldState::WorldState(uint64_t thread_pool_size,
8486 const std::unordered_map<MerkleTreeId, uint32_t >& tree_heights,
8587 const std::unordered_map<MerkleTreeId, index_t >& tree_prefill,
8688 const std::vector<PublicDataLeafValue>& prefilled_public_data,
89+ const std::vector<bb::fr>& prefilled_nullifiers,
8790 uint32_t initial_header_generator_point,
8891 uint64_t genesis_timestamp,
8992 bool ephemeral)
@@ -99,6 +102,7 @@ WorldState::WorldState(uint64_t thread_pool_size,
99102 tree_heights,
100103 tree_prefill,
101104 prefilled_public_data,
105+ prefilled_nullifiers,
102106 initial_header_generator_point,
103107 genesis_timestamp,
104108 ephemeral)
@@ -118,6 +122,7 @@ WorldState::WorldState(uint64_t thread_pool_size,
118122 tree_heights,
119123 tree_prefill,
120124 std::vector<PublicDataLeafValue>(),
125+ std::vector<bb::fr>(),
121126 initial_header_generator_point,
122127 genesis_timestamp,
123128 ephemeral)
@@ -126,6 +131,7 @@ WorldState::WorldState(uint64_t thread_pool_size,
126131void WorldState::create_canonical_fork (const std::string& dataDir,
127132 const std::unordered_map<MerkleTreeId, uint64_t >& dbSize,
128133 const std::vector<PublicDataLeafValue>& prefilled_public_data,
134+ const std::vector<bb::fr>& prefilled_nullifiers,
129135 uint64_t maxReaders,
130136 bool ephemeral)
131137{
@@ -148,9 +154,15 @@ void WorldState::create_canonical_fork(const std::string& dataDir,
148154 {
149155 uint32_t levels = _tree_heights.at (MerkleTreeId::NULLIFIER_TREE );
150156 index_t initial_size = _initial_tree_size.at (MerkleTreeId::NULLIFIER_TREE );
157+ std::vector<NullifierLeafValue> prefilled_nullifier_leaves;
158+ prefilled_nullifier_leaves.reserve (prefilled_nullifiers.size ());
159+ for (const auto & nullifier : prefilled_nullifiers) {
160+ prefilled_nullifier_leaves.emplace_back (nullifier);
161+ }
151162 auto store = std::make_unique<NullifierStore>(
152163 getMerkleTreeName (MerkleTreeId::NULLIFIER_TREE ), levels, _persistentStores->nullifierStore );
153- auto tree = std::make_unique<NullifierTree>(std::move (store), _workers, initial_size);
164+ auto tree =
165+ std::make_unique<NullifierTree>(std::move (store), _workers, initial_size, prefilled_nullifier_leaves);
154166 fork->_trees .insert ({ MerkleTreeId::NULLIFIER_TREE , TreeWithStore (std::move (tree)) });
155167 }
156168 {
0 commit comments