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

remove gossipnet from conductor #332

Closed
Tracked by #325 ...
joroshiba opened this issue Sep 6, 2023 · 3 comments · Fixed by #383
Closed
Tracked by #325 ...

remove gossipnet from conductor #332

joroshiba opened this issue Sep 6, 2023 · 3 comments · Fixed by #383
Assignees
Labels
conductor pertaining to the astria-conductor crate gossipnet pertaining to the astria-gossipnet crate needs-scope Underspecified issues which need more details to be ready for work. production-quality necessary features for production quality software

Comments

@joroshiba
Copy link
Member

joroshiba commented Sep 6, 2023

Based on discussion in #325, where we have opted for option 1.

We want to strip out the gossipnet, and instead rely on a full node of the sequencer to read blocks. This is similar to what we are doing in sequencer-relayer to read new blocks off of proposing chains. We should do this using a cometbft websocket subscription.

Note: we may need to handle network retry logic in here in case a packet goes missing, and ws connection loses a block.

@joroshiba joroshiba added gossipnet pertaining to the astria-gossipnet crate conductor pertaining to the astria-conductor crate production-quality necessary features for production quality software labels Sep 6, 2023
@joroshiba joroshiba added the needs-scope Underspecified issues which need more details to be ready for work. label Sep 7, 2023
@emhane
Copy link
Contributor

emhane commented Sep 8, 2023

before updating events cometbft validates the block. this means blocks received over the web socket always point to the canonical chain, that is their parent block is the soft block.

apply block tries to validate block and last publishes events
https://github.com/astriaorg/cometbft/blob/342404c9011137cb0e9a4abfd9fa1fc2f9ca889e/state/execution.go#L182-L264

validation checks our equivalent to head block's parent block hash with our equivalent to soft block hash
https://github.com/astriaorg/cometbft/blob/342404c9011137cb0e9a4abfd9fa1fc2f9ca889e/state/validation.go#L45-L51

the state where last block hash is taken from is block applied before this one
https://github.com/astriaorg/cometbft/blob/342404c9011137cb0e9a4abfd9fa1fc2f9ca889e/state/execution.go#L234-L238

so event publisher publishes validated block
https://github.com/astriaorg/cometbft/blob/342404c9011137cb0e9a4abfd9fa1fc2f9ca889e/state/execution.go#L259-L261

this constrains the way to handle incoming blocks.

it means, assuming we trust the validator we are connected to via web socket, all blocks that are received at head height point to the soft block. further this implies, if a child to any of the head blocks is received it will certainly finalise the soft block. also by single slot finality it implies that if head block N+1 is lost but we see its child N+2 and grandchild N+3, we can deduce that the parent block hash in N+2 is the final head.

also we know that any blocks that will become part of the canonical chain, will pass conversion from tendermint block response to SequencerBlockData which verifies commit to the rollup data, because all shared-sequencer validators do the same checks on the data before prevoting the block. by this we know that all blocks in the canonical chain will have valid commitment to rollup data, hence with the above example, if N+2 successfully passes the conversion to SequencerBlockData we know when N+3 comes that the parent block of N+2 had valid commitment to rollup data.

https://github.com/astriaorg/astria/blob/main/specs/sequencer-app.md#processproposal

@emhane
Copy link
Contributor

emhane commented Sep 8, 2023

...trust the validator (or sequencer without validator), and trust the connection! add TLS to web socket connection if conductor and sequencer not intended to run on localhost if?

@emhane
Copy link
Contributor

emhane commented Sep 18, 2023

can we divide this issue into two parts: (i) removing gossipnet and (ii) adding web socket ? I'd start working on adding a web socket to conductor and encrypting the messages with this library https://crates.io/crates/tokio-native-tls or some other library, or at least in a away that makes it possible to implement sessions on the connection in the future.

SuperFluffy added a commit that referenced this issue Sep 18, 2023
## Summary
Replace all untyped errors in sequencer-validation by typed errors.

## Background
`sequencer-validation` has to be made a dependency of
`sequencer-client`, which only uses typed errors. Therefore
`sequencer-validation` 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
- Replace `eyre` reports by typed errors
- Fix `MerkleTree::prove_inclusion` to actually return an error: the
docs said it would error, but it actually panicked if `index` was out of
bounds.
- Add eyre error context to sequencer-relayer: because the error in it
wasn't properly wrapped, changing the sequencer-validation types caused
it to no longer compile

## Testing
Added a test to check for out of bounds inclusion proof index. The other
error type is just a wrapper.

## Related Issues
This is done as part of #332, which now requires extra trait methods in
the `SequencerClientExt` and `SequencerSubscriptionClientExt` extension
traits.
SuperFluffy added a commit that referenced this issue 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
SuperFluffy added a commit that referenced this issue Sep 20, 2023
…blocks (#382)

## Summary
Add a `SequencerSubscriptionClientExt` trait with a
`subscribe_new_block_data` method.

## Background
Removing gossipnet from conductor as part of
#332 requires it to read new
blocks directly from cometbft / sequencer. This patch extends the
sequencer-client crate to provide that functionality using a convenience
function so that conductor need not know how to convert comertbft
new-block events to sequencer block data.

## Changes
- Add a `SequencerSubscriptionClientExt` trait to the sequencer-client
crate.
- Reorganize the sequencer-client crate to export items under the
appropriate features.
- warn users if they set neither the `http` nor `websocket` features.

## Testing
Testing this client is out of scope for this PR. We are relying on the
underlying tendermint-rpc WebSocketClient being correctly implemented.
It would be great to extend wiremock or a similar crate to provide a quick way
to test websocket APIs.

An alternative is to derive a jsonrpc server with jsonrpsee, but that's
a lot more work.

## Breaking Changelist
None, only functionality was added crates depending on sequencer-client
were not touched.

## Related Issues
Part of #332

#375 and
#376 are precursor PRs
unblocking this patch.

---------

Co-authored-by: noot <36753753+noot@users.noreply.github.com>
SuperFluffy added a commit that referenced this issue Sep 20, 2023
…383)

## Summary
This patch replaces gossipnet by a websocket stream of new blocks
directly from sequencer.

## Background

Adding a p2p layer adds a lot of complexity to astria services. With
this patch conductor reads new blocks directly off of
cometbft/sequencer, making it much simpler. For background reading, see
this issue: #325

## Changes
- Replace gossipnet directly by a stream of new blocks using the
cometbft subscrition RPC.
- No other changes in regard to how blocks are further processed has
been made.

## Testing
We are relying on the rust tendermint-rpc crate functioning properly. As
a follow-up it makes sense to create blackbox tests for conductor, which
are currently absent.

## Breaking Changelist
- Reading over p2p is no longer supported. Deployments must be updated
and wired to read off of cometbft/sequenceer.

## Related Issues
Precursor PRs unblocking this work:
#375
#376
#382

closes #332

---------

Co-authored-by: Emilia Hane <emiliaha95@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conductor pertaining to the astria-conductor crate gossipnet pertaining to the astria-gossipnet crate needs-scope Underspecified issues which need more details to be ready for work. production-quality necessary features for production quality software
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants