Skip to content

Commit 4bef378

Browse files
pallet-evm ensure gas_price + Storage getter (#6191)
* evm: move gas price check to top-level dispatchable * Add AccountCodes get fn and account_exists helper * Remove account_exists, evm handles non-existing accounts * Runtime bump impl_version 251/2 * Fix Runtime impl_version and spec_version Co-authored-by: Wei Tang <[email protected]>
1 parent 70763b8 commit 4bef378

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pub struct GenesisAccount {
158158
decl_storage! {
159159
trait Store for Module<T: Trait> as EVM {
160160
Accounts get(fn accounts): map hasher(blake2_128_concat) H160 => Account;
161-
AccountCodes: map hasher(blake2_128_concat) H160 => Vec<u8>;
161+
AccountCodes get(fn account_codes): map hasher(blake2_128_concat) H160 => Vec<u8>;
162162
AccountStorages: double_map hasher(blake2_128_concat) H160, hasher(blake2_128_concat) H256 => H256;
163163
}
164164

@@ -288,6 +288,8 @@ decl_module! {
288288
gas_price: U256,
289289
nonce: Option<U256>,
290290
) -> DispatchResult {
291+
ensure!(gas_price >= T::FeeCalculator::min_gas_price(), Error::<T>::GasPriceTooLow);
292+
291293
let sender = ensure_signed(origin)?;
292294
let source = T::ConvertAccountId::convert_account_id(&sender);
293295

@@ -318,6 +320,8 @@ decl_module! {
318320
gas_price: U256,
319321
nonce: Option<U256>,
320322
) -> DispatchResult {
323+
ensure!(gas_price >= T::FeeCalculator::min_gas_price(), Error::<T>::GasPriceTooLow);
324+
321325
let sender = ensure_signed(origin)?;
322326
let source = T::ConvertAccountId::convert_account_id(&sender);
323327

@@ -350,6 +354,8 @@ decl_module! {
350354
gas_price: U256,
351355
nonce: Option<U256>,
352356
) -> DispatchResult {
357+
ensure!(gas_price >= T::FeeCalculator::min_gas_price(), Error::<T>::GasPriceTooLow);
358+
353359
let sender = ensure_signed(origin)?;
354360
let source = T::ConvertAccountId::convert_account_id(&sender);
355361

@@ -498,8 +504,6 @@ impl<T: Trait> Module<T> {
498504
) -> Result<R, Error<T>> where
499505
F: FnOnce(&mut StackExecutor<Backend<T>>) -> (R, ExitReason),
500506
{
501-
ensure!(gas_price >= T::FeeCalculator::min_gas_price(), Error::<T>::GasPriceTooLow);
502-
503507
let vicinity = Vicinity {
504508
gas_price,
505509
origin: source,

0 commit comments

Comments
 (0)