-
Notifications
You must be signed in to change notification settings - Fork 623
feat: implement max invalid proof retries to prevent DoS attacks #1665
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
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughA new mechanism was added to limit the number of invalid proof retries a prover can make. This includes updates to enums, configuration files, and logic to enforce and track the retry limit. New tests and metrics were added to support and verify this functionality, along with corresponding configuration and error handling updates. Changes
Sequence Diagram(s)sequenceDiagram
participant Prover
participant ProofReceiverLogic
participant DB
participant Metrics
participant Config
Prover->>ProofReceiverLogic: Submit Proof
ProofReceiverLogic->>Config: Read MaxInvalidProofRetries
alt MaxInvalidProofRetries > 0
ProofReceiverLogic->>DB: Query failed prover tasks for proof hash
DB-->>ProofReceiverLogic: Return failed tasks
ProofReceiverLogic->>ProofReceiverLogic: Count invalid proof retries for prover
alt Retries >= MaxInvalidProofRetries
ProofReceiverLogic->>Metrics: Increment validateFailureMaxRetriesExceeded
ProofReceiverLogic->>Prover: Return ErrValidatorFailureMaxRetriesExceeded
else Retries < MaxInvalidProofRetries
ProofReceiverLogic->>ProofReceiverLogic: Continue with normal validation
end
else MaxInvalidProofRetries == 0
ProofReceiverLogic->>ProofReceiverLogic: Continue with normal validation
end
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (1.64.8)level=warning msg="[runner] Can't run linter goanalysis_metalinter: buildir: failed to load package zstd: could not load export data: no export data for "github.com/scroll-tech/da-codec/encoding/zstd"" Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (5)
🧰 Additional context used🧬 Code Graph Analysis (2)common/types/db_test.go (1)
coordinator/internal/logic/submitproof/proof_receiver.go (2)
🔇 Additional comments (10)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Hi @crStiv, thank you for submitting this PR. Is this a feature required for your use case? In which setting/project do you use the Scroll |
Hi @Thegaram, thanks for reviewing! I noticed the TODO comment about preventing DoS attacks and thought this would be a useful security feature. I'm not running a production coordinator myself, but figured this could help protect against malicious provers spamming invalid proofs. The implementation is backward compatible (disabled by default) so existing setups won't be affected. Happy to adjust anything if needed. |
Purpose or design rationale of this PR
What does this PR do?
Implements a configurable limit for the number of invalid proof submissions per prover per task, addressing the TODO comment in
proof_receiver.go
.Why does it do it?
Prevents DoS attacks where malicious provers could overwhelm the coordinator by repeatedly submitting invalid proofs, consuming computational resources and blocking legitimate provers.
How does it do it?
MaxInvalidProofRetries
configuration field toProverManager
validator()
function that checks previous failed attempts using existing ORM methodsProverTaskFailureTypeMaxRetriesExceeded
for proper error handlingcoordinator_validate_failure_max_retries_exceeded
for monitoringKey changes:
coordinator/internal/config/config.go
: NewMaxInvalidProofRetries
fieldcommon/types/db.go
: New failure type and string representationcoordinator/internal/logic/submitproof/proof_receiver.go
: Validation logic and metricscommon/types/db_test.go
: Test coverage for new failure typecoordinator/conf/config.json
: Example configurationThe feature is production-ready with comprehensive error handling, logging, and monitoring capabilities.
PR title types
Deployment tag versioning
Breaking change label
Summary by CodeRabbit