Open
Conversation
sysio.bios - Fix BLS key hash in setfinalizer: g1_hash was using std::hash<const char*> which hashed the pointer address, not the key content. sysio.roa - Fix reducepolicy RAM doubling: the reslimit modify lambda was computing row.ram_bytes += (old - reclaim), which doubled RAM instead of decreasing it. Simplified to row.ram_bytes -= reclaim. sysio.roa - Fix increase_reslimit negative RAM handling: casting negative int64_t to uint64_t silently wrapped. Now explicitly branches on sign and adds an underflow guard. sysio.roa - Fix reducepolicy unlimited NET/CPU underflow: when get_resource_limits returns -1 (unlimited), subtracting the weight produced a large negative value. Now preserves -1 for unlimited limits and clamps finite limits to zero. Add ROA contract tests covering addpolicy, expandpolicy, reducepolicy, extendpolicy validation paths, multi-issuer policy interactions, and newuser edge cases.
dtaghavi
requested changes
Feb 20, 2026
| row.ram_bytes += (uint64_t)ram_bytes; | ||
| if (ram_bytes >= 0) { | ||
| row.ram_bytes += static_cast<uint64_t>(ram_bytes); | ||
| } else { |
Contributor
There was a problem hiding this comment.
This should not allow for reduction of resources. It's used in addpolicy / expandpolicy which both check for only positive values. So if it somehow reached here it should reject.
Policies have a time_block which is meant to prevent a policy from being reduced until that block number is passed. Which reducepolicy is correctly enforcing.
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.
Fix reducepolicy RAM doubling: the reslimit modify lambda was computing row.ram_bytes += (old - reclaim), which doubled RAM instead of decreasing it. Simplified to row.ram_bytes -= reclaim.
Fix increase_reslimit negative RAM handling: casting negative int64_t to uint64_t silently wrapped. Now explicitly branches on sign and adds an underflow guard.
Fix reducepolicy unlimited NET/CPU underflow: when get_resource_limits returns -1 (unlimited), subtracting the weight produced a large negative value. Now preserves -1 for unlimited limits and clamps finite limits to zero.
Add ROA contract tests covering addpolicy, expandpolicy, reducepolicy, extendpolicy validation paths, multi-issuer policy interactions, and newuser edge cases.
Also small fix in sysio.bios.