Skip to content

Commit

Permalink
fix: update runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
nakul1010 committed Aug 8, 2023
1 parent a98799a commit e8608a5
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 40 deletions.
52 changes: 27 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ dex-general-rpc-runtime-api = { path = "../crates/dex-general/rpc/runtime-api" }
dex-stable-rpc-runtime-api = { path = "../crates/dex-stable/rpc/runtime-api" }

# Substrate dependencies
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
sc-offchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
Expand Down
6 changes: 3 additions & 3 deletions parachain/runtime/interlay/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1212,13 +1212,13 @@ construct_runtime! {
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 1,
Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 2,
Utility: pallet_utility::{Pallet, Call, Event} = 3,
TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Config<T>, Event<T>} = 4,
TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event<T>} = 4,
Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 5,
Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 6,
Multisig: pallet_multisig::{Pallet, Call, Storage, Event<T>} = 7,
Identity: pallet_identity::{Pallet, Call, Storage, Event<T>} = 8,
Proxy: pallet_proxy::{Pallet, Call, Storage, Event<T>} = 9,
TxPause: tx_pause::{Pallet, Call, Config<T>, Storage, Event<T>} = 10,
TxPause: tx_pause::{Pallet, Call, Storage, Event<T>} = 10,

// # Tokens & Balances
Currency: currency::{Pallet} = 20,
Expand Down Expand Up @@ -1272,7 +1272,7 @@ construct_runtime! {

// # XCM Helpers
XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 90,
PolkadotXcm: pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin} = 91,
PolkadotXcm: pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin, Config<T>} = 91,
CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 92,
DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 93,

Expand Down
6 changes: 3 additions & 3 deletions parachain/runtime/kintsugi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1211,14 +1211,14 @@ construct_runtime! {
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>} = 0,
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 1,
Utility: pallet_utility::{Pallet, Call, Event} = 2,
TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Config<T>, Event<T>} = 3,
TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event<T>} = 3,
Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 4,
Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 5,
Multisig: pallet_multisig::{Pallet, Call, Storage, Event<T>} = 6,
Identity: pallet_identity::{Pallet, Call, Storage, Event<T>} = 7,
Proxy: pallet_proxy::{Pallet, Call, Storage, Event<T>} = 8,
Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 9,
TxPause: tx_pause::{Pallet, Call, Storage, Config<T>, Event<T>} = 10,
TxPause: tx_pause::{Pallet, Call, Storage, Event<T>} = 10,

// # Tokens & Balances
Currency: currency::{Pallet} = 20,
Expand Down Expand Up @@ -1273,7 +1273,7 @@ construct_runtime! {

// # XCM helpers.
XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 90,
PolkadotXcm: pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin} = 91,
PolkadotXcm: pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin, Config<T>} = 91,
CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 92,
DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 93,

Expand Down
11 changes: 10 additions & 1 deletion parachain/src/chain_spec/interlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,16 @@ pub fn interlay_genesis(
);
interlay_runtime::RuntimeGenesisConfig {
system: interlay_runtime::SystemConfig {
_config: Default::default(),
code: interlay_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
},
parachain_system: Default::default(),
parachain_info: interlay_runtime::ParachainInfoConfig { parachain_id: id },
parachain_info: interlay_runtime::ParachainInfoConfig {
_config: Default::default(),
parachain_id: id,
},
collator_selection: interlay_runtime::CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: Zero::zero(),
Expand Down Expand Up @@ -262,6 +266,7 @@ pub fn interlay_genesis(
replace_griefing_collateral: FixedU128::checked_from_rational(1, 10).unwrap(), // 10%
},
nomination: interlay_runtime::NominationConfig {
_marker: Default::default(),
is_nomination_enabled: false,
},
technical_committee: Default::default(),
Expand All @@ -274,16 +279,19 @@ pub fn interlay_genesis(
inflation: FixedU128::checked_from_rational(2, 100).unwrap(), // 2%
},
polkadot_xcm: interlay_runtime::PolkadotXcmConfig {
_config: Default::default(),
safe_xcm_version: Some(3),
},
sudo: interlay_runtime::SudoConfig { key: root_key },
loans: interlay_runtime::LoansConfig {
_marker: Default::default(),
max_exchange_rate: Rate::from_inner(loans::DEFAULT_MAX_EXCHANGE_RATE),
min_exchange_rate: Rate::from_inner(loans::DEFAULT_MIN_EXCHANGE_RATE),
},
base_fee: Default::default(),
ethereum: Default::default(),
evm: kintsugi_runtime::EVMConfig {
_marker: Default::default(),
// we need _some_ code inserted at the precompile address so that
// the evm will actually call the address.
accounts: interlay_runtime::evm::Precompiles::used_addresses()
Expand All @@ -302,6 +310,7 @@ pub fn interlay_genesis(
.collect(),
},
evm_chain_id: kintsugi_runtime::EVMChainIdConfig {
_marker: Default::default(),
chain_id: chain_id.into(),
},
}
Expand Down
11 changes: 10 additions & 1 deletion parachain/src/chain_spec/kintsugi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,16 @@ pub fn kintsugi_genesis(
);
kintsugi_runtime::RuntimeGenesisConfig {
system: kintsugi_runtime::SystemConfig {
_config: Default::default(),
code: kintsugi_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
},
parachain_system: Default::default(),
parachain_info: kintsugi_runtime::ParachainInfoConfig { parachain_id: id },
parachain_info: kintsugi_runtime::ParachainInfoConfig {
_config: Default::default(),
parachain_id: id,
},
collator_selection: kintsugi_runtime::CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: Zero::zero(),
Expand Down Expand Up @@ -290,6 +294,7 @@ pub fn kintsugi_genesis(
replace_griefing_collateral: FixedU128::checked_from_rational(1, 10).unwrap(), // 10%
},
nomination: kintsugi_runtime::NominationConfig {
_marker: Default::default(),
is_nomination_enabled: false,
},
technical_committee: Default::default(),
Expand All @@ -302,16 +307,19 @@ pub fn kintsugi_genesis(
inflation: FixedU128::checked_from_rational(2, 100).unwrap(), // 2%
},
polkadot_xcm: kintsugi_runtime::PolkadotXcmConfig {
_config: Default::default(),
safe_xcm_version: Some(3),
},
sudo: kintsugi_runtime::SudoConfig { key: root_key },
loans: kintsugi_runtime::LoansConfig {
_marker: Default::default(),
max_exchange_rate: Rate::from_inner(loans::DEFAULT_MAX_EXCHANGE_RATE),
min_exchange_rate: Rate::from_inner(loans::DEFAULT_MIN_EXCHANGE_RATE),
},
base_fee: Default::default(),
ethereum: Default::default(),
evm: kintsugi_runtime::EVMConfig {
_marker: Default::default(),
// we need _some_ code inserted at the precompile address so that
// the evm will actually call the address.
accounts: kintsugi_runtime::evm::Precompiles::used_addresses()
Expand All @@ -330,6 +338,7 @@ pub fn kintsugi_genesis(
.collect(),
},
evm_chain_id: kintsugi_runtime::EVMChainIdConfig {
_marker: Default::default(),
chain_id: chain_id.into(),
},
}
Expand Down
44 changes: 37 additions & 7 deletions parachain/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ use cumulus_relay_chain_minimal_node::build_minimal_relay_chain_node;
use futures::StreamExt;
use polkadot_service::CollatorPair;
use primitives::*;
use sc_client_api::{HeaderBackend, StateBackendFor};
use sc_client_api::{Backend, HeaderBackend, StateBackendFor};
use sc_consensus::{ImportQueue, LongestChain};
use sc_executor::{HeapAllocStrategy, NativeElseWasmExecutor, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY};
use sc_network::NetworkBlock;
use sc_network_sync::SyncingService;
use sc_service::{Configuration, PartialComponents, RpcHandlers, TFullBackend, TFullClient, TaskManager};
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_api::ConstructRuntimeApi;
use sp_consensus_aura::{
sr25519::{AuthorityId as AuraId, AuthorityPair as AuraPair},
Expand Down Expand Up @@ -488,11 +489,23 @@ where
};

if parachain_config.offchain_worker.enabled {
sc_service::build_offchain_workers(
&parachain_config,
task_manager.spawn_handle(),
client.clone(),
network.clone(),
use futures::FutureExt;

task_manager.spawn_handle().spawn(
"offchain-workers-runner",
"offchain-work",
sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions {
runtime_api_provider: client.clone(),
keystore: Some(params.keystore_container.keystore()),
offchain_db: backend.offchain_storage(),
transaction_pool: Some(OffchainTransactionPoolFactory::new(transaction_pool.clone())),
network_provider: network.clone(),
is_validator: parachain_config.role.is_authority(),
enable_http_requests: false,
custom_extensions: move |_| vec![],
})
.run(client.clone(), task_manager.spawn_handle())
.boxed(),
);
};

Expand Down Expand Up @@ -723,7 +736,24 @@ where
})?;

if config.offchain_worker.enabled {
sc_service::build_offchain_workers(&config, task_manager.spawn_handle(), client.clone(), network.clone());
use futures::FutureExt;

task_manager.spawn_handle().spawn(
"offchain-workers-runner",
"offchain-work",
sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions {
runtime_api_provider: client.clone(),
keystore: None,
offchain_db: backend.offchain_storage(),
transaction_pool: Some(OffchainTransactionPoolFactory::new(transaction_pool.clone())),
network_provider: network.clone(),
is_validator: config.role.is_authority(),
enable_http_requests: false,
custom_extensions: move |_| vec![],
})
.run(client.clone(), task_manager.spawn_handle())
.boxed(),
);
};

let prometheus_registry = config.prometheus_registry().cloned();
Expand Down

0 comments on commit e8608a5

Please sign in to comment.