Skip to content

Restructure sei data folder for Giga#3155

Open
yzang2019 wants to merge 6 commits intomainfrom
yzang/restruct-data-folder
Open

Restructure sei data folder for Giga#3155
yzang2019 wants to merge 6 commits intomainfrom
yzang/restruct-data-folder

Conversation

@yzang2019
Copy link
Copy Markdown
Contributor

@yzang2019 yzang2019 commented Mar 31, 2026

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
Copy link
Copy Markdown

github-actions bot commented Mar 31, 2026

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

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedApr 2, 2026, 9:05 AM

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

codecov bot commented Mar 31, 2026

Codecov Report

❌ Patch coverage is 92.30769% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.60%. Comparing base (a9ffa16) to head (b4d61bb).

Files with missing lines Patch % Lines
sei-tendermint/cmd/tendermint/commands/reset.go 80.00% 3 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.58%   58.60%   +0.01%     
==========================================
  Files        2055     2099      +44     
  Lines      168301   173447    +5146     
==========================================
+ Hits        98594   101642    +3048     
- Misses      60917    62662    +1745     
- Partials     8790     9143     +353     
Flag Coverage Δ
sei-chain-pr 62.10% <92.30%> (?)
sei-db 70.41% <ø> (ø)

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 71.42% <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 65.59% <100.00%> (ø)
sei-db/state_db/sc/memiavl/store.go 92.59% <100.00%> (ø)
sei-db/state_db/ss/composite/store.go 72.63% <100.00%> (+1.35%) ⬆️
sei-tendermint/config/config.go 70.62% <100.00%> (+0.46%) ⬆️
sei-tendermint/config/db.go 100.00% <100.00%> (ø)
...endermint/cmd/tendermint/commands/reindex_event.go 74.84% <75.00%> (+0.31%) ⬆️
sei-tendermint/cmd/tendermint/commands/reset.go 60.62% <80.00%> (+15.44%) ⬆️

... and 118 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.

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

}
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)
Copy link
Copy Markdown
Collaborator

@masih masih left a comment

Choose a reason for hiding this comment

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

No blockers 🚀

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.

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

@cody-littley cody-littley left a comment

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)?

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