Seedelf-Wallet

seedelf-data: the maintainers’ notes

Why the data layer’s API is built as it is, the checks run against Koios and the chain, and the query planner’s measurements. Each measurement says what it ran on, and when. README.md is the API’s reference, and deploy/README.md the runbook for home and the VPS. The record of the data layer’s plan, with the original reasoning behind each choice, is chunk-26-data-layer.md.

The workspace

Its own Cargo workspace, apart from seedelf-platform/, so nothing here moves the CLI’s Cargo.lock. It pins the same Rust (rust-toolchain.toml): bump the two together. It can’t depend on seedelf-core, so the token pools’ checks are a copy (below).

.env is never committed. .env.example lists the variables, and api/src/config.rs reads them. cargo run and the live tests reach the services it names, home’s mainnet ones included.

Reference code

_reference/ holds shallow clones to read and optimise against. Git ignores it, and its own README says what’s where. To recreate it:

mkdir -p _reference && cd _reference
for r in cardano-community/koios-artifacts blockfrost/blockfrost-backend-ryo \
         IntersectMBO/cardano-db-sync cardano-community/guild-operators \
         CardanoSolutions/kupo; do
  git clone --depth 1 "https://github.com/$r.git"
done

Token decimals

They’re built in (api/data/token-decimals.json), made by scripts/token-decimals.py from a checkout of the Cardano token registry, Koios’s own source. Refreshing them needs that checkout (about 500 MB), wherever it’s kept, then a build:

git clone --depth 1 https://github.com/cardano-foundation/cardano-token-registry.git
python3 scripts/token-decimals.py cardano-token-registry > api/data/token-decimals.json

Refresh it the way the wallet refreshes its token list: the script, a commit, a build, then a deploy.

Tests

One test at a time for the live ones (--test-threads=1): the database role allows 10 connections, and a running server holds some of them.

What the offline tests check, beyond each module’s own:

What the live tests check:

Checked end to end (2026-10-09): the server run once as is and once with db-sync unreachable gave byte-identical contract snapshots, since answers and names at the same tip. The Lovejoin answers differed only in made_by.inputs.

The edge

Logs can’t be turned up to show a request. The database driver logs every query’s parameters at debug, and axum’s rejections quote bodies, so those libraries sit behind a filter of their own (api/src/main.rs), which every line must pass as well as RUST_LOG’s. Checked with RUST_LOG=tokio_postgres::query=debug: no query parameters were logged.

/health is exempt from the page check and the egress ceiling, so a monitor (or a browser tab) can always read it. The submit part’s state is said there but not counted in the status, since the deploy compares the status with the one before.

The private index

db-sync answers first, since its queries are enough for the load. Kupo is the spare: it needs only the node, so the private index keeps answering while db-sync is down, behind or resyncing. Kupo indexes outputs at the two credentials, not who paid for a transaction, which is why its boxes’ made_by.inputs is null.

Checked by cutting each link mid-run, both by closing it and by freezing it so nothing answers. The private index answered from Kupo within 8 s; with both gone, every route answered 503 at once; and both came back within 8 s.

The answers every wallet reads are always kept, whatever the cache’s budget holds (state.rs ALWAYS_KEPT): the snapshots, the names, epoch_params, totals, and the token pools’ snapshot (317-data#1, 1.6.0’s release review).

The SQL:

Lovejoin’s token pools

The code is api/src/lovejoin/. Its checks are a copy of the wallet’s: this workspace can’t depend on seedelf-core, which keeps its own copy, so the two are held to one set of vectors (below), and a box’s datum to the node’s own reading of it. A change to either copy’s rules changes the other’s in the same PR.

Where each part of the rule is: the datum’s shape and its depth walk in datum.rs; the two template sets in templates.rs, applied by hand in flat.rs, with no Pallas, uplc or blst; the shown rule in standard.rs; the crowd in crowd.rs; the holder’s reads in discovery.rs and db.rs.

The two sets’ provenance: tokenV1 is Lovejoin 8131b1d’s scripts, retired; v2 is Lovejoin 29573c5’s, whose mix_logic alone differs (xor32’s fix). The wallet’s WebAssembly names them the same way, and routes.rs’ a_listed_pool_names_its_set holds the names (pr363#2, 1.8.0’s release review).

A release that lists a token is deployed here first: the API builds in the wallet’s mainnet token list, and shows a pool only of a listed token.

A launch’s script row under a datum nested past the wallet’s 128 levels (datum.rs MAX_DEPTH, seedelf-core’s cbor::MAX_DEPTH) leaves its pool out, since the wallet passes such a row over and never shows the pool (314-wasm#0, 1.6.0’s release review).

Verdicts are kept in memory (discovery.rs, at most 200,000). Past that, a candidate is checked again at each request, and still shown when it’s standard.

lovejoin/pools answers by one 5 s deadline, its cursor’s read included: two separate 5 s waits would use up the wallet’s 10 s, and a wallet that gets no answer holds its private part on Koios for 5 minutes (317-data#0). The stable cursor is read once per tip (317-data#2). A cursor read that fails or runs late answers the last list, which is most often this very cursor’s (R3-15).

Held together with the wallet

The public routes

Why every request is bounded: any credential, address or stake key may be asked about, and one listing of a credential with 220,000 unspent outputs read 2.4 GB from disk for every page.

The SQL is the API’s own. The home Postgres has no grest schema and no pg_cardano, and the API reads with the read-only role, so nothing at home is installed. Its indexes beyond db-sync’s own are recorded in deploy/home/db-sync-indexes.sql, with the command that lists what’s there.

db-sync’s statistics are far off, so the hot queries don’t lean on them.

What stands in for Koios’s caches, and why:

Every connection runs with jit = off. JIT compiled plans whose estimates db-sync’s ma_tx_out inflates: 76 of a UTxO query’s 80 ms.

The connections: the role allows 10, and the API holds 9: the tip’s 1, the private index’s 2 and the public routes’ 6, leaving one for a person.

account_txs and credential_txs never join a whole history. A transaction’s id rises with its block, so a page takes the newest ids it needs, its own and every newer one, widened to the whole of the oldest block they reach, and joins only those: 0.5 s a first page for a key with 221,000 transactions, against 2.3 s before, and the same rows. A deeper page needs more of them, and one past the end of a long list would need them all, so no page starts more than 10,000 in (Activity’s 500th Load more).

account_reward_history: the pool’s bech32 comes from pool_hash.view, sorted in SQL by the order the wallet asks for (spendable_epoch.asc,earned_epoch.asc,type.asc,pool_id_bech32.asc,amount.asc), oldest first by every column.

account_update_history: read from stake_registration, stake_deregistration, delegation and delegation_vote, sorted in SQL by the order the wallet asks for (absolute_slot.asc,tx_hash.asc,action_type.asc).

pool_history: deleg_rewards is worked out in floating point and rounded half to even, as Postgres works Koios’s out; the pool’s terms are the latest pool_update by active_epoch_no.

tx_info reads its parts at once, pipelined on one connection: two round trips to home, not six.

The tables behind the README’s plain words: a rewards history reads reward and reward_rest; a token’s supply and latest mint, ma_tx_mint; drep_info, delegation_vote whole. A delegation history’s one row per kind per transaction is Koios’s union.

Known slow cases

The measurements behind the README’s Limits:

The submit part

Its answers matched Koios’s byte for byte on 2026-10-08: Koios fronts the same two services, so the error strings the wallet classifies stay what they are.

Ogmios’s /health gates both paths, so an Ogmios restart sends submits to Koios for its few seconds.

Why sync is judged by the tip’s own slot: networkSynchronization moves in steps of about 48 minutes in its last decimal place, far coarser than the 3-minute limit, and lastTipUpdate stays fresh on a node that’s catching up, since its tip moves every moment.

Errors are logged by kind only: reqwest’s own error messages carry the upstream’s URL, which names home.