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

Prepare for evm-tracker pallet in subspace runtime #3376

Closed
wants to merge 2 commits into from
Closed
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
29 changes: 20 additions & 9 deletions domains/pallets/evm-tracker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,39 @@ codec = { package = "parity-scale-codec", version = "3.6.12", default-features =
domain-runtime-primitives = { version = "0.1.0", path = "../../primitives/runtime", default-features = false }
frame-support = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305" }
frame-system = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305" }
pallet-ethereum = { default-features = false, git = "https://github.com/autonomys/frontier", rev = "f80f9e2bad338f3bf3854b256b3c4edea23e5968" }
pallet-evm = { version = "6.0.0-dev", default-features = false, git = "https://github.com/autonomys/frontier", rev = "f80f9e2bad338f3bf3854b256b3c4edea23e5968" }
pallet-utility = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305" }
scale-info = { version = "2.11.2", default-features = false, features = ["derive"] }
sp-core = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305" }
sp-domains = { version = "0.1.0", default-features = false, path = "../../../crates/sp-domains" }
sp-runtime = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305" }
subspace-runtime-primitives = { version = "0.1.0", path = "../../../crates/subspace-runtime-primitives", default-features = false }

# optional contract creation filter dependencies
pallet-ethereum = { default-features = false, git = "https://github.com/autonomys/frontier", rev = "f80f9e2bad338f3bf3854b256b3c4edea23e5968", optional = true }
pallet-evm = { version = "6.0.0-dev", default-features = false, git = "https://github.com/autonomys/frontier", rev = "f80f9e2bad338f3bf3854b256b3c4edea23e5968", optional = true }
pallet-utility = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "94a1a8143a89bbe9f938c1939ff68abc1519a305", optional = true }
subspace-runtime-primitives = { version = "0.1.0", path = "../../../crates/subspace-runtime-primitives", default-features = false, optional = true }

[features]
default = ["std"]
default = [
"std",
"create-contract-filter",
]
create-contract-filter = [
"pallet-ethereum",
"pallet-evm",
"pallet-utility",
"subspace-runtime-primitives",
]
std = [
"codec/std",
"domain-runtime-primitives/std",
"frame-support/std",
"frame-system/std",
"pallet-ethereum/std",
"pallet-evm/std",
"pallet-utility/std",
"pallet-ethereum?/std",
"pallet-evm?/std",
"pallet-utility?/std",
"scale-info/std",
"sp-core/std",
"sp-domains/std",
"sp-runtime/std",
"subspace-runtime-primitives/std",
"subspace-runtime-primitives?/std",
]
2 changes: 1 addition & 1 deletion domains/pallets/evm-tracker/src/create_contract.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Contract creation allow list implementations
//! Contract creation allow list filtering implementations.

use crate::traits::{AccountIdFor, MaybeIntoEthCall, MaybeIntoEvmCall};
use codec::{Decode, Encode};
Expand Down
23 changes: 15 additions & 8 deletions domains/pallets/evm-tracker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,20 @@
extern crate alloc;

mod check_nonce;
#[cfg(feature = "create-contract-filter")]
pub mod create_contract;
#[cfg(feature = "create-contract-filter")]
pub mod traits;

pub use check_nonce::CheckNonce;
use domain_runtime_primitives::EthereumAccountId;
pub use pallet::*;
use sp_core::U256;
use sp_domains::PermissionedActionAllowedBy;

#[frame_support::pallet]
mod pallet {
use codec::Codec;
use domain_runtime_primitives::EthereumAccountId;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use sp_core::U256;
Expand All @@ -55,14 +58,18 @@ mod pallet {
// When this type name is changed, evm_contract_creation_allowed_by_storage_key() also needs to
// be updated.
#[pallet::storage]
pub(super) type ContractCreationAllowedBy<T: Config> =
StorageValue<_, PermissionedActionAllowedBy<T::AccountId>, ValueQuery, DefaultToAnyone>;
pub(super) type ContractCreationAllowedBy<T: Config> = StorageValue<
_,
PermissionedActionAllowedBy<EthereumAccountId>,
ValueQuery,
DefaultToAnyone,
>;

/// Default value for ContractCreationAllowedBy if it is not set.
pub struct DefaultToAnyone;

impl<AccountId: Codec + Clone> Get<PermissionedActionAllowedBy<AccountId>> for DefaultToAnyone {
fn get() -> PermissionedActionAllowedBy<AccountId> {
impl Get<PermissionedActionAllowedBy<EthereumAccountId>> for DefaultToAnyone {
fn get() -> PermissionedActionAllowedBy<EthereumAccountId> {
PermissionedActionAllowedBy::Anyone
}
}
Expand All @@ -79,7 +86,7 @@ mod pallet {
#[pallet::weight(<T as frame_system::Config>::DbWeight::get().reads_writes(0, 1))]
pub fn set_contract_creation_allowed_by(
origin: OriginFor<T>,
contract_creation_allowed_by: PermissionedActionAllowedBy<T::AccountId>,
contract_creation_allowed_by: PermissionedActionAllowedBy<EthereumAccountId>,
) -> DispatchResult {
ensure_root(origin)?;
ContractCreationAllowedBy::<T>::put(contract_creation_allowed_by);
Expand Down Expand Up @@ -109,7 +116,7 @@ impl<T: Config> Pallet<T> {
}

/// Returns true if the supplied account is allowed to create contracts.
pub fn is_allowed_to_create_contracts(signer: &T::AccountId) -> bool {
pub fn is_allowed_to_create_contracts(signer: &EthereumAccountId) -> bool {
ContractCreationAllowedBy::<T>::get().is_allowed(signer)
}

Expand All @@ -120,7 +127,7 @@ impl<T: Config> Pallet<T> {

/// Returns the current contract creation allow list.
/// Mainly used in tests.
pub fn contract_creation_allowed_by() -> PermissionedActionAllowedBy<T::AccountId> {
pub fn contract_creation_allowed_by() -> PermissionedActionAllowedBy<EthereumAccountId> {
ContractCreationAllowedBy::<T>::get()
}
}
2 changes: 1 addition & 1 deletion domains/runtime/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pallet-domain-sudo = { version = "0.1.0", path = "../../pallets/domain-sudo", de
pallet-ethereum = { default-features = false, git = "https://github.com/autonomys/frontier", rev = "f80f9e2bad338f3bf3854b256b3c4edea23e5968" }
pallet-evm = { version = "6.0.0-dev", default-features = false, git = "https://github.com/autonomys/frontier", rev = "f80f9e2bad338f3bf3854b256b3c4edea23e5968" }
pallet-evm-chain-id = { version = "1.0.0-dev", default-features = false, git = "https://github.com/autonomys/frontier", rev = "f80f9e2bad338f3bf3854b256b3c4edea23e5968" }
pallet-evm-tracker = { version = "0.1.0", path = "../../pallets/evm-tracker", default-features = false }
pallet-evm-tracker = { version = "0.1.0", path = "../../pallets/evm-tracker", default-features = false, features = ["create-contract-filter"] }
pallet-evm-precompile-modexp = { version = "2.0.0-dev", default-features = false, git = "https://github.com/autonomys/frontier", rev = "f80f9e2bad338f3bf3854b256b3c4edea23e5968" }
pallet-evm-precompile-sha3fips = { version = "2.0.0-dev", default-features = false, git = "https://github.com/autonomys/frontier", rev = "f80f9e2bad338f3bf3854b256b3c4edea23e5968" }
pallet-evm-precompile-simple = { version = "2.0.0-dev", default-features = false, git = "https://github.com/autonomys/frontier", rev = "f80f9e2bad338f3bf3854b256b3c4edea23e5968" }
Expand Down
2 changes: 1 addition & 1 deletion domains/test/runtime/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pallet-domain-sudo = { version = "0.1.0", path = "../../../pallets/domain-sudo",
pallet-ethereum = { default-features = false, git = "https://github.com/autonomys/frontier", rev = "f80f9e2bad338f3bf3854b256b3c4edea23e5968" }
pallet-evm = { version = "6.0.0-dev", default-features = false, git = "https://github.com/autonomys/frontier", rev = "f80f9e2bad338f3bf3854b256b3c4edea23e5968" }
pallet-evm-chain-id = { version = "1.0.0-dev", default-features = false, git = "https://github.com/autonomys/frontier", rev = "f80f9e2bad338f3bf3854b256b3c4edea23e5968" }
pallet-evm-tracker = { version = "0.1.0", path = "../../../pallets/evm-tracker", default-features = false }
pallet-evm-tracker = { version = "0.1.0", path = "../../../pallets/evm-tracker", default-features = false, features = ["create-contract-filter"] }
pallet-evm-precompile-modexp = { version = "2.0.0-dev", default-features = false, git = "https://github.com/autonomys/frontier", rev = "f80f9e2bad338f3bf3854b256b3c4edea23e5968" }
pallet-evm-precompile-sha3fips = { version = "2.0.0-dev", default-features = false, git = "https://github.com/autonomys/frontier", rev = "f80f9e2bad338f3bf3854b256b3c4edea23e5968" }
pallet-evm-precompile-simple = { version = "2.0.0-dev", default-features = false, git = "https://github.com/autonomys/frontier", rev = "f80f9e2bad338f3bf3854b256b3c4edea23e5968" }
Expand Down
Loading