-
Notifications
You must be signed in to change notification settings - Fork 75
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(conductor)!: implement chain ID checks #1482
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking this merge because this change exposes private types publicly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't expose implementation details in the public API of service crates.
if let Some(SequencerChainIdError::MismatchedSequencerChainId { | ||
expected, | ||
actual, | ||
}) = err.downcast_ref::<SequencerChainIdError>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't test implementation details in blackbox tests.
It's fine to assert that it exits after receiving a bad chain ID.
let mut source = e.source(); | ||
while source.is_some() { | ||
let err = source.unwrap(); | ||
if let Some(CelestiaChainIdError::MismatchedCelestiaChainId { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above, don't assert on implementation details in blackbox tests. Just check behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With checking the error source text itself, I've managed to work it such that the tests still check the error result without exposing any underlying types. It feels like the tests should probably ensure that the correct thing is causing the error, as opposed to succeeding for any kind of early exit, but I understand this is fragile so I can change if needed.
Mock as GrpcMock, | ||
}; | ||
|
||
// We have to create our own test conductor and perform mounts manually because `TestConductor` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of doing all that lifting here, could you have made use of https://doc.rust-lang.org/std/mem/struct.ManuallyDrop.html to inhibit the custom Drop
from being called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In attempting to do so, I'm not sure this method will work either. Calling await
on the conductor contained by ManuallyDrop<TestConductor>
errs because await takes ownership of the conductor. ManuallyDrop
does have a method take()
which would allow for this, but it is an unsafe function and as far as I know these can't be used in tests :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, let's leave this for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make a followup issue to clean this up?
…ub.com/astriaorg/astria into ENG-73/conductor_chain_id_verification
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is ready to get merged. :) Thank you for your work!
To bring this over the line I did two things:
- flatten the return value of the
conductor::Handle
future by giving some extra context; - replaced the undocumented
eyre::ErrReport
alias byeyre::Report
.
Ok(Err(err)) => Err(err.wrap_err("conductor failed failed")), | ||
Err(err) => Err(eyre::ErrReport::from(err).wrap_err("conductor failed")), | ||
Ok(Err(err)) => Err(err.wrap_err("conductor exited with an error")), | ||
Err(err) => Err(eyre::ErrReport::from(err).wrap_err("conductor panicked")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use undocumented type aliases like ErrReport
.
* main: (34 commits) feat(proto): add bundle and optimistic block apis (#1519) feat(sequencer)!: make empty transactions invalid (#1609) chore(sequencer): simplify boolean expressions in `transaction container` (#1595) refactor(cli): merge argument parsing and command execution (#1568) feat(charts): astrotrek chart (#1513) chore(charts): genesis template to support latest changes (#1594) fix(ci): code freeze action fix (#1610) chore(sequencer)!: exclusively use Borsh encoding for stored data (ENG-768) (#1492) ci: code freeze through github actions (#1588) refactor(sequencer): use builder pattern for transaction container tests (#1592) feat(conductor)!: implement chain ID checks (#1482) chore(ci): upgrade audit-check (#1577) feat(sequencer)!: transaction categories on UnsignedTransaction (#1512) fix(charts): sequencer prometheus rules (#1598) chore(all): Migrate all instances of `#[allow]` to `#[expect]` (#1561) chore(charts,sequencer-faucet): asset precision (#1517) chore(docs): endpoints (#1543) fix(docker): use target binary build param as name of image entrypoint (#1573) fix(ci): ibc bridge test timeout (#1587) Feature: Add `graph-node` to charts. (#1489) ...
Summary
Implemented chain ID validation for both the sequencer and Celestia readers in Conductor.
Background
This is to safeguard against connecting to an incorrect network.
This change was previously blocking on a switch to solely using gRPC for communication with sequencer, but after offline discussion it was decided to implement the chain ID check anyways using the HTTP client.
Changes
run_until_stopped()
to return with an error so that it will not fail silently.Testing
Added 2 blackbox tests to ensure the conductor exits with the proper error in the event of both a Celestia and sequencer chain ID mismatch.
Breaking Changelist
ASTRIA_CONDUCTOR_SEQUENCER_CHAIN_ID
andASTRIA_CONDUCTOR_CELESTIA_CHAIN_ID
environment variables, without which conductor will not function.Related Issues
closes #986