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

add sequencer-relayer protos #12

Merged
merged 30 commits into from May 23, 2023
Merged

Conversation

itamarreif
Copy link
Contributor

@itamarreif itamarreif commented May 18, 2023

addresses issue #20

  • add proto definitions for sequencer blocks and sequenced transactions

@itamarreif itamarreif self-assigned this May 18, 2023
* Fix using extern dependencies

* Fix lint

* Test cleanup

* update ci
crates/astria-proto/buf.work.yaml Outdated Show resolved Hide resolved
bytes block_hash = 1;
tendermint.types.Header header = 2;
repeated IndexedTransaction sequencer_txs = 3;
repeated NamespacedIndexedTransactions rollup_txs = 4;
Copy link
Member

Choose a reason for hiding this comment

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

So these deeply nested types are a bit tricky form a performance point of view:

  1. protobuf does not contain length information in the wire-format for repeated messages (which includes map, because these are just repeated (key,value) tuples);
  2. protobuf does not guarantee that repeated messages are contiguous on the wire (the first element might be in the beginning, the last element at the end of the bytestream);

This means there is no way to pre-allocate sufficiently sized Vecs. And so you will end up with a ton of small allocations in the child-vecs which cannot get amortized.

As an alternative route I would suggest making use of a technique frequently encountered in game dev by inlining all the fields, i.e.:

message NamespacedIndexedTransaction {
    bytes namespace = 1;
    // Maybe with a clearer name here what the index exactly refers to.
    uin64 index = 2;
    bytes transaction = 3;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see issue #31

crates/astria-proto/src/lib.rs Outdated Show resolved Hide resolved
@itamarreif itamarreif temporarily deployed to BUF May 19, 2023 22:23 — with GitHub Actions Inactive
@itamarreif itamarreif temporarily deployed to BUF May 19, 2023 23:49 — with GitHub Actions Inactive
Base automatically changed from astria-proto to main May 21, 2023 20:10
@SuperFluffy
Copy link
Member

@itamarreif the fork off of which this PR is based has experienced quite a bit of churn. Can you fork off recent main, cherry-pick your changes and then force-push to this PR?

@joroshiba
Copy link
Member

LGTM

Copy link
Member

@SuperFluffy SuperFluffy left a comment

Choose a reason for hiding this comment

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

We should ideally comment every field in the protos, explaining what they encode. But I realize that this wasn't done in the source where this is migrated from, so I think it can be done in a follow-up PR.

@itamarreif itamarreif merged commit 7342ba7 into main May 23, 2023
4 checks passed
@itamarreif itamarreif deleted the itamarreif/sequencer-relayer-proto branch May 23, 2023 14:47
SuperFluffy added a commit that referenced this pull request Sep 18, 2023
## Summary
Replace all implicit eyre errors by context specific typed errors

## Background
Same reasoning as for #375 as
part of the work for #332:

`sequencer-types` has to be made a dependency of `sequencer-client`,
which only uses typed errors. Therefore `sequencer-types` must have
typed errors (because otherwise `sequencer-client` would be "infected"
by eyre, which would require changing all of sequencer-client to also
use eyre.

## Changes
- Introduced one error variant per distinct eyre error.

## Testing
N/A. Nothing changed on the code level. Testing that the errors are
actually triggered could be done in a follow-up PR, but big parts of the
code will be replaced by the work in
#355 and follow-up PRs to it,
moving the types exchanged over RPCs to the astria-proto crate.

## Breaking Changelist
- No observable breaking changes in the astria services. Breaking
changes in the library crates because their public API changed (errors),
but we are not considering them right now

## Related Issues
#12
#86
#366
#332
joroshiba added a commit that referenced this pull request Nov 30, 2023
## Summary
This patch defines protobuf versions of various types that are currently
only defined in Rust and exchange as json-serialized text.

## Background
`astria-proto` is intended to be the single source of truth for the wire
format of data that is exchanged between services. At the moment
`SequencerBlockData`, `SequencerNamespaceData`, `RollupNamespaceData`
and `InclusionProof` are only defined in Rust. Some older versions of
these exist as protobuf but were never used in the public interfaces.

## Changes
- Replace `SequencerBlockData` by a protobuf `SequencerBlock` (rewriting
this protobuf type is technically a breaking change, but it was never
used, so in practice it is not)
- Replace `SequencerNamespaceData` and `RollupNamespaceData` by protobuf
`CelestiaSequencerBlob` and `CelestiaRollupBlob`.
- Introduce other protobuf types like `RollupTransactions`, `Proof` to
decode/encode all required objects
- Write idiomatic rust types for all generated protobuf representations
to uphold invariants

## Testing
- all tests have been updated and still pass
- testing this is in a devnet to check that the data still flows is open

## Related Issues

#12 originally defined sequencer
blocks and transactions as protobuf, but these were never actually
implemented.

#86 is the reason this effort
was started.

---------

Co-authored-by: Jordan Oroshiba <jordan@astria.org>
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.

None yet

4 participants