-
Notifications
You must be signed in to change notification settings - Fork 23
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
fix: validate tx chain id #126
Conversation
WalkthroughThe changes enhance the Changes
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Files selected for processing (4)
- bolt-sidecar/src/client/rpc.rs (1 hunks)
- bolt-sidecar/src/primitives/commitment.rs (1 hunks)
- bolt-sidecar/src/state/execution.rs (5 hunks)
- bolt-sidecar/src/state/fetcher.rs (2 hunks)
Additional comments not posted (8)
bolt-sidecar/src/primitives/commitment.rs (1)
46-53
: LGTM! Add tests for the new method.The
validate_chain_id
method is correctly implemented.However, ensure that unit tests are added to verify its functionality.
bolt-sidecar/src/state/fetcher.rs (2)
42-42
: LGTM!The
get_chain_id
method is correctly added to theStateFetcher
trait.
183-185
: LGTM! Add tests for the new method.The
get_chain_id
method is correctly implemented in theStateClient
struct.However, ensure that unit tests are added to verify its functionality.
bolt-sidecar/src/client/rpc.rs (1)
36-39
: LGTM! Add tests for the new method.The
get_chain_id
method is correctly implemented in theRpcClient
struct.However, ensure that unit tests are added to verify its functionality.
bolt-sidecar/src/state/execution.rs (4)
40-42
: LGTM!The
ChainIdMismatch
error variant is correctly added to theValidationError
enum.
85-86
: LGTM!The
chain_id
field is correctly added to theExecutionState
struct.
117-120
: LGTM!The
chain_id
method is correctly implemented in theExecutionState
struct.
151-154
: LGTM! Add tests for the new validation logic.The chain ID validation logic is correctly implemented in the
try_commit
method.However, ensure that unit tests are added to verify its functionality.
slot: 0, | ||
account_states: HashMap::new(), | ||
block_templates: HashMap::new(), | ||
chain_id: client.get_chain_id().await?, | ||
client, | ||
}) |
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.
Another way to do this can be to pass the chain ID value from config as a parameter while initializing the execution state, which felt to me as a dirty/ un-clean way.
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.
Yeah this is cleaner, great job
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Files selected for processing (1)
- bolt-sidecar/src/state/execution.rs (5 hunks)
Additional comments not posted (5)
bolt-sidecar/src/state/execution.rs (5)
40-42
: LGTM! ValidationError enum extended with ChainIdMismatchThe addition of
ChainIdMismatch
toValidationError
is appropriate for handling chain ID mismatches.
85-86
: LGTM! ExecutionState struct extended with chain_idThe addition of the
chain_id
field toExecutionState
is appropriate for managing chain ID validation.
102-102
: LGTM! ExecutionState::new method initializes chain_idThe initialization of the
chain_id
field in thenew
method is appropriate for ensuring that thechain_id
is set when theExecutionState
is created.
117-119
: LGTM! ExecutionState::chain_id method addedThe addition of the
chain_id
method is appropriate for retrieving thechain_id
field.
133-136
: LGTM! ExecutionState::try_commit method validates chain_idThe addition of the chain ID validation in the
try_commit
method is appropriate for ensuring that transactions are processed with the correct chain ID.
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.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Files selected for processing (1)
- bolt-sidecar/src/state/execution.rs (4 hunks)
Additional comments not posted (2)
bolt-sidecar/src/state/execution.rs (2)
40-42
: Good addition ofChainIdMismatch
variant.The
ChainIdMismatch
variant is correctly added to theValidationError
enum with an appropriate error message.
85-86
: Good addition ofchain_id
field.The
chain_id
field is correctly added to theExecutionState
struct and initialized in thenew
method.Also applies to: 102-102
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.
LGTM
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.
LGTM!
fixes #124
Summary by CodeRabbit
New Features
get_chain_id
).InclusionRequest
.ExecutionState
with corresponding retrieval method.Improvements
ChainIdMismatch
variant inValidationError
.Bug Fixes
ExecutionState
.These updates enhance the reliability and functionality of the system by improving chain ID management and validation processes.