feat(dbtool): add moho state and export-entries commands - #5
Open
vladb-ai wants to merge 4 commits into
Open
Conversation
The Moho worker only ever reads, appends, and prunes-from-below, so the sled state store exposed just those. Offline tooling (dbtool) needs to enumerate, remove individual snapshots, and roll the store back to a known-good height, so add the read-only `list`, the single-key `delete`, and `prune_after` — mirroring `asm-storage`'s `SledAsmStateDb`.
dbtool only covered the storage DB's `asm` domain. Add a `moho` domain so the runner's Moho data can be inspected and maintained offline too. The two resources live in different databases, so each opens the one it needs: `moho state` (per-block MohoState snapshots) in the proof DB, and `moho export-entries` (the per-container export-entry MMR the RPC rebuilds inclusion proofs from) in the storage DB — a split the README's earlier "planned" section got wrong. Both go through the existing sync surface of `strata-asm-moho-storage`, keeping dbtool fully synchronous. Records render as their cheap public fields plus a lossless `ssz_hex` blob, and mutating verbs stay behind the `--write` gate, matching the `asm` commands.
Drives the prover env until a Moho proof lands (implying the Moho worker persisted its state), stops the runner, then exercises `moho state` against the proof DB — list/latest/get round-trips, a missing lookup, the --write gate, and a delete on a snapshot — and `moho export-entries` against the storage DB. No export entry can be driven from the harness (ASM lacks assignment-fulfillment tooling), so export-entries gets negative-path coverage, matching the existing RPC test.
🔒 AI Security ReviewReviewed the full diff ( No exploitable vulnerabilities found. Context that shapes the risk here:
Nothing in this diff introduces injection, auth/access-control gaps, unsafe deserialization, crypto misuse, or memory-safety issues. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Extends
dbtoolwith amohodomain so the runner's Moho data can be inspected and maintained offline, the same way the existingasmdomain covers the storage DB. Previously there was no offline tooling for any Moho state.Two resources, in two databases (each command opens the one it needs):
moho state— per-blockMohoStatesnapshots, in the proof DB.get <commitment>·latest·list·put <commitment> --file F·delete <commitment>·prune (--before|--after) <h>.moho export-entries— the per-container export-entry MMR the RPC rebuilds inclusion proofs from, in the storage DB.get·find·height·count·range·proof·append·prune --from.Everything goes through the existing synchronous surface of
strata-asm-moho-storage, sodbtoolstays fully synchronous. Records render as their cheap public fields plus a losslessssz_hexblob, and mutating verbs stay behind the--writegate — consistent with theasmcommands.The one storage-crate change is additive:
SledMohoStateDbgainslist,delete, andprune_after(the worker only reads/appends/prunes-from-below), mirroringasm-storage'sSledAsmStateDb.SledExportEntriesDbalready exposed everything needed.This also corrects the README's earlier "planned" section, which put export-entries in the proof DB — it actually lives in the storage DB alongside the ASM manifests.
The remaining proof-DB resources (
proof asm/moho/mapping/status/prune) are a separate PR (alpenlabs#172).Type of Change
Notes to Reviewers
The
moho stateandmoho export-entriesresources deliberately target different--dbdirectories; the dispatcher picks the opener per resource (seemain.rs/cmd::moho_target).Verified end-to-end against a real sled DB through the built binary: the
--writegate,append→count/get/find/height/range/proof, andprune --fromall behave, plus the empty-DB read paths and the prune-arg validation.A functional test (
fn_asm_dbtool_moho_test.py) drives theproverenv until a Moho proof lands, then exercisesmoho stateagainst the real proof DB (list/latest/get round-trips, missing lookup,--writegate, delete on a snapshot) andmoho export-entriesagainst the storage DB (negative paths — ASM has no assignment-fulfillment tooling to drive a real export entry).Checklist