Skip to content

Add config to enable lattice hash#3043

Merged
yzang2019 merged 4 commits intomainfrom
yzang/add-lattice-hash-participation
Mar 10, 2026
Merged

Add config to enable lattice hash#3043
yzang2019 merged 4 commits intomainfrom
yzang/add-lattice-hash-participation

Conversation

@yzang2019
Copy link
Contributor

Describe your changes and provide context

This PR add a new config to enable lattice hash participation in app hash.

Testing performed to validate your change

Added unit test

@github-actions
Copy link

github-actions bot commented Mar 9, 2026

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

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedMar 10, 2026, 6:09 PM

@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.32%. Comparing base (fa2080d) to head (827bfcc).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3043      +/-   ##
==========================================
- Coverage   58.38%   58.32%   -0.06%     
==========================================
  Files        2080     2080              
  Lines      171898   171831      -67     
==========================================
- Hits       100364   100223     -141     
- Misses      62596    62675      +79     
+ Partials     8938     8933       -5     
Flag Coverage Δ
sei-chain-pr 56.27% <100.00%> (?)
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/seidb.go 63.85% <100.00%> (+0.44%) ⬆️
sei-cosmos/server/config/config.go 94.68% <100.00%> (+0.02%) ⬆️
sei-db/config/sc_config.go 100.00% <100.00%> (ø)
sei-db/state_db/sc/composite/store.go 64.74% <100.00%> (+16.00%) ⬆️
sei-db/state_db/sc/flatkv/store.go 59.40% <100.00%> (+0.61%) ⬆️

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

StoreInfos: combined,
}
}
return commitInfo
Copy link
Contributor

Choose a reason for hiding this comment

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

duplicate "evm" StoreInfo: in DualWrite mode, all changesets (including EVM) are sent to the cosmos committer. This means cosmosCommitter.WorkingCommitInfo() already contains an "evm" StoreInfo with the IAVL hash. The code then appends a second "evm" StoreInfo with the lattice hash

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's what we want. MemIAVL still have data for EVM, and we also have EVM for flatKV during the migration. So both EVM data need to participate in hash

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh actually we can't have two module hash with the same name, going to fix this

scConfig.ReadMode = parsedRM
}

scConfig.EnableLatticeHash = cast.ToBool(appOpts.Get(FlagSCEnableLatticeHash))
Copy link
Contributor

Choose a reason for hiding this comment

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

Setting EnableLatticeHash = true with WriteMode = CosmosOnlyWrite is a silent no-op because evmCommitter is nil. The Validate() method can catch this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, but I think this is probably fine, we don't have to panic here. EnableLatticeHash only take effects when FlatKV is being used, which is expected.

}

// LastCommitInfo returns the last commit info
func (cs *CompositeCommitStore) LastCommitInfo() *proto.CommitInfo {
Copy link
Contributor

Choose a reason for hiding this comment

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

some code duplication between WorkingCommitInfo and LastCommitInfo, consider extract a helper?

Copy link
Contributor Author

@yzang2019 yzang2019 Mar 9, 2026

Choose a reason for hiding this comment

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

Will look into that, good suggestion!

ReadMode ReadMode `mapstructure:"read_mode"`

// EnableLatticeHash controls whether lattice hash will be participating in final app hash or not
EnableLatticeHash bool `mapstructure:"enable-lattice-hash"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Data format:

EnableLatticeHash bool mapstructure:"enable-lattice-hash"

other fields:
WriteMode WriteMode mapstructure:"write_mode"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, will fix

}
})

t.Run("enabled appends flatkv lattice hash", func(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding a multi-commit test to ensure the lattice hash accumulates correctly and doesn't reset or diverge across versions. Also consider testing the interaction with SplitWrite mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"Consider adding a multi-commit test to ensure the lattice hash accumulates correctly and doesn't reset or diverge across versions"

Isn't that already covered by the store_test in flatkv?

Also consider testing the interaction with SplitWrite mode

Yes, I can add that as well

@yzang2019 yzang2019 enabled auto-merge (squash) March 10, 2026 18:08
@yzang2019 yzang2019 merged commit 206552b into main Mar 10, 2026
39 checks passed
@yzang2019 yzang2019 deleted the yzang/add-lattice-hash-participation branch March 10, 2026 18:26
blindchaser added a commit that referenced this pull request Mar 13, 2026
This commit was inadvertently reverted by the squash-merge of #3039.
Restores LatticeHashEnabled config option in StateCommitConfig,
composite store lattice hash support, and related tests.

Conflict resolved: store_test.go needed all three imports (metrics
from HEAD, evm+logger from #3043).

Made-with: Cursor
blindchaser added a commit that referenced this pull request Mar 13, 2026
The cherry-picked tests from #3035 and #3043 still referenced the
old logger package (removed by #3050 slog migration). Fix:
- composite/store_test.go: remove logger import/arg, add CommittedRootHash to mock
- parquet/store_config_test.go: remove dbLogger arg from NewStore
- receipt/parquet_store_test.go: remove dbLogger arg from NewReceiptStore

Made-with: Cursor
github-merge-queue bot pushed a commit that referenced this pull request Mar 13, 2026
## Summary

The squash-merge of #3039 (`feat(flatkv): add read-only LoadVersion for
state sync`) inadvertently reverted changes from 5 previously-merged
PRs. The `yiren/flatkv-readonly` branch had accumulated stale versions
of files through merge-from-main commits, and when the final
squash-merge landed, those stale versions overwrote the newer code on
`main`.

### PRs reverted by #3039 and restored in this PR

| PR | Title | Key changes lost |
|---|---|---|
| **#2810** | fix(giga): check whether txs follow Giga ordering |
`firstCosmosSeen` tx ordering check, `len(evmEntries) > 0` /
`len(v2Entries) > 0` guards in `ProcessTXsWithOCCGiga` |
| **#3035** | Add receiptdb config option in app.toml |
`ReceiptStoreConfig` in app.toml, `readReceiptStoreConfig()`,
`BackendTypeName()`, receipt config tests |
| **#3043** | Add config to enable lattice hash | `EnableLatticeHash`
config, composite store lattice hash support |
| **#3021** | Background Transaction Generation | `block.go`,
`block_builder.go` for cryptosim benchmark |
| **#3046** | Add console logger and fix memiavl config for benchmark |
`BlocksPerCommit=1`, `SnapshotInterval=1000`,
`SnapshotMinTimeInterval=60` |

### Conflict resolutions

Since several PRs landed after #3039 (notably #3050 slog migration,
#3053 flaky test fix, #3062 admin service), cherry-picks required manual
conflict resolution:

- **`app/app.go`** (#2810): Kept #2810's structural changes, used
`logger.Error` (from #3050) instead of `ctx.Logger().Error`
- **`cmd/seid/cmd/app_config.go`** (#3035): Kept both `ReceiptStore`
(from #3035) and `Admin` (from #3062)
- **`sei-db/ledger_db/receipt/receipt_store.go`** (#3035): Restored
`BackendTypeName` but dropped logger param (superseded by #3050 slog)
- **`sei-db/ledger_db/receipt/parquet_store_test.go`** (#3035): Kept
#3053's deterministic pruning test fix
- **`sei-db/state_db/sc/composite/store_test.go`** (#3043): Merged all
three needed imports
- **`sei-db/common/logger/logger.go`** (#3046): Kept deletion from
#3050; `consoleLogger` is no longer needed with slog
- **`sei-db/state_db/bench/wrappers/db_implementations.go`** (#3046):
Kept #3050's no-logger-param API

---------

Signed-off-by: Cody Littley <cody.littley@seinetwork.io>
Co-authored-by: Cody Littley <56973212+cody-littley@users.noreply.github.com>
Co-authored-by: Cody Littley <cody.littley@seinetwork.io>
yzang2019 added a commit that referenced this pull request Mar 19, 2026
This PR add a new config to enable lattice hash participation in app
hash.

Added unit test
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.

3 participants