diff --git a/bin/collator/src/local/service.rs b/bin/collator/src/local/service.rs index 1d837bdfe7..d6027b2cb3 100644 --- a/bin/collator/src/local/service.rs +++ b/bin/collator/src/local/service.rs @@ -198,10 +198,12 @@ pub fn start_node( .expect("Genesis block exists; qed"), &config.chain_spec, ); + let net_config = sc_network::config::FullNetworkConfiguration::new(&config.network); let (network, system_rpc_tx, tx_handler_controller, network_starter, sync_service) = sc_service::build_network(sc_service::BuildNetworkParams { config: &config, + net_config, client: client.clone(), transaction_pool: transaction_pool.clone(), spawn_handle: task_manager.spawn_handle(), @@ -258,7 +260,7 @@ pub fn start_node( task_manager.spawn_essential_handle().spawn( "frontier-mapping-sync-worker", Some("frontier"), - fc_mapping_sync::MappingSyncWorker::new( + fc_mapping_sync::kv::MappingSyncWorker::new( client.import_notification_stream(), Duration::new(6, 0), client.clone(), @@ -491,10 +493,12 @@ pub fn start_node(config: Configuration) -> Result { .expect("Genesis block exists; qed"), &config.chain_spec, ); + let net_config = sc_network::config::FullNetworkConfiguration::new(&config.network); let (network, system_rpc_tx, tx_handler_controller, network_starter, sync_service) = sc_service::build_network(sc_service::BuildNetworkParams { config: &config, + net_config, client: client.clone(), transaction_pool: transaction_pool.clone(), spawn_handle: task_manager.spawn_handle(), @@ -530,7 +534,7 @@ pub fn start_node(config: Configuration) -> Result { task_manager.spawn_essential_handle().spawn( "frontier-mapping-sync-worker", Some("frontier"), - fc_mapping_sync::MappingSyncWorker::new( + fc_mapping_sync::kv::MappingSyncWorker::new( client.import_notification_stream(), Duration::new(6, 0), client.clone(), diff --git a/bin/collator/src/parachain/service.rs b/bin/collator/src/parachain/service.rs index 1821e4bd9d..ab566c08e3 100644 --- a/bin/collator/src/parachain/service.rs +++ b/bin/collator/src/parachain/service.rs @@ -44,7 +44,7 @@ use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, Ta use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; use sp_api::ConstructRuntimeApi; use sp_consensus_aura::sr25519::AuthorityId as AuraId; -use sp_keystore::SyncCryptoStorePtr; +use sp_keystore::KeystorePtr; use sp_runtime::traits::BlakeTwo256; use sp_runtime::Percent; use std::{collections::BTreeMap, sync::Arc, time::Duration}; @@ -377,7 +377,7 @@ where >, >, Arc>, - SyncCryptoStorePtr, + KeystorePtr, bool, ) -> Result>, sc_service::Error>, { @@ -386,6 +386,7 @@ where let params = new_partial::(¶chain_config, build_import_queue)?; let (parachain_block_import, mut telemetry, telemetry_worker_handle, frontier_backend) = params.other; + let net_config = sc_network::config::FullNetworkConfiguration::new(¶chain_config.network); let client = params.client.clone(); let backend = params.backend.clone(); @@ -409,6 +410,7 @@ where let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) = cumulus_client_service::build_network(BuildNetworkParams { parachain_config: ¶chain_config, + net_config, para_id: id, client: client.clone(), transaction_pool: transaction_pool.clone(), @@ -436,7 +438,7 @@ where task_manager.spawn_essential_handle().spawn( "frontier-mapping-sync-worker", Some("frontier"), - fc_mapping_sync::MappingSyncWorker::new( + fc_mapping_sync::kv::MappingSyncWorker::new( client.import_notification_stream(), Duration::new(6, 0), client.clone(), @@ -695,7 +697,7 @@ where >, >, Arc>, - SyncCryptoStorePtr, + KeystorePtr, bool, ) -> Result>, sc_service::Error>, { @@ -704,6 +706,7 @@ where let params = new_partial::(¶chain_config, build_import_queue)?; let (parachain_block_import, mut telemetry, telemetry_worker_handle, frontier_backend) = params.other; + let net_config = sc_network::config::FullNetworkConfiguration::new(¶chain_config.network); let client = params.client.clone(); let backend = params.backend.clone(); @@ -727,6 +730,7 @@ where let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) = cumulus_client_service::build_network(BuildNetworkParams { parachain_config: ¶chain_config, + net_config, para_id: id, client: client.clone(), transaction_pool: transaction_pool.clone(), @@ -775,7 +779,7 @@ where task_manager.spawn_essential_handle().spawn( "frontier-mapping-sync-worker", Some("frontier"), - fc_mapping_sync::MappingSyncWorker::new( + fc_mapping_sync::kv::MappingSyncWorker::new( client.import_notification_stream(), Duration::new(6, 0), client.clone(), diff --git a/bin/collator/src/rpc.rs b/bin/collator/src/rpc.rs index 09d292102d..fc07b2c8d2 100644 --- a/bin/collator/src/rpc.rs +++ b/bin/collator/src/rpc.rs @@ -81,7 +81,7 @@ where Ok(Arc::new(fc_db::Backend::::new( client, - &fc_db::DatabaseSettings { + &fc_db::kv::DatabaseSettings { source: fc_db::DatabaseSource::RocksDb { path, cache_size: 0, diff --git a/chain-extensions/pallet-assets/src/lib.rs b/chain-extensions/pallet-assets/src/lib.rs index f4ff4695e9..261eb61cdd 100644 --- a/chain-extensions/pallet-assets/src/lib.rs +++ b/chain-extensions/pallet-assets/src/lib.rs @@ -21,8 +21,10 @@ pub mod weights; use assets_chain_extension_types::{select_origin, Origin, Outcome}; -use frame_support::traits::fungibles::InspectMetadata; -use frame_support::traits::tokens::fungibles::approvals::Inspect; +use frame_support::traits::{ + fungibles::approvals::Inspect as ApprovalInspect, + fungibles::metadata::Inspect as MetadataInspect, +}; use frame_system::RawOrigin; use pallet_assets::WeightInfo; use pallet_contracts::chain_extension::{ @@ -362,7 +364,7 @@ where let base_weight = ::metadata_name(); env.charge_weight(base_weight)?; - let name = pallet_assets::Pallet::::name(&id); + let name = pallet_assets::Pallet::::name(id.clone()); env.write(&name.encode(), false, None)?; } AssetsFunc::MetadataSymbol => { @@ -371,7 +373,7 @@ where let base_weight = ::metadata_symbol(); env.charge_weight(base_weight)?; - let symbol = pallet_assets::Pallet::::symbol(&id); + let symbol = pallet_assets::Pallet::::symbol(id.clone()); env.write(&symbol.encode(), false, None)?; } AssetsFunc::MetadataDecimals => { @@ -380,7 +382,7 @@ where let base_weight = ::metadata_decimals(); env.charge_weight(base_weight)?; - let decimals = pallet_assets::Pallet::::decimals(&id); + let decimals = pallet_assets::Pallet::::decimals(id.clone()); env.write(&decimals.encode(), false, None)?; } AssetsFunc::TransferOwnership => { diff --git a/chain-extensions/xvm/src/lib.rs b/chain-extensions/xvm/src/lib.rs index 27952d220f..94a0eacd4c 100644 --- a/chain-extensions/xvm/src/lib.rs +++ b/chain-extensions/xvm/src/lib.rs @@ -20,7 +20,10 @@ use frame_support::dispatch::Encode; use frame_support::weights::Weight; -use pallet_contracts::chain_extension::{ChainExtension, Environment, Ext, InitState, RetVal}; +use pallet_contracts::{ + chain_extension::{ChainExtension, Environment, Ext, InitState, RetVal}, + Origin, +}; use pallet_xvm::XvmContext; use sp_runtime::DispatchError; use sp_std::marker::PhantomData; @@ -73,7 +76,17 @@ where let charged_weight = env.charge_weight(remaining_weight.set_proof_size(32 * 1024))?; - let caller = env.ext().caller().clone(); + let caller = match env.ext().caller().clone() { + Origin::Signed(address) => address, + Origin::Root => { + log::trace!( + target: "xvm-extension::xvm_call", + "root origin not supported" + ); + + return Ok(RetVal::Converging(XvmExecutionResult::UnknownError as u32)); + } + }; let XvmCallArgs { vm_id, to, input } = env.read_as_unbounded(env.in_len())?; diff --git a/pallets/contracts-migration/src/lib.rs b/pallets/contracts-migration/src/lib.rs index 81825bcdd3..f2e5b7e5e2 100644 --- a/pallets/contracts-migration/src/lib.rs +++ b/pallets/contracts-migration/src/lib.rs @@ -174,7 +174,7 @@ pub mod pallet { initial: old.initial, maximum: old.maximum, code: old.code, - determinism: pallet_contracts::Enforced, + determinism: pallet_contracts::Determinism::Enforced, }) }); diff --git a/pallets/ethereum-checked/src/lib.rs b/pallets/ethereum-checked/src/lib.rs index 4be7799d86..303a063255 100644 --- a/pallets/ethereum-checked/src/lib.rs +++ b/pallets/ethereum-checked/src/lib.rs @@ -189,6 +189,10 @@ impl Pallet { is_transactional: true, }, tx_data.into(), + // TODO: solve this prior to the merge + None, + // TODO: solve this prior to the merge + None, ) // Gas limit validation. The fee payment has been validated as the tx is `checked`. .validate_common() diff --git a/pallets/pallet-xvm/src/evm.rs b/pallets/pallet-xvm/src/evm.rs index fd4cb7faef..e810f3b4b2 100644 --- a/pallets/pallet-xvm/src/evm.rs +++ b/pallets/pallet-xvm/src/evm.rs @@ -72,6 +72,10 @@ where Vec::new(), is_transactional, validate, + // TODO: set this properly before merging the PR + None, + // TODO: set this properly before merging the PR + None, T::config(), ) .map_err(|e| { @@ -90,7 +94,8 @@ where Ok(XvmCallOk { output: info.value, consumed_weight: T::GasWeightMapping::gas_to_weight( - info.used_gas.unique_saturated_into(), + // Temporary, will be updated once XVM is adjusted for the new code + info.used_gas.effective.unique_saturated_into(), false, ) .ref_time(), diff --git a/pallets/pallet-xvm/src/pallet/mod.rs b/pallets/pallet-xvm/src/pallet/mod.rs index b34d4090a8..e22a14a542 100644 --- a/pallets/pallet-xvm/src/pallet/mod.rs +++ b/pallets/pallet-xvm/src/pallet/mod.rs @@ -104,6 +104,8 @@ pub mod pallet { let result = T::SyncVM::xvm_call(context, from, to, input); let consumed_weight = consumed_weight(&result); + // TODO: solve this before merging the uplift PR - XVM should work with 2D weights!!! + let consumed_weight = Weight::from_parts(consumed_weight, 0); log::trace!( target: "xvm::pallet::xvm_call", diff --git a/pallets/pallet-xvm/src/wasm.rs b/pallets/pallet-xvm/src/wasm.rs index ad08f6cf71..f13d43b8f4 100644 --- a/pallets/pallet-xvm/src/wasm.rs +++ b/pallets/pallet-xvm/src/wasm.rs @@ -67,7 +67,8 @@ where gas_limit.into(), None, input, - false, + pallet_contracts::DebugInfo::Skip, + pallet_contracts::CollectEvents::Skip, pallet_contracts::Determinism::Enforced, ); diff --git a/runtime/local/src/lib.rs b/runtime/local/src/lib.rs index 56cd9777a9..be31dcdf9a 100644 --- a/runtime/local/src/lib.rs +++ b/runtime/local/src/lib.rs @@ -28,7 +28,7 @@ use frame_support::{ construct_runtime, parameter_types, traits::{ AsEnsureOriginWithArg, ConstU128, ConstU32, ConstU64, Currency, EitherOfDiverse, - EqualPrivilegeOnly, FindAuthor, Get, InstanceFilter, Nothing, WithdrawReasons, + EqualPrivilegeOnly, FindAuthor, Get, InstanceFilter, Nothing, OnFinalize, WithdrawReasons, }, weights::{ constants::{RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND}, @@ -172,9 +172,6 @@ pub fn native_version() -> NativeVersion { /// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used /// by Operational extrinsics. const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); -/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers. -/// This is used to limit the maximal weight of a single extrinsic. -const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10); parameter_types! { pub const Version: RuntimeVersion = VERSION; @@ -616,6 +613,7 @@ impl pallet_preimage::Config for Runtime { parameter_types! { pub CouncilMotionDuration: BlockNumber = 3 * MINUTES; + pub MaxProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block; } type CouncilCollective = pallet_collective::Instance1; @@ -629,6 +627,7 @@ impl pallet_collective::Config for Runtime { type DefaultVote = pallet_collective::PrimeDefaultVote; type WeightInfo = pallet_collective::weights::SubstrateWeight; type SetMembersOrigin = EnsureRoot; + type MaxProposalWeight = MaxProposalWeight; } parameter_types! { @@ -646,6 +645,7 @@ impl pallet_collective::Config for Runtime { type DefaultVote = pallet_collective::PrimeDefaultVote; type WeightInfo = pallet_collective::weights::SubstrateWeight; type SetMembersOrigin = EnsureRoot; + type MaxProposalWeight = MaxProposalWeight; } parameter_types! { @@ -778,7 +778,7 @@ parameter_types! { pub const DepositPerItem: Balance = deposit(1, 0); pub const DepositPerByte: Balance = deposit(0, 1); // Fallback value if storage deposit limit not set by the user - pub const DefaultDepositLimit: Balance = contracts_deposit(1024, 1024 * 1024); + pub const DefaultDepositLimit: Balance = deposit(1024, 1024 * 1024); pub Schedule: pallet_contracts::Schedule = Default::default(); } @@ -1509,7 +1509,7 @@ impl_runtime_apis! { fn pending_block( xts: Vec<::Extrinsic>, - ) -> (Option, Option>) { + ) -> (Option, Option>) { for ext in xts.into_iter() { let _ = Executive::apply_extrinsic(ext); } diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index cb122a3cad..4deee5278f 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -29,7 +29,8 @@ use frame_support::{ parameter_types, traits::{ AsEnsureOriginWithArg, ConstU32, Contains, Currency, EitherOfDiverse, EqualPrivilegeOnly, - FindAuthor, Get, Imbalance, InstanceFilter, Nothing, OnUnbalanced, WithdrawReasons, + FindAuthor, Get, Imbalance, InstanceFilter, Nothing, OnFinalize, OnUnbalanced, + WithdrawReasons, }, weights::{ constants::{ @@ -113,7 +114,7 @@ pub const fn deposit(items: u32, bytes: u32) -> Balance { /// key can grow so it doesn't make sense to have as high deposit per item as in the general approach. /// /// TODO: using this requires storage migration (good to test on Shibuya first!) -pub const fn _contracts_deposit(items: u32, bytes: u32) -> Balance { +pub const fn contracts_deposit(items: u32, bytes: u32) -> Balance { items as Balance * 4 * MILLISBY + (bytes as Balance) * STORAGE_BYTE_FEE } @@ -881,6 +882,7 @@ impl pallet_ethereum::Config for Runtime { parameter_types! { pub CouncilMotionDuration: BlockNumber = 36 * HOURS; + pub MaxProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block; } type CouncilCollective = pallet_collective::Instance1; @@ -894,6 +896,7 @@ impl pallet_collective::Config for Runtime { type DefaultVote = pallet_collective::PrimeDefaultVote; type WeightInfo = pallet_collective::weights::SubstrateWeight; type SetMembersOrigin = EnsureRoot; + type MaxProposalWeight = MaxProposalWeight; } parameter_types! { @@ -911,6 +914,7 @@ impl pallet_collective::Config for Runtime { type DefaultVote = pallet_collective::PrimeDefaultVote; type WeightInfo = pallet_collective::weights::SubstrateWeight; type SetMembersOrigin = EnsureRoot; + type MaxProposalWeight = MaxProposalWeight; } parameter_types! { @@ -1771,7 +1775,7 @@ impl_runtime_apis! { fn pending_block( xts: Vec<::Extrinsic>, - ) -> (Option, Option>) { + ) -> (Option, Option>) { for ext in xts.into_iter() { let _ = Executive::apply_extrinsic(ext); } diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index 5e210564b7..6e01a9920d 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -29,7 +29,7 @@ use frame_support::{ parameter_types, traits::{ AsEnsureOriginWithArg, ConstU32, Contains, Currency, FindAuthor, Get, InstanceFilter, - Nothing, OnUnbalanced, WithdrawReasons, + Nothing, OnFinalize, OnUnbalanced, WithdrawReasons, }, weights::{ constants::{ @@ -112,7 +112,7 @@ pub const fn deposit(items: u32, bytes: u32) -> Balance { /// key can grow so it doesn't make sense to have as high deposit per item as in the general approach. /// /// TODO: using this requires some storage migration since we're using some old, legacy values ATM -pub const fn _contracts_deposit(items: u32, bytes: u32) -> Balance { +pub const fn contracts_deposit(items: u32, bytes: u32) -> Balance { items as Balance * 4 * MILLISDN * INIT_SUPPLY_FACTOR + (bytes as Balance) * STORAGE_BYTE_FEE } @@ -1527,7 +1527,7 @@ impl_runtime_apis! { fn pending_block( xts: Vec<::Extrinsic>, - ) -> (Option, Option>) { + ) -> (Option, Option>) { for ext in xts.into_iter() { let _ = Executive::apply_extrinsic(ext); } @@ -1597,6 +1597,16 @@ impl_runtime_apis! { ) } + fn upload_code( + origin: AccountId, + code: Vec, + storage_deposit_limit: Option, + determinism: pallet_contracts::Determinism, + ) -> pallet_contracts_primitives::CodeUploadResult + { + Contracts::bare_upload_code(origin, code, storage_deposit_limit, determinism) + } + fn get_storage( address: AccountId, key: Vec, diff --git a/vendor/rpc/debug/src/lib.rs b/vendor/rpc/debug/src/lib.rs index d917c1ef39..8fc4ef6638 100644 --- a/vendor/rpc/debug/src/lib.rs +++ b/vendor/rpc/debug/src/lib.rs @@ -142,7 +142,7 @@ where pub fn task( client: Arc, backend: Arc, - frontier_backend: Arc>, + frontier_backend: Arc + Send + Sync>, permit_pool: Arc, overrides: Arc>, raw_max_memory_usage: usize, @@ -282,7 +282,7 @@ where fn handle_block_request( client: Arc, backend: Arc, - frontier_backend: Arc>, + frontier_backend: Arc + Send + Sync>, request_block_id: RequestBlockId, params: Option, overrides: Arc>, @@ -301,11 +301,11 @@ where Err(internal_err("'pending' blocks are not supported")) } RequestBlockId::Hash(eth_hash) => { - match frontier_backend_client::load_hash::( + match futures::executor::block_on(frontier_backend_client::load_hash::( client.as_ref(), frontier_backend.as_ref(), eth_hash, - ) { + )) { Ok(Some(hash)) => Ok(BlockId::Hash(hash)), Ok(_) => Err(internal_err("Block hash not found".to_string())), Err(e) => Err(e), @@ -417,7 +417,7 @@ where fn handle_transaction_request( client: Arc, backend: Arc, - frontier_backend: Arc>, + frontier_backend: Arc + Send + Sync>, transaction_hash: H256, params: Option, overrides: Arc>, @@ -425,26 +425,28 @@ where ) -> RpcResult { let (tracer_input, trace_type) = Self::handle_params(params)?; - let (hash, index) = match frontier_backend_client::load_transactions::( - client.as_ref(), - frontier_backend.as_ref(), - transaction_hash, - false, - ) { - Ok(Some((hash, index))) => (hash, index as usize), - Ok(None) => return Err(internal_err("Transaction hash not found".to_string())), - Err(e) => return Err(e), - }; - - let reference_id = match frontier_backend_client::load_hash::( - client.as_ref(), - frontier_backend.as_ref(), - hash, - ) { - Ok(Some(hash)) => BlockId::Hash(hash), - Ok(_) => return Err(internal_err("Block hash not found".to_string())), - Err(e) => return Err(e), - }; + let (hash, index) = + match futures::executor::block_on(frontier_backend_client::load_transactions::( + client.as_ref(), + frontier_backend.as_ref(), + transaction_hash, + false, + )) { + Ok(Some((hash, index))) => (hash, index as usize), + Ok(None) => return Err(internal_err("Transaction hash not found".to_string())), + Err(e) => return Err(e), + }; + + let reference_id = + match futures::executor::block_on(frontier_backend_client::load_hash::( + client.as_ref(), + frontier_backend.as_ref(), + hash, + )) { + Ok(Some(hash)) => BlockId::Hash(hash), + Ok(_) => return Err(internal_err("Block hash not found".to_string())), + Err(e) => return Err(e), + }; // Get ApiRef. This handle allow to keep changes between txs in an internal buffer. let api = client.runtime_api(); // Get Blockchain backend