Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kianenigma committed Sep 15, 2021
1 parent 560e965 commit b36dd83
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 76 deletions.
68 changes: 36 additions & 32 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ impl SubstrateCli for Cli {
#[cfg(feature = "kusama-native")]
"kusama-staging" => Box::new(service::chain_spec::kusama_staging_testnet_config()?),
#[cfg(not(feature = "kusama-native"))]
name if name.starts_with("kusama-") && !name.ends_with(".json") =>
Err(format!("`{}` only supported with `kusama-native` feature enabled.", name))?,
name if name.starts_with("kusama-") && !name.ends_with(".json") => {
Err(format!("`{}` only supported with `kusama-native` feature enabled.", name))?
}
"polkadot" => Box::new(service::chain_spec::polkadot_config()?),
#[cfg(feature = "polkadot-native")]
"polkadot-dev" | "dev" => Box::new(service::chain_spec::polkadot_development_config()?),
Expand All @@ -116,8 +117,9 @@ impl SubstrateCli for Cli {
#[cfg(feature = "rococo-native")]
"rococo-staging" => Box::new(service::chain_spec::rococo_staging_testnet_config()?),
#[cfg(not(feature = "rococo-native"))]
name if name.starts_with("rococo-") && !name.ends_with(".json") =>
Err(format!("`{}` only supported with `rococo-native` feature enabled.", name))?,
name if name.starts_with("rococo-") && !name.ends_with(".json") => {
Err(format!("`{}` only supported with `rococo-native` feature enabled.", name))?
}
"westend" => Box::new(service::chain_spec::westend_config()?),
#[cfg(feature = "westend-native")]
"westend-dev" => Box::new(service::chain_spec::westend_development_config()?),
Expand All @@ -126,16 +128,18 @@ impl SubstrateCli for Cli {
#[cfg(feature = "westend-native")]
"westend-staging" => Box::new(service::chain_spec::westend_staging_testnet_config()?),
#[cfg(not(feature = "westend-native"))]
name if name.starts_with("westend-") && !name.ends_with(".json") =>
Err(format!("`{}` only supported with `westend-native` feature enabled.", name))?,
name if name.starts_with("westend-") && !name.ends_with(".json") => {
Err(format!("`{}` only supported with `westend-native` feature enabled.", name))?
}
"wococo" => Box::new(service::chain_spec::wococo_config()?),
#[cfg(feature = "rococo-native")]
"wococo-dev" => Box::new(service::chain_spec::wococo_development_config()?),
#[cfg(feature = "rococo-native")]
"wococo-local" => Box::new(service::chain_spec::wococo_local_testnet_config()?),
#[cfg(not(feature = "rococo-native"))]
name if name.starts_with("wococo-") =>
Err(format!("`{}` only supported with `rococo-native` feature enabled.", name))?,
name if name.starts_with("wococo-") => {
Err(format!("`{}` only supported with `rococo-native` feature enabled.", name))?
}
path => {
let path = std::path::PathBuf::from(path);

Expand All @@ -153,24 +157,24 @@ impl SubstrateCli for Cli {
} else {
chain_spec
}
},
}
})
}

fn native_runtime_version(spec: &Box<dyn service::ChainSpec>) -> &'static RuntimeVersion {
#[cfg(feature = "kusama-native")]
if spec.is_kusama() {
return &service::kusama_runtime::VERSION
return &service::kusama_runtime::VERSION;
}

#[cfg(feature = "westend-native")]
if spec.is_westend() {
return &service::westend_runtime::VERSION
return &service::westend_runtime::VERSION;
}

#[cfg(feature = "rococo-native")]
if spec.is_rococo() || spec.is_wococo() {
return &service::rococo_runtime::VERSION
return &service::rococo_runtime::VERSION;
}

#[cfg(not(all(
Expand All @@ -182,7 +186,7 @@ impl SubstrateCli for Cli {

#[cfg(feature = "polkadot-native")]
{
return &service::polkadot_runtime::VERSION
return &service::polkadot_runtime::VERSION;
}

#[cfg(not(feature = "polkadot-native"))]
Expand Down Expand Up @@ -274,7 +278,7 @@ pub fn run() -> Result<()> {
Some(Subcommand::BuildSpec(cmd)) => {
let runner = cli.create_runner(cmd)?;
Ok(runner.sync_run(|config| cmd.run(config.chain_spec, config.network))?)
},
}
Some(Subcommand::CheckBlock(cmd)) => {
let runner = cli.create_runner(cmd).map_err(Error::SubstrateCli)?;
let chain_spec = &runner.config().chain_spec;
Expand All @@ -286,7 +290,7 @@ pub fn run() -> Result<()> {
service::new_chain_ops(&mut config, None)?;
Ok((cmd.run(client, import_queue).map_err(Error::SubstrateCli), task_manager))
})
},
}
Some(Subcommand::ExportBlocks(cmd)) => {
let runner = cli.create_runner(cmd)?;
let chain_spec = &runner.config().chain_spec;
Expand All @@ -298,7 +302,7 @@ pub fn run() -> Result<()> {
service::new_chain_ops(&mut config, None).map_err(Error::PolkadotService)?;
Ok((cmd.run(client, config.database).map_err(Error::SubstrateCli), task_manager))
})?)
},
}
Some(Subcommand::ExportState(cmd)) => {
let runner = cli.create_runner(cmd)?;
let chain_spec = &runner.config().chain_spec;
Expand All @@ -309,7 +313,7 @@ pub fn run() -> Result<()> {
let (client, _, _, task_manager) = service::new_chain_ops(&mut config, None)?;
Ok((cmd.run(client, config.chain_spec).map_err(Error::SubstrateCli), task_manager))
})?)
},
}
Some(Subcommand::ImportBlocks(cmd)) => {
let runner = cli.create_runner(cmd)?;
let chain_spec = &runner.config().chain_spec;
Expand All @@ -321,11 +325,11 @@ pub fn run() -> Result<()> {
service::new_chain_ops(&mut config, None)?;
Ok((cmd.run(client, import_queue).map_err(Error::SubstrateCli), task_manager))
})?)
},
}
Some(Subcommand::PurgeChain(cmd)) => {
let runner = cli.create_runner(cmd)?;
Ok(runner.sync_run(|config| cmd.run(config.database))?)
},
}
Some(Subcommand::Revert(cmd)) => {
let runner = cli.create_runner(cmd)?;
let chain_spec = &runner.config().chain_spec;
Expand All @@ -336,7 +340,7 @@ pub fn run() -> Result<()> {
let (client, backend, _, task_manager) = service::new_chain_ops(&mut config, None)?;
Ok((cmd.run(client, backend).map_err(Error::SubstrateCli), task_manager))
})?)
},
}
Some(Subcommand::PvfPrepareWorker(cmd)) => {
let mut builder = sc_cli::LoggerBuilder::new("");
builder.with_colors(false);
Expand All @@ -347,15 +351,15 @@ pub fn run() -> Result<()> {
return Err(sc_cli::Error::Input(
"PVF preparation workers are not supported under this platform".into(),
)
.into())
.into());
}

#[cfg(not(target_os = "android"))]
{
polkadot_node_core_pvf::prepare_worker_entrypoint(&cmd.socket_path);
Ok(())
}
},
}
Some(Subcommand::PvfExecuteWorker(cmd)) => {
let mut builder = sc_cli::LoggerBuilder::new("");
builder.with_colors(false);
Expand All @@ -366,15 +370,15 @@ pub fn run() -> Result<()> {
return Err(sc_cli::Error::Input(
"PVF execution workers are not supported under this platform".into(),
)
.into())
.into());
}

#[cfg(not(target_os = "android"))]
{
polkadot_node_core_pvf::execute_worker_entrypoint(&cmd.socket_path);
Ok(())
}
},
}
Some(Subcommand::Benchmark(cmd)) => {
let runner = cli.create_runner(cmd)?;
let chain_spec = &runner.config().chain_spec;
Expand All @@ -389,7 +393,7 @@ pub fn run() -> Result<()> {
config,
)
.map_err(|e| Error::SubstrateCli(e))
})?)
})?);
}

#[cfg(feature = "westend-native")]
Expand All @@ -399,7 +403,7 @@ pub fn run() -> Result<()> {
config,
)
.map_err(|e| Error::SubstrateCli(e))
})?)
})?);
}

// else we assume it is polkadot.
Expand All @@ -410,11 +414,11 @@ pub fn run() -> Result<()> {
config,
)
.map_err(|e| Error::SubstrateCli(e))
})?)
})?);
}
#[cfg(not(feature = "polkadot-native"))]
panic!("No runtime feature (polkadot, kusama, westend, rococo) is enabled")
},
}
Some(Subcommand::Key(cmd)) => Ok(cmd.run(&cli)?),
#[cfg(feature = "try-runtime")]
Some(Subcommand::TryRuntime(cmd)) => {
Expand All @@ -439,7 +443,7 @@ pub fn run() -> Result<()> {
.map_err(Error::SubstrateCli),
task_manager,
))
})
});
}

#[cfg(feature = "westend-native")]
Expand All @@ -452,7 +456,7 @@ pub fn run() -> Result<()> {
.map_err(Error::SubstrateCli),
task_manager,
))
})
});
}
// else we assume it is polkadot.
#[cfg(feature = "polkadot-native")]
Expand All @@ -465,11 +469,11 @@ pub fn run() -> Result<()> {
.map_err(Error::SubstrateCli),
task_manager,
))
})
});
}
#[cfg(not(feature = "polkadot-native"))]
panic!("No runtime feature (polkadot, kusama, westend, rococo) is enabled")
},
}
#[cfg(not(feature = "try-runtime"))]
Some(Subcommand::TryRuntime) => Err(Error::Other(
"TryRuntime wasn't enabled when building the node. \
Expand Down
17 changes: 10 additions & 7 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1043,22 +1043,22 @@ impl InstanceFilter<Call> for ProxyType {
),
ProxyType::Governance => matches!(
c,
Call::Democracy(..) |
Call::Council(..) | Call::TechnicalCommittee(..) |
Call::PhragmenElection(..) |
Call::Treasury(..) | Call::Bounties(..) |
Call::Tips(..) | Call::Utility(..)
Call::Democracy(..)
| Call::Council(..) | Call::TechnicalCommittee(..)
| Call::PhragmenElection(..)
| Call::Treasury(..) | Call::Bounties(..)
| Call::Tips(..) | Call::Utility(..)
),
ProxyType::Staking => {
matches!(c, Call::Staking(..) | Call::Session(..) | Call::Utility(..))
},
}
ProxyType::IdentityJudgement => matches!(
c,
Call::Identity(pallet_identity::Call::provide_judgement(..)) | Call::Utility(..)
),
ProxyType::CancelProxy => {
matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement(..)))
},
}
ProxyType::Auction => matches!(
c,
Call::Auctions(..) | Call::Crowdloan(..) | Call::Registrar(..) | Call::Slots(..)
Expand Down Expand Up @@ -1918,6 +1918,9 @@ sp_api::impl_runtime_apis! {
let weight = Executive::try_runtime_upgrade()?;
Ok((weight, BlockWeights::get().max_block))
}
fn execute_block_no_state_root_check(block: Block) -> Weight {
Executive::execute_block_no_state_root_check(block)
}
}

#[cfg(feature = "runtime-benchmarks")]
Expand Down
72 changes: 38 additions & 34 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("polkadot"),
impl_name: create_runtime_str!("parity-polkadot"),
authoring_version: 0,
spec_version: 9100,
spec_version: 9090,
impl_version: 0,
#[cfg(not(feature = "disable-runtime-api"))]
apis: RUNTIME_API_VERSIONS,
Expand All @@ -123,32 +123,32 @@ impl Contains<Call> for BaseFilter {
fn contains(call: &Call) -> bool {
match call {
// These modules are all allowed to be called by transactions:
Call::Democracy(_) |
Call::Council(_) |
Call::TechnicalCommittee(_) |
Call::TechnicalMembership(_) |
Call::Treasury(_) |
Call::PhragmenElection(_) |
Call::System(_) |
Call::Scheduler(_) |
Call::Indices(_) |
Call::Babe(_) |
Call::Timestamp(_) |
Call::Balances(_) |
Call::Authorship(_) |
Call::Staking(_) |
Call::Session(_) |
Call::Grandpa(_) |
Call::ImOnline(_) |
Call::Utility(_) |
Call::Claims(_) |
Call::Vesting(_) |
Call::Identity(_) |
Call::Proxy(_) |
Call::Multisig(_) |
Call::Bounties(_) |
Call::Tips(_) |
Call::ElectionProviderMultiPhase(_) => true,
Call::Democracy(_)
| Call::Council(_)
| Call::TechnicalCommittee(_)
| Call::TechnicalMembership(_)
| Call::Treasury(_)
| Call::PhragmenElection(_)
| Call::System(_)
| Call::Scheduler(_)
| Call::Indices(_)
| Call::Babe(_)
| Call::Timestamp(_)
| Call::Balances(_)
| Call::Authorship(_)
| Call::Staking(_)
| Call::Session(_)
| Call::Grandpa(_)
| Call::ImOnline(_)
| Call::Utility(_)
| Call::Claims(_)
| Call::Vesting(_)
| Call::Identity(_)
| Call::Proxy(_)
| Call::Multisig(_)
| Call::Bounties(_)
| Call::Tips(_)
| Call::ElectionProviderMultiPhase(_) => true,
}
}
}
Expand Down Expand Up @@ -993,22 +993,22 @@ impl InstanceFilter<Call> for ProxyType {
),
ProxyType::Governance => matches!(
c,
Call::Democracy(..) |
Call::Council(..) | Call::TechnicalCommittee(..) |
Call::PhragmenElection(..) |
Call::Treasury(..) | Call::Bounties(..) |
Call::Tips(..) | Call::Utility(..)
Call::Democracy(..)
| Call::Council(..) | Call::TechnicalCommittee(..)
| Call::PhragmenElection(..)
| Call::Treasury(..) | Call::Bounties(..)
| Call::Tips(..) | Call::Utility(..)
),
ProxyType::Staking => {
matches!(c, Call::Staking(..) | Call::Session(..) | Call::Utility(..))
},
}
ProxyType::IdentityJudgement => matches!(
c,
Call::Identity(pallet_identity::Call::provide_judgement(..)) | Call::Utility(..)
),
ProxyType::CancelProxy => {
matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement(..)))
},
}
}
}
fn is_superset(&self, o: &Self) -> bool {
Expand Down Expand Up @@ -1535,6 +1535,10 @@ sp_api::impl_runtime_apis! {
let weight = Executive::try_runtime_upgrade()?;
Ok((weight, BlockWeights::get().max_block))
}

fn execute_block_no_state_root_check(block: Block) -> Weight {
Executive::execute_block_no_state_root_check(block)
}
}

#[cfg(feature = "runtime-benchmarks")]
Expand Down
Loading

0 comments on commit b36dd83

Please sign in to comment.