Skip to content

Conversation

@jewei1997
Copy link
Contributor

@jewei1997 jewei1997 commented Oct 13, 2025

Describe your changes and provide context

A common workflow that users do is to query the latest height and then query information about that height such as events/logs. However, since we have an option to do async writes for receipts, the events/logs may not be available yet for that height, causing the query to fail.

In general, we want all of our heights outputted by our RPC endpoints to be aligned with each other. We have introduced the concept of a watermark (sei-protocol/sei-db#116) across Tendermint block store, SS Store, and receipt store. Pulling this watermark across all 3 dbs should allow the evmrpc to output the minimum height available across these dbs for a latest height. This will ensure that all data for a given height outputted by our RPCs is available across all our endpoints.

This PR introduces a WatermarkManager that manages the heights of these DBs, which the evmrpc endpoints can use to get the latest heights that are ready.

Testing performed to validate your change

unit tests + manual testing

@github-actions
Copy link

github-actions bot commented Oct 13, 2025

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

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedOct 27, 2025, 6:57 PM

@codecov
Copy link

codecov bot commented Oct 13, 2025

Codecov Report

❌ Patch coverage is 61.90476% with 128 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.57%. Comparing base (555bd4c) to head (9c745f3).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
evmrpc/watermark_manager.go 72.46% 20 Missing and 18 partials ⚠️
evmrpc/filter.go 52.54% 17 Missing and 11 partials ⚠️
testutil/keeper/evm.go 0.00% 22 Missing ⚠️
x/evm/keeper/receipt.go 54.16% 8 Missing and 3 partials ⚠️
evmrpc/info.go 61.53% 5 Missing and 5 partials ⚠️
evmrpc/state.go 62.50% 3 Missing and 3 partials ⚠️
sei-cosmos/storev2/rootmulti/store.go 0.00% 5 Missing ⚠️
evmrpc/block.go 66.66% 3 Missing ⚠️
sei-db/ss/pebbledb/db.go 0.00% 1 Missing and 1 partial ⚠️
x/evm/keeper/keeper.go 0.00% 2 Missing ⚠️
... and 1 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2465      +/-   ##
==========================================
- Coverage   43.62%   43.57%   -0.05%     
==========================================
  Files        1679     1695      +16     
  Lines      143747   145352    +1605     
==========================================
+ Hits        62708    63338     +630     
- Misses      75414    76311     +897     
- Partials     5625     5703      +78     
Flag Coverage Δ
sei-chain 31.66% <63.22%> (+0.16%) ⬆️
sei-cosmos 52.36% <0.00%> (-0.04%) ⬇️
sei-db 48.02% <0.00%> (-0.02%) ⬇️
sei-tendermint 47.47% <ø> (-0.17%) ⬇️
sei-wasmd 45.80% <100.00%> (-0.03%) ⬇️
sei-wasmvm 40.37% <ø> (?)

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

Files with missing lines Coverage Δ
app/app.go 73.29% <100.00%> (+0.01%) ⬆️
app/test_helpers.go 47.19% <ø> (-1.63%) ⬇️
evmrpc/config.go 87.80% <ø> (+1.92%) ⬆️
evmrpc/server.go 91.09% <100.00%> (+0.23%) ⬆️
evmrpc/tx.go 85.31% <100.00%> (+0.75%) ⬆️
evmrpc/utils.go 71.16% <88.88%> (-2.76%) ⬇️
sei-db/ss/pebbledb/db.go 63.86% <0.00%> (-0.20%) ⬇️
x/evm/keeper/keeper.go 48.95% <0.00%> (-0.30%) ⬇️
evmrpc/block.go 54.60% <66.66%> (+3.18%) ⬆️
sei-cosmos/storev2/rootmulti/store.go 31.91% <0.00%> (-0.33%) ⬇️
... and 6 more

... and 34 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 on lines +117 to +121
for h := range c.mockedBlockResults {
if h > latest {
latest = h
}
}

Check warning

Code scanning / CodeQL

Iteration over map Warning test

Iteration over map may be a possible source of non-determinism
@jewei1997 jewei1997 changed the title [wip] Integrate watermark into evmrpc Integrate watermark into evmrpc Oct 14, 2025
@yzang2019
Copy link
Contributor

We should be able to remove sync flush receipt in this PR since we have watermark

if err := k.FlushTransientReceipts(ctx); err != nil {
return err
}
deadline := time.Now().Add(2 * time.Second)

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
} else if err != nil && err.Error() != "not found" {
return err
}
if time.Now().After(deadline) {

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
Copy link
Collaborator

@codchen codchen left a comment

Choose a reason for hiding this comment

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

question: for the earliest state, is it possible for it to become stale after the request to pass the check but before the state is read? (i.e. state pruned after the check but before the actual read)

@jewei1997 jewei1997 enabled auto-merge (squash) October 27, 2025 19:15
@jewei1997 jewei1997 merged commit abdeefe into main Oct 27, 2025
46 of 53 checks passed
@jewei1997 jewei1997 deleted the watermark-evmrpc branch October 27, 2025 19:32
@jewei1997
Copy link
Contributor Author

@codchen I think the situation you mentioned is possible. However, I think we mostly care about latest height for the watermark guarantees.

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.

5 participants