Skip to content

Commit

Permalink
bump refs and fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
acatangiu committed Mar 23, 2023
1 parent 6540f74 commit 7f9a3dc
Show file tree
Hide file tree
Showing 12 changed files with 1,327 additions and 923 deletions.
2,068 changes: 1,227 additions & 841 deletions Cargo.lock

Large diffs are not rendered by default.

31 changes: 4 additions & 27 deletions bin/millau/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use sc_client_api::BlockBackend;
use sc_consensus_aura::{CompatibilityMode, ImportQueueParams, SlotProportion, StartAuraParams};
use sc_consensus_grandpa::SharedVoterState;
pub use sc_executor::NativeElseWasmExecutor;
use sc_keystore::LocalKeystore;
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
use sc_telemetry::{Telemetry, TelemetryWorker};
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
Expand Down Expand Up @@ -78,10 +77,6 @@ pub fn new_partial(
>,
ServiceError,
> {
if config.keystore_remote.is_some() {
return Err(ServiceError::Other("Remote Keystores are not supported.".into()))
}

let telemetry = config
.telemetry_endpoints
.clone()
Expand Down Expand Up @@ -175,13 +170,6 @@ pub fn new_partial(
})
}

fn remote_keystore(_url: &str) -> Result<Arc<LocalKeystore>, &'static str> {
// FIXME: here would the concrete keystore be built,
// must return a concrete type (NOT `LocalKeystore`) that
// implements `CryptoStore` and `SyncCryptoStore`
Err("Remote Keystore not supported.")
}

/// Builds a new service for a full client.
pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError> {
use sc_network_common::sync::warp::WarpSyncParams;
Expand All @@ -191,22 +179,12 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
backend,
mut task_manager,
import_queue,
mut keystore_container,
keystore_container,
select_chain,
transaction_pool,
other: (block_import, grandpa_link, beefy_voter_links, beefy_rpc_links, mut telemetry),
} = new_partial(&config)?;

if let Some(url) = &config.keystore_remote {
match remote_keystore(url) {
Ok(k) => keystore_container.set_remote_keystore(k),
Err(e) =>
return Err(ServiceError::Other(format!(
"Error hooking up remote keystore for {url}: {e}"
))),
};
}

let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed");

// Note: GrandPa is pushed before the Polkadot-specific protocols. This doesn't change
Expand Down Expand Up @@ -332,7 +310,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
let _rpc_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams {
network: network.clone(),
client: client.clone(),
keystore: keystore_container.sync_keystore(),
keystore: keystore_container.keystore(),
task_manager: &mut task_manager,
transaction_pool: transaction_pool.clone(),
sync_service: sync_service.clone(),
Expand Down Expand Up @@ -375,7 +353,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
},
force_authoring,
backoff_authoring_blocks,
keystore: keystore_container.sync_keystore(),
keystore: keystore_container.keystore(),
sync_oracle: sync_service.clone(),
justification_sync_link: sync_service.clone(),
block_proposal_slot_portion: SlotProportion::new(2f32 / 3f32),
Expand All @@ -394,8 +372,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>

// if the node isn't actively participating in consensus then it doesn't
// need a keystore, regardless of which protocol we use below.
let keystore =
if role.is_authority() { Some(keystore_container.sync_keystore()) } else { None };
let keystore = if role.is_authority() { Some(keystore_container.keystore()) } else { None };

let justifications_protocol_name = beefy_on_demand_justifications_handler.protocol_name();
let payload_provider = sp_consensus_beefy::mmr::MmrRootProvider::new(client.clone());
Expand Down
12 changes: 12 additions & 0 deletions bin/millau/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ impl pallet_balances::Config for Runtime {
type MaxLocks = ConstU32<50>;
type MaxReserves = ConstU32<50>;
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
}

parameter_types! {
Expand Down Expand Up @@ -655,6 +659,14 @@ impl_runtime_apis! {
fn metadata() -> OpaqueMetadata {
OpaqueMetadata::new(Runtime::metadata().into())
}

fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
Runtime::metadata_at_version(version)
}

fn metadata_versions() -> sp_std::vec::Vec<u32> {
Runtime::metadata_versions()
}
}

impl sp_block_builder::BlockBuilder<Block> for Runtime {
Expand Down
2 changes: 2 additions & 0 deletions bin/millau/runtime/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use frame_support::{
traits::{ConstU32, Everything, Nothing},
weights::Weight,
};
use frame_system::EnsureRoot;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, CurrencyAdapter as XcmCurrencyAdapter, IsConcrete, MintLocation,
Expand Down Expand Up @@ -186,6 +187,7 @@ impl pallet_xcm::Config for Runtime {
type WeightInfo = pallet_xcm::TestWeightInfo;
#[cfg(feature = "runtime-benchmarks")]
type ReachableDest = ReachableDest;
type AdminOrigin = EnsureRoot<AccountId>;
}

pub struct ToRialtoOrRialtoParachainSwitchExporter;
Expand Down
8 changes: 4 additions & 4 deletions bin/rialto/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.

use frame_support::weights::Weight;
use polkadot_primitives::v2::{AssignmentId, ValidatorId};
use polkadot_primitives::v4::{AssignmentId, ValidatorId};
use rialto_runtime::{
AccountId, BabeConfig, BalancesConfig, BeefyConfig, BridgeMillauMessagesConfig,
ConfigurationConfig, GenesisConfig, GrandpaConfig, SessionConfig, SessionKeys, Signature,
Expand Down Expand Up @@ -244,8 +244,8 @@ fn testnet_genesis(
validation_upgrade_cooldown: 2u32,
validation_upgrade_delay: 2,
code_retention_period: 1200,
max_code_size: polkadot_primitives::v2::MAX_CODE_SIZE,
max_pov_size: polkadot_primitives::v2::MAX_POV_SIZE,
max_code_size: polkadot_primitives::v4::MAX_CODE_SIZE,
max_pov_size: polkadot_primitives::v4::MAX_POV_SIZE,
max_head_data_size: 32 * 1024,
group_rotation_frequency: 20,
chain_availability_period: 4,
Expand All @@ -255,7 +255,7 @@ fn testnet_genesis(
max_downward_message_size: 1024 * 1024,
ump_service_total_weight: Weight::from_parts(
100_000_000_000,
polkadot_primitives::v2::MAX_POV_SIZE as u64,
polkadot_primitives::v4::MAX_POV_SIZE as u64,
),
max_upward_message_size: 50 * 1024,
max_upward_message_num_per_candidate: 5,
Expand Down
106 changes: 63 additions & 43 deletions bin/rialto/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ impl pallet_balances::Config for Runtime {
type MaxLocks = ConstU32<50>;
type MaxReserves = ConstU32<50>;
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
}

parameter_types! {
Expand Down Expand Up @@ -579,6 +583,14 @@ impl_runtime_apis! {
fn metadata() -> OpaqueMetadata {
OpaqueMetadata::new(Runtime::metadata().into())
}

fn metadata_at_version(version: u32) -> Option<OpaqueMetadata> {
Runtime::metadata_at_version(version)
}

fn metadata_versions() -> sp_std::vec::Vec<u32> {
Runtime::metadata_versions()
}
}

impl sp_block_builder::BlockBuilder<Block> for Runtime {
Expand Down Expand Up @@ -754,55 +766,55 @@ impl_runtime_apis! {
}

impl polkadot_primitives::runtime_api::ParachainHost<Block, Hash, BlockNumber> for Runtime {
fn validators() -> Vec<polkadot_primitives::v2::ValidatorId> {
polkadot_runtime_parachains::runtime_api_impl::v2::validators::<Runtime>()
fn validators() -> Vec<polkadot_primitives::v4::ValidatorId> {
polkadot_runtime_parachains::runtime_api_impl::v4::validators::<Runtime>()
}

fn validator_groups() -> (Vec<Vec<polkadot_primitives::v2::ValidatorIndex>>, polkadot_primitives::v2::GroupRotationInfo<BlockNumber>) {
polkadot_runtime_parachains::runtime_api_impl::v2::validator_groups::<Runtime>()
fn validator_groups() -> (Vec<Vec<polkadot_primitives::v4::ValidatorIndex>>, polkadot_primitives::v4::GroupRotationInfo<BlockNumber>) {
polkadot_runtime_parachains::runtime_api_impl::v4::validator_groups::<Runtime>()
}

fn availability_cores() -> Vec<polkadot_primitives::v2::CoreState<Hash, BlockNumber>> {
polkadot_runtime_parachains::runtime_api_impl::v2::availability_cores::<Runtime>()
fn availability_cores() -> Vec<polkadot_primitives::v4::CoreState<Hash, BlockNumber>> {
polkadot_runtime_parachains::runtime_api_impl::v4::availability_cores::<Runtime>()
}

fn persisted_validation_data(para_id: polkadot_primitives::v2::Id, assumption: polkadot_primitives::v2::OccupiedCoreAssumption)
-> Option<polkadot_primitives::v2::PersistedValidationData<Hash, BlockNumber>> {
polkadot_runtime_parachains::runtime_api_impl::v2::persisted_validation_data::<Runtime>(para_id, assumption)
fn persisted_validation_data(para_id: polkadot_primitives::v4::Id, assumption: polkadot_primitives::v4::OccupiedCoreAssumption)
-> Option<polkadot_primitives::v4::PersistedValidationData<Hash, BlockNumber>> {
polkadot_runtime_parachains::runtime_api_impl::v4::persisted_validation_data::<Runtime>(para_id, assumption)
}

fn assumed_validation_data(
para_id: polkadot_primitives::v2::Id,
para_id: polkadot_primitives::v4::Id,
expected_persisted_validation_data_hash: Hash,
) -> Option<(polkadot_primitives::v2::PersistedValidationData<Hash, BlockNumber>, polkadot_primitives::v2::ValidationCodeHash)> {
polkadot_runtime_parachains::runtime_api_impl::v2::assumed_validation_data::<Runtime>(
) -> Option<(polkadot_primitives::v4::PersistedValidationData<Hash, BlockNumber>, polkadot_primitives::v4::ValidationCodeHash)> {
polkadot_runtime_parachains::runtime_api_impl::v4::assumed_validation_data::<Runtime>(
para_id,
expected_persisted_validation_data_hash,
)
}

fn check_validation_outputs(
para_id: polkadot_primitives::v2::Id,
outputs: polkadot_primitives::v2::CandidateCommitments,
para_id: polkadot_primitives::v4::Id,
outputs: polkadot_primitives::v4::CandidateCommitments,
) -> bool {
polkadot_runtime_parachains::runtime_api_impl::v2::check_validation_outputs::<Runtime>(para_id, outputs)
polkadot_runtime_parachains::runtime_api_impl::v4::check_validation_outputs::<Runtime>(para_id, outputs)
}

fn session_index_for_child() -> polkadot_primitives::v2::SessionIndex {
polkadot_runtime_parachains::runtime_api_impl::v2::session_index_for_child::<Runtime>()
fn session_index_for_child() -> polkadot_primitives::v4::SessionIndex {
polkadot_runtime_parachains::runtime_api_impl::v4::session_index_for_child::<Runtime>()
}

fn validation_code(para_id: polkadot_primitives::v2::Id, assumption: polkadot_primitives::v2::OccupiedCoreAssumption)
-> Option<polkadot_primitives::v2::ValidationCode> {
polkadot_runtime_parachains::runtime_api_impl::v2::validation_code::<Runtime>(para_id, assumption)
fn validation_code(para_id: polkadot_primitives::v4::Id, assumption: polkadot_primitives::v4::OccupiedCoreAssumption)
-> Option<polkadot_primitives::v4::ValidationCode> {
polkadot_runtime_parachains::runtime_api_impl::v4::validation_code::<Runtime>(para_id, assumption)
}

fn candidate_pending_availability(para_id: polkadot_primitives::v2::Id) -> Option<polkadot_primitives::v2::CommittedCandidateReceipt<Hash>> {
polkadot_runtime_parachains::runtime_api_impl::v2::candidate_pending_availability::<Runtime>(para_id)
fn candidate_pending_availability(para_id: polkadot_primitives::v4::Id) -> Option<polkadot_primitives::v4::CommittedCandidateReceipt<Hash>> {
polkadot_runtime_parachains::runtime_api_impl::v4::candidate_pending_availability::<Runtime>(para_id)
}

fn candidate_events() -> Vec<polkadot_primitives::v2::CandidateEvent<Hash>> {
polkadot_runtime_parachains::runtime_api_impl::v2::candidate_events::<Runtime, _>(|ev| {
fn candidate_events() -> Vec<polkadot_primitives::v4::CandidateEvent<Hash>> {
polkadot_runtime_parachains::runtime_api_impl::v4::candidate_events::<Runtime, _>(|ev| {
match ev {
RuntimeEvent::Inclusion(ev) => {
Some(ev)
Expand All @@ -812,46 +824,54 @@ impl_runtime_apis! {
})
}

fn session_info(index: polkadot_primitives::v2::SessionIndex) -> Option<polkadot_primitives::v2::SessionInfo> {
polkadot_runtime_parachains::runtime_api_impl::v2::session_info::<Runtime>(index)
fn session_info(index: polkadot_primitives::v4::SessionIndex) -> Option<polkadot_primitives::v4::SessionInfo> {
polkadot_runtime_parachains::runtime_api_impl::v4::session_info::<Runtime>(index)
}

fn dmq_contents(recipient: polkadot_primitives::v2::Id) -> Vec<polkadot_primitives::v2::InboundDownwardMessage<BlockNumber>> {
polkadot_runtime_parachains::runtime_api_impl::v2::dmq_contents::<Runtime>(recipient)
fn dmq_contents(recipient: polkadot_primitives::v4::Id) -> Vec<polkadot_primitives::v4::InboundDownwardMessage<BlockNumber>> {
polkadot_runtime_parachains::runtime_api_impl::v4::dmq_contents::<Runtime>(recipient)
}

fn inbound_hrmp_channels_contents(
recipient: polkadot_primitives::v2::Id
) -> BTreeMap<polkadot_primitives::v2::Id, Vec<polkadot_primitives::v2::InboundHrmpMessage<BlockNumber>>> {
polkadot_runtime_parachains::runtime_api_impl::v2::inbound_hrmp_channels_contents::<Runtime>(recipient)
recipient: polkadot_primitives::v4::Id
) -> BTreeMap<polkadot_primitives::v4::Id, Vec<polkadot_primitives::v4::InboundHrmpMessage<BlockNumber>>> {
polkadot_runtime_parachains::runtime_api_impl::v4::inbound_hrmp_channels_contents::<Runtime>(recipient)
}

fn validation_code_by_hash(hash: polkadot_primitives::v2::ValidationCodeHash) -> Option<polkadot_primitives::v2::ValidationCode> {
polkadot_runtime_parachains::runtime_api_impl::v2::validation_code_by_hash::<Runtime>(hash)
fn validation_code_by_hash(hash: polkadot_primitives::v4::ValidationCodeHash) -> Option<polkadot_primitives::v4::ValidationCode> {
polkadot_runtime_parachains::runtime_api_impl::v4::validation_code_by_hash::<Runtime>(hash)
}

fn on_chain_votes() -> Option<polkadot_primitives::v2::ScrapedOnChainVotes<Hash>> {
polkadot_runtime_parachains::runtime_api_impl::v2::on_chain_votes::<Runtime>()
fn on_chain_votes() -> Option<polkadot_primitives::v4::ScrapedOnChainVotes<Hash>> {
polkadot_runtime_parachains::runtime_api_impl::v4::on_chain_votes::<Runtime>()
}

fn submit_pvf_check_statement(stmt: polkadot_primitives::v2::PvfCheckStatement, signature: polkadot_primitives::v2::ValidatorSignature) {
polkadot_runtime_parachains::runtime_api_impl::v2::submit_pvf_check_statement::<Runtime>(stmt, signature)
fn submit_pvf_check_statement(stmt: polkadot_primitives::v4::PvfCheckStatement, signature: polkadot_primitives::v4::ValidatorSignature) {
polkadot_runtime_parachains::runtime_api_impl::v4::submit_pvf_check_statement::<Runtime>(stmt, signature)
}

fn pvfs_require_precheck() -> Vec<polkadot_primitives::v2::ValidationCodeHash> {
polkadot_runtime_parachains::runtime_api_impl::v2::pvfs_require_precheck::<Runtime>()
fn pvfs_require_precheck() -> Vec<polkadot_primitives::v4::ValidationCodeHash> {
polkadot_runtime_parachains::runtime_api_impl::v4::pvfs_require_precheck::<Runtime>()
}

fn validation_code_hash(para_id: polkadot_primitives::v2::Id, assumption: polkadot_primitives::v2::OccupiedCoreAssumption)
-> Option<polkadot_primitives::v2::ValidationCodeHash>
fn validation_code_hash(para_id: polkadot_primitives::v4::Id, assumption: polkadot_primitives::v4::OccupiedCoreAssumption)
-> Option<polkadot_primitives::v4::ValidationCodeHash>
{
polkadot_runtime_parachains::runtime_api_impl::v2::validation_code_hash::<Runtime>(para_id, assumption)
polkadot_runtime_parachains::runtime_api_impl::v4::validation_code_hash::<Runtime>(para_id, assumption)
}

fn disputes() -> Vec<(polkadot_primitives::v4::SessionIndex, polkadot_primitives::v4::CandidateHash, polkadot_primitives::v4::DisputeState<BlockNumber>)> {
polkadot_runtime_parachains::runtime_api_impl::v4::get_session_disputes::<Runtime>()
}

fn session_executor_params(session_index: polkadot_primitives::v4::SessionIndex) -> Option<polkadot_primitives::v4::ExecutorParams> {
polkadot_runtime_parachains::runtime_api_impl::v4::session_executor_params::<Runtime>(session_index)
}
}

impl sp_authority_discovery::AuthorityDiscoveryApi<Block> for Runtime {
fn authorities() -> Vec<AuthorityDiscoveryId> {
polkadot_runtime_parachains::runtime_api_impl::v2::relevant_authority_ids::<Runtime>()
polkadot_runtime_parachains::runtime_api_impl::v4::relevant_authority_ids::<Runtime>()
}
}

Expand Down
2 changes: 1 addition & 1 deletion bin/rialto/runtime/src/parachains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::{

use frame_support::{parameter_types, traits::KeyOwnerProofSystem};
use frame_system::EnsureRoot;
use polkadot_primitives::v2::{ValidatorId, ValidatorIndex};
use polkadot_primitives::v4::{ValidatorId, ValidatorIndex};
use polkadot_runtime_common::{paras_registrar, paras_sudo_wrapper, slots};
use polkadot_runtime_parachains::{
configuration as parachains_configuration, disputes as parachains_disputes,
Expand Down
2 changes: 2 additions & 0 deletions bin/rialto/runtime/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use frame_support::{
traits::{ConstU32, Everything, Nothing},
weights::Weight,
};
use frame_system::EnsureRoot;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, CurrencyAdapter as XcmCurrencyAdapter, IsConcrete, MintLocation,
Expand Down Expand Up @@ -182,6 +183,7 @@ impl pallet_xcm::Config for Runtime {
type WeightInfo = pallet_xcm::TestWeightInfo;
#[cfg(feature = "runtime-benchmarks")]
type ReachableDest = ReachableDest;
type AdminOrigin = EnsureRoot<AccountId>;
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion bin/runtime-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"

[dependencies]
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] }
hash-db = { version = "0.15.2", default-features = false }
hash-db = { version = "0.16.0", default-features = false }
log = { version = "0.4.17", default-features = false }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
static_assertions = { version = "1.1", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion primitives/chain-bridge-hub-cumulus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
/// This is a copy-paste from the cumulus repo's `parachains-common` crate.
const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(constants::WEIGHT_REF_TIME_PER_SECOND, 0)
.saturating_div(2)
.set_proof_size(polkadot_primitives::v2::MAX_POV_SIZE as u64);
.set_proof_size(polkadot_primitives::v4::MAX_POV_SIZE as u64);

/// All cumulus bridge hubs assume that about 5 percent of the block weight is consumed by
/// `on_initialize` handlers. This is used to limit the maximal weight of a single extrinsic.
Expand Down
Loading

0 comments on commit 7f9a3dc

Please sign in to comment.