Skip to content

Conversation

@RembrandtK
Copy link
Contributor

@RembrandtK RembrandtK commented Dec 30, 2025

Address open issues and recommendations in Graph_IssuanceAllocator_v02.

TRST-M-3 More tokens could be issued than what is tracked by the accumulation of all distribution periods (8f5c074, f1337d9)

  • Document model, key invariants, and expected behaviour for selfMintingOffset.
  • Commit also includes other documentation correction and cleanup.
  • Made selfMintingOffset related event logging more complete (f1337d9) for better tracking.

TRST-L-4 Historic pending rewards could display wrong values in several cases (468f176)

  • Comment added to ensure the limitation is understood.
  • Addressing this is out-of-scope for this piece of work.

TRST-L-5 Key issuance operations could become permanently unreachable if gas limit is reached (aedce7c, f283815)

  • Added governance-controlled self-minting allocation event emmission mode that allows disabling of looping over all targets.

TRST-R-8 Improve safety of reclaim address modification

  • Not addressed in favour of keeping idempotent setting of reclaim address.

TRST-R-9 Improve documentation (aedce7c)

  • Documentation added to explain reclaim precedence and retroactive behaviour.

TRST-R-10 Avoid legacy library integrations (32c6809)

  • Replaced use of ReentrancyGuardTransientUpgradeable with ReentrancyGuardTransient.

TRST-R-11 Avoid dead code

  • No change, kept as defensive code that avoids making assumptions about default target.

TRST-R-12 Mixing of different self-minting pause restrictions is incompatible with IssuanceAllocator

  • Kept as is as by design; related to documentation changes for TRTST-M-3 (8f5c074).

Addresses TRST-M-3 audit finding by documenting the mathematical
relationship between self-minting and allocator-minting.

Changes:
- Add comprehensive documentation of 5 key invariants in IssuanceAllocator.sol
  proving total issuance never exceeds Σ(issuancePerBlock_b) for any period
- Remove duplicate sections (Events, Error Conditions, Storage) from
  IssuanceAllocator.md that are better documented in NatSpec
- Add WIP Initial Setup deployment sequence to IssuanceAllocator.md
Addresses TRST-M-3 audit finding.

Events for offset adjustments of accumulation and during pending
distribution, emitting whenever offset changes and showing both
before and after states for complete accounting transparency.
Addresses TRST-L-5 by adding configurable event emission to prevent
potential gas limit deadlock in _advanceSelfMintingBlock().

Adds three modes controllable by governance:
- None (0): Skip event emission entirely (lowest gas)
- Aggregate (1): Single aggregated event (medium gas)
- PerTarget (2): Per-target events (highest gas, default)

Defaults to PerTarget to provide event visibility by default.
Governance can switch to None or Aggregate to reduce gas costs
as target count grows.

Implementation:
- Add SelfMintingEventMode enum to IIssuanceAllocatorTypes
- Add selfMintingEventMode field to storage struct
- Add IssuanceSelfMintAllowanceAggregate event
- Add SelfMintingEventModeUpdated event
- Add setSelfMintingEventMode(mode) governance function
- Add getSelfMintingEventMode() view function
- Modify _advanceSelfMintingBlock() to respect emission mode
- Initialize to PerTarget in initialize()
…adeable version

Replace ReentrancyGuardTransientUpgradeable (deprecated in OpenZeppelin 5.5+)
with ReentrancyGuardTransient. The non-upgradeable version is appropriate since
the guard only uses transient storage and has no upgradeable state.

Resolves TRST-R-10
Add comments clarifying that accRewardsPending tracking is incomplete
due to _presentPOI clearing pending even when rewards are not consumed.

Addresses audit finding TRST-L-4 as acknowledged limitation.
@openzeppelin-code
Copy link

openzeppelin-code bot commented Dec 30, 2025

Issuance allocator audit responses (for Graph_IssuanceAllocator_v02)

Generated at commit: f283815a4231fa65034dd97275ec4e07a570a378

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
3
5
0
14
38
60
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

@codecov
Copy link

codecov bot commented Dec 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.41%. Comparing base (9488b9d) to head (f283815).
⚠️ Report is 7 commits behind head on issuance-allocator-3.

Additional details and impacted files
@@                   Coverage Diff                    @@
##           issuance-allocator-3    #1272      +/-   ##
========================================================
+ Coverage                 86.30%   86.41%   +0.11%     
========================================================
  Files                        45       45              
  Lines                      2373     2393      +20     
  Branches                    708      714       +6     
========================================================
+ Hits                       2048     2068      +20     
  Misses                      325      325              
Flag Coverage Δ
unittests 86.41% <100.00%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@RembrandtK RembrandtK changed the title Issuance allocator 3 fix 2 Issuance allocator audit responses (for Graph_IssuanceAllocator_v02) Dec 31, 2025
@RembrandtK RembrandtK requested a review from Copilot December 31, 2025 08:07
Copy link
Contributor

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 pull request implements audit responses for the IssuanceAllocator contract (Graph_IssuanceAllocator_v02), adding configurable event emission modes for gas optimization, improved offset tracking with visibility events, and comprehensive documentation enhancements.

Key changes:

  • Introduced SelfMintingEventMode enum (None, Aggregate, PerTarget) to allow governance to control event emission behavior based on gas cost requirements
  • Added SelfMintingOffsetReconciled and SelfMintingOffsetAccumulated events for complete visibility into offset accounting during pause/distribution cycles
  • Enhanced documentation with detailed accounting invariants, reclaim target hierarchy, and retroactive address change behavior

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/issuance/contracts/allocate/IssuanceAllocator.sol Core implementation: added SelfMintingEventMode functionality, offset reconciliation events, transient reentrancy guard, accounting invariants documentation, and various typo/clarity fixes
packages/interfaces/contracts/issuance/allocate/IIssuanceAllocatorTypes.sol Added SelfMintingEventMode enum with gas cost documentation
packages/interfaces/contracts/issuance/allocate/IIssuanceAllocationAdministration.sol Added setSelfMintingEventMode() and getSelfMintingEventMode() interface methods
packages/issuance/test/tests/allocate/SelfMintingEventMode.test.ts Comprehensive test coverage for all three event modes, mode switching, edge cases, and gas optimization verification
packages/issuance/test/tests/allocate/IssuanceAllocator.test.ts Added test verifying SelfMintingOffsetReconciled event is not emitted when offset unchanged
packages/issuance/test/tests/allocate/InterfaceIdStability.test.ts Updated interface ID for IIssuanceAllocationAdministration to reflect new methods
packages/issuance/contracts/test/allocate/IssuanceAllocatorTestHarness.sol Added @Custom:oz-upgrades-unsafe-allow constructor annotation
packages/issuance/contracts/allocate/IssuanceAllocator.md Updated deployment documentation and removed broken target references
packages/subgraph-service/contracts/utilities/AllocationManager.sol Documented reclaim target hierarchy and retroactive reclaim address change behavior
packages/interfaces/contracts/contracts/rewards/IRewardsManager.sol Documented retroactive behavior of setReclaimAddress()
packages/contracts/contracts/rewards/RewardsManager.sol Documented retroactive behavior of setReclaimAddress() implementation

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

@RembrandtK RembrandtK marked this pull request as ready for review December 31, 2025 14:06
@RembrandtK RembrandtK merged commit 89f1321 into issuance-allocator-3 Dec 31, 2025
6 checks passed
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.

2 participants