Skip to content

Commit

Permalink
clean and avoid a bit copying
Browse files Browse the repository at this point in the history
  • Loading branch information
cassc committed Jul 17, 2024
1 parent 7072148 commit daff002
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 27 deletions.
20 changes: 0 additions & 20 deletions src/chain_inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,4 @@ impl<DB: Database> Inspector<DB> for ChainInspector {
}
outcome
}

// fn eofcreate(
// &mut self,
// context: &mut EvmContext<DB>,
// inputs: &mut EOFCreateInputs,
// ) -> Option<CreateOutcome> {
// None
// }

// fn eofcreate_end(
// &mut self,
// context: &mut EvmContext<DB>,
// inputs: &EOFCreateInputs,
// outcome: CreateOutcome,
// ) -> CreateOutcome {
// outcome
// }

// #[inline]
// fn selfdestruct(&mut self, contract: Address, target: Address, value: U256) {}
}
6 changes: 1 addition & 5 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,12 @@ pub fn bigint_to_ruint_u256(b: &BigInt) -> Result<U256> {
return Err(eyre::eyre!("BigInt is negative"));
}

let mut padded_bytes = [0u8; 32];
let bytes_len = bytes.len();
if bytes_len > 32 {
return Err(eyre::eyre!("BigInt is too large"));
}

// Copy bytes into the end of the padded array
padded_bytes[(32 - bytes_len)..].copy_from_slice(&bytes);

Ok(U256::from_be_slice(&padded_bytes))
Ok(U256::from_be_slice(&bytes))
}

/// Returns the distance between two U256 numbers
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ impl TinyEVM {
transient_logs: logs,
ignored_addresses,
};
revm_result.into()
Response::from(revm_result)
}

/// Set code of an account
Expand Down Expand Up @@ -1119,6 +1119,8 @@ impl TinyEVM {
bug_inspector.bug_data.clear();
bug_inspector.created_addresses.clear();
bug_inspector.heuristics = Default::default();
self.log_inspector_mut().traces.clear();
self.log_inspector_mut().logs.clear();
}

/// Restore a snapshot for an account, raise error if there is no snapshot for the account
Expand Down
1 change: 0 additions & 1 deletion tests/test_account_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ def reset_contract_call(contract, owner):
resp = tevm.contract_call(contract, owner, data_balance_check, None)
assert _initialSupply - 1000 == int.from_bytes(bytes(resp.data), 'big')


random_address = '0x253397db4016dE1983D29f7DEc2901c54dB81A22'
tevm.copy_snapshot(contract, random_address)

Expand Down

0 comments on commit daff002

Please sign in to comment.