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

chore: remove some clones #12008

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/evm/src/system_calls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ where
DB::Error: Display,
{
let result_and_state = eip2935::transact_blockhashes_contract_call(
&self.evm_config.clone(),
&self.evm_config,
&self.chain_spec,
timestamp,
block_number,
Expand Down Expand Up @@ -226,7 +226,7 @@ where
DB::Error: Display,
{
let result_and_state = eip4788::transact_beacon_root_contract_call(
&self.evm_config.clone(),
&self.evm_config,
&self.chain_spec,
timestamp,
block_number,
Expand Down
14 changes: 4 additions & 10 deletions crates/optimism/payload/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,7 @@ where
args: BuildArguments<Pool, Client, OptimismPayloadBuilderAttributes, OptimismBuiltPayload>,
) -> Result<BuildOutcome<OptimismBuiltPayload>, PayloadBuilderError> {
let (cfg_env, block_env) = self.cfg_and_block_env(&args.config, &args.config.parent_block);
optimism_payload(
self.evm_config.clone(),
args,
cfg_env,
block_env,
self.compute_pending_block,
)
optimism_payload(&self.evm_config, args, cfg_env, block_env, self.compute_pending_block)
}

fn on_missing_payload(
Expand Down Expand Up @@ -140,7 +134,7 @@ where
best_payload: None,
};
let (cfg_env, block_env) = self.cfg_and_block_env(&args.config, &args.config.parent_block);
optimism_payload(self.evm_config.clone(), args, cfg_env, block_env, false)?
optimism_payload(&self.evm_config, args, cfg_env, block_env, false)?
.into_payload()
.ok_or_else(|| PayloadBuilderError::MissingPayload)
}
Expand All @@ -156,7 +150,7 @@ where
/// a result indicating success with the payload or an error in case of failure.
#[inline]
pub(crate) fn optimism_payload<EvmConfig, Pool, Client>(
evm_config: EvmConfig,
evm_config: &EvmConfig,
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is not strictly required

Suggested change
evm_config: &EvmConfig,
evm_config: EvmConfig,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, we need this to pass &self.evm_config in from try_build and build_empty_payload instead of cloning anew?

Copy link
Collaborator

Choose a reason for hiding this comment

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

EvmConfig is auto_impl for & so this shouldn't be required by we can also do &

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wouldn't work 😅.

error[E0521]: borrowed data escapes outside of method
   --> crates/optimism/payload/src/builder.rs:108:9
    |
104 |         &self,
    |         -----
    |         |
    |         `self` is a reference that is only valid in the method body
    |         let's call the lifetime of this reference `'1`
...
108 |         optimism_payload(&self.evm_config, args, cfg_env, block_env, self.compute_pending_block)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |         |
    |         `self` escapes the method body here
    |         argument requires that `'1` must outlive `'static`

args: BuildArguments<Pool, Client, OptimismPayloadBuilderAttributes, OptimismBuiltPayload>,
initialized_cfg: CfgEnvWithHandlerCfg,
initialized_block_env: BlockEnv,
Expand Down Expand Up @@ -430,7 +424,7 @@ where
&mut db,
&chain_spec,
attributes.payload_attributes.timestamp,
attributes.clone().payload_attributes.withdrawals,
attributes.payload_attributes.withdrawals.clone(),
)?;

// merge all transitions into bundle state, this would apply the withdrawal balance changes
Expand Down
Loading