Skip to content

Conversation

@gzliudan
Copy link
Collaborator

@gzliudan gzliudan commented Dec 24, 2025

Proposed changes

Previously, the code used binary.BigEndian.Uint64(data[8:40]), which incorrectly read the index and only extracted the highest 8 bytes of the 32-byte left-padded block number, resulting in wrong values (often zero). Now, the code uses new(big.Int).SetBytes(data[4:36]).Uint64() to correctly extract the block number from the proper 32-byte field. This change fixes both the incorrect index and the parsing logic, ensuring accurate block number extraction and correct validation for special transactions.

eg:

when data is e341eaa4000000000000000000000000000000000000000000000000000000000000000f077c098bfe0729811df156252455c1debd1a8e4b7e781d8c7384ea32d15e5021

old(wrong):
data[8:40] is 0000000000000000000000000000000000000000000000000000000f077c098b
blkNumber is 0

new(right):
data[4:36] is 000000000000000000000000000000000000000000000000000000000000000f
blkNumber is 15

Types of changes

What types of changes does your code introduce to XDC network?
Put an in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)
  • Regular KTLO or any of the maintaince work. e.g code style
  • CICD Improvement

Impacted Components

Which part of the codebase this PR will touch base on,

Put an in the boxes that apply

  • Consensus
  • Account
  • Network
  • Geth
  • Smart Contract
  • External components
  • Not sure (Please specify below)

Checklist

Put an in the boxes once you have confirmed below actions (or provide reasons on not doing so) that

  • This PR has sufficient test coverage (unit/integration test) OR I have provided reason in the PR description for not having test coverage
  • Provide an end-to-end test plan in the PR description on how to manually test it on the devnet/testnet.
  • Tested the backwards compatibility.
  • Tested with XDC nodes running this version co-exist with those running the previous version.
  • Relevant documentation has been updated as part of this PR
  • N/A

@coderabbitai
Copy link

coderabbitai bot commented Dec 24, 2025

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.

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


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 and usage tips.

@gzliudan gzliudan requested a review from anunay-xin December 27, 2025 08:43
Previously, the code used binary.BigEndian.Uint64(data[8:40]), which incorrectly read the index and only extracted the highest 8 bytes of the 32-byte left-padded block number, resulting in wrong values (often zero).
Now, the code uses new(big.Int).SetBytes(data[4:36]).Uint64() to correctly extract the block number from the proper 32-byte field.
This change fixes both the incorrect index and the parsing logic, ensuring accurate block number extraction and correct validation for special transactions.
Copilot AI review requested due to automatic review settings January 5, 2026 08:12
Copy link

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 a critical bug in block number extraction for BlockSignersBinary special transactions. The original code was reading from the wrong byte offset and only parsing the first 8 bytes of a 32-byte field, often resulting in incorrect values (typically zero). The fix correctly extracts the full 32-byte block number field and interprets it as a big-endian integer.

Key Changes:

  • Corrected byte slice from data[8:40] to data[4:36] to properly extract the 32-byte block number field
  • Changed parsing from binary.BigEndian.Uint64() (8-byte read) to new(big.Int).SetBytes().Uint64() (full 32-byte interpretation)
  • Removed unused encoding/binary import

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

@AnilChinchawale AnilChinchawale merged commit 51b99e4 into XinFinOrg:dev-upgrade Jan 5, 2026
19 checks passed
@gzliudan gzliudan deleted the fix-blkNumber branch January 5, 2026 10:33
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.

4 participants