block DB interface#3445
Draft
wen-coding wants to merge 6 commits into
Draft
Conversation
…N-272)
Interface only — no implementation, no consumer rewiring. Captures the
contract we want from a database that will replace the file-WAL-based
DataWAL.Blocks + DataWAL.CommitQCs and add a by-hash block index.
Surface:
- WriteBlock(n, *types.Block)
- WriteQC(*types.FullCommitQC) // qc carries its GlobalRange
- PruneBefore(n)
- Flush
- ReadAll() → Loaded{Blocks, QCs}
- ReadBlockByNumber(n)
- ReadBlockByHash(hash)
- ReadQCByBlockNumber(n) // QC covering block n
- Close
Godocs spell out:
- Concurrency: all methods safe for concurrent use
- Crash safety: each Write is atomic; cross-write atomicity is the
caller's problem (DataWAL.reconcile-style)
- Read-your-writes within a session
- Contiguity guarantee for QC writes (caller-guaranteed, not
implementation-enforced)
- Why n is required on WriteBlock (Block does not carry
GlobalBlockNumber; only per-lane BlockNumber)
- Why no separate hash arg on WriteBlock (derivable via
block.Header().Hash())
- Read methods are non-blocking; "not yet written" reports as
(nil, false, nil) — wait semantics live above the interface
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3445 +/- ##
=======================================
Coverage 59.29% 59.29%
=======================================
Files 2125 2125
Lines 175629 175629
=======================================
+ Hits 104144 104145 +1
+ Misses 62404 62403 -1
Partials 9081 9081
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
…N-272) Removing Flush from the Store interface. The existing FullCommitQCPersister and GlobalBlockPersister don't have Flush either; data.State.runPersist already relies on PersistQC/PersistBlock returning only after the write is on disk in order to advance nextBlockToPersist (which gates PushAppHash → AppVote durability). Codify that directly: WriteBlock and WriteQC return only after the record is durable. Implementations that want to batch fsyncs internally can do so, but the individual Write call still blocks until the batch covering it has been committed. Smaller interface, no semantic change vs. the WAL it replaces. If a future implementation needs an async fast-path with a separate Flush, we can add it then with a real use case to design against. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop the "No separate Flush method is exposed; if an implementation wants to..." sentence from the type comment. The synchronous-durability contract above already covers the substance. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Reframe the "Ordering" section as "Ordering and the GlobalRange convention". Calls out that GlobalRange is [First(), Next()) — First inclusive, Next exclusive — so the QC covers First, First+1, ..., Next-1, and Next is the First of the next contiguous QC. The convention was implicit before (used in ReadQCByBlockNumber's "GlobalRange().First ≤ n < GlobalRange().Next" and Loaded.QCs's "[First, Next)" but never stated outright). Implementers shouldn't have to reverse-engineer it from those scattered references. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds a "What this does NOT store" section to the Store type doc. Heads
off the natural question — "don't we need to persist execution
results?" — by walking through why AppHash recovery works without
storing it:
- App.Info().LastBlockAppHash on restart gives us the AppHash for
the last committed height (lives in the app's CMS, not in
data.State or DataWAL)
- Heights above that are re-executed from replayed blocks +
re-derived AppHashes
- GlobalBlock.FinalAppState comes from qc.Proposal().App(),
extracted from the persisted QC — no separate record needed
Per-tx execution results / logs / events live on the receipt store
(canonical txHash → execution result, per the Giga Transaction Query
proposal). Store stays scoped to blocks + QCs.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… error) Per reviewer preference for utils.Option over Go's (value, bool) tuple pattern. The autobahn data package can freely import sei-tendermint/libs/utils, so no layering concern (unlike sei-db, where Transaction.Result() stayed on (bytes, bool) because sei-db can't see the Option type). Changed: - ReadBlockByNumber(ctx, n) → (utils.Option[*types.Block], error) - ReadBlockByHash(ctx, hash) → (utils.Option[*types.Block], error) - ReadQCByBlockNumber(ctx, n) → (utils.Option[*types.FullCommitQC], error) Updated doc comments to refer to utils.None where they previously said (nil, false, nil). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
9 tasks
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.
Summary
Interface only — no implementation, no consumer rewiring yet.
The
data.Storeinterface captures whatdata.Stateneeds from a durable backing store to replace the currentDataWAL(separate file WALs for blocks and FullCommitQCs). Adds a by-hash block index that the WAL didn't have — needed for the/block_by_hashRPC path.Surface
Contract highlights (full docs in the file)
DataWAL.reconcile).app.Info().LastBlockAppHash+ re-execution;data.State.inner.appProposalsis in-memory only), and per-tx execution results / logs / events (those live on the receipt store per the Giga Transaction Query proposal).GlobalBlock.FinalAppStateis extracted fromqc.Proposal().App()— derivable from the persisted QC, no separate AppHash record needed.[GlobalRange.First(), GlobalRange.Next()). The QC covers GlobalBlockNumbersFirst, First+1, …, Next-1, andNextis theFirstof the next contiguous QC.Firstequals the previous one'sNext; implementations may but need not enforce.GlobalRange.Firstfor QCs) are silent no-ops.non WriteBlock: required because*types.Blockdoes NOT carry its GlobalBlockNumber —block.Header().BlockNumber()is the per-lane number (different typedef). The lane→global mapping lives in the QC's GlobalRange.block.Header().Hash(); implementation indexes it automatically.utils.Option: "not yet written" / "pruned" surface asutils.None. Reads are non-blocking; wait semantics live above the interface indata.State.What's not in this PR
data.State.NewState/runPersist/runPruningstill talk toDataWAL; that swap happens once an implementation exists.Test plan
go build ./sei-tendermint/internal/autobahn/data/...— cleangofmt -s -l— cleango vet— clean🤖 Generated with Claude Code