Skip to content

Commit 6a3e70d

Browse files
author
AztecBot
committed
Merge branch 'next' into merge-train/spartan
2 parents 18dc1f1 + 9a9810a commit 6a3e70d

180 files changed

Lines changed: 5181 additions & 3357 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

barretenberg/cpp/format.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
#!/usr/bin/env bash
2+
3+
# we have to unset this env var set by git hooks so that the relative paths below work correctly when used inside worktrees
4+
unset GIT_DIR
5+
26
function format_files {
37
if [ -n "$1" ]; then
48
echo "$1" | parallel -j+0 'clang-format-20 -i {} && sed -i.bak "s/\r$//" {} && rm {}.bak'

barretenberg/cpp/pil/vm2/constants_gen.pil

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ namespace constants;
1515
pol MAX_L2_TO_L1_MSGS_PER_TX = 8;
1616
pol MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS = 3000;
1717
pol MAX_PROTOCOL_CONTRACTS = 11;
18+
pol CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS = 1;
1819
pol CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS = 2;
19-
pol CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS = 3;
20-
pol MULTI_CALL_ENTRYPOINT_ADDRESS = 4;
21-
pol FEE_JUICE_ADDRESS = 5;
20+
pol FEE_JUICE_ADDRESS = 3;
2221
pol FEE_JUICE_BALANCES_SLOT = 1;
2322
pol UPDATED_CLASS_IDS_SLOT = 1;
2423
pol FLAT_PUBLIC_LOGS_HEADER_LENGTH = 1;

barretenberg/cpp/src/barretenberg/aztec/aztec_constants.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121
#define GENESIS_ARCHIVE_ROOT "0x177a4955b31ecaafad999753938a44e526b54c5ba5d536688227f85f15cfbdf5"
2222
#define MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS 3000
2323
#define MAX_PROTOCOL_CONTRACTS 11
24+
#define CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS 1
2425
#define CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS 2
25-
#define CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS 3
26-
#define MULTI_CALL_ENTRYPOINT_ADDRESS 4
27-
#define FEE_JUICE_ADDRESS 5
26+
#define FEE_JUICE_ADDRESS 3
2827
#define FEE_JUICE_BALANCES_SLOT 1
2928
#define UPDATED_CLASS_IDS_SLOT 1
3029
#define FLAT_PUBLIC_LOGS_HEADER_LENGTH 1

barretenberg/cpp/src/barretenberg/crypto/merkle_tree/lmdb_store/lmdb_tree_store.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ int index_key_cmp(const MDB_val* a, const MDB_val* b)
5454
return value_cmp<uint64_t>(a, b);
5555
}
5656

57-
LMDBTreeStore::LMDBTreeStore(std::string directory, std::string name, uint64_t mapSizeKb, uint64_t maxNumReaders)
58-
: LMDBStoreBase(directory, mapSizeKb, maxNumReaders, 5)
57+
LMDBTreeStore::LMDBTreeStore(
58+
std::string directory, std::string name, uint64_t mapSizeKb, uint64_t maxNumReaders, bool ephemeral)
59+
: LMDBStoreBase(directory, mapSizeKb, maxNumReaders, 5, ephemeral)
5960
, _name(std::move(name))
6061
{
6162

barretenberg/cpp/src/barretenberg/crypto/merkle_tree/lmdb_store/lmdb_tree_store.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ class LMDBTreeStore : public LMDBStoreBase {
159159
using SharedPtr = std::shared_ptr<LMDBTreeStore>;
160160
using ReadTransaction = LMDBReadTransaction;
161161
using WriteTransaction = LMDBWriteTransaction;
162-
LMDBTreeStore(std::string directory, std::string name, uint64_t mapSizeKb, uint64_t maxNumReaders);
162+
LMDBTreeStore(
163+
std::string directory, std::string name, uint64_t mapSizeKb, uint64_t maxNumReaders, bool ephemeral = false);
163164
LMDBTreeStore(const LMDBTreeStore& other) = delete;
164165
LMDBTreeStore(LMDBTreeStore&& other) = delete;
165166
LMDBTreeStore& operator=(const LMDBTreeStore& other) = delete;

barretenberg/cpp/src/barretenberg/lmdblib/lmdb_environment.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88

99
namespace bb::lmdblib {
1010

11-
LMDBEnvironment::LMDBEnvironment(const std::string& directory,
12-
uint64_t mapSizeKB,
13-
uint32_t maxNumDBs,
14-
uint32_t maxNumReaders)
11+
LMDBEnvironment::LMDBEnvironment(
12+
const std::string& directory, uint64_t mapSizeKB, uint32_t maxNumDBs, uint32_t maxNumReaders, bool ephemeral)
1513
: _id(0)
1614
, _directory(directory)
1715
, _readGuard(maxNumReaders)
@@ -21,6 +19,9 @@ LMDBEnvironment::LMDBEnvironment(const std::string& directory,
2119
uint64_t kb = 1024;
2220
uint64_t totalMapSize = kb * mapSizeKB;
2321
uint32_t flags = MDB_NOTLS;
22+
if (ephemeral) {
23+
flags |= MDB_NOSYNC | MDB_NOMETASYNC;
24+
}
2425
try {
2526
call_lmdb_func("mdb_env_set_mapsize", mdb_env_set_mapsize, _mdbEnv, static_cast<size_t>(totalMapSize));
2627
call_lmdb_func("mdb_env_set_maxdbs", mdb_env_set_maxdbs, _mdbEnv, static_cast<MDB_dbi>(maxNumDBs));

barretenberg/cpp/src/barretenberg/lmdblib/lmdb_environment.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,19 @@ class LMDBEnvironment {
2525
* @param mapSizeKb The maximum size of the database, can be increased from a previously used value
2626
* @param maxNumDbs The maximum number of databases that can be created withn this environment
2727
* @param maxNumReaders The maximum number of concurrent read transactions permitted.
28+
* @param ephemeral When true, opens the env with `MDB_NOSYNC | MDB_NOMETASYNC`. Commits
29+
* return as soon as the dirty pages are queued; the kernel flushes them
30+
* lazily and never blocks the commit. Files stay sparse (we deliberately
31+
* avoid `MDB_WRITEMAP`, which would eagerly allocate the full map size
32+
* on disk). Intended for short-lived ephemeral world states (e.g. TXE
33+
* test sessions) that discard the directory on close; never use for a
34+
* real node — a crash mid-write yields an unrecoverable env.
2835
*/
29-
LMDBEnvironment(const std::string& directory, uint64_t mapSizeKb, uint32_t maxNumDBs, uint32_t maxNumReaders);
36+
LMDBEnvironment(const std::string& directory,
37+
uint64_t mapSizeKb,
38+
uint32_t maxNumDBs,
39+
uint32_t maxNumReaders,
40+
bool ephemeral = false);
3041
LMDBEnvironment(const LMDBEnvironment& other) = delete;
3142
LMDBEnvironment(LMDBEnvironment&& other) = delete;
3243
LMDBEnvironment& operator=(const LMDBEnvironment& other) = delete;

barretenberg/cpp/src/barretenberg/lmdblib/lmdb_store.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
#include <stdexcept>
1515

1616
namespace bb::lmdblib {
17-
LMDBStore::LMDBStore(std::string directory, uint64_t mapSizeKb, uint64_t maxNumReaders, uint64_t maxDbs)
18-
: LMDBStoreBase(std::move(directory), mapSizeKb, maxNumReaders, maxDbs)
17+
LMDBStore::LMDBStore(std::string directory, uint64_t mapSizeKb, uint64_t maxNumReaders, uint64_t maxDbs, bool ephemeral)
18+
: LMDBStoreBase(std::move(directory), mapSizeKb, maxNumReaders, maxDbs, ephemeral)
1919
{}
2020

2121
void LMDBStore::open_database(const std::string& name, bool duplicateKeysPermitted)

barretenberg/cpp/src/barretenberg/lmdblib/lmdb_store.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class LMDBStore : public LMDBStoreBase {
3535
std::string name;
3636
};
3737

38-
LMDBStore(std::string directory, uint64_t mapSizeKb, uint64_t maxNumReaders, uint64_t maxDbs);
38+
LMDBStore(
39+
std::string directory, uint64_t mapSizeKb, uint64_t maxNumReaders, uint64_t maxDbs, bool ephemeral = false);
3940
LMDBStore(const LMDBStore& other) = delete;
4041
LMDBStore(LMDBStore&& other) = delete;
4142
LMDBStore& operator=(const LMDBStore& other) = delete;

barretenberg/cpp/src/barretenberg/lmdblib/lmdb_store_base.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#include "barretenberg/lmdblib/lmdb_store_base.hpp"
22

33
namespace bb::lmdblib {
4-
LMDBStoreBase::LMDBStoreBase(std::string directory, uint64_t mapSizeKb, uint64_t maxNumReaders, uint64_t maxDbs)
4+
LMDBStoreBase::LMDBStoreBase(
5+
std::string directory, uint64_t mapSizeKb, uint64_t maxNumReaders, uint64_t maxDbs, bool ephemeral)
56
: _dbDirectory(std::move(directory))
6-
, _environment((std::make_shared<LMDBEnvironment>(_dbDirectory, mapSizeKb, maxDbs, maxNumReaders)))
7+
, _environment(std::make_shared<LMDBEnvironment>(_dbDirectory, mapSizeKb, maxDbs, maxNumReaders, ephemeral))
78
{}
89
LMDBStoreBase::~LMDBStoreBase() = default;
910
LMDBStoreBase::ReadTransaction::Ptr LMDBStoreBase::create_read_transaction() const

0 commit comments

Comments
 (0)