Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit cc912dc

Browse files
authored
Improves EVM gas price check (#7051)
1 parent 38a0d36 commit cc912dc

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

frame/evm/src/lib.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ decl_module! {
333333
input,
334334
value,
335335
gas_limit,
336-
Some(gas_price),
336+
gas_price,
337337
nonce,
338338
true,
339339
)? {
@@ -367,7 +367,7 @@ decl_module! {
367367
init,
368368
value,
369369
gas_limit,
370-
Some(gas_price),
370+
gas_price,
371371
nonce,
372372
true,
373373
)? {
@@ -402,7 +402,7 @@ decl_module! {
402402
salt,
403403
value,
404404
gas_limit,
405-
Some(gas_price),
405+
gas_price,
406406
nonce,
407407
true,
408408
)? {
@@ -482,7 +482,7 @@ impl<T: Trait> Module<T> {
482482
init: Vec<u8>,
483483
value: U256,
484484
gas_limit: u32,
485-
gas_price: Option<U256>,
485+
gas_price: U256,
486486
nonce: Option<U256>,
487487
apply_state: bool,
488488
) -> Result<(ExitReason, H160, U256), Error<T>> {
@@ -514,7 +514,7 @@ impl<T: Trait> Module<T> {
514514
salt: H256,
515515
value: U256,
516516
gas_limit: u32,
517-
gas_price: Option<U256>,
517+
gas_price: U256,
518518
nonce: Option<U256>,
519519
apply_state: bool,
520520
) -> Result<(ExitReason, H160, U256), Error<T>> {
@@ -548,7 +548,7 @@ impl<T: Trait> Module<T> {
548548
input: Vec<u8>,
549549
value: U256,
550550
gas_limit: u32,
551-
gas_price: Option<U256>,
551+
gas_price: U256,
552552
nonce: Option<U256>,
553553
apply_state: bool,
554554
) -> Result<(ExitReason, Vec<u8>, U256), Error<T>> {
@@ -574,20 +574,18 @@ impl<T: Trait> Module<T> {
574574
source: H160,
575575
value: U256,
576576
gas_limit: u32,
577-
gas_price: Option<U256>,
577+
gas_price: U256,
578578
nonce: Option<U256>,
579579
apply_state: bool,
580580
f: F,
581581
) -> Result<(ExitReason, R, U256), Error<T>> where
582582
F: FnOnce(&mut StackExecutor<Backend<T>>) -> (ExitReason, R),
583583
{
584-
let gas_price = match gas_price {
585-
Some(gas_price) => {
586-
ensure!(gas_price >= T::FeeCalculator::min_gas_price(), Error::<T>::GasPriceTooLow);
587-
gas_price
588-
},
589-
None => U256::zero(),
590-
};
584+
585+
// Gas price check is skipped when performing a gas estimation.
586+
if apply_state {
587+
ensure!(gas_price >= T::FeeCalculator::min_gas_price(), Error::<T>::GasPriceTooLow);
588+
}
591589

592590
let vicinity = Vicinity {
593591
gas_price,

0 commit comments

Comments
 (0)