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

Update-stable2409 #55

Merged
merged 8 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
1,358 changes: 666 additions & 692 deletions Cargo.lock

Large diffs are not rendered by default.

278 changes: 139 additions & 139 deletions Cargo.toml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/consensus/nimbus-consensus/src/import_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ where
}

async fn import_block(
&mut self,
&self,
mut block_import_params: sc_consensus::BlockImportParams<Block>,
) -> Result<sc_consensus::ImportResult, Self::Error> {
// If we are in the parachain context, best block is determined by the relay chain
Expand Down
1 change: 1 addition & 0 deletions precompiles/assets-erc20/src/eip2612.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ where
<<Runtime as frame_system::Config>::RuntimeCall as Dispatchable>::RuntimeOrigin: OriginTrait,
AssetIdOf<Runtime, Instance>: Display,
Runtime::AccountId: Into<H160>,
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
{
fn compute_domain_separator(address: H160, asset_id: AssetIdOf<Runtime, Instance>) -> [u8; 32] {
let asset_name = pallet_assets::Pallet::<Runtime, Instance>::name(asset_id.clone());
Expand Down
1 change: 1 addition & 0 deletions precompiles/assets-erc20/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ where
<<Runtime as frame_system::Config>::RuntimeCall as Dispatchable>::RuntimeOrigin: OriginTrait,
AssetIdOf<Runtime, Instance>: Display,
Runtime::AccountId: Into<H160>,
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
{
/// PrecompileSet discriminant. Allows to knows if the address maps to an asset id,
/// and if this is the case which one.
Expand Down
1 change: 1 addition & 0 deletions precompiles/assets-erc20/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ parameter_types! {
}

impl pallet_evm::Config for Runtime {
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Self>;
type FeeCalculator = ();
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
type WeightPerGas = WeightPerGas;
Expand Down
1 change: 1 addition & 0 deletions precompiles/balances-erc20/src/eip2612.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ where
BalanceOf<Runtime, Instance>: TryFrom<U256> + Into<U256>,
Metadata: Erc20Metadata,
Instance: InstanceToPrefix + 'static,
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
{
pub fn compute_domain_separator(address: H160) -> [u8; 32] {
let name: H256 = keccak_256(Metadata::name().as_bytes()).into();
Expand Down
1 change: 1 addition & 0 deletions precompiles/balances-erc20/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ where
BalanceOf<Runtime, Instance>: TryFrom<U256> + Into<U256>,
Metadata: Erc20Metadata,
Instance: InstanceToPrefix + 'static,
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
{
#[precompile::public("totalSupply()")]
#[precompile::view]
Expand Down
1 change: 1 addition & 0 deletions precompiles/balances-erc20/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ parameter_types! {
}

impl pallet_evm::Config for Runtime {
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Self>;
type FeeCalculator = ();
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
type WeightPerGas = WeightPerGas;
Expand Down
1 change: 1 addition & 0 deletions precompiles/batch/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ parameter_types! {
}

impl pallet_evm::Config for Runtime {
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Self>;
type FeeCalculator = ();
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
type WeightPerGas = WeightPerGas;
Expand Down
1 change: 1 addition & 0 deletions precompiles/call-permit/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ parameter_types! {
}

impl pallet_evm::Config for Runtime {
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Self>;
type FeeCalculator = ();
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
type WeightPerGas = WeightPerGas;
Expand Down
1 change: 1 addition & 0 deletions precompiles/pallet-xcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ where
From<Option<Runtime::AccountId>>,
<Runtime as frame_system::Config>::RuntimeCall: From<pallet_xcm::Call<Runtime>>,
LocationMatcher: AccountIdToLocationMatcher<<Runtime as frame_system::Config>::AccountId>,
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
{
#[precompile::public(
"transferAssetsLocation(\
Expand Down
8 changes: 2 additions & 6 deletions precompiles/pallet-xcm/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ impl GasWeightMapping for MockGasWeightMapping {
}

impl pallet_evm::Config for Runtime {
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Self>;
type FeeCalculator = ();
type GasWeightMapping = MockGasWeightMapping;
type WeightPerGas = WeightPerGas;
Expand Down Expand Up @@ -480,14 +481,9 @@ parameter_types! {

pub RelayLocation: Location = Location::parent();

pub RelayAsset: Asset = Asset {
fun: Fungible(10000000),
id: AssetId(Location::parent()),
};

pub LocalAsset: (AssetFilter, Location) = (All.into(), Location::here());
pub TrustedForeignAsset: (AssetFilter, Location) = (ForeignAsset::get().into(), ForeignReserveLocation::get());
pub RelayForeignAsset: (AssetFilter, Location) = (RelayAsset::get().into(), RelayLocation::get());
pub RelayForeignAsset: (AssetFilter, Location) = (All.into(), RelayLocation::get());
}

pub struct XcmConfig;
Expand Down
5 changes: 4 additions & 1 deletion precompiles/proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ where
<Runtime as frame_system::Config>::RuntimeCall:
From<ProxyCall<Runtime>> + From<BalancesCall<Runtime>>,
<Runtime as pallet_balances::Config<()>>::Balance: TryFrom<U256> + Into<U256>,
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
{
fn is_allowed(_caller: H160, selector: Option<u32>) -> bool {
match selector {
Expand Down Expand Up @@ -86,6 +87,7 @@ where
<Runtime as frame_system::Config>::RuntimeCall:
From<ProxyCall<Runtime>> + From<BalancesCall<Runtime>>,
<Runtime as pallet_balances::Config<()>>::Balance: TryFrom<U256> + Into<U256>,
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
{
fn is_allowed(_caller: H160, selector: Option<u32>) -> bool {
match selector {
Expand Down Expand Up @@ -147,6 +149,7 @@ where
<Runtime as frame_system::Config>::RuntimeCall:
From<ProxyCall<Runtime>> + From<BalancesCall<Runtime>>,
<Runtime as pallet_balances::Config<()>>::Balance: TryFrom<U256> + Into<U256>,
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
{
/// Register a proxy account for the sender that is able to make calls on its behalf.
/// The dispatch origin for this call must be Signed.
Expand Down Expand Up @@ -180,7 +183,7 @@ where
handle.record_db_read::<Runtime>(
28 + (29 * (<Runtime as pallet_proxy::Config>::MaxProxies::get() as usize)) + 8,
)?;
if ProxyPallet::<Runtime>::proxies(&origin)
if ProxyPallet::<Runtime>::proxies(origin.clone())
.0
.iter()
.any(|pd| pd.delegate == delegate)
Expand Down
1 change: 1 addition & 0 deletions precompiles/proxy/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ parameter_types! {
};
}
impl pallet_evm::Config for Runtime {
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Self>;
type FeeCalculator = ();
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
type WeightPerGas = WeightPerGas;
Expand Down
5 changes: 3 additions & 2 deletions precompiles/xcm-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,17 @@ xcm-builder = { workspace = true }
[features]
default = [ "std" ]
std = [
"cumulus-primitives-core/std",
"frame-support/std",
"frame-system/std",
"pallet-balances/std",
"pallet-evm/std",
"pallet-timestamp/std",
"pallet-xcm/std",
"parity-scale-codec/std",
"precompile-utils/std",
"sp-core/std",
"sp-io/std",
"sp-std/std",
"xcm/std",
"xcm-builder/std",
"xcm-executor/std",
"xcm-primitives/std",
Expand Down
2 changes: 2 additions & 0 deletions precompiles/xcm-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ where
<<Runtime as frame_system::Config>::RuntimeCall as Dispatchable>::RuntimeOrigin:
From<Option<Runtime::AccountId>>,
<Runtime as frame_system::Config>::RuntimeCall: From<pallet_xcm::Call<Runtime>>,
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
{
fn is_allowed(_caller: H160, selector: Option<u32>) -> bool {
match selector {
Expand Down Expand Up @@ -102,6 +103,7 @@ where
<<Runtime as frame_system::Config>::RuntimeCall as Dispatchable>::RuntimeOrigin:
From<Option<Runtime::AccountId>>,
<Runtime as frame_system::Config>::RuntimeCall: From<pallet_xcm::Call<Runtime>>,
<Runtime as pallet_evm::Config>::AddressMapping: AddressMapping<Runtime::AccountId>,
{
#[precompile::public("multilocationToAddress((uint8,bytes[]))")]
#[precompile::view]
Expand Down
15 changes: 9 additions & 6 deletions precompiles/xcm-utils/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ use sp_core::{H256, U256};
use sp_io;
use sp_runtime::traits::{BlakeTwo256, IdentityLookup, TryConvert};
use sp_runtime::BuildStorage;
use xcm::latest::Error as XcmError;
use xcm_builder::AllowUnpaidExecutionFrom;
use xcm_builder::FixedWeightBounds;
use xcm_builder::IsConcrete;
use xcm_builder::SovereignSignedViaLocation;
use xcm::latest::{Error as XcmError, WildAsset::All};
use xcm_builder::{
AllowUnpaidExecutionFrom, Case, FixedWeightBounds, IsConcrete, SovereignSignedViaLocation,
};
use xcm_executor::{
traits::{ConvertLocation, TransactAsset, WeightTrader},
AssetsInHolding,
Expand Down Expand Up @@ -269,6 +268,7 @@ impl GasWeightMapping for MockGasWeightMapping {
}

impl pallet_evm::Config for Runtime {
type AccountProvider = pallet_evm::FrameSystemAccountProvider<Self>;
type FeeCalculator = ();
type GasWeightMapping = MockGasWeightMapping;
type WeightPerGas = WeightPerGas;
Expand Down Expand Up @@ -403,6 +403,9 @@ parameter_types! {
[GlobalConsensus(RelayNetwork::get()), Parachain(ParachainId::get().into()).into()].into();

pub const MaxAssetsIntoHolding: u32 = 64;

pub RelayLocation: Location = Location::parent();
pub RelayForeignAsset: (AssetFilter, Location) = (All.into(), RelayLocation::get());
}

pub type XcmOriginToTransactDispatchOrigin = (
Expand All @@ -417,7 +420,7 @@ impl xcm_executor::Config for XcmConfig {
type XcmSender = TestSendXcm;
type AssetTransactor = DummyAssetTransactor;
type OriginConverter = XcmOriginToTransactDispatchOrigin;
type IsReserve = ();
type IsReserve = Case<RelayForeignAsset>;
type IsTeleporter = ();
type UniversalLocation = UniversalLocation;
type Barrier = Barrier;
Expand Down
16 changes: 4 additions & 12 deletions template/node/src/command.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
use std::net::SocketAddr;

use cumulus_primitives_core::ParaId;
use frame_benchmarking_cli::BenchmarkCmd;
use log::info;
use moonkit_template_runtime::Block;
use sc_cli::{
ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,
NetworkParams, Result, SharedParams, SubstrateCli,
NetworkParams, Result, RpcEndpoint, SharedParams, SubstrateCli,
};
use sc_service::config::{BasePath, PrometheusConfig};
use sp_runtime::traits::AccountIdConversion;
Expand Down Expand Up @@ -325,7 +323,7 @@ impl CliConfiguration<Self> for RelayChainCli {
.or_else(|| Some(self.base_path.clone().into())))
}

fn rpc_addr(&self, default_listen_port: u16) -> Result<Option<SocketAddr>> {
fn rpc_addr(&self, default_listen_port: u16) -> Result<Option<Vec<RpcEndpoint>>> {
self.base.base.rpc_addr(default_listen_port)
}

Expand All @@ -339,15 +337,9 @@ impl CliConfiguration<Self> for RelayChainCli {
.prometheus_config(default_listen_port, chain_spec)
}

fn init<F>(
&self,
_support_url: &String,
_impl_version: &String,
_logger_hook: F,
_config: &sc_service::Configuration,
) -> Result<()>
fn init<F>(&self, _support_url: &String, _impl_version: &String, _logger_hook: F) -> Result<()>
where
F: FnOnce(&mut sc_cli::LoggerBuilder, &sc_service::Configuration),
F: FnOnce(&mut sc_cli::LoggerBuilder),
{
unreachable!("PolkadotCli is never initialized; qed");
}
Expand Down
11 changes: 2 additions & 9 deletions template/node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use std::sync::Arc;
use moonkit_template_runtime::{opaque::Block, AccountId, Balance, Nonce};

use sc_client_api::AuxStore;
pub use sc_rpc::DenyUnsafe;
use sc_transaction_pool_api::TransactionPool;
use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder;
Expand All @@ -25,8 +24,6 @@ pub struct FullDeps<C, P> {
pub client: Arc<C>,
/// Transaction pool instance.
pub pool: Arc<P>,
/// Whether to deny unsafe calls
pub deny_unsafe: DenyUnsafe,
}

/// Instantiate all RPC extensions.
Expand All @@ -50,13 +47,9 @@ where
use substrate_frame_rpc_system::{System, SystemApiServer};

let mut module = RpcExtension::new(());
let FullDeps {
client,
pool,
deny_unsafe,
} = deps;
let FullDeps { client, pool } = deps;

module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
module.merge(System::new(client.clone(), pool).into_rpc())?;
module.merge(TransactionPayment::new(client).into_rpc())?;

Ok(module)
Expand Down
26 changes: 15 additions & 11 deletions template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,18 @@ pub fn new_partial(
.transpose()?;

let heap_pages = config
.executor
.default_heap_pages
.map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static {
extra_pages: h as _,
});

let wasm = WasmExecutor::builder()
.with_execution_method(config.wasm_method)
.with_execution_method(config.executor.wasm_method)
.with_onchain_heap_alloc_strategy(heap_pages)
.with_offchain_heap_alloc_strategy(heap_pages)
.with_max_runtime_instances(config.max_runtime_instances)
.with_runtime_cache_size(config.runtime_cache_size)
.with_max_runtime_instances(config.executor.max_runtime_instances)
.with_runtime_cache_size(config.executor.runtime_cache_size)
.build();

let executor = ParachainExecutor::new_with_wasm_executor(wasm);
Expand Down Expand Up @@ -240,7 +241,10 @@ where
let transaction_pool = params.transaction_pool.clone();
let import_queue_service = params.import_queue.service();

let net_config = FullNetworkConfiguration::<_, _, N>::new(&parachain_config.network);
let net_config = FullNetworkConfiguration::<_, _, N>::new(
&parachain_config.network,
prometheus_registry.clone(),
);

let metrics = N::register_notification_metrics(
parachain_config
Expand All @@ -259,7 +263,7 @@ where
block_announce_validator_builder: Some(Box::new(|_| {
Box::new(block_announce_validator)
})),
warp_sync_params: None,
warp_sync_config: None,
net_config,
block_relay: None,
metrics,
Expand All @@ -269,11 +273,10 @@ where
let client = client.clone();
let transaction_pool = transaction_pool.clone();

Box::new(move |deny_unsafe, _| {
Box::new(move |_| {
let deps = crate::rpc::FullDeps {
client: client.clone(),
pool: transaction_pool.clone(),
deny_unsafe,
};

crate::rpc::create_full(deps).map_err(Into::into)
Expand Down Expand Up @@ -442,7 +445,9 @@ where
other: (_, mut telemetry, _),
} = new_partial(&config, false)?;

let net_config = FullNetworkConfiguration::<_, _, N>::new(&config.network);
let prometheus_registry = config.prometheus_registry().cloned();
let net_config =
FullNetworkConfiguration::<_, _, N>::new(&config.network, prometheus_registry.clone());

let metrics = N::register_notification_metrics(
config.prometheus_config.as_ref().map(|cfg| &cfg.registry),
Expand All @@ -456,7 +461,7 @@ where
spawn_handle: task_manager.spawn_handle(),
import_queue,
block_announce_validator_builder: None,
warp_sync_params: None,
warp_sync_config: None,
net_config,
block_relay: None,
metrics,
Expand Down Expand Up @@ -490,11 +495,10 @@ where
let client = client.clone();
let transaction_pool = transaction_pool.clone();

Box::new(move |deny_unsafe, _| {
Box::new(move |_| {
let deps = crate::rpc::FullDeps {
client: client.clone(),
pool: transaction_pool.clone(),
deny_unsafe,
};

crate::rpc::create_full(deps).map_err(Into::into)
Expand Down
4 changes: 1 addition & 3 deletions template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,9 +688,7 @@ construct_runtime!(
{
// System support stuff.
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>} = 0,
ParachainSystem: cumulus_pallet_parachain_system::{
Pallet, Call, Config<T>, Storage, Inherent, Event<T>, ValidateUnsigned,
} = 1,
ParachainSystem: cumulus_pallet_parachain_system = 1,
RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip::{Pallet, Storage} = 2,
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 3,
ParachainInfo: staging_parachain_info::{Pallet, Storage, Config<T>} = 4,
Expand Down
Loading