Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Lohann committed Nov 20, 2023
1 parent 168de4a commit f020894
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/executor/stack/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>

match reason {
ExitReason::Succeed(s) => {
let mut out = return_data;
let out = return_data;
let address = created_address;
// As of EIP-3541 code starting with 0xef cannot be deployed
if let Err(e) = check_first_byte(self.config, &out) {
Expand All @@ -1003,27 +1003,34 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>
}

// Before EIP-2 is possible to create empty contract
let result = if self.config.empty_considered_exists {
if self.state.metadata().gasometer.can_deposit(out.len()) {
out.clear();
}
Ok(())
let bytecode = if self.config.empty_considered_exists
&& !self.state.metadata().gasometer.can_deposit(out.len())
{
Ok(None)
} else {
self.state
.metadata_mut()
.gasometer
.record_deposit(out.len())
.map(|_| Some(out))
};

match result {
Ok(()) => {
match bytecode {
Ok(Some(bytecode)) => {
let exit_result = self.exit_substate(StackExitKind::Succeeded);
if let Err(e) = self.record_external_operation(
crate::ExternalOperation::Write(U256::from(out.len())),
crate::ExternalOperation::Write(U256::from(bytecode.len())),
) {
return (e.into(), None, Vec::new());
}
self.state.set_code(address, out);
self.state.set_code(address, bytecode);
if let Err(e) = exit_result {
return (e.into(), None, Vec::new());
}
(ExitReason::Succeed(s), Some(address), Vec::new())
}
Ok(None) => {
let exit_result = self.exit_substate(StackExitKind::Succeeded);
if let Err(e) = exit_result {
return (e.into(), None, Vec::new());
}
Expand Down

0 comments on commit f020894

Please sign in to comment.