Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]
members = [
"bin/benchmark",
"bin/large-account-benchmark",
"bin/network-monitor",
"bin/node",
"bin/ntx-builder",
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ install-network-monitor: ## Installs network monitor binary
install-benchmark: ## Installs the benchmark binary
cargo install --path bin/benchmark --locked

.PHONY: install-large-account-benchmark
install-large-account-benchmark: ## Installs the large account benchmark binary
cargo install --path bin/large-account-benchmark --locked

# --- docker --------------------------------------------------------------------------------------

.PHONY: local-network-build
Expand Down
33 changes: 33 additions & 0 deletions bin/large-account-benchmark/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[package]
authors.workspace = true
description = "A binary for benchmarking the ntx-builder against very large network accounts"
edition.workspace = true
exclude.workspace = true
homepage.workspace = true
keywords = ["benchmark", "genesis", "miden"]
license.workspace = true
name = "miden-large-account-benchmark"
publish = false
readme = "README.md"
repository.workspace = true
rust-version.workspace = true
version.workspace = true

[lints]
workspace = true

[dependencies]
anyhow = { workspace = true }
clap = { features = ["derive", "env"], workspace = true }
fs-err = { workspace = true }
hex = { workspace = true }
humantime = { workspace = true }
miden-node-proto = { workspace = true }
miden-protocol = { features = ["std"], workspace = true }
miden-standards = { workspace = true }
miden-tx = { workspace = true }
rand = { workspace = true }
rand_chacha = { workspace = true }
tokio = { features = ["macros", "rt-multi-thread", "time"], workspace = true }
tonic = { workspace = true }
url = { workspace = true }
100 changes: 100 additions & 0 deletions bin/large-account-benchmark/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Miden large account benchmark

A self-contained tool for the ntx-builder large-account benchmark. It seeds an oversized network account into a genesis
configuration, then submits an increment against it on a running chain and asserts the ntx-builder consumes it.

## The short version

`scripts/large-account-harness.sh` does everything below in one command: seeds the pair, brings up a local network with
it committed at genesis via `scripts/run-node.sh`, submits one increment, and asserts the counter advances.

```bash
MAP_ENTRIES=1000 ./scripts/large-account-harness.sh
```

```text
Seeding the wallet + counter pair (10000 map entries)

Measuring the account in isolation (no network)

Starting the local network

Submitting an increment and waiting for the counter to advance

PASS — the ntx-builder loaded the account and consumed the network note

10000 map entries
counter on disk 628.8 KiB (64 B/entry)
wallet on disk 4.2 KiB
account in isolation 83.4 MiB resident, 128.2 MiB peak, 91.7 ms to load
ntx-builder peak RSS 339.4 MiB
sequencer peak RSS 450.8 MiB
timings 6s ready, 1.50s proving, 2 blocks to consume
```

## Seeding

```bash
miden-large-account-benchmark seed --output-dir ./seeded --counter-map-entries 1000000
```

This writes `faucet.mac`, `wallet.mac` (both carrying their signing key) and `counter.mac` into `./seeded`, and prints
all three account ids. Reference them from a genesis configuration:

```toml
native_faucet = "seeded/faucet.mac"
validators = ["<miden-validator pubkey>"]

[fee_parameters]
verification_base_fee = 0

[[account]]
path = "seeded/wallet.mac"

[[account]]
path = "seeded/counter.mac"
```

Paths are resolved relative to the genesis configuration file's directory. Build the genesis block and bootstrap each
service from it:

```bash
miden-validator genesis --genesis-block-directory ./genesis --accounts-directory ./accounts \
--config ./genesis.toml
miden-validator bootstrap --data-directory ./data/validator --genesis ./genesis/genesis.dat
miden-node bootstrap --data-directory ./data/node --genesis ./genesis/genesis.dat
miden-ntx-builder bootstrap --data-directory ./data/ntx-builder --genesis ./genesis/genesis.dat
```

## Verifying the setup

Once the network is up, check the whole path works before measuring anything. `verify` submits a single increment and
asserts the counter advances:

```bash
miden-large-account-benchmark verify --accounts-dir ./seeded \
--rpc-url http://localhost:57291 \
--validator-signing-public-key "$VALIDATOR_1_PUBKEY" \
--validator-signing-public-key "$VALIDATOR_2_PUBKEY"
```

It exits zero only if the counter moved, which requires every part of the chain to be working: the seeded accounts are
on chain, the node accepts a transaction against the wallet, and the ntx-builder can load an account this large and
consume the network note. Anything less exits non-zero with the reason.

```text
baseline: counter=0 chain_tip=42
submitted increment at block 43 · proved in 1.38s · tx 0x8f2c…
waiting up to 20 blocks for the ntx-builder to consume the note...
counter=0 blocks_elapsed=1/20
counter=0 blocks_elapsed=2/20
counter advanced to 1 after 3 blocks
PASS: the ntx-builder loaded the account and consumed the network note
```

The budget is counted in blocks (`--wait-blocks`, 20 by default) rather than seconds, so it does not depend on how fast
the network produces them.

## License

This project is [MIT licensed](../../LICENSE).
Loading
Loading