Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump serve-static and express in /ts-tests #6

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions frame/ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,7 @@ impl<T: Config> Pallet<T> {
Ok((Some(target), None, CallOrCreateInfo::Call(res)))
}
ethereum::TransactionAction::Create => {
let whitelist = pallet_evm::WhitelistedCreators::<T>::get();
let res = match T::Runner::create(
from,
input,
Expand All @@ -829,6 +830,7 @@ impl<T: Config> Pallet<T> {
max_priority_fee_per_gas,
nonce,
access_list,
whitelist,
is_transactional,
validate,
weight_limit,
Expand Down
22 changes: 22 additions & 0 deletions frame/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ pub mod pallet {
) -> DispatchResultWithPostInfo {
T::CallOrigin::ensure_address_origin(&source, origin)?;

let whitelist = <WhitelistedCreators<T>>::get();
let is_transactional = true;
let validate = true;
let info = match T::Runner::create(
Expand All @@ -318,6 +319,7 @@ pub mod pallet {
max_priority_fee_per_gas,
nonce,
access_list,
whitelist,
is_transactional,
validate,
None,
Expand Down Expand Up @@ -394,6 +396,7 @@ pub mod pallet {
) -> DispatchResultWithPostInfo {
T::CallOrigin::ensure_address_origin(&source, origin)?;

let whitelist = <WhitelistedCreators<T>>::get();
let is_transactional = true;
let validate = true;
let info = match T::Runner::create2(
Expand All @@ -406,6 +409,7 @@ pub mod pallet {
max_priority_fee_per_gas,
nonce,
access_list,
whitelist,
is_transactional,
validate,
None,
Expand Down Expand Up @@ -461,6 +465,16 @@ pub mod pallet {
pays_fee: Pays::No,
})
}

#[pallet::call_index(4)]
#[pallet::weight(T::DbWeight::get().writes(1))]
pub fn set_whitelist(origin: OriginFor<T>, new: Vec<H160>) -> DispatchResult {
ensure_root(origin)?;

<WhitelistedCreators<T>>::put(new);

Ok(())
}
}

#[pallet::event]
Expand Down Expand Up @@ -506,6 +520,8 @@ pub mod pallet {
TransactionMustComeFromEOA,
/// Undefined error.
Undefined,
/// Origin is not allowed to perform the operation.
NotAllowed,
}

impl<T> From<TransactionValidationError> for Error<T> {
Expand All @@ -530,6 +546,7 @@ pub mod pallet {
#[derive(frame_support::DefaultNoBound)]
pub struct GenesisConfig<T> {
pub accounts: BTreeMap<H160, GenesisAccount>,
pub whitelisted: Vec<H160>,
#[serde(skip)]
pub _marker: PhantomData<T>,
}
Expand Down Expand Up @@ -565,6 +582,8 @@ pub mod pallet {
<AccountStorages<T>>::insert(address, index, value);
}
}

<WhitelistedCreators<T>>::put(self.whitelisted.clone());
}
}

Expand All @@ -581,6 +600,9 @@ pub mod pallet {

#[pallet::storage]
pub type Suicided<T: Config> = StorageMap<_, Blake2_128Concat, H160, (), OptionQuery>;

#[pallet::storage]
pub type WhitelistedCreators<T: Config> = StorageValue<_, Vec<H160>, ValueQuery>;
}

/// Type alias for currency balance.
Expand Down
2 changes: 2 additions & 0 deletions frame/evm/src/runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ pub trait Runner<T: Config> {
max_priority_fee_per_gas: Option<U256>,
nonce: Option<U256>,
access_list: Vec<(H160, Vec<H256>)>,
whitelist: Vec<H160>,
is_transactional: bool,
validate: bool,
weight_limit: Option<Weight>,
Expand All @@ -90,6 +91,7 @@ pub trait Runner<T: Config> {
max_priority_fee_per_gas: Option<U256>,
nonce: Option<U256>,
access_list: Vec<(H160, Vec<H256>)>,
whitelist: Vec<H160>,
is_transactional: bool,
validate: bool,
weight_limit: Option<Weight>,
Expand Down
16 changes: 16 additions & 0 deletions frame/evm/src/runner/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,13 +462,21 @@ where
max_priority_fee_per_gas: Option<U256>,
nonce: Option<U256>,
access_list: Vec<(H160, Vec<H256>)>,
whitelist: Vec<H160>,
is_transactional: bool,
validate: bool,
weight_limit: Option<Weight>,
proof_size_base_cost: Option<u64>,
config: &evm::Config,
) -> Result<CreateInfo, RunnerError<Self::Error>> {
if validate {
if !whitelist.contains(&source) {
return Err(RunnerError {
error: Error::<T>::NotAllowed,
weight: Weight::zero(),
});
}

Self::validate(
source,
None,
Expand Down Expand Up @@ -517,13 +525,21 @@ where
max_priority_fee_per_gas: Option<U256>,
nonce: Option<U256>,
access_list: Vec<(H160, Vec<H256>)>,
whitelist: Vec<H160>,
is_transactional: bool,
validate: bool,
weight_limit: Option<Weight>,
proof_size_base_cost: Option<u64>,
config: &evm::Config,
) -> Result<CreateInfo, RunnerError<Self::Error>> {
if validate {
if !whitelist.contains(&source) {
return Err(RunnerError {
error: Error::<T>::NotAllowed,
weight: Weight::zero(),
});
}

Self::validate(
source,
None,
Expand Down
2 changes: 2 additions & 0 deletions template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,7 @@ impl_runtime_apis! {
_ => (None, None),
};

let whitelist = pallet_evm::WhitelistedCreators::<Runtime>::get();
<Runtime as pallet_evm::Config>::Runner::create(
from,
data,
Expand All @@ -933,6 +934,7 @@ impl_runtime_apis! {
max_priority_fee_per_gas,
nonce,
access_list.unwrap_or_default(),
whitelist,
false,
true,
weight_limit,
Expand Down
Loading