Skip to content

add receipt generation to cryptosim#3047

Merged
jewei1997 merged 27 commits intomainfrom
cryptosim-receipt-gen
Mar 18, 2026
Merged

add receipt generation to cryptosim#3047
jewei1997 merged 27 commits intomainfrom
cryptosim-receipt-gen

Conversation

@jewei1997
Copy link
Contributor

@jewei1997 jewei1997 commented Mar 10, 2026

Describe your changes and provide context

  • Add receipt generation to cryptosim: each simulated ERC20 transfer transaction now produces a realistic receipt with logs, bloom filter, gas fields, and tx type distribution
  • Add a RecieptStoreSimulator that consumes generated receipts and writes them to a parquet store with WAL, flush, rotation, and pruning — matching the real node's write path
  • Add configurable parquet store settings: ReceiptKeepRecent, ReceiptPruneIntervalSeconds, ReceiptMaxBlocksPerFile, ReceiptBlockFlushInterval
  • Add receipt write metrics: receipt_block_write_duration_seconds (histogram), receipt_channel_depth (gauge), receipts_written_total (counter), receipt_errors_total (counter)
  • Move block building to a background goroutine (blockBuilder) so transaction generation doesn't block the main execution loop

Set "GenerateReceipts": true to enable. See config/reciept-store.json for an example config. All receipt store tuning parameters have production-matching defaults and can be left unset.

Testing performed to validate your change

unit tests + running cryptosim simulation

@github-actions
Copy link

github-actions bot commented Mar 10, 2026

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

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedMar 18, 2026, 6:29 PM

@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.58%. Comparing base (8a11ce5) to head (00f5e88).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3047      +/-   ##
==========================================
- Coverage   58.61%   58.58%   -0.03%     
==========================================
  Files        2090     2090              
  Lines      172771   172771              
==========================================
- Hits       101262   101211      -51     
- Misses      62532    62567      +35     
- Partials     8977     8993      +16     
Flag Coverage Δ
sei-chain-pr 75.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 Δ
sei-db/ledger_db/receipt/parquet_store.go 67.42% <100.00%> (ø)

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

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

LGTM, pending review of dashboard changes.

Comment on lines +22 to +26
var receiptWriteLatencyBuckets = []float64{
0.001, 0.0025, 0.005, 0.0075, 0.01,
0.015, 0.02, 0.03, 0.05, 0.075,
0.1, 0.25, 0.5, 0.75, 1, 2.5, 5,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll want to eventually replace this block with the one defined in https://github.com/sei-protocol/sei-chain/blob/fe31475c4e295d695ee7f09fcbfefea9f39e7032/sei-db/common/metrics/buckets.go

The buckets.go linked above isn't merged yet, so no need to block this PR. Just mentioning this so we don't forget to do it later.

m.mainThreadPhase.SetPhase(phase)
}

func (m *CryptosimMetrics) RecordReceiptBlockWriteDuration(seconds float64) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to change the parameter to latency time.Duration, then convert it to seconds internally in this method? In general, I think it's cleaner to pass around time quantities as durations when possible, since it reduces the chances of accidentally messing up the units. There are a few rare exceptions to this rule, e.g. we probably want to use non-duration values in config files. But when we are measuring latencies, the duration type is good to use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@jewei1997 jewei1997 added this pull request to the merge queue Mar 18, 2026
Merged via the queue into main with commit ee28dfe Mar 18, 2026
38 checks passed
@jewei1997 jewei1997 deleted the cryptosim-receipt-gen branch March 18, 2026 20:28
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