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

sequencer-validation: type errors #375

Merged
merged 2 commits into from
Sep 18, 2023

Conversation

SuperFluffy
Copy link
Member

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.

@github-actions github-actions bot added the sequencer-relayer pertaining to the astria-sequencer-relayer crate label Sep 15, 2023
@SuperFluffy SuperFluffy requested a review from a team September 15, 2023 22:14
@SuperFluffy SuperFluffy temporarily deployed to BUF September 15, 2023 22:14 — with GitHub Actions Inactive
@SuperFluffy SuperFluffy force-pushed the superfluffy/type-sequencer-validation-errors branch from 00a5ce9 to cc3d495 Compare September 15, 2023 22:17
@SuperFluffy SuperFluffy temporarily deployed to BUF September 15, 2023 22:18 — with GitHub Actions Inactive
Copy link
Collaborator

@noot noot left a comment

Choose a reason for hiding this comment

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

looks good! should we move the errors to their own module or do you think it's fine for now (since there's just 2)?

@SuperFluffy
Copy link
Member Author

SuperFluffy commented Sep 17, 2023

@noot I like to keep errors close to their use so that the logic is one coherent unit especially if it's so few lines and also only used here.

Makes sense especially for bigger errors that are used throughout a codebase though.

@SuperFluffy SuperFluffy temporarily deployed to BUF September 18, 2023 15:55 — with GitHub Actions Inactive
@SuperFluffy SuperFluffy merged commit 57a3103 into main Sep 18, 2023
24 checks passed
@SuperFluffy SuperFluffy deleted the superfluffy/type-sequencer-validation-errors branch September 18, 2023 16:10
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
steezeburger added a commit that referenced this pull request Sep 18, 2023
* main:
  sequencer-types: type all errors (#376)
  sequencer-validation: type errors (#375)
  conductor: remove defaults from configuration (#380)
  Update Conductor config management (#329)
steezeburger added a commit that referenced this pull request Sep 18, 2023
…ure/conductor-implement-execution-api-v1alpha2

* feature/conductor-use-execution-api-v1alpha2:
  sequencer-types: type all errors (#376)
  sequencer-validation: type errors (#375)
  conductor: remove defaults from configuration (#380)
  Update Conductor config management (#329)
steezeburger added a commit that referenced this pull request Sep 19, 2023
* main:
  update ct-merkle dependency (#377)
  Add just commands for lint, update readme (#367)
  sequencer-types: type all errors (#376)
  sequencer-validation: type errors (#375)
  conductor: remove defaults from configuration (#380)
  Update Conductor config management (#329)
  fix(sequencer): remove unneeded `AppHash` alias (#362)
  remove `Namespace` from `SequencerBlockData`, use `ChainId` instead (#346)
  feat(sequencer): implement generating and verifying chain ID commitment (#338)
  sequencer-relayer: update config to astria standard (#336)
  Conductor: More structured logging (#335)
  proto: regenerate (#350)
  proto: remove concept of head from execution api (#344)
  feat(sequencer-types): verify `last_commit_hash` when constructing `SequencerBlockData` (#327)
  feat(conductor): implement `RollupNamespaceData` verification inside conductor (#290)
  remove alert actor from conductor (#324)
  sequencer: remove todo for issue that's done (#326)
SuperFluffy added a commit that referenced this pull request 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 pull request 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
sequencer-client sequencer-relayer pertaining to the astria-sequencer-relayer crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants