Skip to content

test(consensus): pin the timestamp check before the parent lookup - #2553

Open
gzliudan wants to merge 1 commit into
XinFinOrg:dev-upgradefrom
gzliudan:test-timestamp-check-precedes-parent
Open

test(consensus): pin the timestamp check before the parent lookup#2553
gzliudan wants to merge 1 commit into
XinFinOrg:dev-upgradefrom
gzliudan:test-timestamp-check-precedes-parent

Conversation

@gzliudan

@gzliudan gzliudan commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Pin the timestamp-check ordering in header verification with regression tests, extracted from the verified work on fix-insertchain-known-blocks.

XDPoS v1/v2 (under full verification) check the block timestamp before resolving the parent: a block whose timestamp is too far ahead answers ErrFutureBlock even when its parent is not yet resolvable. These tests pin that behavior — the future-batch tail queueing (queueFutureTail) relies on children of a future block surfacing as ErrFutureBlock, not ErrUnknownAncestor.

Changes

  • consensus/XDPoS/engines/engine_v1/verify_header_test.go (new, 117 lines): TestFutureTimestampCheckPrecedesParentLookup
  • consensus/tests/engine_v2_tests/verify_header_test.go (+78): same pin for the v2 engine

No production code is changed.

Verification

  • gofmt / goimports / go vet clean
  • TestFutureTimestampCheckPrecedesParentLookup passes on both engines
  • Full package tests pass: go test ./consensus/XDPoS/engines/engine_v1/... ./consensus/tests/engine_v2_tests/... — 0 failures

@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: aadf0405-05ed-4910-af8d-132c792a6631

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Add regression tests asserting that header verification checks the
timestamp first and answers ErrFutureBlock for blocks too far ahead,
without requiring their parent to be resolvable. XDPoS v1/v2 (under
full verification) order the checks this way; these tests pin the
behavior the future-batch tail queueing (queueFutureTail) relies on:
children of a future block surface as ErrFutureBlock, not
ErrUnknownAncestor.

No production code is changed.
@gzliudan
gzliudan force-pushed the test-timestamp-check-precedes-parent branch from 87930b8 to 3a06cb3 Compare September 8, 2026 05:39
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