-
Notifications
You must be signed in to change notification settings - Fork 886
feat(data): integrate LittDB-backed BlockDB into autobahn data layer (CON-272) #3707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
wen-coding
wants to merge
46
commits into
main
Choose a base branch
from
wen/blockdb_integrate_with_data
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
2ed09bf
feat(data): wire BlockDB into State — persist QCs and blocks across r…
wen-coding 49cb596
fix: close data.State on router shutdown; guard rootify against empty…
wen-coding 4887f74
docs: update --persistent-state-dir flag help — persistence is now re…
wen-coding 5f57fe5
refactor: PersistentStateDir required string in consensus/avail; fix …
wen-coding 6009978
fix: missed Option[string] call site in producer test; fix stale comm…
wen-coding a828ae3
fix: add PersistentStateDir to giga test helpers
wen-coding ebe6cb8
docs: document PruneBefore async-GC behavior; validate empty persiste…
wen-coding 13bc4ec
test(data): add PruneBefore-without-GC recovery test; validate empty …
wen-coding 1331181
chore(persist): remove dead noopPersister and stale None-mode comments
wen-coding 2fa77ed
chore(persist): rename stale TestNoOp* tests; fix misplaced comment i…
wen-coding b5a7d61
chore: remove remaining stale no-op persister references from comments
wen-coding 6e66336
fix: close BlockDB in router tests; simplify loadPersistedState retur…
wen-coding 0cf1aea
chore: remove last stale no-op-mode references from test comments
wen-coding 3ecc27c
fix: propagate data.Close() error on router shutdown
wen-coding db32fcb
fix(data): trim orphaned QC entries when first block is beyond QC start
wen-coding 8b332dc
revert: restore Option[*loadedAvailState] return from loadPersistedState
wen-coding 345d268
refactor(persist): drop Option wrapper from commitQCState.iw
wen-coding 29d6ba4
refactor(consensus): drop Option wrapper from State.persister
wen-coding 355838b
doc(avail): fix loadPersistedState comment — always returns Some
wen-coding 53ea2b7
refactor(data): move BlockDB open/close into GigaRouter.Run
wen-coding 416743a
refactor(data): change blockDB field to utils.Option[BlockDB]; restor…
wen-coding 288c776
fix(lint): check blockDB.Close() error return in GigaRouter.Run
wen-coding 044c7ee
fix(config): restore PersistentStateDir as Option[string]; allow empt…
wen-coding 2ea7b94
fix(tests): wrap PersistentStateDir literals in utils.Some after Opti…
wen-coding c4ec2e9
fix(node): mkdir persistent state dir before constructing GigaRouter
wen-coding 5e22de8
fix(data): always call Init; seed persisted cursors from FirstBlock i…
wen-coding 264804b
refactor(avail): use Init(nil) in inner_test; revert state.go to main
wen-coding aab405d
refactor(consensus): revert state.go/inner.go to main; use Init(nil) …
wen-coding d3e8f77
refactor(producer): use Init(nil) in mempool_test; drop BlockDB depen…
wen-coding 979da63
refactor(giga): use Init(nil) in data_test; drop BlockDB and persistence
wen-coding 6ab21de
refactor(producer): drop unused t from newTestEnv
wen-coding 408dd23
refactor(giga): drop unused t from newTestNode and newTestEnv
wen-coding 8d7552d
revert(avail): restore state.go to origin/main (MaxLaneRangeInProposal)
wen-coding b70e97e
refactor(data): replace blockDBPersistedQC/Block fields with local va…
wen-coding b3c6242
fix(data): remove leftover blockDBPersistedQC/Block assignments in lo…
wen-coding 290a76e
fix(giga): update avail_test.go call site for newTestEnv signature ch…
wen-coding c46ee9d
fix(giga): update consensus_test.go call site for newTestEnv signatur…
wen-coding 87d6bfb
fix(data): capture persist cursors in Init to prevent PushQC startup …
wen-coding 9311628
fix(giga): log loud warning when HashVault disabled due to missing Pe…
wen-coding e12bf9c
test(data,consensus): rename newTestLittDB→newTestBlockDB, use real B…
wen-coding 6f0795f
fix(data): clarify loadFromBlockDB comment re lock usage
wen-coding 46e6a31
refactor(data): replace iterErr pattern with IIFE, drop Close() error…
wen-coding 3aead2c
fix(giga): update stale buildDataState comment to reflect Init+Run split
wen-coding 53951f5
refactor(data): move BlockDB open+replay into NewState constructor
wen-coding df8ddcf
refactor(p2p): pass hashVault as param to executeBlock, drop struct f…
wen-coding 344eb21
refactor(data): IIFE+defer for iterators, drop bool flags in loadFrom…
wen-coding File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,9 +3,12 @@ package consensus | |
| import ( | ||
| "context" | ||
| "errors" | ||
| "fmt" | ||
| "path/filepath" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/sei-protocol/sei-chain/sei-db/ledger_db/block/littblock" | ||
| "github.com/sei-protocol/sei-chain/sei-tendermint/autobahn/types" | ||
| "github.com/sei-protocol/sei-chain/sei-tendermint/internal/autobahn/consensus/persist" | ||
| "github.com/sei-protocol/sei-chain/sei-tendermint/internal/autobahn/data" | ||
|
|
@@ -15,6 +18,28 @@ import ( | |
| "github.com/sei-protocol/sei-chain/sei-tendermint/libs/utils/require" | ||
| ) | ||
|
|
||
| func newTestBlockDB(t *testing.T, dir string) types.BlockDB { | ||
| t.Helper() | ||
| cfg, err := littblock.DefaultConfig(dir) | ||
| if err != nil { | ||
| t.Fatalf("littblock.DefaultConfig: %v", err) | ||
| } | ||
| db, err := littblock.NewBlockDB(cfg) | ||
| if err != nil { | ||
| t.Fatalf("littblock.NewBlockDB: %v", err) | ||
| } | ||
| t.Cleanup(func() { _ = db.Close() }) | ||
| return db | ||
| } | ||
|
wen-coding marked this conversation as resolved.
|
||
|
|
||
| func newTestDataState(committee *types.Committee) *data.State { | ||
| s, err := data.NewState(&data.Config{Committee: committee}, utils.None[types.BlockDB]()) | ||
| if err != nil { | ||
| panic(fmt.Sprintf("data.NewState: %v", err)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seem kind of inconsistent that you use panic in some helpers and t.Fatalf in others (t.Fatalf won't work in non-main goroutine). |
||
| } | ||
| return s | ||
| } | ||
|
|
||
| // seedPersistedInner is a test helper that persists a persistedInner using the public API. | ||
| func seedPersistedInner(dir string, state *persistedInner) { | ||
| p, _, err := persist.NewPersister[*pb.PersistedInner](utils.Some(dir), innerFile) | ||
|
|
@@ -923,15 +948,21 @@ func (f failPersister[T]) Persist(T) error { return f.err } | |
| func TestRunOutputsPersistErrorPropagates(t *testing.T) { | ||
| // Verify that a persist error in runOutputs propagates | ||
| // and terminates the consensus component (instead of panicking). | ||
| dir := t.TempDir() | ||
| rng := utils.TestRng() | ||
| committee, keys := types.GenCommittee(rng, 4) | ||
| ds := utils.OrPanic1(data.NewState(&data.Config{Committee: committee}, utils.OrPanic1(data.NewDataWAL(utils.None[string](), committee)))) | ||
| db := newTestBlockDB(t, filepath.Join(dir, "blockdb")) | ||
| ds, err := data.NewState(&data.Config{Committee: committee}, utils.Some[types.BlockDB](db)) | ||
| if err != nil { | ||
| t.Fatalf("data.NewState: %v", err) | ||
| } | ||
|
|
||
| wantErr := errors.New("disk on fire") | ||
| pers := utils.Some[persist.Persister[*pb.PersistedInner]](failPersister[*pb.PersistedInner]{err: wantErr}) | ||
| cs, err := newState(&Config{ | ||
| Key: keys[0], | ||
| ViewTimeout: func(types.View) time.Duration { return time.Hour }, | ||
| Key: keys[0], | ||
| ViewTimeout: func(types.View) time.Duration { return time.Hour }, | ||
| PersistentStateDir: utils.Some(dir), | ||
| }, ds, pers, utils.None[*pb.PersistedInner]()) | ||
| require.NoError(t, err) | ||
|
|
||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't you say that you will use the real BlockDB in tests though?