Skip to content

Restructure sei data folder for Giga#3155

Merged
yzang2019 merged 12 commits into
mainfrom
yzang/restruct-data-folder
Apr 22, 2026
Merged

Restructure sei data folder for Giga#3155
yzang2019 merged 12 commits into
mainfrom
yzang/restruct-data-folder

Conversation

@yzang2019

@yzang2019 yzang2019 commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Describe your changes and provide context

The current data folder is not intuitive and not very clean for Giga storage. It currently looks like this:
image

The goal of this PR is to restructure the data folder for Giga into this new structure while also making it backward compatible:
image

Testing performed to validate your change

Added unit test to make sure it works for both new nodes and existing nodes which has the old path

@github-actions

github-actions Bot commented Mar 31, 2026

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedApr 22, 2026, 5:01 AM

@yzang2019 yzang2019 requested a review from jewei1997 March 31, 2026 23:45
@codecov

codecov Bot commented Mar 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.03540% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.77%. Comparing base (f3d84e0) to head (8ebf801).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
sei-tendermint/cmd/tendermint/commands/reset.go 76.66% 5 Missing and 2 partials ⚠️
...endermint/cmd/tendermint/commands/reindex_event.go 75.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3155      +/-   ##
==========================================
+ Coverage   58.50%   58.77%   +0.26%     
==========================================
  Files        2072     2101      +29     
  Lines      207965   175825   -32140     
==========================================
- Hits       121680   103334   -18346     
+ Misses      77494    63325   -14169     
- Partials     8791     9166     +375     
Flag Coverage Δ
sei-chain-pr 61.65% <91.66%> (?)
sei-db 69.36% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
app/receipt_store_config.go 70.00% <100.00%> (ø)
sei-db/common/utils/path.go 100.00% <100.00%> (ø)
sei-db/config/ss_config.go 100.00% <ø> (ø)
sei-db/state_db/sc/composite/store.go 64.83% <100.00%> (ø)
sei-db/state_db/sc/memiavl/store.go 90.90% <100.00%> (ø)
sei-db/state_db/ss/composite/store.go 79.39% <100.00%> (+11.10%) ⬆️
sei-tendermint/config/config.go 72.60% <100.00%> (+3.88%) ⬆️
sei-tendermint/config/db.go 100.00% <100.00%> (ø)
...endermint/cmd/tendermint/commands/reindex_event.go 73.65% <75.00%> (+0.25%) ⬆️
sei-tendermint/cmd/tendermint/commands/reset.go 58.44% <76.66%> (+14.61%) ⬆️

... and 1801 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread sei-tendermint/config/db.go Outdated
return filepath.Join(baseDir, subDir)
}

func pathExists(path string) bool {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dup func pathExists

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean this one and the one in sei-db? I think this is fine we don't wanna couple sei-tendemrint and sei-db. Tendermint manages their own db separately than sei-db

if !os.FileExists(filepath.Join(cfg.DBDir(), "blockstore.db")) {
blockstoreDir := tmcfg.ResolveDBDir("blockstore", cfg.DBDir())
if !os.FileExists(filepath.Join(blockstoreDir, "blockstore.db")) {
return nil, nil, fmt.Errorf("no blockstore found in %v", cfg.DBDir())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the error msg seems to should be against blockstoreDir instead of cfg.DBDir()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

return nil, nil, fmt.Errorf("no blockstore found in %v", cfg.DBDir())
stateDir := tmcfg.ResolveDBDir("state", cfg.DBDir())
if !os.FileExists(filepath.Join(stateDir, "state.db")) {
return nil, nil, fmt.Errorf("no state store found in %v", cfg.DBDir())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, error msg against stateDir instead of cfg.DBDir()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

}
// ResetState removes all blocks, tendermint state, indexed transactions and evidence.
// It handles both the legacy flat layout and the new subdirectory layout.
func ResetState(dbDir string) error {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider updating reset related unit testings

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

Comment thread app/receipt_store_config.go Outdated
}
if receiptConfig.DBDirectory == "" {
receiptConfig.DBDirectory = filepath.Join(homePath, "data", "receipt.db")
receiptConfig.DBDirectory = utils.GetReceiptStorePath(homePath)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

readReceiptStoreConfig() was changed to default to data/ledger/receipt.db, but the emitted config template still says /data/receipt.db

need to update the related toml.go

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

yzang2019 and others added 3 commits April 1, 2026 13:07
* main:
  plt-228 fixed static check on app and evmrpc package (#3154)
  flatkv cache (#3027)
  Make cryptosim state store backend configurable + No Op Wrapper + Read Disable Config (#3145)
  Add warning message for IAVL deprecation (#3159)
  Change default min valid per window to zero (#3157)
  support for starting autobahn from non-zero global block (#3136)
  Fix upgrade list comparison to respect semver (#3153)

@masih masih left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blockers 🚀

Comment thread sei-db/common/utils/path.go Outdated
func GetStateStorePath(homePath string, backend string) string {
return filepath.Join(homePath, "data", backend)
legacyPath := filepath.Join(homePath, "data", backend)
if PathExists(legacyPath) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: Is there ever a case where an abrupt node failure could cause the creation of an empty directory here?

If so, for robustness i recommend checking if this dir is empty and proceed with legacy path iff it is not empty.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the creation of empty dir happens, then it will continue proceed with the old path, which is fine. I don't think there's any case where it is started with the new path first and then suddenly crash and create an old path

Comment thread sei-db/common/utils/path.go Outdated
return filepath.Join(homePath, "data", "committer.db")
// PathExists returns true if the given path exists on disk.
func PathExists(path string) bool {
_, err := os.Stat(path)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Harden this by requiring the type of path? e.g. directory? file etc.

This is racy in that it doesn't atomically check and it repeatedly checks but hopefully the probability of race is low enough that we can accept the race condition as negligible.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense, will do

@cody-littley cody-littley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this PR handle migration (i.e. moving memiavl data from original location to new location)?

@yzang2019

Copy link
Copy Markdown
Contributor Author

Does this PR handle migration (i.e. moving memiavl data from original location to new location)?

We can handle that in the future, this PR doesn't do the migration, it's preparing the new folder structure for new nodes only

@yzang2019 yzang2019 enabled auto-merge April 3, 2026 17:01
@yzang2019 yzang2019 added this pull request to the merge queue Apr 3, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 3, 2026
* main: (51 commits)
  Giga storage integration test (#3268)
  test(flatkv): add flatkv integration testings (#3262)
  perf(app): reuse decoded transactions across ProcessProposalHandler hot path (#3257)
  Fix of the proto conv testing (#3261)
  FlatKV refactor for state sync import + export (#3250)
  Validate block part index matches proof index (CON-20) (#3256)
  fix: add retry to apt-get update in Docker CI (#3264)
  fix: autobahn InitChain, GetValidators, and mempool TTL (CON-249) (#3243)
  Fix buffer offset in ProposerPriorityHash (CON-200) (#3255)
  Handle error case in light client divergence detector (#3254)
  perf(evmrpc): eliminate redundant block fetches in simulate backend (#3208)
  fix(evmrpc): omit notifications from legacy JSON-RPC batch responses per spec (#3246)
  fix: deduplicate block fetch in getTransactionReceipt (#3244)
  Made autobahn producer use TxMempool (#3224)
  Skip signature event building during Cosmos CheckTx/ReCheckTx (#3230)
  Regenerate changelog in prep to tag v6.4.2 (#3240)
  Fix receipt default retention (#3237)
  feat(flatkv): introduce module-prefix physical keys across all FlatKV DBs (#3229)
  added a ProposerAddress check to setProposal CON-250 (#3232)
  feat: add AUTOBAHN option to local docker cluster (CON-247) (#3220)
  ...
@yzang2019 yzang2019 enabled auto-merge April 20, 2026 20:33
* main:
  Giga store migration guide (#3227)
  Update SS write/read modes into single evm-ss-mode (#3278)
  fix(evmrpc): return empty array instead of null for eth_getFilterLogs and eth_getFilterChanges (#3292)
  feat: add autobahn integration tests - batch 1 (CON-249) (#3234)
  add block height modified to legacy data (#3276)
  Export ProposerPriorityHash metric for divergence monitoring (#3277)
  backport CW/wasmd@76eaff4 (#3258)
@yzang2019 yzang2019 added this pull request to the merge queue Apr 22, 2026
Merged via the queue into main with commit 8a0da0e Apr 22, 2026
40 of 41 checks passed
@yzang2019 yzang2019 deleted the yzang/restruct-data-folder branch April 22, 2026 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants