Return new instances of big int for DefaultConfig#804
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a race condition during concurrent TOML marshal/unmarshal of node configuration by ensuring the default max gas price is not shared via a global *big.Int pointer.
Changes:
- Replaced the exported
DefaultMaxGasPriceglobal*big.Intwith a function that returns a new*big.Intper call. - Updated default config/oracle initialization to call
DefaultMaxGasPrice()instead of referencing a shared pointer.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| gossip/gasprice/gasprice.go | Converts default max gas price from shared global pointer to per-call allocation; updates oracle initialization accordingly. |
| gossip/config.go | Updates default gossip config to use gasprice.DefaultMaxGasPrice() when setting GPO.MaxGasPrice. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 11 files with indirect coverage changes 🚀 New features to boost your workflow:
|
LuisPH3
approved these changes
Apr 3, 2026
Contributor
LuisPH3
left a comment
There was a problem hiding this comment.
The PR identifies the source of races during testing, this issue cannot happen in production, but shadows mechanism to detect other race conditions.
- The cause was rather old. Weird that it did not happen before.
- The change introduces regression testing
6461a1c to
130e243
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes https://github.com/0xsoniclabs/sonic-admin/issues/687
The Problem:
A data race was detected in integration tests when multiple nodes attempted to load or save their configurations concurrently. This occurred during the TOML marshaling/unmarshaling process.
To reproduce, checkout commit c89694f and run the following command:
The resulting race detector log points to
UnmarshalTOMLfor both the read and write operations.The Root of the issue:
The
DefaultMaxGasPriceglobal variable was defined as a*big.Int. When the default configuration was copied to load/save the node config, only the pointer address was copied, not the underlying value.When an integration test spins up multiple nodes simultaneously:
UnmarshalTOML, the*big.Intvalue is modified in place.The Solution
Convert the global variable
DefaultMaxGasPriceinto a function that returns a new*big.Intinstance on every call.