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
Tracing Fields The execute_external_transaction function is instrumented with tracing::instrument, but it does not record any identifiers as span fields. Consider adding relevant fields such as tx_hash or block_number to the span.
Error Logging When logging errors, ensure the original error is logged in a field called reason. This is done correctly in some places but missed in others, such as when comparing execution with receipt.
Dynamic Fields in Tracing Avoid formatting dynamic fields in tracing events. Instead, add these dynamic fields as tracing fields. For example, in the error logging within execute_external_transaction, the json_tx, json_receipt, and json_execution_logs should be added as fields.
Tokio Task Naming If there are any tokio::spawn or tokio::spawn_blocking calls, consider using spawn_named or spawn_blocking_named for better traceability.
-false => {- let sender = self.storage.read_account(&receipt.from.into(), &StoragePointInTime::Pending)?;- let execution = EvmExecution::from_failed_external_transaction(sender, receipt, block)?;- let evm_result = EvmExecutionResult {- execution,- metrics: EvmExecutionMetrics::default(),- };- ExternalTransactionExecution::new(tx.clone(), receipt.clone(), evm_result)-}+false => self.handle_failed_external_transaction(tx, receipt, block)?
Suggestion importance[1-10]: 8
Why: This suggestion significantly improves code readability and maintainability by modularizing the code.
8
Possible issue
Use if let instead of match to handle the result of receipt.is_success() to avoid potential panics
To avoid potential panics, consider using if let instead of match when handling the result of receipt.is_success(). This will ensure that the code gracefully handles the Err case.
-let tx_execution = match receipt.is_success() {- true => {- // re-execute transaction- let evm_input = EvmInput::from_external(tx, receipt, block)?;- let evm_execution = self.evms.execute(evm_input.clone(), EvmRoute::External);- // handle re-execution result- let mut evm_execution = match evm_execution {- Ok(inner) => inner,- Err(e) => {- let json_tx = to_json_string(&tx);- let json_receipt = to_json_string(&receipt);- tracing::error!(reason = ?e, block_number = %block.number(), tx_hash = %tx.hash(), %json_tx, %json_receipt, "failed to reexecute external transaction");- return Err(e.into());- }- };+let tx_execution = if receipt.is_success() {+ // re-execute transaction+ let evm_input = EvmInput::from_external(tx, receipt, block)?;+ let evm_execution = self.evms.execute(evm_input.clone(), EvmRoute::External);+ // handle re-execution result+ let mut evm_execution = match evm_execution {+ Ok(inner) => inner,+ Err(e) => {+ let json_tx = to_json_string(&tx);+ let json_receipt = to_json_string(&receipt);+ tracing::error!(reason = ?e, block_number = %block.number(), tx_hash = %tx.hash(), %json_tx, %json_receipt, "failed to reexecute external transaction");+ return Err(e.into());+ }+ };
Suggestion importance[1-10]: 7
Why: This suggestion improves code safety by avoiding potential panics, but it does not address a critical issue.
7
Use get(..4).map_or to avoid potential panics when parsing the Solidity function signature
To avoid potential panics, consider using the get(..4).map_or method instead of get(..4)?.try_into().ok()? when parsing the Solidity function signature.
-let sig = Signature::Function(self.input.get(..4)?.try_into().ok()?);+let sig = Signature::Function(self.input.get(..4).map_or(None, |slice| slice.try_into().ok())?);
Some(sig.extract())
Suggestion importance[1-10]: 7
Why: This suggestion improves code safety by avoiding potential panics, but it does not address a critical issue.
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
Bug fix, Enhancement
Description
extract_function
tosolidity_signature
across multiple files for consistency.ExternalTransaction
for better code organization.Changes walkthrough 📝
evm.rs
Refactor EVM executor and remove unused code
src/eth/executor/evm.rs
execute_external_transaction
function.solidity_signature
function toExternalTransaction
.call_input.rs
Rename and document function signature extraction
src/eth/primitives/call_input.rs
extract_function
tosolidity_signature
.solidity_signature
.external_transaction.rs
Add and refactor methods in ExternalTransaction
src/eth/primitives/external_transaction.rs
solidity_signature
andis_contract_deployment
methods.solidity_signature
logic fromEvmInput
.transaction_input.rs
Rename and document function signature extraction
src/eth/primitives/transaction_input.rs
extract_function
tosolidity_signature
.solidity_signature
.rpc_middleware.rs
Use unified function signature extraction in RPC middleware
src/eth/rpc/rpc_middleware.rs
extract_function
withsolidity_signature
.executor.rs
Fix and enhance external transaction execution and metrics
src/eth/executor/executor.rs
execute_external_transaction
to persist state beforecomputing metrics.
solidity_signature
.