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(composer)!: Add chain_id check on executor build #1175

Merged
merged 38 commits into from
Jul 22, 2024

Conversation

eoroshiba
Copy link
Contributor

@eoroshiba eoroshiba commented Jun 10, 2024

Summary

Added check to ensure the executor's configured chain_id and the sequencer client's actual chain_id match.

Background

This check ensures that the composer is communicating with the sequencer RPC on the correct network.

Changes

Added chain_id check to the composer executor builder.

Made executor builder async to accommodate for async communication with sequencer client.

Moved nonce guard declaration from mock startup to individual tests in executor tests.

Added function to mount a status response with a given chain_id to the mock. This is so the executor builder can gather the status response without throwing an HTTP 404 error.

Testing

Added executor test to validate the failure of an executor build with a chain_id mismatch.

Related Issues

Part of #986

@eoroshiba eoroshiba requested a review from a team as a code owner June 10, 2024 21:41
@eoroshiba eoroshiba requested a review from noot June 10, 2024 21:41
@github-actions github-actions bot added the composer pertaining to composer label Jun 10, 2024
@eoroshiba eoroshiba changed the title Eoroshiba feat(composer)!: Add chain_id check on executor build Jun 10, 2024
crates/astria-composer/src/executor/mod.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/mod.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/mod.rs Show resolved Hide resolved
crates/astria-composer/src/executor/mod.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/builder.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/tests.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/tests.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/mod.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/mod.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/builder.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/mod.rs Outdated Show resolved Hide resolved
@eoroshiba eoroshiba requested a review from joroshiba June 27, 2024 16:50
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.

Code is moving in the right direction, thank you for bearing with me and working on it. :)

I have left a bunch of comments on what what I'd like to see changed to test this.

The tests are currently not set up in the most ideal way, but short of making the exit reason publicly observable I don't see a way for you to test it other than you did.

I would only ask for you to type out the returned errors so that the tests won't stop silently breaking (and yet still passing).

crates/astria-composer/src/executor/builder.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/mod.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/mod.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/mod.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/tests.rs Show resolved Hide resolved
crates/astria-composer/src/executor/mod.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/mod.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/tests.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/tests.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/tests.rs Outdated Show resolved Hide resolved
@eoroshiba
Copy link
Contributor Author

@SuperFluffy I should be thanking you for bearing with me! Recent commits should implement all the changes you requested.

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.

Looks good. Thank you very much!

I have left a few comments, primarily to not just throw away the error in get_sequencer_chain_id. Please address these before merging.

crates/astria-composer/src/executor/mod.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/mod.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/mod.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/mod.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/mod.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/mod.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/tests.rs Outdated Show resolved Hide resolved
crates/astria-composer/src/executor/tests.rs Show resolved Hide resolved
assert_eq!(*actual, *configured_actual);
}
other @ EnsureChainIdError::GetChainId(_) => {
panic!("expected `EnsureChainIdError::WrongChainId`, but got '{other}'")
Copy link
Member

Choose a reason for hiding this comment

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

Last change before merge:

Suggested change
panic!("expected `EnsureChainIdError::WrongChainId`, but got '{other}'")
panic!("expected `EnsureChainIdError::WrongChainId`, but got '{other:?}'")

^ I'd have done it myself but don't have push rights for your fork.

@ethanoroshiba ethanoroshiba added this pull request to the merge queue Jul 22, 2024
Merged via the queue into astriaorg:main with commit b8f26d2 Jul 22, 2024
42 checks passed
steezeburger added a commit that referenced this pull request Jul 24, 2024
* main:
  feat(charts)!: refactor of evm chart (#995)
  feat(composer)!: Add chain_id check on executor build (#1175)
  fix(bridge-withdrawer): don't panic on init (#1281)
bharath-123 pushed a commit that referenced this pull request Jul 25, 2024
## Summary
Added check to ensure the executor's configured chain_id and the
sequencer client's actual chain_id match.

## Background
This check ensures that the composer is communicating with the sequencer
RPC on the correct network.

## Changes
Added chain_id check to the composer executor builder.

Made executor builder async to accommodate for async communication with
sequencer client.

Moved nonce guard declaration from mock startup to individual tests in
executor tests.

Added function to mount a status response with a given chain_id to the
mock. This is so the executor builder can gather the status response
without throwing an HTTP 404 error.

## Testing
Added executor test to validate the failure of an executor build with a
chain_id mismatch.

## Related Issues
Part of #986

---------

Co-authored-by: Richard Janis Goldschmidt <github@aberrat.io>
Co-authored-by: Ethan Oroshiba <ethan@astria.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
composer pertaining to composer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants