Skip to content

fix(logpoller): minor patches#584

Open
jadepark-dev wants to merge 11 commits intomainfrom
jade/logpoller-minor-fixes
Open

fix(logpoller): minor patches#584
jadepark-dev wants to merge 11 commits intomainfrom
jade/logpoller-minor-fixes

Conversation

@jadepark-dev
Copy link
Collaborator

@jadepark-dev jadepark-dev commented Feb 5, 2026

Summary

  • Fix replay data model to store fromBlock (uint32) and prevBlock (*BlockIDExt) separately instead of a single requestBlock, fixing off-by-one edge cases in (prev, to] block
    range semantics and enabling block 1 replay
  • Add ValidateBlockIDExt to validate RootHash/FileHash lengths (32 bytes) at ingestion and deserialization boundaries
  • Harden BOC handling: reject nil log data and detect inconsistent header/payload states
  • Fix read-locked replay status access via ReplayStatus() accessor
  • Fix test BlockIDExt fixtures to include required RootHash/FileHash fields

@jadepark-dev jadepark-dev marked this pull request as ready for review February 5, 2026 13:58
@jadepark-dev jadepark-dev requested a review from a team as a code owner February 5, 2026 13:58
Copilot AI review requested due to automatic review settings February 5, 2026 13:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes several issues in the logpoller replay mechanism and hardens data validation:

Changes:

  • Refactors replay data model to separately track fromBlock and prevBlock instead of a single requestBlock, fixing off-by-one errors and enabling block 1 replay
  • Adds ValidateBlockIDExt function to validate RootHash/FileHash are 32 bytes at ingestion and deserialization points
  • Hardens BOC handling by rejecting nil log data and detecting inconsistent header/payload states
  • Fixes replay status access using ReplayStatus() method instead of direct field access
  • Updates test fixtures to include required RootHash/FileHash fields

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/logpoller/store/postgres/models_test.go Adds required RootHash/FileHash fields to test BlockIDExt fixture
pkg/logpoller/store/postgres/models.go Adds nil check for log.Data, validates BlockIDExt, and detects inconsistent BOC header/payload states
pkg/logpoller/service.go Updates replay logic to use new fromBlock/prevBlock model and fixes status access
pkg/logpoller/replay_test.go Updates tests to reflect new replay data model with fromBlock/prevBlock separation
pkg/logpoller/replay.go Refactors replay state tracking to use fromBlock+prevBlock instead of single requestBlock
pkg/logpoller/models/models_test.go Adds comprehensive tests for ValidateBlockIDExt function
pkg/logpoller/models/models.go Adds ValidateBlockIDExt function with int256Len constant
pkg/logpoller/loader/loader.go Adds ValidateBlockIDExt call during transaction loading
integration-tests/smoke/chainaccessor/accessor_test.go Adds testBlockIDExt helper and updates fixtures to include hash fields
integration-tests/logpoller/pg_pruning_test.go Updates test fixtures to use testBlockIDExt helper
integration-tests/logpoller/pg_logs_test.go Adds testBlockIDExt helper and updates fixtures

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ogtownsend
ogtownsend previously approved these changes Feb 6, 2026
@@ -99,18 +99,21 @@ type logModel struct {

// FromLog converts a models.Log to logModel
func (l *logModel) FromLog(log lptypes.Log) (logModel, error) {
Copy link
Contributor

@huangzhen1997 huangzhen1997 Feb 6, 2026

Choose a reason for hiding this comment

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

Nit: I noticed both value and pointer receivers are used for logModel (and filterModel above). The Go convention if any method needs a pointer receiver (state changes), make them all pointer receivers for that type.

)

// testBlockIDExt creates a valid BlockIDExt for testing with required hash fields
func testBlockIDExt(seqNo uint32) *ton.BlockIDExt {
Copy link
Contributor

Choose a reason for hiding this comment

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

This duplicates with integration-tests/logpoller/pg_logs_test.go, could consider moving into testutil package

huangzhen1997
huangzhen1997 previously approved these changes Feb 6, 2026
Copy link
Contributor

@huangzhen1997 huangzhen1997 left a comment

Choose a reason for hiding this comment

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

lgtm, just few minor nits

@jadepark-dev jadepark-dev dismissed stale reviews from huangzhen1997 and ogtownsend via 210452b February 7, 2026 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants