Skip to content

persist: add CRC32-C integrity check and seq validation to A/B files#3105

Open
wen-coding wants to merge 4 commits intomainfrom
wen/productionize_ab_file_persistence
Open

persist: add CRC32-C integrity check and seq validation to A/B files#3105
wen-coding wants to merge 4 commits intomainfrom
wen/productionize_ab_file_persistence

Conversation

@wen-coding
Copy link
Contributor

Summary

  • Add a crc32 field to PersistedWrapper proto covering both seq and data (CRC32-C Castagnoli, matching sei-tendermint/internal/libs/wal).
  • On write, compute and store the checksum. On load, reject files with missing/zero seq or missing/mismatched crc32 as ErrCorrupt.
  • This catches silent truncation and bit-rot that proto.Unmarshal alone would miss, since trailing optional fields can be silently lost.

Changes:

  • autobahn.proto: new optional uint32 crc32 = 3 on PersistedWrapper
  • persist.go: wrapperChecksum(seq, data) helper using CRC32-C over [8-byte LE seq || data]; validation in loadWrapped; checksum set in Persist
  • persist_test.go: tests for CRC32 mismatch (data corruption), CRC32 mismatch (seq corruption), missing CRC32, missing seq, zero seq, and CRC32 round-trip verification

Test plan

  • All autobahn tests pass (avail, consensus, persist, data, types)
  • Race detector clean
  • go vet clean

Made with Cursor

Add a crc32 field to PersistedWrapper covering seq and data (CRC32-C
Castagnoli, matching the WAL library). On load, reject files with
missing/zero seq or missing/mismatched crc32 as ErrCorrupt.

This catches silent truncation and bit-rot that proto.Unmarshal alone
would miss, since trailing optional fields can be silently lost.

Made-with: Cursor
@github-actions
Copy link

github-actions bot commented Mar 20, 2026

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

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedMar 21, 2026, 3:30 AM

@github-actions
Copy link

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

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedMar 20, 2026, 11:33 PM

@codecov
Copy link

codecov bot commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.68%. Comparing base (f6b04aa) to head (b740a7f).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3105   +/-   ##
=======================================
  Coverage   58.68%   58.68%           
=======================================
  Files        2096     2096           
  Lines      173248   173261   +13     
=======================================
+ Hits       101667   101680   +13     
  Misses      62541    62541           
  Partials     9040     9040           
Flag Coverage Δ
sei-chain-pr 76.01% <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 Δ
...int/internal/autobahn/consensus/persist/persist.go 82.08% <100.00%> (+1.92%) ⬆️
🚀 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.

Avoid hash.Hash.Write (gosec G104) by chaining crc32.Update like the
WAL library; document the parallel with Checksum/Update.

Made-with: Cursor
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.

1 participant