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

Export function to determine max blob bytes in a block #2108

Closed
rootulp opened this issue Jul 14, 2023 · 9 comments
Closed

Export function to determine max blob bytes in a block #2108

rootulp opened this issue Jul 14, 2023 · 9 comments
Assignees
Labels
enhancement New feature or request

Comments

@rootulp
Copy link
Collaborator

rootulp commented Jul 14, 2023

Context

celestia-node would like to add a validation step on blobs that checks that the blob size does not exceed the maximum possible bytes that a single blob can occupy in a block.

Proposal

Export a function from celestia-app that informs celestia-node what is the maximum possible bytes in a block. The amount of data in a block is constrained by two parameters (see ADR-021): MaxBytes and GovMaxSquareSize.

Rough steps:

  1. Learn the current value for the params GovMaxSquareSize and MaxBytes. Note celestia-node has access to the celestia-app version but both these params are governance modifiable so they require a state access
  2. Compute the max blob size that can fit into GovMaxSquareSize
  3. Compute the max blob size that can fit into MaxBytes
  4. Take the minimum of steps 2 and 3

cc: @Wondertan @renaynay @musalbas

@rootulp rootulp added the enhancement New feature or request label Jul 14, 2023
@rootulp rootulp added this to the Mainnet milestone Jul 17, 2023
@rootulp
Copy link
Collaborator Author

rootulp commented Jul 17, 2023

I think the proposed function will return an upper bound for blob size but it won't be an exact maximum size due to the number of bytes occupied by the PFB tx. In other words, smaller blobs than this upper bound may also be invalid.

We should consider fuzz testing by attempting to submit blobs of various sizes and confirming that blob sizes > the returned value from the proposed function(s) are never included in a block.

@rootulp
Copy link
Collaborator Author

rootulp commented Jul 24, 2023

Idea from @evan-forbes is for the first version of this to assume the default values for GovMaxSquareSize and MaxBytes so that the function isn't stateful which would make it much easier to invoke from celestia-node.

@Wondertan
Copy link
Member

Wondertan commented Jul 24, 2023

@rootulp, I am fine with such solution initially. Still, would be nice to think of the long term approach and if not complicated to aim to implement it first.

The stateful approach is annoying, but we can keep it inside stateful blob.Service. It already imports chain state methods and can query any param on start and reuse it throughout its lifespan. At even later point, we may implement listening for param changes in runtime.

@rootulp
Copy link
Collaborator Author

rootulp commented Jul 24, 2023

we can keep it inside stateful blob.Service

Specifically https://github.com/celestiaorg/celestia-node/blob/main/blob/service.go ?

can query any param on start

Does it already do this? Can you please link to an example? I'm not sure how celestia-node knows which major version of celestia-app it is connected to?

@Wondertan
Copy link
Member

My bad, I mean technically/in-theory can. It does not do this right now. The BlobSubmitter api can be extended with MaxBlobSize or something method that it could use.

@evan-forbes
Copy link
Member

evan-forbes commented Jul 31, 2023

This was discussed with @rootulp synchronously, but I think the best approach here is to validate the size of the blob statelessly using validate basic, and then adding an antehandler that will check the tx size using the stateful parameters upon submission.

This way we get protection locally before we even submit the blob, and then final protection at the mempool level that is stateful and complete

@rootulp
Copy link
Collaborator Author

rootulp commented Jul 31, 2023

I think we can close this issue as won't do in favor of #2156

@rootulp rootulp closed this as not planned Won't fix, can't repro, duplicate, stale Jul 31, 2023
@Wondertan
Copy link
Member

Agree with the decision. Only wonderting how stateless verification would work then or how what error will it incorporate

@rootulp
Copy link
Collaborator Author

rootulp commented Jul 31, 2023

how stateless verification would work

A stateless check on blob size can validate that the blob is < max blob size where max blob size is based on the upper bounds for max square size and max block bytes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants