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

feat: New performant Block and Tx structures with raw auxiliary data. #534

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

Mr-Leshiy
Copy link
Contributor

During implementation our https://github.com/input-output-hk/catalyst-libs/tree/main/rust/cardano-chain-follower we have faced a necessity to decode auxiliary data by our own and not for every transaction.
Which means that if we will skip CBOR decoding for such transactions in which we are not interested in, we can increase a performance of the blockchain synchronisation.

This PR introduces a naive and a strait forward implementation and basically shows at least what we need on the cardano-chain-follower side. So we are open to any suggestions how to change/improve this approach.

Added a new MultiEraBlockWithRawAuxiliary and MultiEraTxWithRawAuxiliary structures which does not actually decode Auxiliary data and keeps a raw bytes (replaced the usage of KeepRaw<'b, T> with the new OnlyRaw<'b, T>).
This allows in the cases where user do not want to use pallas specific encoding of the metadata and decode by ourselves avoid redundant decoding by pallas.
With the added benchmarks OnlyRaw<'b, AuxiliaryData> 5x faster in decoding rather than KeepRaw<'b, AuxiliaryData >:
https://github.com/input-output-hk/catalyst-pallas/blob/feff0ef1ffe458d4fb61036d2290307ec67388c1/pallas-primitives/benches/alonzo_decoding.rs#L7.

Alonzo Auxilary Data Decoding/KeepRaw<AuxiliaryData>
                        time:   [4.8648 µs 5.0116 µs 5.2403 µs]
                        change: [-2.6346% +3.1304% +8.9719%] (p = 0.31 > 0.05)
                        No change in performance detected.
Found 13 outliers among 100 measurements (13.00%)
  4 (4.00%) high mild
  9 (9.00%) high severe
Alonzo Auxilary Data Decoding/OnlyRaw<AuxiliaryData>
                        time:   [983.42 ns 988.56 ns 994.95 ns]
                        change: [+0.7429% +1.3247% +2.0350%] (p = 0.00 < 0.05)
                        Change within noise threshold.
Found 12 outliers among 100 measurements (12.00%)
  3 (3.00%) high mild
  9 (9.00%) high severe

Changes

  • Added new structs MultiEraBlockWithRawAuxiliary and MultiEraTxWithRawAuxiliary, preserving the same API as original
    MultiEraBlock and MultiEraTx. Except that MultiEraTxWithRawAuxiliary does not have metadata method.
  • Added new OnlyRaw struct which skips any cobra decoding and store only original cbor raw bytes for the corresponded object.
  • Added criterion benchmarks to compare OnlyRaw<'b, AuxiliaryData> with KeepRaw<'b, AuxiliaryData > decoding.
  • Added new model types for each era (where it is appropriate) like MintedBlockWithRawAuxiliary or MintedTxWithRawAuxiliary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

1 participant