-
Notifications
You must be signed in to change notification settings - Fork 0
Add special case to handle validator manager update #660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds version-gated corrective logic in accumulate.ts to handle validatorsManager during transitions between GpVersion 0.7.0 and 0.7.1+. When the current manager changes but remains in the service list, the code re-accumulates the new validatorsManager and updates privilegedServices to avoid double-counting. Duplicated handling exists in parallel accumulation paths. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Caller
participant Accumulator
participant InputState
participant CurrentState
participant Services
participant Compat as Compatibility
Caller->>Accumulator: accumulate(updatedState, services)
Accumulator->>CurrentState: Read privilegedServices.validatorsManager (currentManager)
Accumulator->>InputState: Read privilegedServices.validatorsManager (inputManager)
Accumulator->>Compat: isTransition(0.7.0 -> 0.7.1+ )?
Compat-->>Accumulator: result
alt Version-compatible repair needed
Accumulator->>Services: accumulate(all services) Note right of Services: Standard pass
Accumulator->>Accumulator: Detect new validatorsManager present in updated state and services
Accumulator->>Services: Re-accumulate(new validatorsManager) Note right of Services: Prevent double-counting
Accumulator->>CurrentState: Update privilegedServices.validatorsManager to new manager
else Normal path
Accumulator->>Services: accumulate(all services) Note right of Services: No special handling
end
Note over Accumulator,Services: The repair logic is duplicated in parallel accumulation branches
Accumulator-->>Caller: final accumulated state
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/jam/transition/accumulate/accumulate.ts (2)
305-308: Name this initialManager for clarityThis is the manager at the start of the parallel pass; it doesn’t reflect any mid-loop updates. Renaming avoids confusion with “current” state that is being mutated below.
- const currentManager = (inputStateUpdate.privilegedServices ?? this.state.privilegedServices).manager; + const initialManager = (inputStateUpdate.privilegedServices ?? this.state.privilegedServices).manager;And update the reference in the condition below:
- serviceId === currentManager + serviceId === initialManager
328-357: Tighten 0.7.0-only patch, fix typos, and avoid unnecessary re-accumulation
- Use Compatibility.is(V0_7_0) for precision/readability.
- Guard against newV === serviceId to skip redundant self re-accumulation.
- Use
!= nullto accept both null/undefined.- Reword and lower the log level; current message has typos and is alarming.
- if ( - Compatibility.isLessThan(GpVersion.V0_7_1) && - Compatibility.isGreaterOrEqual(GpVersion.V0_7_0) && - serviceId === currentManager - ) { + if (Compatibility.is(GpVersion.V0_7_0) && serviceId === currentManager) { const newV = currentState.privilegedServices?.validatorsManager; - if (currentState.privilegedServices !== null && newV !== undefined && serviceIds.includes(newV)) { - logger.info( - "Entering completly incorrect code that problably reverts validatorsManager change. This is valid in 0.7.0 only and incorrect in 0.7.1+", - ); + if (currentState.privilegedServices != null && newV !== undefined && newV !== serviceId && serviceIds.includes(newV)) { + logger.debug( + "Applying 0.7.0 compatibility patch: re-accumulating validatorsManager; must not run on >=0.7.1", + ); // Since serviceIds already contains newV, this service gets accumulated twice. // To avoid double-counting, we skip stats and gas cost tracking here. // We need this accumulation to get the correct `validatorsManager` const { stateUpdate } = await this.accumulateSingleService( newV, accumulateData.getOperands(newV), accumulateData.getGasCost(newV), slot, entropy, checkpoint, ); const correctV = stateUpdate?.privilegedServices?.validatorsManager ?? this.state.privilegedServices.validatorsManager; currentState.privilegedServices = PrivilegedServices.create({ ...currentState.privilegedServices, validatorsManager: correctV, }); } }Also, confirm the intent to ignore gas/stats from this corrective re-accumulation (it’s correct, just worth an inline comment clarifying it’s intentional).
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/jam/transition/accumulate/accumulate.ts(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.ts
⚙️ CodeRabbit configuration file
**/*.ts:asconversions must not be used. Suggest usingtryAsconversion methods.
**/*.ts: Classes withstatic Codecfield must have private constructor and staticcreatemethod.
**/*.ts: Casting abigint(orU64) usingNumber(x)must have an explanation comment why
it is safe.
**/*.ts: When making changes to code with comments containing links (in classes, constants, methods, etc.)
to graypaper.fluffylabs.dev, ensure those links point to the current version for this update.
Files:
packages/jam/transition/accumulate/accumulate.ts
🧬 Code graph analysis (1)
packages/jam/transition/accumulate/accumulate.ts (3)
packages/jam/block/common.ts (2)
ServiceGas(31-31)tryAsServiceGas(32-32)packages/core/utils/compatibility.ts (1)
Compatibility(45-104)packages/jam/state/privileged-services.ts (1)
PrivilegedServices(27-54)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: run (22.x)
- GitHub Check: state_transition (22.x)
- GitHub Check: benchmarks (22.x)
- GitHub Check: run (22.x)
- GitHub Check: test (22.x)
- GitHub Check: e2e (22.x)
🔇 Additional comments (2)
packages/jam/transition/accumulate/accumulate.ts (2)
28-32: Import PrivilegedServices looks correctNo issues with bringing PrivilegedServices into scope for state updates.
34-34: Compatibility/GpVersion import is appropriateNeeded for the 0.7.0-specific guard.
tomusdrw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Co-authored-by: Tomek Drwięga <tomusdrw@users.noreply.github.com>
Co-authored-by: Tomek Drwięga <tomusdrw@users.noreply.github.com>
View all
Benchmarks summary: 63/63 OK ✅ |
No description provided.