Skip to content

Conversation

@ruslan0012
Copy link
Contributor

The Sub() method on *big.Int modifies the receiver in place. The old code was mutating latestHeader.Number that was passed from the caller, which could lead to incorrect block number being used after the function returns.

Changed from:
latestHeader.Number.Sub(latestHeader.Number, big.NewInt(5))

To:
new(big.Int).Sub(latestHeader.Number, big.NewInt(5))

This matches the pattern used elsewhere in the codebase (e.g. challenge_manager.go:220).

@eljobe eljobe self-assigned this Dec 16, 2025
eljobe
eljobe previously approved these changes Dec 19, 2025
Copy link
Member

@eljobe eljobe left a comment

Choose a reason for hiding this comment

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

Nice catch. This isn't currently causing any problems, because the only caller of this method in production code doesn't go on to use the latestHeader.Number later in the code. But, if the code were changed to start reading it, this would, indeed be quite surprising.

@eljobe eljobe enabled auto-merge December 19, 2025 09:23
@eljobe eljobe added this pull request to the merge queue Dec 19, 2025
@codecov
Copy link

codecov bot commented Dec 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.24%. Comparing base (9e434ee) to head (eb49c49).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #4116       +/-   ##
===========================================
+ Coverage   33.05%   57.24%   +24.19%     
===========================================
  Files         459      459               
  Lines       55830    55830               
===========================================
+ Hits        18453    31959    +13506     
+ Misses      34159    19072    -15087     
- Partials     3218     4799     +1581     

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 19, 2025
@pmikolajczyk41 pmikolajczyk41 assigned ruslan0012 and unassigned eljobe Dec 19, 2025
@pmikolajczyk41
Copy link
Member

@ruslan0012 please add a changelog fragment

@ruslan0012
Copy link
Contributor Author

done, thanks

Copy link
Member

@joshuacolvin0 joshuacolvin0 left a comment

Choose a reason for hiding this comment

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

LGTM

@joshuacolvin0 joshuacolvin0 added this pull request to the merge queue Dec 29, 2025
Merged via the queue into OffchainLabs:master with commit beb5c5b Dec 29, 2025
24 checks passed
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.

4 participants