fix(erpc:PLA-1610): harden consensus and HyperEVM filtering#93
fix(erpc:PLA-1610): harden consensus and HyperEVM filtering#930x666c6f wants to merge 9 commits into
Conversation
| Action: func(a *consensusAnalysis) *slotResult { | ||
| return &slotResult{ | ||
| Error: common.NewErrConsensusLowParticipants( | ||
| "not enough required consensus participants: "+strings.Join(a.missingRequiredParticipants(), ", "), |
There was a problem hiding this comment.
missingRequiredParticipants() is invoked twice; call it once, store the result, and reuse it for length check and join to avoid redundant computation
Details
✨ AI Reasoning
The Action builds an error string by calling missingRequiredParticipants() twice (once to test length and again to produce the joined string). This re-computes the same slice twice. Capture the slice once and reuse it to avoid redundant work and make intent clearer.
🔧 How do I fix it?
Rewrite the snippet in the simpler, behavior-equivalent form: return a boolean expression directly instead of if cond return true else return false, avoid using lists when they are guaranteed to contain one element, etc.
Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
There was a problem hiding this comment.
Pull request overview
Hardens eRPC’s consensus behavior under wait caps and required-participant quotas, and tightens HyperEVM system-transaction filtering to prevent invalid/undesired transactions from affecting block handling.
Changes:
- Consensus: fail closed when wait caps fire before reaching
agreementThreshold, and enforcerequiredParticipantsquotas against valid responses. - HyperEVM: strengthen system-transaction identification (multiple zero-ish fields) and run filtering before block validation.
- Tests/docs: add/adjust regression coverage and update consensus documentation to reflect the new rule ordering/semantics.
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 |
|---|---|
erpc/networks_hedge_cancel_test.go |
Makes hedge/consensus tests explicit about wait-cap timing to avoid ambiguous behavior. |
docs/pages/config/failsafe/consensus.mdx |
Updates docs to reflect fail-closed wait-cap semantics and strict required-participant enforcement (26 rules). |
consensus/wait_cap_test.go |
Adds regression tests for fail-closed behavior below threshold and updates existing wait-cap expectations. |
consensus/rules.go |
Introduces new top-priority rules for wait-capped low participants and missing required-participant quotas. |
consensus/quota.go |
Updates quota semantics comments to match strict enforcement in analysis. |
consensus/quota_test.go |
Adds unit coverage ensuring required participant quotas can reject an otherwise “winning” result. |
consensus/executor.go |
Propagates wait-cap state into analysis to support fail-closed rule evaluation. |
consensus/analysis.go |
Adds waitCapped to analysis and implements required-participant quota checking over valid responses. |
common/config.go |
Updates ConsensusPolicyConfig.RequiredParticipants comment to reflect fail-closed semantics. |
architecture/evm/eth_getBlockByNumber.go |
Moves HyperEVM filtering before validation and tightens system-tx detection fields. |
architecture/evm/eth_getBlockByNumber_test.go |
Updates fixtures/assertions to ensure only true system txs are filtered on HyperEVM. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if analysis == nil { | ||
| analysis = newConsensusAnalysis(e.logger, ctx, e.config, responses) | ||
| analysis = newConsensusAnalysisWithOptions(e.logger, ctx, e.config, responses, waitCapped) | ||
| winner = e.determineWinner(lg, analysis) | ||
| } else if waitCapped { | ||
| analysis = newConsensusAnalysisWithOptions(e.logger, ctx, e.config, responses, true) |
Summary
Changes
transactionsRootregression coverage.Linear