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

Commit

Permalink
Improves EVM gas price check (#7051)
Browse files Browse the repository at this point in the history
  • Loading branch information
crystalin authored and bkchr committed Sep 18, 2020
1 parent b4fbdda commit 67c778b
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions frame/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ decl_module! {
input,
value,
gas_limit,
Some(gas_price),
gas_price,
nonce,
true,
)? {
Expand Down Expand Up @@ -367,7 +367,7 @@ decl_module! {
init,
value,
gas_limit,
Some(gas_price),
gas_price,
nonce,
true,
)? {
Expand Down Expand Up @@ -402,7 +402,7 @@ decl_module! {
salt,
value,
gas_limit,
Some(gas_price),
gas_price,
nonce,
true,
)? {
Expand Down Expand Up @@ -482,7 +482,7 @@ impl<T: Trait> Module<T> {
init: Vec<u8>,
value: U256,
gas_limit: u32,
gas_price: Option<U256>,
gas_price: U256,
nonce: Option<U256>,
apply_state: bool,
) -> Result<(ExitReason, H160, U256), Error<T>> {
Expand Down Expand Up @@ -514,7 +514,7 @@ impl<T: Trait> Module<T> {
salt: H256,
value: U256,
gas_limit: u32,
gas_price: Option<U256>,
gas_price: U256,
nonce: Option<U256>,
apply_state: bool,
) -> Result<(ExitReason, H160, U256), Error<T>> {
Expand Down Expand Up @@ -548,7 +548,7 @@ impl<T: Trait> Module<T> {
input: Vec<u8>,
value: U256,
gas_limit: u32,
gas_price: Option<U256>,
gas_price: U256,
nonce: Option<U256>,
apply_state: bool,
) -> Result<(ExitReason, Vec<u8>, U256), Error<T>> {
Expand All @@ -574,20 +574,18 @@ impl<T: Trait> Module<T> {
source: H160,
value: U256,
gas_limit: u32,
gas_price: Option<U256>,
gas_price: U256,
nonce: Option<U256>,
apply_state: bool,
f: F,
) -> Result<(ExitReason, R, U256), Error<T>> where
F: FnOnce(&mut StackExecutor<Backend<T>>) -> (ExitReason, R),
{
let gas_price = match gas_price {
Some(gas_price) => {
ensure!(gas_price >= T::FeeCalculator::min_gas_price(), Error::<T>::GasPriceTooLow);
gas_price
},
None => U256::zero(),
};

// Gas price check is skipped when performing a gas estimation.
if apply_state {
ensure!(gas_price >= T::FeeCalculator::min_gas_price(), Error::<T>::GasPriceTooLow);
}

let vicinity = Vicinity {
gas_price,
Expand Down

0 comments on commit 67c778b

Please sign in to comment.