fix(nano): Stop sharing NanoRNG object between contracts#1333
Merged
fix(nano): Stop sharing NanoRNG object between contracts#1333
Conversation
msbrogli
commented
Jul 22, 2025
ca750a4 to
00cec83
Compare
msbrogli
commented
Jul 22, 2025
3649819 to
1bf0004
Compare
|
| Branch | fix/nano-shared-rng |
| Testbed | ubuntu-22.04 |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result minutes (m) (Result Δ%) | Lower Boundary minutes (m) (Limit %) | Upper Boundary minutes (m) (Limit %) |
|---|---|---|---|---|
| sync-v2 (up to 20000 blocks) | 📈 view plot 🚷 view threshold | 1.66 m(+1.54%)Baseline: 1.64 m | 1.47 m (88.63%) | 1.80 m (92.31%) |
71c2e35 to
a25f88a
Compare
glevco
previously approved these changes
Jul 23, 2025
a25f88a to
79aaeba
Compare
222f605 to
3af7c29
Compare
53280da to
a70744d
Compare
glevco
reviewed
Jul 24, 2025
jansegre
previously approved these changes
Jul 24, 2025
a70744d to
3c57a23
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1333 +/- ##
=======================================
Coverage 85.65% 85.66%
=======================================
Files 424 424
Lines 32095 32120 +25
Branches 4994 4997 +3
=======================================
+ Hits 27492 27516 +24
- Misses 3603 3604 +1
Partials 1000 1000 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jansegre
previously approved these changes
Jul 28, 2025
9be1685 to
0ea08d7
Compare
glevco
previously approved these changes
Jul 29, 2025
0ea08d7 to
1927f37
Compare
glevco
approved these changes
Jul 30, 2025
jansegre
approved these changes
Jul 30, 2025
This was referenced Aug 5, 2025
Merged
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.
Motivation
The Nano runner previously returned the same NanoRNG instance to all contracts, allowing potential exploits where an attacker could override methods in one contract to manipulate random number generation in others. To mitigate this, several layers of protection have been introduced:
__setattr__()in a metaclass, ensuring the class definition remains immutable.__setattr__()are blocked on individual instances.__slots__, restricting attribute modifications.These measures collectively enhance security by isolating RNG behavior and preventing unauthorized modifications. These measures can also be applied to other classes and instances accessible by contracts.
Original discussion: https://github.com/HathorNetwork/nano-hathor-core/pull/168#discussion_r2025167397
Acceptance Criteria
Checklist
master, confirm this code is production-ready and can be included in future releases as soon as it gets merged