Skip to content

Commit c16557c

Browse files
committed
Run cargo fmt
1 parent 08fda31 commit c16557c

File tree

4 files changed

+50
-18
lines changed

4 files changed

+50
-18
lines changed

jsontests/src/run.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ pub fn run_test(
197197
// there's nothing for us to test here for `TR_TypeNotSupported`.
198198
Some(TestExpectException::TR_TypeNotSupported) => return Ok(()),
199199

200-
Some(TestExpectException::TR_RLP_WRONGVALUE) if test.transaction.value.0.is_err() => return Ok(()),
200+
Some(TestExpectException::TR_RLP_WRONGVALUE) if test.transaction.value.0.is_err() => {
201+
return Ok(());
202+
}
201203

202204
// The responsibility to check gas limit / gas cap is on the block executor.
203205
Some(TestExpectException::TR_FeeCapLessThanBlocks) => return Ok(()),
@@ -258,7 +260,10 @@ pub fn run_test(
258260
TransactGasPrice::Legacy(gas_price)
259261
} else {
260262
TransactGasPrice::FeeMarket {
261-
max_priority: test.transaction.max_priority_fee_per_gas.unwrap_or_default(),
263+
max_priority: test
264+
.transaction
265+
.max_priority_fee_per_gas
266+
.unwrap_or_default(),
262267
max: test.transaction.max_fee_per_gas.unwrap_or_default(),
263268
}
264269
};

jsontests/src/types.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ impl TestMulti {
9292
transaction: TestTransaction {
9393
data: self.transaction.data[post_state.indexes.data].0.clone(),
9494
gas_limit: self.transaction.gas_limit[post_state.indexes.gas],
95-
gas_price: self
96-
.transaction
97-
.gas_price,
95+
gas_price: self.transaction.gas_price,
9896
max_priority_fee_per_gas: self.transaction.max_priority_fee_per_gas,
9997
max_fee_per_gas: self.transaction.max_fee_per_gas,
10098
nonce: self.transaction.nonce,

src/standard/invoker/mod.rs

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,24 +86,39 @@ pub enum TransactGasPrice {
8686
max_priority: U256,
8787
/// `max_fee_per_gas` according to EIP-1559.
8888
max: U256,
89-
}
89+
},
9090
}
9191

9292
impl TransactGasPrice {
9393
/// Caller fee.
94-
pub fn fee<H: RuntimeEnvironment>(&self, gas_limit: U256, config: &Config, handler: &H) -> U256 {
94+
pub fn fee<H: RuntimeEnvironment>(
95+
&self,
96+
gas_limit: U256,
97+
config: &Config,
98+
handler: &H,
99+
) -> U256 {
95100
let effective_gas_price = self.effective_gas_price(config, handler);
96101
gas_limit.saturating_mul(effective_gas_price)
97102
}
98103

99104
/// Refunded caller fee after call.
100-
pub fn refunded_fee<H: RuntimeEnvironment>(&self, refunded_gas: U256, config: &Config, handler: &H) -> U256 {
105+
pub fn refunded_fee<H: RuntimeEnvironment>(
106+
&self,
107+
refunded_gas: U256,
108+
config: &Config,
109+
handler: &H,
110+
) -> U256 {
101111
let effective_gas_price = self.effective_gas_price(config, handler);
102112
refunded_gas.saturating_mul(effective_gas_price)
103113
}
104114

105115
/// Coinbase reward.
106-
pub fn coinbase_reward<H: RuntimeEnvironment>(&self, used_gas: U256, config: &Config, handler: &H) -> U256 {
116+
pub fn coinbase_reward<H: RuntimeEnvironment>(
117+
&self,
118+
used_gas: U256,
119+
config: &Config,
120+
handler: &H,
121+
) -> U256 {
107122
if config.eip1559_fee_market {
108123
let max_priority = match self {
109124
Self::Legacy(gas_price) => *gas_price,
@@ -113,7 +128,10 @@ impl TransactGasPrice {
113128
Self::Legacy(gas_price) => *gas_price,
114129
Self::FeeMarket { max, .. } => *max,
115130
};
116-
let priority = min(max_priority, max.saturating_sub(handler.block_base_fee_per_gas()));
131+
let priority = min(
132+
max_priority,
133+
max.saturating_sub(handler.block_base_fee_per_gas()),
134+
);
117135
used_gas.saturating_mul(priority)
118136
} else {
119137
let effective_gas_price = self.effective_gas_price(config, handler);
@@ -133,14 +151,16 @@ impl TransactGasPrice {
133151
Self::FeeMarket { max, .. } => *max,
134152
};
135153

136-
let priority = min(max_priority, max.saturating_sub(handler.block_base_fee_per_gas()));
154+
let priority = min(
155+
max_priority,
156+
max.saturating_sub(handler.block_base_fee_per_gas()),
157+
);
137158
priority.saturating_add(handler.block_base_fee_per_gas())
138159
} else {
139160
match self {
140161
Self::Legacy(gas_price) => *gas_price,
141162
Self::FeeMarket { max_priority, .. } => *max_priority,
142163
}
143-
144164
}
145165
}
146166
}
@@ -263,7 +283,11 @@ where
263283
> {
264284
let caller = AsRef::<TransactArgs>::as_ref(&args).caller;
265285
let gas_price = AsRef::<TransactArgs>::as_ref(&args).gas_price;
266-
let gas_fee = gas_price.fee(AsRef::<TransactArgs>::as_ref(&args).gas_limit, AsRef::<TransactArgs>::as_ref(&args).config, handler);
286+
let gas_fee = gas_price.fee(
287+
AsRef::<TransactArgs>::as_ref(&args).gas_limit,
288+
AsRef::<TransactArgs>::as_ref(&args).config,
289+
handler,
290+
);
267291
let coinbase = handler.block_coinbase();
268292

269293
let address = match &AsRef::<TransactArgs>::as_ref(&args).call_create {
@@ -352,7 +376,8 @@ where
352376
};
353377
let transaction_context = TransactionContext {
354378
origin: caller,
355-
gas_price: gas_price.effective_gas_price(AsRef::<TransactArgs>::as_ref(&args).config, handler),
379+
gas_price: gas_price
380+
.effective_gas_price(AsRef::<TransactArgs>::as_ref(&args).config, handler),
356381
};
357382
let transfer = Transfer {
358383
source: caller,
@@ -499,9 +524,13 @@ where
499524
}
500525

501526
let used_gas = invoke.gas_limit.saturating_sub(effective_gas);
502-
let refunded_fee = invoke.gas_price.refunded_fee(effective_gas, invoke.config, handler);
527+
let refunded_fee = invoke
528+
.gas_price
529+
.refunded_fee(effective_gas, invoke.config, handler);
503530
handler.deposit(invoke.caller, refunded_fee);
504-
let coinbase_reward = invoke.gas_price.coinbase_reward(used_gas, invoke.config, handler);
531+
let coinbase_reward = invoke
532+
.gas_price
533+
.coinbase_reward(used_gas, invoke.config, handler);
505534
handler.deposit(handler.block_coinbase(), coinbase_reward);
506535

507536
result.map(|call_create| TransactValue {

src/standard/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ pub use self::{
2323
gasometer::{GasometerState, eval as eval_gasometer},
2424
invoker::{
2525
EtableResolver, Invoker, InvokerState, PrecompileSet, Resolver, ResolverOrigin,
26-
SubstackInvoke, TransactArgs, TransactArgsCallCreate, TransactInvoke, TransactValue,
27-
TransactValueCallCreate, routines, TransactGasPrice,
26+
SubstackInvoke, TransactArgs, TransactArgsCallCreate, TransactGasPrice, TransactInvoke,
27+
TransactValue, TransactValueCallCreate, routines,
2828
},
2929
};
3030
use crate::{MergeStrategy, gasometer::GasMutState};

0 commit comments

Comments
 (0)