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 to Polkadot v0.9.42 #1263

Merged
merged 9 commits into from
May 12, 2023
Merged
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
1,117 changes: 689 additions & 428 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ members = [
# TODO.kevin: Move back to crates.io once it released 1.0
derive_more = { version = "0.99.17", git = "https://github.com/JelteF/derive_more" }

sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
sp-core-hashing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
sp-runtime-interface = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sp-core-hashing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sp-runtime-interface = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }

# For pink-extension-runtime, it will introduce Substrate from crates-io which usually different with polkadot-branch
pink-extension = { path = "crates/pink/pink-extension" }
Expand Down
20 changes: 10 additions & 10 deletions crates/phactory/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ prpc = { path = "../prpc" }
pink = { path = "../pink/runner", package = "pink-runner" }
pink-extension-runtime = { path = "../pink/pink-extension-runtime" }

sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41", features = ["disable_panic_handler", "disable_oom", "disable_allocator"] }
sp-runtime-interface = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41", features = ["disable_target_static_assertions"] }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
sp-externalities = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", features = ["disable_panic_handler", "disable_oom", "disable_allocator"] }
sp-runtime-interface = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", features = ["disable_target_static_assertions"] }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sp-externalities = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
parity-scale-codec = { package = "parity-scale-codec", version = "3.3", default-features = false, features = ["derive", "full", "chain-error"] }
scopeguard = { version = "1.1", default-features = false }

Expand All @@ -56,11 +56,11 @@ derive_more = "0.99.0"
hash-db = { version = "0.16.0", default-features = false }
num = { package = "num-traits", version = "0.2", default-features = false }
finality-grandpa = { version = "0.16.1", default-features = false, features = ["derive-codec"] }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
sp-consensus-grandpa = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sp-consensus-grandpa = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }

fixed = "1.9.0"
fixed-sqrt = "0.2.4"
Expand Down
10 changes: 5 additions & 5 deletions crates/phactory/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ phala-crypto = { path = "../../../crates/phala-crypto" }
phala-mq = { path = "../../../crates/phala-mq" }
chain = { path = "../../../standalone/runtime", default-features = false, package = "phala-node-runtime" }

sp-consensus-grandpa = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41", default-features = false }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41", default-features = false, features = ["full_crypto"] }
sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41", default-features = false, features = ["full_crypto"] }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41", default-features = false }
sp-consensus-grandpa = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false, features = ["full_crypto"] }
sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false, features = ["full_crypto"] }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
phala-git-revision = { path = "../../phala-git-revision" }

# for pruntime_client
Expand Down
14 changes: 12 additions & 2 deletions crates/phactory/api/src/crypto.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::convert::TryFrom;

use alloc::vec;
use alloc::vec::Vec;
use parity_scale_codec::{Decode, Encode, Error as CodecError};
Expand Down Expand Up @@ -97,11 +99,19 @@ impl Signature {
}
}

fn verify<T>(pubkey: &[u8], sig: &[u8], msg: &[u8]) -> bool
pub fn verify<T>(pubkey: &[u8], sig: &[u8], msg: &[u8]) -> bool
where
T: sp_core::crypto::Pair,
T::Public: for<'a> TryFrom<&'a [u8]>,
T::Signature: for<'a> TryFrom<&'a [u8]>,
{
T::verify_weak(sig, msg, pubkey)
let Ok(public) = T::Public::try_from(pubkey) else {
return false;
};
let Ok(signature) = T::Signature::try_from(sig) else {
return false;
};
T::verify(&signature, msg, &public)
}

/// Wraps the message in the same format as it defined in Polkadot.js extension:
Expand Down
7 changes: 4 additions & 3 deletions crates/phactory/src/prpc_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1946,14 +1946,15 @@ impl<Platform: pal::Platform + Serialize + DeserializeOwned> PhactoryApi for Rpc
let receiver = try_decode_hex(&receiver).map_err(|_| from_display("Invalid receiver"))?;
let signature =
try_decode_hex(&signature).map_err(|_| from_display("Invalid signature"))?;

// Check the validity of the state request with the remote public key
if !sr25519::Pair::verify_weak(
if !crypto::verify::<sr25519::Pair>(
&receiver,
&signature,
wrap_content_to_sign(
&wrap_content_to_sign(
&min_block_number.to_be_bytes(),
SignedContentType::ClusterStateRequest,
),
&receiver,
) {
return Err(from_display("Invalid signature"));
}
Expand Down
4 changes: 2 additions & 2 deletions crates/phala-crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ edition = "2018"
resolver = "2"

[dependencies]
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41", default-features = false }
sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }

ring = { version = "0.16.20", default-features = false, features = ["alloc"] }
curve25519-dalek = { version = "2.0", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion crates/phala-mq/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ hex = { version = "0.4.3", default-features = false, features = ['alloc'] }
derive_more = { version = "0.99", default-features = false, features = ["display"] }
parity-scale-codec = { version = "3.3", default-features = false, features = ["derive"] }
scale-info = { version = "2.3", default-features = false, features = ["derive"] }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
serde = { version = "1.0", default-features = false, features = ["derive"] }

spin = { version = "0.9", default-features = false, features = ["mutex", "use_ticket_mutex"], optional = true }
Expand Down
12 changes: 6 additions & 6 deletions crates/phala-node-rpc-ext/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ codec = { package = "parity-scale-codec", version = "3.3" }
scale-info = { version = "2.3", default-features = false }

# primitives
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }

# client dependencies
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }

phala-mq = { path = "../../crates/phala-mq" }
phala-pallets = { path = "../../pallets/phala" }
Expand Down
2 changes: 1 addition & 1 deletion crates/phala-serde-more/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"

[dependencies]
serde = { version = "1.0.130", default-features = false, features = ["derive", "alloc"] }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
scale = { package = "parity-scale-codec", version = "3.3", default-features = false }
hex = { version = "0.4.3", default-features = false, features = ["alloc"] }

Expand Down
10 changes: 5 additions & 5 deletions crates/phala-trie-storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ repository = "https://github.com/Phala-Network/phala-blockchain"
[dependencies]
parity-scale-codec = { version = "3.3", default-features = false }
scale-info = { version = "2.3", default-features = false, features = ["derive"] }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41", features = ["full_crypto"] }
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", features = ["full_crypto"] }
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }

serde = { version = "1.0", default-features = false, features = ["derive", "alloc"], optional = true }
hash-db = "0.16.0"
Expand All @@ -21,8 +21,8 @@ im = { version = "15", features = ["serde"] }
log = "0.4"

[dev-dependencies]
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41", features = ["full_crypto"] }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", features = ["full_crypto"] }
hash256-std-hasher = { version = "0.15", default-features = false }
hex = "0.4"
serde_json = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/phala-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ hex = { version = "0.4", default-features = false, features = ["alloc"] }
serde = { version = "1.0.101", default-features = false, optional = true }
codec = { package = "parity-scale-codec", version = "3.3", default-features = false, features = ["full"] }
scale-info = { version = "2.3", default-features = false, features = ["derive"] }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }

phala-mq = { path = "../../crates/phala-mq", default-features = false }
prpc = { path = "../../crates/prpc", default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions crates/phaxt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ phala-types = { path = "../phala-types" }
phala-node-rpc-ext-types = { path = "../phala-node-rpc-ext/types" }
phala-pallets = { path = "../../pallets/phala" }
jsonrpsee = "0.16.2"
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41", default-features = false }
primitive-types = { version = "0.12.0", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
primitive-types = { version = "0.12.1", default-features = false }
2 changes: 1 addition & 1 deletion crates/pink-libs/subrpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ base58 = { version = "0.2.0", default-features = false }

[dev-dependencies]
pink-extension-runtime = { version = "0.4", path = "../../pink/pink-extension-runtime" }
xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.41", default-features = false, features = ["std"] }
xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.42", default-features = false, features = ["std"] }

[features]
default = ["std"]
Expand Down
4 changes: 2 additions & 2 deletions crates/pink/capi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version = "0.1.0"
edition = "2021"

[dependencies]
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
pink-extension = { path = "../pink-extension" }
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = [
"derive",
Expand Down
2 changes: 1 addition & 1 deletion crates/pink/pink-extension-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"
[dependencies]
pink-extension = { version = "0.4.2", path = "../pink-extension" }
reqwest-env-proxy = { version = "0.1", path = "../../reqwest-env-proxy" }
sp-core = { version = "7" }
sp-core = { version = "7", features = ["full_crypto"] }
sp-runtime-interface = { version = "7", features = ["disable_target_static_assertions"] }
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "socks", "blocking"] }
log = "0.4"
Expand Down
8 changes: 5 additions & 3 deletions crates/pink/pink-extension-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,16 @@ impl<T: PinkRuntimeEnv, E: From<&'static str>> PinkExtBackend for DefaultPinkExt
) -> Result<bool, Self::Error> {
macro_rules! verify_with {
($sigtype:ident) => {{
sp_core::$sigtype::Pair::verify_weak(&signature, &message, &pubkey)
let pubkey = sp_core::$sigtype::Public::from_slice(&pubkey).map_err(|_| "Invalid public key")?;
let signature = sp_core::$sigtype::Signature::from_slice(&signature).ok_or("Invalid signature")?;
Ok(sp_core::$sigtype::Pair::verify(&signature, message, &pubkey))
}};
}
Ok(match sigtype {
match sigtype {
SigType::Sr25519 => verify_with!(sr25519),
SigType::Ed25519 => verify_with!(ed25519),
SigType::Ecdsa => verify_with!(ecdsa),
})
}
}

fn derive_sr25519_key(&self, salt: Cow<[u8]>) -> Result<Vec<u8>, Self::Error> {
Expand Down
6 changes: 3 additions & 3 deletions crates/pink/runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pink-capi = { path = "../capi" }
pink-extension-runtime = { path = "../pink-extension-runtime" }
phala-crypto = { path = "../../phala-crypto" }
serde = { version = "1", features = ["derive"] }
sp-weights = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
sp-weights = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
im = "15"
once_cell = "1"
libc = "0.2"
Expand All @@ -22,7 +22,7 @@ scale = { package = "parity-scale-codec", version = "3.1", default-features = fa
"derive",
] }
insta = "1"
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
pallet-contracts-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
pallet-contracts-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
env_logger = "0.10.0"
assert_matches = "1.5.0"
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
---
source: crates/pink/runner/tests/test_pink_contract.rs
assertion_line: 115
expression: result
---
ContractResult {
gas_consumed: Weight {
ref_time: 1670460672,
proof_size: 201180,
ref_time: 1902834726,
proof_size: 45015,
},
gas_required: Weight {
ref_time: 66475808693,
proof_size: 10546826,
ref_time: 79195633637,
proof_size: 2113745,
},
storage_deposit: StorageDeposit::Charge(
4,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
---
source: crates/pink/runner/tests/test_pink_contract.rs
assertion_line: 51
expression: result
---
ContractResult {
gas_consumed: Weight {
ref_time: 897860439,
proof_size: 139822,
ref_time: 1065811083,
proof_size: 28129,
},
gas_required: Weight {
ref_time: 65728937984,
proof_size: 10485760,
ref_time: 78387347456,
proof_size: 2097152,
},
storage_deposit: StorageDeposit::Charge(
2,
Expand Down
Loading