Skip to content
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

hotfix: overestimate batch size to avoid a DoS #1775

Open
wants to merge 1 commit into
base: testnet
Choose a base branch
from

Conversation

Oppen
Copy link
Collaborator

@Oppen Oppen commented Jan 22, 2025

The batcher could be brought to a stalemate by how it estimates the serialized size of a batch.
Currently, it misses the type and length indicator in the CBOR format when building the array of proofs to verify, so it sends batches bigger than operators had agreed on accepting.
See #1746

An accurate fix would be to use the whole array size by serializing the batch completely. However, that involves the following sources of complexity:

  • We would need to either move the proofs to an array from the queue or use a custom serializer;
  • We would need to do the whole serialization at each step of the loop, as the size of the indicator is variable (from 1 to 9 bytes).

Instead, we go for a little over-estimation in the estimation, assuming it will always be the biggest marker (9 bytes).

We also add an assertion at startup to make sure configuration is consistent: if you won't send batches bigger than N bytes, you can't accept proofs bigger than N-9 bytes.

Type of change

  • Bug fix

Checklist

  • “Hotfix” to testnet, everything else to staging
  • Linked to Github Issue
  • This change depends on code or research by an external entity
    • Acknowledgements were updated to give credit
  • Unit tests added
  • This change requires new documentation.
    • Documentation has been added/updated.
  • This change is an Optimization
    • Benchmarks added/run
  • Has a known issue
  • If your PR changes the Operator compatibility (Ex: Upgrade prover versions)
    • This PR adds compatibility for operator for both versions and do not change batcher/docs/examples
    • This PR updates batcher and docs/examples to the newer version. This requires the operator are already updated to be compatible

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.

1 participant