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

Improve BlobReader interface #794

Merged
merged 12 commits into from
Sep 5, 2023
Merged

Improve BlobReader interface #794

merged 12 commits into from
Sep 5, 2023

Conversation

preston-evans98
Copy link
Member

@preston-evans98 preston-evans98 commented Sep 4, 2023

Description

The current BlobReaderTrait looks almost identical to std::io::Read with a few extra methods for fetching blockchain-specific data. However, there significant differences in the way that the two traits are meant to be used. While the std reader is meant to be consumed only once, our readers are meant to be consumed twice - once by the prover and once by the verifier. This makes it very easy to introduce subtle bugs, such as consuming data in the host and forgetting to "reset" the reader before passing it to the guest.

This PR changes the BlobReader API to make it more misuse resistant, and uses the new API to fix a bug in the old implementation.

Fixes #456

Testing

This change is covered by existing unit tests.

@codecov
Copy link

codecov bot commented Sep 4, 2023

Codecov Report

Merging #794 (c66fc32) into nightly (777ce00) will decrease coverage by 0.1%.
The diff coverage is 70.9%.

Files Changed Coverage Δ
adapters/celestia/src/verifier/mod.rs 0.0% <0.0%> (ø)
...ystem/sov-modules-stf-template/src/app_template.rs 89.0% <87.5%> (-0.3%) ⬇️
rollup-interface/src/state_machine/da.rs 97.2% <95.8%> (+17.6%) ⬆️
full-node/sov-sequencer/src/lib.rs 93.0% <100.0%> (-0.5%) ⬇️
rollup-interface/src/state_machine/mocks/da.rs 70.1% <100.0%> (+2.9%) ⬆️

... and 2 files with indirect coverage changes

@preston-evans98 preston-evans98 added this pull request to the merge queue Sep 5, 2023
Merged via the queue into nightly with commit 5226818 Sep 5, 2023
@preston-evans98 preston-evans98 deleted the preston/da_interface branch September 5, 2023 15:42
preston-evans98 added a commit that referenced this pull request Sep 14, 2023
* Make BlobReaderTrait misuse resistant

* Prevent advancing blob in zk mode

* fix feature gate

* Remove dead code

* lint

* Prevent nondeterminism in blob deserialization

* fix celestia native feature

* fix demo-simple-stf native

* fix the fix
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.

verify_relevant_tx_list fails if blob reader wasn't consumed
2 participants