Recover StreamCore bytecode headroom#116
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
📝 WalkthroughWalkthroughStreamCore replaces several string reverts with four typed custom errors, refactors collection-data access, adds regression tests for the new errors, updates changelog/docs/ops size-headroom policy, and regenerates release and deployment artifact checksums due to ABI/bytecode changes. ChangesStreamCore Bytecode Headroom Recovery via Custom Errors
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
smart-contracts/StreamCore.sol (1)
652-664:⚠️ Potential issue | 🟠 Major | ⚡ Quick winGuard
setFinalSupplyagainst unset collection data to avoid panic reverts.Line 656 onward can still hit an arithmetic panic path when
_collectionIDis not fully initialized (reservedMinTokensIndex == 0and zero circulation), because_finalizeCollectionSupplycomputesreservedMin - 1. Add explicit mutable-collection and data-initialized checks before the time-window check.💡 Suggested patch
function setFinalSupply(uint256 _collectionID) public FunctionAdminRequired(this.setFinalSupply.selector) { - _requireCollectionNotFrozen(_collectionID); + _requireExistingMutableCollection(_collectionID); + if (!wereDataAdded[_collectionID]) { + revert CollectionDataMissing(_collectionID); + } if ( block.timestamp <= IStreamMinter(minterContract).getEndTime(_collectionID) + collectionAdditionalData[_collectionID].setFinalSupplyTimeAfterMint ) { revert FinalSupplyTimeNotPassed(); } _finalizeCollectionSupply(_collectionID); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@smart-contracts/StreamCore.sol` around lines 652 - 664, The setFinalSupply function can underflow in _finalizeCollectionSupply when collection data isn't initialized (e.g., reservedMinTokensIndex == 0 and zero circulation); add an explicit guard at the top of setFinalSupply that ensures the collection's mutable/data-initialized state before doing the time-window check and calling _finalizeCollectionSupply. Specifically, check collectionAdditionalData[_collectionID].reservedMinTokensIndex != 0 (or otherwise verify collectionCirculation[_collectionID] > 0 / a "data initialized" flag) and revert with a descriptive error (e.g., CollectionNotInitialized or InvalidCollectionData) if not initialized; keep the existing calls to _requireCollectionNotFrozen, IStreamMinter(minterContract).getEndTime, and collectionAdditionalData for locating the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@smart-contracts/StreamCore.sol`:
- Around line 652-664: The setFinalSupply function can underflow in
_finalizeCollectionSupply when collection data isn't initialized (e.g.,
reservedMinTokensIndex == 0 and zero circulation); add an explicit guard at the
top of setFinalSupply that ensures the collection's mutable/data-initialized
state before doing the time-window check and calling _finalizeCollectionSupply.
Specifically, check
collectionAdditionalData[_collectionID].reservedMinTokensIndex != 0 (or
otherwise verify collectionCirculation[_collectionID] > 0 / a "data initialized"
flag) and revert with a descriptive error (e.g., CollectionNotInitialized or
InvalidCollectionData) if not initialized; keep the existing calls to
_requireCollectionNotFrozen, IStreamMinter(minterContract).getEndTime, and
collectionAdditionalData for locating the change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0f4d94ae-711c-420e-9bb6-6de24b002ff8
📒 Files selected for processing (16)
CHANGELOG.mddeployments/address-books/anvil-6529stream-v0.1.0-001-broadcast.jsondeployments/address-books/anvil-6529stream-v0.1.0-001.jsondeployments/examples/anvil-6529stream-v0.1.0-001-broadcast.jsondeployments/examples/anvil-6529stream-v0.1.0-001.jsondocs/status.mdops/AUTONOMOUS_RUN.mdops/ROADMAP.mdrelease-artifacts/latest/SHA256SUMSrelease-artifacts/latest/abi-checksums.jsonrelease-artifacts/latest/release-artifact-manifest.jsonrelease-artifacts/latest/release-checksums.jsonrelease-artifacts/latest/release-manifest.jsonrelease-artifacts/latest/source-verification-inputs.jsonsmart-contracts/StreamCore.soltest/StreamCoreCustomErrors.t.sol
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ops/AUTONOMOUS_RUN.md`:
- Around line 121-125: The status line under the "PR candidate: Recover
`StreamCore` bytecode headroom (Queue Item 61)" heading is out of date; edit the
Status text in ops/AUTONOMOUS_RUN.md for that section (the block that currently
reads "Status: CodeRabbit review fix validated locally; ready to push PR
update.") to reflect that PR `#116` (branch `codex/recover-streamcore-headroom`,
PR URL https://github.com/6529-Collections/6529Stream/pull/116) has been opened
and the follow-up validation is complete (e.g., "Status: PR `#116` opened and
validated; ready to merge" or equivalent), so the durable state matches the
recorded PR and validation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c04e6873-98ae-4900-9e84-c7b2b2a41ae6
📒 Files selected for processing (16)
CHANGELOG.mddeployments/address-books/anvil-6529stream-v0.1.0-001-broadcast.jsondeployments/address-books/anvil-6529stream-v0.1.0-001.jsondeployments/examples/anvil-6529stream-v0.1.0-001-broadcast.jsondeployments/examples/anvil-6529stream-v0.1.0-001.jsondocs/status.mdops/AUTONOMOUS_RUN.mdops/ROADMAP.mdrelease-artifacts/latest/SHA256SUMSrelease-artifacts/latest/abi-checksums.jsonrelease-artifacts/latest/release-artifact-manifest.jsonrelease-artifacts/latest/release-checksums.jsonrelease-artifacts/latest/release-manifest.jsonrelease-artifacts/latest/source-verification-inputs.jsonsmart-contracts/StreamCore.soltest/StreamCoreCustomErrors.t.sol
✅ Files skipped from review due to trivial changes (8)
- release-artifacts/latest/release-artifact-manifest.json
- release-artifacts/latest/release-checksums.json
- release-artifacts/latest/SHA256SUMS
- deployments/examples/anvil-6529stream-v0.1.0-001-broadcast.json
- deployments/examples/anvil-6529stream-v0.1.0-001.json
- release-artifacts/latest/abi-checksums.json
- CHANGELOG.md
- release-artifacts/latest/source-verification-inputs.json
🚧 Files skipped from review as they are similar to previous changes (6)
- deployments/address-books/anvil-6529stream-v0.1.0-001-broadcast.json
- docs/status.md
- deployments/address-books/anvil-6529stream-v0.1.0-001.json
- test/StreamCoreCustomErrors.t.sol
- release-artifacts/latest/release-manifest.json
- smart-contracts/StreamCore.sol
Summary
StreamCorestring reverts with typed custom errors to recover production runtime bytecode headroom.setFinalSupplyreview finding by rejecting created collections with missing collection data viaCollectionDataMissing(collectionId)before_finalizeCollectionSupplycan underflow.StreamCoresize policy: 384-byte minimum release floor and 512-byte warning threshold for future non-trivial Core work.Closes #115.
Validation
forge test --match-contract StreamCoreCustomErrorsTest -vvvforge build --sizes --via-ir --skip test --skip script --force(StreamCore: 24,135 runtime bytes, 441 bytes EIP-170 headroom)make release-checksumsmake checkpowershell -ExecutionPolicy Bypass -File scripts\check.ps1forge fmt --check smart-contracts\StreamCore.sol test\StreamCoreCustomErrors.t.solgit diff --check(only known Windows line-ending warning forrelease-artifacts/latest/SHA256SUMS)Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Tests
Chores