Skip to content
Merged
Show file tree
Hide file tree
Changes from 135 commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
296088f
Enforce fee payer in protocol circuits.
LeilaWang Jan 11, 2025
329dc58
Remove empty fee payer assumption in avm trace.
LeilaWang Jan 13, 2025
e334f25
Allow to prefill public data tree in the world state.
LeilaWang Jan 18, 2025
eca81fc
Merge remote-tracking branch 'origin/master' into lw/fee_payer
LeilaWang Jan 18, 2025
b2d2392
feat: Add update contract fn and test contracts
sirasistant Jan 20, 2025
867fc56
fix
sirasistant Jan 20, 2025
4fd2c2a
Merge branch 'master' into arv/set_code
sirasistant Jan 21, 2025
4bda8c7
kernel changes
sirasistant Jan 23, 2025
c3f004b
fixes
sirasistant Jan 23, 2025
953d483
fix
sirasistant Jan 23, 2025
1beef36
wip
sirasistant Jan 24, 2025
171bd7b
Enforce fees.
LeilaWang Jan 24, 2025
f074daa
changes
sirasistant Jan 24, 2025
5efaeed
Merge branch 'master' into arv/set_code
sirasistant Jan 24, 2025
4e72de9
Merge remote-tracking branch 'origin/master' into lw/fee_payer
LeilaWang Jan 24, 2025
8de83e3
fix
sirasistant Jan 27, 2025
a6f2e8a
Merge branch 'master' into arv/set_code
sirasistant Jan 27, 2025
8ba771c
bug repro
sirasistant Jan 27, 2025
eae28a0
bug report
sirasistant Jan 27, 2025
d1ea8dc
added noop to bypass bug
sirasistant Jan 27, 2025
038f508
Merge branch 'master' into arv/set_code
sirasistant Jan 27, 2025
a4dfbdc
Private function updates
sirasistant Jan 28, 2025
2dfc0cc
towards public updates
sirasistant Jan 28, 2025
93e5a61
update memory store
sirasistant Jan 29, 2025
1ed42d2
fix archiving
sirasistant Jan 29, 2025
cbd863d
add originalClassId
sirasistant Jan 29, 2025
2570da0
Merge branch 'master' into arv/set_code
sirasistant Jan 29, 2025
ddf4c27
fix
sirasistant Jan 29, 2025
cbc42cb
fix
sirasistant Jan 30, 2025
4e4ace7
fixes after merge
sirasistant Jan 30, 2025
8f30be9
moar fixes
sirasistant Jan 30, 2025
3978506
pass hints to the avm
sirasistant Jan 30, 2025
5ef9f10
Merge branch 'master' into arv/set_code
sirasistant Jan 30, 2025
d73ccd9
fixes
sirasistant Jan 30, 2025
d81a250
add validation in vm1
sirasistant Jan 31, 2025
14d9adc
Merge branch 'master' into arv/set_code
sirasistant Jan 31, 2025
1282abf
Merge branch 'master' into arv/set_code
sirasistant Jan 31, 2025
53a3caf
remove extraneous file
sirasistant Jan 31, 2025
a557ad9
use shared constants
sirasistant Jan 31, 2025
3d0ba29
Fix tests.
LeilaWang Jan 31, 2025
406c15d
refactor value and delay change
sirasistant Jan 31, 2025
bb75c62
Merge remote-tracking branch 'origin/master' into lw/fee_payer
LeilaWang Jan 31, 2025
4db32ec
Merge branch 'master' into arv/set_code
sirasistant Jan 31, 2025
4bfa0c6
Merge branch 'master' into arv/set_code
sirasistant Jan 31, 2025
bee6541
Merge branch 'master' into arv/set_code
sirasistant Feb 3, 2025
6383365
add current class id check
sirasistant Feb 3, 2025
f3713db
Merge branch 'master' into arv/set_code
sirasistant Feb 3, 2025
0f0da77
fix some tests
sirasistant Feb 3, 2025
86da24f
Fixes.
LeilaWang Feb 3, 2025
26df235
Merge remote-tracking branch 'origin/master' into lw/fee_payer
LeilaWang Feb 3, 2025
1b384c8
fix moar tests
sirasistant Feb 4, 2025
c6e859a
Fix.
LeilaWang Feb 4, 2025
bcf9460
Merge remote-tracking branch 'origin/master' into lw/fee_payer
LeilaWang Feb 4, 2025
e1e99c4
Merge branch 'master' into arv/set_code
sirasistant Feb 4, 2025
fd5e009
fix
sirasistant Feb 4, 2025
65dae9d
fixes
sirasistant Feb 4, 2025
208d1ff
Merge branch 'master' into arv/set_code
sirasistant Feb 4, 2025
59b088f
Fix.
LeilaWang Feb 4, 2025
93b8a05
fix
sirasistant Feb 4, 2025
a7cd684
fix vm2 serialization
sirasistant Feb 4, 2025
6b7036f
final fixes
sirasistant Feb 4, 2025
4a1211c
regen test data
sirasistant Feb 5, 2025
0b3950c
Merge remote-tracking branch 'origin/master' into lw/fee_payer
LeilaWang Feb 5, 2025
416c424
fix tests
sirasistant Feb 5, 2025
670c113
Fix.
LeilaWang Feb 5, 2025
86da1fb
Merge remote-tracking branch 'origin/master' into lw/fee_payer
LeilaWang Feb 5, 2025
dacbe94
moar fixes
sirasistant Feb 5, 2025
8a7ba14
Merge branch 'master' into arv/set_code
sirasistant Feb 5, 2025
07e2b9f
update tomls
sirasistant Feb 5, 2025
00e4739
fix txe public storage read
sirasistant Feb 6, 2025
8f74a1c
hopefully fix?
sirasistant Feb 6, 2025
1783b17
default delay constant
sirasistant Feb 6, 2025
fc51441
Merge branch 'master' into arv/set_code
sirasistant Feb 6, 2025
96d50df
Fix.
LeilaWang Feb 6, 2025
16d19bf
Merge remote-tracking branch 'origin/master' into lw/fee_payer
LeilaWang Feb 6, 2025
a82c4ec
fix aztecjs test
sirasistant Feb 6, 2025
5f250c8
remove workaround
sirasistant Feb 6, 2025
78ecd79
Merge branch 'lw/fee_payer' into arv/set_code
sirasistant Feb 6, 2025
b03d89d
Add testAccounts option.
LeilaWang Feb 7, 2025
7448c22
Merge remote-tracking branch 'origin/master' into lw/fee_payer
LeilaWang Feb 7, 2025
385c4f3
Merge remote-tracking branch 'origin/master' into lw/fee_payer
LeilaWang Feb 7, 2025
c29187f
fix contract updates with real delays
sirasistant Feb 7, 2025
fed55a0
Fix dependencies.
LeilaWang Feb 7, 2025
589d5bc
add tests for shared mutable hints
sirasistant Feb 7, 2025
632c482
Fix.
LeilaWang Feb 7, 2025
bca2541
Merge remote-tracking branch 'origin/master' into lw/fee_payer
LeilaWang Feb 7, 2025
6f926a7
Deploy fpc to sandbox.
LeilaWang Feb 8, 2025
a7010ca
Use test account in bot.
LeilaWang Feb 8, 2025
2f4cb12
Deploy test accounts for e2e native network.
LeilaWang Feb 10, 2025
7a8faee
Fix.
LeilaWang Feb 10, 2025
8b8e8a9
Merge remote-tracking branch 'origin/master' into lw/fee_payer
LeilaWang Feb 10, 2025
e22a9dc
Formatting.
LeilaWang Feb 10, 2025
0ecc38f
Fix tests.
LeilaWang Feb 10, 2025
bdf2076
Fix tests.
LeilaWang Feb 10, 2025
f92be8f
Fix tests.
LeilaWang Feb 11, 2025
190f64b
Formatting.
LeilaWang Feb 11, 2025
c548e0f
Merge remote-tracking branch 'origin/master' into lw/fee_payer
LeilaWang Feb 11, 2025
ebcdd8a
Fix.
LeilaWang Feb 11, 2025
d7fc10a
Merge remote-tracking branch 'origin/master' into lw/fee_payer
LeilaWang Feb 11, 2025
5434274
Formatting.
LeilaWang Feb 11, 2025
ec1bdeb
Allow to skip fee when checking if a tx is valid.
LeilaWang Feb 11, 2025
5f05e7f
Merge branch 'lw/fee_payer' into arv/set_code
sirasistant Feb 12, 2025
be73f2d
Merge branch 'lw/fee_payer' into arv/set_code
sirasistant Feb 12, 2025
5ea76e0
fix avm trace building
sirasistant Feb 12, 2025
8aa9d5a
Allow bot to bridge fee juice from L1.
LeilaWang Feb 12, 2025
99438a5
Merge remote-tracking branch 'origin/master' into lw/fee_payer
LeilaWang Feb 12, 2025
59cf224
Merge branch 'lw/fee_payer' into arv/set_code
sirasistant Feb 12, 2025
3065588
Fix tests.
LeilaWang Feb 12, 2025
6f8dde1
Progress l2 blocks for claiming fee juice from L1.
LeilaWang Feb 12, 2025
ef02acd
Merge remote-tracking branch 'origin/master' into lw/fee_payer
LeilaWang Feb 12, 2025
aa24a6f
Formatting.
LeilaWang Feb 12, 2025
f881a99
Merge remote-tracking branch 'origin/master' into lw/fee_payer
LeilaWang Feb 12, 2025
2e44da5
Bridge fee juice in network tests.
LeilaWang Feb 12, 2025
31e64f7
Port forward.
LeilaWang Feb 13, 2025
a7cbf1f
Merge remote-tracking branch 'origin/master' into lw/fee_payer
LeilaWang Feb 13, 2025
f97fa1b
allow contracts to change their update delay
sirasistant Feb 13, 2025
7cc9114
fix
sirasistant Feb 13, 2025
12f510d
Merge branch 'lw/fee_payer' into arv/set_code
sirasistant Feb 13, 2025
31688fa
fix updates test
sirasistant Feb 13, 2025
72d14a9
add check in pxe service before updating an instance
sirasistant Feb 13, 2025
8fd158c
moar tests
sirasistant Feb 13, 2025
e4a0931
Fix.
LeilaWang Feb 13, 2025
7edd511
Merge remote-tracking branch 'origin/master' into lw/fee_payer
LeilaWang Feb 13, 2025
137c836
Merge remote-tracking branch 'origin/master' into lw/fee_payer
LeilaWang Feb 13, 2025
4db0b8f
Merge branch 'lw/fee_payer' into arv/set_code
sirasistant Feb 13, 2025
6db13d3
fix
sirasistant Feb 13, 2025
baaf392
more fix
sirasistant Feb 13, 2025
c47cd35
Update configs.
LeilaWang Feb 13, 2025
90d561a
Merge remote-tracking branch 'origin/master' into lw/fee_payer
LeilaWang Feb 13, 2025
b3b916e
merge fix
sirasistant Feb 14, 2025
8c2a786
Add migration note.
LeilaWang Feb 14, 2025
0f6a0a8
fix updated contract non membership check
sirasistant Feb 14, 2025
6cbb9ec
Merge remote-tracking branch 'origin/master' into lw/fee_payer
LeilaWang Feb 14, 2025
b177e27
Merge branch 'lw/fee_payer' into arv/set_code
sirasistant Feb 14, 2025
7f5381b
added noir tests
sirasistant Feb 14, 2025
963214e
Merge branch 'master' into arv/set_code
sirasistant Feb 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .github/workflows/network-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ jobs:
-var="AZTEC_DOCKER_IMAGE=${{ env.AZTEC_DOCKER_IMAGE }}" \
-var="L1_DEPLOYMENT_PRIVATE_KEY=${{ secrets.SEPOLIA_L1_DEPLOYMENT_PRIVATE_KEY }}" \
-var="L1_DEPLOYMENT_MNEMONIC=$L1_DEPLOYMENT_MNEMONIC" \
-var="BOT_L1_MNEMONIC=$L1_DEPLOYMENT_MNEMONIC" \
-var="EXTERNAL_ETHEREUM_HOST=${{ env.EXTERNAL_ETHEREUM_HOST }}" \
-var="EXTERNAL_ETHEREUM_CONSENSUS_HOST=${{ env.EXTERNAL_ETHEREUM_CONSENSUS_HOST }}" \
-var="EXTERNAL_ETHEREUM_CONSENSUS_HOST_API_KEY=${{ secrets.SEPOLIA_API_KEY }}" \
Expand All @@ -207,6 +208,7 @@ jobs:
-var="GKE_CLUSTER_CONTEXT=${{ env.GKE_CLUSTER_CONTEXT }}" \
-var="AZTEC_DOCKER_IMAGE=${{ env.AZTEC_DOCKER_IMAGE }}" \
-var="L1_DEPLOYMENT_MNEMONIC=${{ steps.get-mnemonic.outputs.mnemonic }}" \
-var="BOT_L1_MNEMONIC=$L1_DEPLOYMENT_MNEMONIC" \
-lock=${{ inputs.respect_tf_lock }}
fi

Expand All @@ -222,6 +224,7 @@ jobs:
-var="AZTEC_DOCKER_IMAGE=${{ env.AZTEC_DOCKER_IMAGE }}" \
-var="L1_DEPLOYMENT_PRIVATE_KEY=${{ secrets.SEPOLIA_L1_DEPLOYMENT_PRIVATE_KEY }}" \
-var="L1_DEPLOYMENT_MNEMONIC=$L1_DEPLOYMENT_MNEMONIC" \
-var="BOT_L1_MNEMONIC=$L1_DEPLOYMENT_MNEMONIC" \
-var="L1_DEPLOYMENT_SALT=${DEPLOYMENT_SALT:-$RANDOM}" \
-var="EXTERNAL_ETHEREUM_HOST=${{ env.EXTERNAL_ETHEREUM_HOST }}" \
-var="EXTERNAL_ETHEREUM_CONSENSUS_HOST=${{ env.EXTERNAL_ETHEREUM_CONSENSUS_HOST }}" \
Expand All @@ -237,6 +240,7 @@ jobs:
-var="AZTEC_DOCKER_IMAGE=${{ env.AZTEC_DOCKER_IMAGE }}" \
-var="L1_DEPLOYMENT_MNEMONIC=${{ steps.get-mnemonic.outputs.mnemonic }}" \
-var="L1_DEPLOYMENT_SALT=${DEPLOYMENT_SALT:-$RANDOM}" \
-var="BOT_L1_MNEMONIC=$L1_DEPLOYMENT_MNEMONIC" \
-out=tfplan \
-lock=${{ inputs.respect_tf_lock }}
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ class ContentAddressedIndexedTree : public ContentAddressedAppendOnlyTree<Store,

ContentAddressedIndexedTree(std::unique_ptr<Store> store,
std::shared_ptr<ThreadPool> workers,
const index_t& initial_size);
const index_t& initial_size,
const std::vector<LeafValueType>& prefilled_values);
ContentAddressedIndexedTree(std::unique_ptr<Store> store,
std::shared_ptr<ThreadPool> workers,
const index_t& initial_size)
: ContentAddressedIndexedTree(std::move(store), workers, initial_size, std::vector<LeafValueType>()){};
ContentAddressedIndexedTree(ContentAddressedIndexedTree const& other) = delete;
ContentAddressedIndexedTree(ContentAddressedIndexedTree&& other) = delete;
~ContentAddressedIndexedTree() = default;
Expand Down Expand Up @@ -265,14 +270,19 @@ class ContentAddressedIndexedTree : public ContentAddressedAppendOnlyTree<Store,
};

template <typename Store, typename HashingPolicy>
ContentAddressedIndexedTree<Store, HashingPolicy>::ContentAddressedIndexedTree(std::unique_ptr<Store> store,
std::shared_ptr<ThreadPool> workers,
const index_t& initial_size)
ContentAddressedIndexedTree<Store, HashingPolicy>::ContentAddressedIndexedTree(
std::unique_ptr<Store> store,
std::shared_ptr<ThreadPool> workers,
const index_t& initial_size,
const std::vector<LeafValueType>& prefilled_values)
: ContentAddressedAppendOnlyTree<Store, HashingPolicy>(std::move(store), workers, {}, false)
{
if (initial_size < 2) {
throw std::runtime_error("Indexed trees must have initial size > 1");
}
if (prefilled_values.size() > initial_size) {
throw std::runtime_error("Number of prefilled values can't be more than initial size");
}
zero_hashes_.resize(depth_ + 1);

// Create the zero hashes for the tree
Expand All @@ -293,12 +303,23 @@ ContentAddressedIndexedTree<Store, HashingPolicy>::ContentAddressedIndexedTree(s

std::vector<IndexedLeafValueType> appended_leaves;
std::vector<bb::fr> appended_hashes;
std::vector<LeafValueType> initial_set;
auto num_default_values = static_cast<uint32_t>(initial_size - prefilled_values.size());
for (uint32_t i = 0; i < num_default_values; ++i) {
initial_set.push_back(LeafValueType::padding(i));
}
initial_set.insert(initial_set.end(), prefilled_values.begin(), prefilled_values.end());
for (uint32_t i = num_default_values; i < initial_size; ++i) {
if (i > 0 && (uint256_t(initial_set[i].get_key()) <= uint256_t(initial_set[i - 1].get_key()))) {
const auto* msg = i == num_default_values ? "Prefilled values must not be the same as the default values"
: "Prefilled values must be unique and sorted";
throw std::runtime_error(msg);
}
}
// Inserts the initial set of leaves as a chain in incrementing value order
for (uint32_t i = 0; i < initial_size; ++i) {
// Insert the zero leaf to the `leaves` and also to the tree at index 0.
bool last = i == (initial_size - 1);
IndexedLeafValueType initial_leaf =
IndexedLeafValueType(LeafValueType::padding(i), last ? 0 : i + 1, last ? 0 : i + 1);
uint32_t next_index = i == (initial_size - 1) ? 0 : i + 1;
auto initial_leaf = IndexedLeafValueType(initial_set[i], next_index, initial_set[next_index].get_key());
fr leaf_hash = HashingPolicy::hash(initial_leaf.get_hash_inputs());
appended_leaves.push_back(initial_leaf);
appended_hashes.push_back(leaf_hash);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ using HashPolicy = Poseidon2HashPolicy;
using Store = ContentAddressedCachedTreeStore<NullifierLeafValue>;
using TreeType = ContentAddressedIndexedTree<Store, HashPolicy>;

using PublicDataStore = ContentAddressedCachedTreeStore<PublicDataLeafValue>;
using PublicDataTreeType = ContentAddressedIndexedTree<PublicDataStore, Poseidon2HashPolicy>;

using CompletionCallback = TreeType::AddCompletionCallbackWithWitness;
using SequentialCompletionCallback = TreeType::AddSequentiallyCompletionCallbackWithWitness;

Expand Down Expand Up @@ -2775,6 +2778,102 @@ TEST_F(PersistedContentAddressedIndexedTreeTest, can_sync_and_unwind_empty_block
}
}

TEST_F(PersistedContentAddressedIndexedTreeTest, test_prefilled_public_data)
{
ThreadPoolPtr workers = make_thread_pool(1);
constexpr size_t depth = 3;
std::string name = random_string();
LMDBTreeStore::SharedPtr db = std::make_shared<LMDBTreeStore>(_directory, name, _mapSize, _maxReaders);
std::unique_ptr<PublicDataStore> store = std::make_unique<PublicDataStore>(name, depth, db);

index_t initial_size = 4;
std::vector<PublicDataLeafValue> prefilled_values = { PublicDataLeafValue(3, 9), PublicDataLeafValue(5, 7) };
auto tree = PublicDataTreeType(std::move(store), workers, initial_size, prefilled_values);

/**
* Intial state:
*
* index 0 1 2 3 4 5 6 7
* ---------------------------------------------------------------------
* slot 0 1 3 5 0 0 0 0
* val 0 0 9 7 0 0 0 0
* nextIdx 1 2 3 0 0 0 0 0
* nextVal 1 3 5 0 0 0 0 0
*/
IndexedPublicDataLeafType leaf_0 = create_indexed_public_data_leaf(0, 0, 1, 1);
IndexedPublicDataLeafType leaf_1 = create_indexed_public_data_leaf(1, 0, 2, 3);
IndexedPublicDataLeafType leaf_2 = create_indexed_public_data_leaf(3, 9, 3, 5);
IndexedPublicDataLeafType leaf_3 = create_indexed_public_data_leaf(5, 7, 0, 0);
check_size(tree, initial_size);
EXPECT_EQ(get_leaf<PublicDataLeafValue>(tree, 0), leaf_0);
EXPECT_EQ(get_leaf<PublicDataLeafValue>(tree, 1), leaf_1);
EXPECT_EQ(get_leaf<PublicDataLeafValue>(tree, 2), leaf_2);
EXPECT_EQ(get_leaf<PublicDataLeafValue>(tree, 3), leaf_3);
}

TEST_F(PersistedContentAddressedIndexedTreeTest, test_full_prefilled_public_data)
{
ThreadPoolPtr workers = make_thread_pool(1);
constexpr size_t depth = 3;
std::string name = random_string();
LMDBTreeStore::SharedPtr db = std::make_shared<LMDBTreeStore>(_directory, name, _mapSize, _maxReaders);
std::unique_ptr<PublicDataStore> store = std::make_unique<PublicDataStore>(name, depth, db);

index_t initial_size = 4;
std::vector<PublicDataLeafValue> prefilled_values = {
PublicDataLeafValue(1, 2), PublicDataLeafValue(3, 4), PublicDataLeafValue(5, 6), PublicDataLeafValue(7, 8)
};
auto tree = PublicDataTreeType(std::move(store), workers, initial_size, prefilled_values);

/**
* Intial state:
*
* index 0 1 2 3 4 5 6 7
* ---------------------------------------------------------------------
* slot 0 1 3 5 0 0 0 0
* val 0 0 9 7 0 0 0 0
* nextIdx 1 2 3 0 0 0 0 0
* nextVal 1 3 5 0 0 0 0 0
*/
IndexedPublicDataLeafType leaf_0 = create_indexed_public_data_leaf(1, 2, 1, 3);
IndexedPublicDataLeafType leaf_1 = create_indexed_public_data_leaf(3, 4, 2, 5);
IndexedPublicDataLeafType leaf_2 = create_indexed_public_data_leaf(5, 6, 3, 7);
IndexedPublicDataLeafType leaf_3 = create_indexed_public_data_leaf(7, 8, 0, 1);
check_size(tree, initial_size);
EXPECT_EQ(get_leaf<PublicDataLeafValue>(tree, 0), leaf_0);
EXPECT_EQ(get_leaf<PublicDataLeafValue>(tree, 1), leaf_1);
EXPECT_EQ(get_leaf<PublicDataLeafValue>(tree, 2), leaf_2);
EXPECT_EQ(get_leaf<PublicDataLeafValue>(tree, 3), leaf_3);
}

TEST_F(PersistedContentAddressedIndexedTreeTest, test_prefilled_unsorted_public_data_should_fail)
{
ThreadPoolPtr workers = make_thread_pool(1);
constexpr size_t depth = 3;
std::string name = random_string();
LMDBTreeStore::SharedPtr db = std::make_shared<LMDBTreeStore>(_directory, name, _mapSize, _maxReaders);
std::unique_ptr<PublicDataStore> store = std::make_unique<PublicDataStore>(name, depth, db);

index_t initial_size = 4;
// The prefilled values are not sorted: 5 > 3.
std::vector<PublicDataLeafValue> prefilled_values = { PublicDataLeafValue(5, 7), PublicDataLeafValue(3, 9) };
EXPECT_THROW(PublicDataTreeType(std::move(store), workers, initial_size, prefilled_values), std::runtime_error);
}

TEST_F(PersistedContentAddressedIndexedTreeTest, test_prefilled_default_public_data_should_fail)
{
ThreadPoolPtr workers = make_thread_pool(1);
constexpr size_t depth = 3;
std::string name = random_string();
LMDBTreeStore::SharedPtr db = std::make_shared<LMDBTreeStore>(_directory, name, _mapSize, _maxReaders);
std::unique_ptr<PublicDataStore> store = std::make_unique<PublicDataStore>(name, depth, db);

index_t initial_size = 4;
// The first prefilled value is the same as one of the default values (1).
std::vector<PublicDataLeafValue> prefilled_values = { PublicDataLeafValue(1, 9), PublicDataLeafValue(5, 7) };
EXPECT_THROW(PublicDataTreeType(std::move(store), workers, initial_size, prefilled_values), std::runtime_error);
}

TEST_F(PersistedContentAddressedIndexedTreeTest, test_can_commit_and_revert_checkpoints)
{
index_t initial_size = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ WorldStateWrapper::WorldStateWrapper(const Napi::CallbackInfo& info)
};
std::unordered_map<MerkleTreeId, uint32_t> tree_height;
std::unordered_map<MerkleTreeId, index_t> tree_prefill;
std::vector<PublicDataLeafValue> prefilled_public_data;
std::vector<MerkleTreeId> tree_ids{
MerkleTreeId::NULLIFIER_TREE, MerkleTreeId::NOTE_HASH_TREE, MerkleTreeId::PUBLIC_DATA_TREE,
MerkleTreeId::L1_TO_L2_MESSAGE_TREE, MerkleTreeId::ARCHIVE,
Expand Down Expand Up @@ -87,15 +88,38 @@ WorldStateWrapper::WorldStateWrapper(const Napi::CallbackInfo& info)
throw Napi::TypeError::New(env, "Tree prefill must be a map");
}

size_t initial_header_generator_point_index = 3;
size_t prefilled_public_data_index = 3;
if (info.Length() > prefilled_public_data_index && info[prefilled_public_data_index].IsArray()) {
Napi::Array arr = info[prefilled_public_data_index].As<Napi::Array>();
for (uint32_t i = 0; i < arr.Length(); ++i) {
Napi::Array deserialized = arr.Get(i).As<Napi::Array>();
if (deserialized.Length() != 2 || !deserialized.Get(uint32_t(0)).IsBuffer() ||
!deserialized.Get(uint32_t(1)).IsBuffer()) {
throw Napi::TypeError::New(env, "Prefilled public data value must be a buffer array of size 2");
}
Napi::Buffer<uint8_t> slot_buf = deserialized.Get(uint32_t(0)).As<Napi::Buffer<uint8_t>>();
Napi::Buffer<uint8_t> value_buf = deserialized.Get(uint32_t(1)).As<Napi::Buffer<uint8_t>>();
uint256_t slot = 0;
uint256_t value = 0;
for (size_t j = 0; j < 32; ++j) {
slot = (slot << 8) | slot_buf[j];
value = (value << 8) | value_buf[j];
}
prefilled_public_data.push_back(PublicDataLeafValue(slot, value));
}
} else {
throw Napi::TypeError::New(env, "Prefilled public data must be an array");
}

size_t initial_header_generator_point_index = 4;
if (info.Length() > initial_header_generator_point_index && info[initial_header_generator_point_index].IsNumber()) {
initial_header_generator_point = info[initial_header_generator_point_index].As<Napi::Number>().Uint32Value();
} else {
throw Napi::TypeError::New(env, "Header generator point needs to be a number");
}

// optional parameters
size_t map_size_index = 4;
size_t map_size_index = 5;
if (info.Length() > map_size_index) {
if (info[4].IsObject()) {
Napi::Object obj = info[map_size_index].As<Napi::Object>();
Expand All @@ -115,7 +139,7 @@ WorldStateWrapper::WorldStateWrapper(const Napi::CallbackInfo& info)
}
}

size_t thread_pool_size_index = 5;
size_t thread_pool_size_index = 6;
if (info.Length() > thread_pool_size_index) {
if (!info[thread_pool_size_index].IsNumber()) {
throw Napi::TypeError::New(env, "Thread pool size must be a number");
Expand All @@ -124,8 +148,13 @@ WorldStateWrapper::WorldStateWrapper(const Napi::CallbackInfo& info)
thread_pool_size = info[thread_pool_size_index].As<Napi::Number>().Uint32Value();
}

_ws = std::make_unique<WorldState>(
thread_pool_size, data_dir, map_size, tree_height, tree_prefill, initial_header_generator_point);
_ws = std::make_unique<WorldState>(thread_pool_size,
data_dir,
map_size,
tree_height,
tree_prefill,
prefilled_public_data,
initial_header_generator_point);

_dispatcher.registerTarget(
WorldStateMessageType::GET_TREE_INFO,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@ class AvmExecutionTests : public ::testing::Test {
auto tagging_key = grumpkin::g1::affine_one;
PublicKeysHint public_keys{ nullifier_key, incoming_viewing_key, outgoing_viewing_key, tagging_key };
ContractInstanceHint contract_instance = {
FF::one() /* temp address */, true /* exists */, FF(2) /* salt */, FF(3) /* deployer_addr */, class_id,
FF::one() /* temp address */, true /* exists */, FF(2) /* salt */, FF(3) /* deployer_addr */, class_id, class_id,
FF(8) /* initialisation_hash */, public_keys,
/*membership_hint=*/ { .low_leaf_preimage = { .nullifier = 0, .next_nullifier = 0, .next_index = 0, }, .low_leaf_index = 0, .low_leaf_sibling_path = {} },
/* update_hint*/ { .leaf_preimage = { .slot = 0, .value = 0, .next_index = 0, .next_slot = 0, }, .leaf_index = 0, .sibling_path = {} },
/* update_preimage */ {},
};
FF address = AvmBytecodeTraceBuilder::compute_address_from_instance(contract_instance);
contract_instance.address = address;
Expand Down Expand Up @@ -2293,10 +2295,13 @@ TEST_F(AvmExecutionTests, opGetContractInstanceOpcode)
.exists = true,
.salt = 2,
.deployer_addr = 42,
.contract_class_id = 66,
.current_contract_class_id = 66,
.original_contract_class_id = 66,
.initialisation_hash = 99,
.public_keys = public_keys_hints,
.membership_hint = { .low_leaf_preimage = { .nullifier = 0, .next_nullifier = 0, .next_index = 0, }, .low_leaf_index = 0, .low_leaf_sibling_path = {} },
.initialization_membership_hint = { .low_leaf_preimage = { .nullifier = 0, .next_nullifier = 0, .next_index = 0, }, .low_leaf_index = 0, .low_leaf_sibling_path = {} },
.update_membership_hint = { .leaf_preimage = { .slot = 0, .value = 0, .next_index = 0, .next_slot = 0, }, .leaf_index = 0, .sibling_path = {} },
.update_preimage = {}
};
auto execution_hints = ExecutionHints().with_contract_instance_hints({ { address, instance } });

Expand Down Expand Up @@ -2341,7 +2346,7 @@ TEST_F(AvmExecutionTests, opGetContractInstanceOpcode)
std::vector<FF> const calldata{};
// alternating member value, exists bool
std::vector<FF> const expected_returndata = {
instance.deployer_addr, 1, instance.contract_class_id, 1, instance.initialisation_hash, 1,
instance.deployer_addr, 1, instance.current_contract_class_id, 1, instance.initialisation_hash, 1,
};

std::vector<FF> returndata{};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ FF AvmBytecodeTraceBuilder::compute_address_from_instance(const ContractInstance
contract_instance.initialisation_hash,
contract_instance.deployer_addr });
FF partial_address = poseidon2::hash(
{ GENERATOR_INDEX__PARTIAL_ADDRESS, contract_instance.contract_class_id, salted_initialization_hash });
{ GENERATOR_INDEX__PARTIAL_ADDRESS, contract_instance.original_contract_class_id, salted_initialization_hash });

std::vector<FF> public_keys_hash_fields = contract_instance.public_keys.to_fields();
std::vector<FF> public_key_hash_vec{ GENERATOR_INDEX__PUBLIC_KEYS_HASH };
Expand Down Expand Up @@ -144,7 +144,7 @@ void AvmBytecodeTraceBuilder::build_bytecode_hash_columns()
contract_bytecode.contract_class_id_preimage.private_fn_root,
running_hash);
// Assert that the computed class id is the same as what we received as the hint
ASSERT(last_entry.class_id == contract_bytecode.contract_instance.contract_class_id);
ASSERT(last_entry.class_id == contract_bytecode.contract_instance.current_contract_class_id);

last_entry.contract_address = compute_address_from_instance(contract_bytecode.contract_instance);
// Assert that the computed contract address is the same as what we received as the hint
Expand Down
Loading