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

DA compression for fuel-tx types #670

Merged
merged 82 commits into from
Sep 10, 2024
Merged

DA compression for fuel-tx types #670

merged 82 commits into from
Sep 10, 2024

Conversation

Dentosal
Copy link
Member

@Dentosal Dentosal commented Feb 1, 2024

Part of FuelLabs/fuel-core#1605. See the corresponding fuel-core PR as well: FuelLabs/fuel-core#1609

This PR adds Compact derive macro and fuel-compression machinery, that are used to convert Transaction and contained types into CompressedTransaction and Compressed*. The compact types are equivalent to the original types, except that malleable fields are removed, and often-repeated types like AssetId and Address are converted to three-byte keys to a separate database, called temporal storage. UtxoIds (which are used only once) are converted to use TxPointer instead.

@Dentosal Dentosal added fuel-types Related to the `fuel-types` crate. mainnet labels Feb 1, 2024
@Dentosal Dentosal self-assigned this Feb 1, 2024
@Dentosal Dentosal mentioned this pull request Feb 1, 2024
6 tasks
@xgreenx xgreenx requested a review from a team February 19, 2024 18:11
Copy link
Collaborator

@xgreenx xgreenx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you nice PR!=) It is cool that Compact can be derived almost for all types.

I feel like we put too many details about the implementation of the algorithm and how keys are created, and it seems we can simplify that part a lot to be agnostic. But the main with compaction looks good; I will review it one more time, more precisely when PR is in final shape.

BTW, compilation fails for me:

image

fuel-compression/src/compaction.rs Outdated Show resolved Hide resolved
fuel-compression/src/compaction.rs Outdated Show resolved Hide resolved
fuel-compression/src/registry/block_section.rs Outdated Show resolved Hide resolved
fuel-compression/src/registry/mod.rs Outdated Show resolved Hide resolved
fuel-tx/src/transaction/types/input/message.rs Outdated Show resolved Hide resolved
fuel-tx/src/transaction/types/output.rs Outdated Show resolved Hide resolved
fuel-tx/src/transaction/types/utxo_id.rs Outdated Show resolved Hide resolved
fuel-compression/src/registry/block_section.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@bvrooman bvrooman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 6/41 so far, will continue review at the next chance I get

fuel-compression/src/compaction.rs Outdated Show resolved Hide resolved
fuel-compression/src/compaction.rs Outdated Show resolved Hide resolved
fuel-compression/src/compaction.rs Outdated Show resolved Hide resolved
@Dentosal Dentosal marked this pull request as ready for review July 22, 2024 16:57
@Dentosal Dentosal requested a review from a team September 9, 2024 09:26
fuel-derive/src/lib.rs Outdated Show resolved Hide resolved
fuel-derive/src/lib.rs Outdated Show resolved Hide resolved
fuel-derive/src/compression/compress.rs Show resolved Hide resolved
fuel-derive/src/compression/compress.rs Show resolved Hide resolved
fuel-derive/src/compression/compress.rs Outdated Show resolved Hide resolved
fuel-derive/src/compression/compress.rs Outdated Show resolved Hide resolved
fuel-derive/src/compression/decompress.rs Outdated Show resolved Hide resolved
Comment on lines +16 to +19
pub use fuel_derive::{
Compress,
Decompress,
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, Compress implements both Compressible and CompressibleBy, and the define macros having the same names as the trait obfuscates this fact even more.

Yeah, it is true. But Compressible is a super trait of CompressibleBy, so it is not so bad=D But I agree that it is hidden property of the macro that can be discovered only from the comment.

But in the case of DecompressibleBy everything is clear=) The macro implements the same trait.

But it is up to you, I will not push it futher=)

xgreenx
xgreenx previously approved these changes Sep 9, 2024
@xgreenx xgreenx requested a review from a team September 9, 2024 13:17
fuel-tx/src/tests/da_compression.rs Outdated Show resolved Hide resolved
fuel-tx/src/tests/da_compression.rs Outdated Show resolved Hide resolved
fuel-tx/src/tests/da_compression.rs Outdated Show resolved Hide resolved
fuel-tx/src/tests/da_compression.rs Outdated Show resolved Hide resolved
fuel-tx/src/tests/da_compression.rs Outdated Show resolved Hide resolved
fuel-tx/src/tests/da_compression.rs Show resolved Hide resolved
fuel-compression/src/impls.rs Outdated Show resolved Hide resolved
fuel-compression/src/impls.rs Outdated Show resolved Hide resolved
fuel-compression/src/key.rs Show resolved Hide resolved
fuel-tx/src/transaction/types/script.rs Outdated Show resolved Hide resolved
Co-authored-by: Rafał Chabowski <[email protected]>
Copy link
Contributor

@rafal-ch rafal-ch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@Dentosal Dentosal added this pull request to the merge queue Sep 10, 2024
Merged via the queue into master with commit d28a143 Sep 10, 2024
39 checks passed
@Dentosal Dentosal deleted the dento/da-compression branch September 10, 2024 08:29
xgreenx added a commit to FuelLabs/fuel-core that referenced this pull request Oct 5, 2024
Related #1605. VM PR
FuelLabs/fuel-vm#670.

This PR adds DA compression crate for Fuel blocks, performed upon block
creation. The compressed blocks are stored into the offchain database
and can be fetched using the GraphQL API.

## Note for reviewers

To keep this reasonably compact, decompression support is not included
in this PR, and will be done as a follow-up. As a result, the full data
roundtrip testing is not part of this PR. There's no proof here that
compression of full blocks is reversible.

## TODO
#### Features
- [x] Temporal registry db support
- [x] Optimize temporal registry eviction implementation
- [x] Implement TxId ↔ TxPointer lookups
- [x] Integrate with the block committer (GraphQL interface, probably)
#### Tests
- [x] compressed blocks are available from non-block-producer nodes
- [ ] e2e test for the full decompression cycle (moved to a follow-up)


## Follow-up issues
- Sync the node from L1:
#2208
- Decompression roudntrip tests
#2238
- Figure out which cache eviction algorithm/behavior is wanted:
#2231
- Figure out if we need to remove the compressed blocks from the db
after a while
- Merkle roots for fraud proofs
#2232

---------

Co-authored-by: Aaryamann Challani <[email protected]>
Co-authored-by: Green Baneling <[email protected]>
Co-authored-by: Rafał Chabowski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fuel-types Related to the `fuel-types` crate. mainnet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants