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

Upgrade polkadot-sdk to version 1.7.0 #2688

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
4,440 changes: 2,131 additions & 2,309 deletions Cargo.lock

Large diffs are not rendered by default.

725 changes: 365 additions & 360 deletions Cargo.toml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/rpc-core/txpool/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub use self::inspect::Summary;

pub type TransactionMap<T> = HashMap<H160, HashMap<U256, T>>;

#[derive(Debug, Serialize)]
#[derive(Debug, Clone, Serialize)]
pub struct TxPoolResult<T: Serialize> {
pub pending: T,
pub queued: T,
Expand Down
7 changes: 5 additions & 2 deletions client/rpc/debug/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ use moonbeam_rpc_core_types::{RequestBlockId, RequestBlockTag};
use moonbeam_rpc_primitives_debug::{DebugRuntimeApi, TracerInput};
use sc_client_api::backend::{Backend, StateBackend, StorageProvider};
use sc_utils::mpsc::TracingUnboundedSender;
use sp_api::{ApiExt, BlockId, Core, HeaderT, ProvideRuntimeApi};
use sp_api::{ApiExt, Core, ProvideRuntimeApi};
use sp_block_builder::BlockBuilder;
use sp_blockchain::{
Backend as BlockchainBackend, Error as BlockChainError, HeaderBackend, HeaderMetadata,
};
use sp_runtime::traits::{BlakeTwo256, Block as BlockT, UniqueSaturatedInto};
use sp_runtime::{
generic::BlockId,
traits::{BlakeTwo256, Block as BlockT, Header as HeaderT, UniqueSaturatedInto},
};
use std::{future::Future, marker::PhantomData, sync::Arc};

pub enum RequesterInput {
Expand Down
42 changes: 23 additions & 19 deletions client/rpc/manual-xcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@
// along with Moonbeam. If not, see <http://www.gnu.org/licenses/>.
use cumulus_primitives_core::ParaId;
use cumulus_primitives_core::XcmpMessageFormat;
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
use jsonrpsee::{
core::RpcResult,
proc_macros::rpc,
types::{
error::{INTERNAL_ERROR_CODE, INTERNAL_ERROR_MSG},
ErrorObjectOwned,
},
};
use parity_scale_codec::Encode;
use xcm::latest::prelude::*;
use xcm::opaque::lts::Weight;
use xcm::v4::prelude::*;
use xcm_primitives::DEFAULT_PROOF_SIZE;

/// This RPC interface is used to manually submit XCM messages that will be injected into a
Expand Down Expand Up @@ -59,7 +66,7 @@ impl ManualXcmApiServer for ManualXcm {
let downward_message_channel = self.downward_message_channel.clone();
// If no message is supplied, inject a default one.
let msg = if msg.is_empty() {
xcm::VersionedXcm::<()>::V3(Xcm(vec![
xcm::VersionedXcm::<()>::V4(Xcm(vec![
ReserveAssetDeposited((Parent, 10000000000000u128).into()),
ClearOrigin,
BuyExecution {
Expand All @@ -68,12 +75,12 @@ impl ManualXcmApiServer for ManualXcm {
},
DepositAsset {
assets: AllCounted(1).into(),
beneficiary: MultiLocation::new(
beneficiary: Location::new(
0,
X1(AccountKey20 {
[AccountKey20 {
network: None,
key: hex_literal::hex!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac"),
}),
}],
),
},
]))
Expand All @@ -99,7 +106,7 @@ impl ManualXcmApiServer for ManualXcm {
let msg = if msg.is_empty() {
let mut mes = XcmpMessageFormat::ConcatenatedVersionedXcm.encode();
mes.append(
&mut (xcm::VersionedXcm::<()>::V3(Xcm(vec![
&mut (xcm::VersionedXcm::<()>::V4(Xcm(vec![
ReserveAssetDeposited(
((Parent, Parachain(sender.into())), 10000000000000u128).into(),
),
Expand All @@ -113,12 +120,12 @@ impl ManualXcmApiServer for ManualXcm {
},
DepositAsset {
assets: AllCounted(1).into(),
beneficiary: MultiLocation::new(
beneficiary: Location::new(
0,
X1(AccountKey20 {
[AccountKey20 {
network: None,
key: hex_literal::hex!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac"),
}),
}],
),
},
]))
Expand All @@ -141,13 +148,10 @@ impl ManualXcmApiServer for ManualXcm {
}

// This bit cribbed from frontier.
pub fn internal_err<T: AsRef<str>>(message: T) -> jsonrpsee::core::Error {
jsonrpsee::core::Error::Call(jsonrpsee::types::error::CallError::Custom(
jsonrpsee::types::error::ErrorObject::borrowed(
jsonrpsee::types::error::INTERNAL_ERROR_CODE,
&message,
None,
)
.into_owned(),
))
pub fn internal_err<T: ToString>(message: T) -> ErrorObjectOwned {
ErrorObjectOwned::owned(
INTERNAL_ERROR_CODE,
INTERNAL_ERROR_MSG,
Some(message.to_string()),
)
}
4 changes: 2 additions & 2 deletions client/rpc/trace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ use tracing::{instrument, Instrument};

use sc_client_api::backend::{Backend, StateBackend, StorageProvider};
use sc_utils::mpsc::TracingUnboundedSender;
use sp_api::{ApiExt, Core, HeaderT, ProvideRuntimeApi};
use sp_api::{ApiExt, Core, ProvideRuntimeApi};
use sp_block_builder::BlockBuilder;
use sp_blockchain::{
Backend as BlockchainBackend, Error as BlockChainError, HeaderBackend, HeaderMetadata,
};
use sp_runtime::traits::{BlakeTwo256, Block as BlockT};
use sp_runtime::traits::{BlakeTwo256, Block as BlockT, Header as HeaderT};
use substrate_prometheus_endpoint::{
register, Counter, PrometheusError, Registry as PrometheusRegistry, U64,
};
Expand Down
14 changes: 8 additions & 6 deletions client/vrf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,23 @@ version = "0.1.0"

[dependencies]
# Substrate
parity-scale-codec = { workspace = true, features = [ "derive", "std" ] }
sp-api = { workspace = true, features = [ "std" ] }
parity-scale-codec = { workspace = true, features = ["derive", "std"] }
sp-api = { workspace = true, features = ["std"] }
sp-application-crypto = { workspace = true }
sp-core = { workspace = true, features = [ "std" ] }
sp-core = { workspace = true, features = ["std"] }
sp-keystore = { workspace = true }
sp-runtime = { workspace = true }

# Moonbeam
session-keys-primitives = { workspace = true, features = [ "std" ] }
session-keys-primitives = { workspace = true, features = ["std"] }

# Nimbus
nimbus-primitives = { workspace = true, features = [ "std" ] }
nimbus-primitives = { workspace = true, features = ["std"] }

# Polkadot
polkadot-primitives = { workspace = true }

# Other
schnorrkel = { workspace = true, default-features = false, features = [ "preaudit_deprecated", "u64_backend" ] }
schnorrkel = { workspace = true, default-features = false, features = [
"preaudit_deprecated",
] }
4 changes: 2 additions & 2 deletions client/vrf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn sign_vrf(last_vrf_output: H256, key: VrfId, keystore: &KeystorePtr) -> Option
if let Ok(Some(signature)) = try_sign {
let public = PublicKey::from_bytes(&key.to_raw_vec()).ok()?;
if signature
.output
.pre_output
.0
.attach_input_hash(&public, transcript.0.clone())
.is_err()
Expand All @@ -70,7 +70,7 @@ fn sign_vrf(last_vrf_output: H256, key: VrfId, keystore: &KeystorePtr) -> Option
return None;
}
Some(PreDigest {
vrf_output: signature.output,
vrf_output: signature.pre_output,
vrf_proof: signature.proof,
})
} else {
Expand Down
4 changes: 2 additions & 2 deletions node/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use std::path::PathBuf;
pub enum Subcommand {
/// Export the genesis state of the parachain.
#[clap(name = "export-genesis-state")]
ExportGenesisState(ExportGenesisStateCommand),
ExportGenesisHead(ExportGenesisHeadCommand),

/// Export the genesis wasm of the parachain.
#[clap(name = "export-genesis-wasm")]
Expand Down Expand Up @@ -91,7 +91,7 @@ pub struct BuildSpecCommand {

/// Command for exporting the genesis state of the parachain
#[derive(Debug, Parser)]
pub struct ExportGenesisStateCommand {
pub struct ExportGenesisHeadCommand {
/// Output file name or stdout if unspecified.
#[clap(value_parser)]
pub output: Option<PathBuf>,
Expand Down
45 changes: 42 additions & 3 deletions node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! This module constructs and executes the appropriate service components for the given subcommand

use crate::cli::{Cli, RelayChainCli, RunCmd, Subcommand};
use cumulus_client_cli::{extract_genesis_wasm, generate_genesis_block};
use cumulus_client_cli::extract_genesis_wasm;
use cumulus_primitives_core::ParaId;
use frame_benchmarking_cli::BenchmarkCmd;
use log::{info, warn};
Expand All @@ -35,7 +35,10 @@ use sc_service::{
DatabaseSource, PartialComponents,
};
use sp_core::hexdisplay::HexDisplay;
use sp_runtime::traits::{AccountIdConversion, Block as _};
use sp_runtime::{
traits::{AccountIdConversion, Block as BlockT, Hash as HashT, Header as HeaderT, Zero},
StateVersion,
};
use std::{io::Write, net::SocketAddr};

fn load_spec(
Expand Down Expand Up @@ -388,7 +391,7 @@ pub fn run() -> Result<()> {
_ => panic!("invalid chain spec"),
}
}
Some(Subcommand::ExportGenesisState(params)) => {
Some(Subcommand::ExportGenesisHead(params)) => {
let mut builder = sc_cli::LoggerBuilder::new("");
builder.with_profiling(sc_tracing::TracingReceiver::Log, "");
let _ = builder.init();
Expand Down Expand Up @@ -956,3 +959,39 @@ impl CliConfiguration<Self> for RelayChainCli {
self.base.base.announce_block()
}
}

/// Generate the genesis block from a given ChainSpec.
pub fn generate_genesis_block<Block: BlockT>(
chain_spec: &dyn ChainSpec,
genesis_state_version: StateVersion,
) -> std::result::Result<Block, String> {
let storage = chain_spec.build_storage()?;

let child_roots = storage.children_default.iter().map(|(sk, child_content)| {
let state_root = <<<Block as BlockT>::Header as HeaderT>::Hashing as HashT>::trie_root(
child_content.data.clone().into_iter().collect(),
genesis_state_version,
);
(sk.clone(), state_root.encode())
});
let state_root = <<<Block as BlockT>::Header as HeaderT>::Hashing as HashT>::trie_root(
storage.top.clone().into_iter().chain(child_roots).collect(),
genesis_state_version,
);

let extrinsics_root = <<<Block as BlockT>::Header as HeaderT>::Hashing as HashT>::trie_root(
Vec::new(),
genesis_state_version,
);

Ok(Block::new(
<<Block as BlockT>::Header as HeaderT>::new(
Zero::zero(),
extrinsics_root,
state_root,
Default::default(),
Default::default(),
),
Default::default(),
))
}
1 change: 1 addition & 0 deletions node/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ cumulus-client-network = { workspace = true }
cumulus-client-service = { workspace = true }
cumulus-primitives-core = { workspace = true }
cumulus-primitives-parachain-inherent = { workspace = true }
cumulus-client-parachain-inherent = { workspace = true }
cumulus-relay-chain-inprocess-interface = { workspace = true }
cumulus-relay-chain-interface = { workspace = true }
cumulus-relay-chain-minimal-node = { workspace = true }
Expand Down
Loading
Loading