You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Error Handling The error type has been changed from TransactionFailed to TransactionEvmFailed, but the new error type is being created with e.to_string(). Consider preserving the original error type or adding more context to the error message.
Missing Span Fields The execute_local_transaction function is instrumented with tracing::instrument, but no span fields are recorded. Consider adding relevant identifiers as span fields.
Logging Improvement The forward_to_leader function logs the rpc_client using tracing::info!. Ensure that the rpc_client is logged with structured fields instead of formatting the entire object.
Blocking Call in Async Context The block_on call in the eth_send_raw_transaction function can block the async context. Consider using spawn_blocking_named to avoid blocking the Tokio async runtime.
Error Logging When logging errors in send_raw_transaction_to_leader, ensure the original error is logged in a field called reason.
Why: Adding error handling for the get_chain method enhances robustness and provides more context in case of failure, which is crucial for debugging and reliability.
8
Add a check to ensure that tx_client is not None before inserting it into the request extensions
Add a check to ensure that tx_client is not None before inserting it into the request extensions.
if let Some(tx_client) = tx.as_ref().and_then(|tx| tx.client.clone()) {
request.extensions_mut().insert(tx_client.clone());
client = tx_client;
+} else {+ tracing::warn!("Transaction client is None");
}
Suggestion importance[1-10]: 6
Why: Adding a check for None improves robustness and ensures that only valid clients are inserted into the request extensions. However, the impact is relatively minor as tx_client being None might be an edge case.
6
Best practice
Use a more specific error type for TransactionEvmFailed instead of converting the error to a string
Consider using a more specific error type for TransactionEvmFailed instead of converting the error to a string. This will provide more context and make error handling easier.
Why: Using a more specific error type can provide better context and improve error handling. However, this change might require additional modifications in other parts of the codebase to handle the new error type properly.
7
Enhancement
Add a log statement to indicate the start of transaction execution
Add a log statement to indicate when the transaction execution starts, which will help in tracing and debugging.
Change the function parameter to take a reference instead of consuming the RpcClientApp
The forward_to_leader function should take a reference to RpcClientApp instead of consuming it. This will avoid unnecessary cloning and improve performance.
Why: This suggestion is correct and improves performance by avoiding unnecessary cloning. It is contextually accurate and derived from the PR code diff.
9
Change the method call to pass a reference instead of consuming the RpcClientApp
The send_raw_transaction method should take a reference to RpcClientApp instead of consuming it. This will avoid unnecessary cloning and improve performance.
Why: This suggestion is correct and improves performance by avoiding unnecessary cloning. It is contextually accurate and derived from the PR code diff.
9
Change the function call to pass a reference instead of consuming the RpcClientApp
The forward_to_leader function should take a reference to RpcClientApp instead of consuming it. This will avoid unnecessary cloning and improve performance.
-Some(consensus) => match Handle::current().block_on(consensus.forward_to_leader(tx_data, ext.rpc_client())) {+Some(consensus) => match Handle::current().block_on(consensus.forward_to_leader(tx_data, &ext.rpc_client())) {
Suggestion importance[1-10]: 9
Why: This suggestion is correct and improves performance by avoiding unnecessary cloning. It is contextually accurate and derived from the PR code diff.
9
Change the method parameter to take a reference instead of consuming the RpcClientApp
The send_raw_transaction method should take a reference to RpcClientApp instead of consuming it. This will avoid unnecessary cloning and improve performance.
Why: This suggestion is correct and improves performance by avoiding unnecessary cloning. It is contextually accurate and derived from the PR code diff.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
Enhancement, Bug fix, Tests
Description
TransactionFailed
toTransactionEvmFailed
.forward_to_leader
for forwarding transactions to the leader in the consensus module.Deserialize
forRpcClientApp
.TransactionLeaderFailed
andTransactionForwardToLeaderFailed
.pending_transaction
module and related handling.run-leader
for running the leader.Changes walkthrough 📝
1 files
evm.rs
Update error type for EVM transaction failures
src/eth/executor/evm.rs
TransactionFailed
toTransactionEvmFailed
.9 files
executor.rs
Add logging and rename variables in transaction execution
src/eth/executor/executor.rs
tx_input
totx
.consensus.rs
Add method to forward transactions to leader
src/eth/follower/consensus.rs
forward_to_leader
for forwarding transactions to theleader.
StratusError
andRpcClientApp
.stratus_error.rs
Add new error types for leader transaction failures
src/eth/primitives/stratus_error.rs
TransactionLeaderFailed
andTransactionForwardToLeaderFailed
.From
implementation to handleTransactionLeaderFailed
.rpc_client_app.rs
Implement Deserialize for RpcClientApp
src/eth/rpc/rpc_client_app.rs
Deserialize
forRpcClientApp
.rpc_middleware.rs
Update RPC middleware to handle client information
src/eth/rpc/rpc_middleware.rs
RpcServiceT
to handle client information in transactiontracing.
TransactionTracingIdentifiers
.rpc_server.rs
Refactor transaction forwarding and execution logic
src/eth/rpc/rpc_server.rs
eth_send_raw_transaction
to forward transactions to the leaderif not the leader.
blockchain_client.rs
Add method to forward transactions to leader
src/infra/blockchain_client/blockchain_client.rs
send_raw_transaction_to_leader
for forwardingtransactions.
PendingTransaction
usage.mod.rs
Remove pending_transaction module
src/infra/blockchain_client/mod.rs
pending_transaction
module.pending_transaction.rs
Remove pending transaction handling
src/infra/blockchain_client/pending_transaction.rs
2 files
e2e-tx-serial-transfer.test.ts
Add test case for sending raw transactions
e2e/test/automine/e2e-tx-serial-transfer.test.ts
rpc.ts
Update chain ID for tests
e2e/test/helpers/rpc.ts
CHAIN_ID_DEC
to 3000.1 files
justfile
Add alias for running leader
justfile
run-leader
for running the leader.