Skip to content

Commit

Permalink
fix: clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuajbouw committed Jan 24, 2023
1 parent c69fb52 commit e704caf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion engine-precompiles/src/set_gas_token.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::prelude::{vec, Cow};
use crate::set_gas_token::events::SetGasTokenLog;
use crate::{EvmPrecompileResult, Precompile, PrecompileOutput};
use aurora_engine_types::types::{Address, EthGas};
use evm::backend::Log;
use evm::{Context, ExitError};
use std::borrow::Cow;

pub use consts::SET_GAS_TOKEN_ADDRESS;

Expand Down
4 changes: 2 additions & 2 deletions engine-tests/src/tests/standalone/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use aurora_engine::engine;
use aurora_engine_sdk::env::DEFAULT_PREPAID_GAS;
use aurora_engine_test_doubles::io::{Storage, StoragePointer};
use aurora_engine_test_doubles::promise::PromiseTracker;
use aurora_engine_types::types::{Address, Wei};
use aurora_engine_types::types::{Address, EthGas, Wei};
use aurora_engine_types::{account_id::AccountId, H160, H256, U256};
use std::sync::RwLock;

Expand Down Expand Up @@ -41,7 +41,7 @@ fn test_deploy_code() {
origin,
Wei::zero(),
evm_deploy(&code_to_deploy),
u64::MAX,
EthGas::MAX,
Vec::new(),
&mut handler,
);
Expand Down
25 changes: 15 additions & 10 deletions engine/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ pub struct Engine<'env, I: IO, E: Env> {
state: EngineState,
origin: Address,
gas_price: U256,
gas_token: GasToken,
current_account_id: AccountId,
io: I,
env: &'env E,
Expand Down Expand Up @@ -464,7 +463,6 @@ impl<'env, I: IO + Copy, E: Env> Engine<'env, I, E> {
state,
origin,
gas_price: U256::zero(),
gas_token: GasToken::ETH,
current_account_id,
io,
env,
Expand Down Expand Up @@ -509,7 +507,7 @@ impl<'env, I: IO + Copy, E: Env> Engine<'env, I, E> {
// This part is questionable.
set_balance(&mut self.io, sender, &new_balance);
}
GasToken::ERC20(addr) => {
GasToken::ERC20(_addr) => {
// TODO: Needs SputnikVM balance check
todo!()
}
Expand Down Expand Up @@ -814,7 +812,7 @@ impl<'env, I: IO + Copy, E: Env> Engine<'env, I, E> {
&erc20_token,
Wei::zero(),
setup_receive_erc20_tokens_input(args, &recipient),
u64::MAX,
EthGas::MAX,
Vec::new(), // TODO: are there values we should put here?
handler,
)
Expand Down Expand Up @@ -986,10 +984,13 @@ pub fn submit<I: IO + Copy, E: Env, P: PromiseHandler>(
return Err(EngineErrorKind::GasPayment(err).into());
}
};
let gas_limit: EthGas = transaction
.gas_limit
.try_into()
.map_err(|_| EngineErrorKind::GasOverflow)?;
let gas_limit: EthGas = {
let gas_limit: u64 = transaction
.gas_limit
.try_into()
.map_err(|_| EngineErrorKind::GasOverflow)?;
EthGas::new(gas_limit)
};
let access_list = transaction
.access_list
.into_iter()
Expand Down Expand Up @@ -1564,7 +1565,7 @@ unsafe fn schedule_promise_callback<P: PromiseHandler>(
handler.promise_attach_callback(base_id, promise)
}

impl<'env, I: IO + Copy, E: Env> evm::backend::Backend for Engine<'env, I, E> {
impl<'env, I: IO + Copy, E: Env> Backend for Engine<'env, I, E> {
/// Returns the "effective" gas price (as defined by EIP-1559)
fn gas_price(&self) -> U256 {
self.gas_price
Expand Down Expand Up @@ -1851,6 +1852,7 @@ impl<'env, J: IO + Copy, E: Env> ApplyBackend for Engine<'env, J, E> {
}

#[cfg(test)]
#[cfg(feature = "std")]
mod tests {
use super::*;
use crate::parameters::{FunctionCallArgsV1, FunctionCallArgsV2};
Expand Down Expand Up @@ -2139,7 +2141,10 @@ mod tests {
data: vec![],
access_list: vec![],
};
let actual_result = engine.charge_gas(&origin, &transaction).unwrap();
// TODO: Add other tests than just ETH as a gas token.
let actual_result = engine
.charge_gas(&origin, &transaction, GasToken::ETH)
.unwrap();

let expected_result = GasPaymentResult {
prepaid_amount: Wei::zero(),
Expand Down

0 comments on commit e704caf

Please sign in to comment.