Skip to content

Commit 7cca106

Browse files
authored
Merge pull request #1263 from Phala-Network/polkadot-v0.9.42
Upgrade to Polkadot v0.9.42
2 parents 140a690 + e296027 commit 7cca106

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2727
-2511
lines changed

Cargo.lock

Lines changed: 689 additions & 428 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ members = [
9898
# TODO.kevin: Move back to crates.io once it released 1.0
9999
derive_more = { version = "0.99.17", git = "https://github.com/JelteF/derive_more" }
100100

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

106106
# For pink-extension-runtime, it will introduce Substrate from crates-io which usually different with polkadot-branch
107107
pink-extension = { path = "crates/pink/pink-extension" }

crates/phactory/Cargo.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ prpc = { path = "../prpc" }
3636
pink = { path = "../pink/runner", package = "pink-runner" }
3737
pink-extension-runtime = { path = "../pink/pink-extension-runtime" }
3838

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

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

6565
fixed = "1.9.0"
6666
fixed-sqrt = "0.2.4"

crates/phactory/api/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ phala-crypto = { path = "../../../crates/phala-crypto" }
1919
phala-mq = { path = "../../../crates/phala-mq" }
2020
chain = { path = "../../../standalone/runtime", default-features = false, package = "phala-node-runtime" }
2121

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

2929
# for pruntime_client

crates/phactory/api/src/crypto.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::convert::TryFrom;
2+
13
use alloc::vec;
24
use alloc::vec::Vec;
35
use parity_scale_codec::{Decode, Encode, Error as CodecError};
@@ -97,11 +99,19 @@ impl Signature {
9799
}
98100
}
99101

100-
fn verify<T>(pubkey: &[u8], sig: &[u8], msg: &[u8]) -> bool
102+
pub fn verify<T>(pubkey: &[u8], sig: &[u8], msg: &[u8]) -> bool
101103
where
102104
T: sp_core::crypto::Pair,
105+
T::Public: for<'a> TryFrom<&'a [u8]>,
106+
T::Signature: for<'a> TryFrom<&'a [u8]>,
103107
{
104-
T::verify_weak(sig, msg, pubkey)
108+
let Ok(public) = T::Public::try_from(pubkey) else {
109+
return false;
110+
};
111+
let Ok(signature) = T::Signature::try_from(sig) else {
112+
return false;
113+
};
114+
T::verify(&signature, msg, &public)
105115
}
106116

107117
/// Wraps the message in the same format as it defined in Polkadot.js extension:

crates/phactory/src/prpc_service.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,14 +1946,15 @@ impl<Platform: pal::Platform + Serialize + DeserializeOwned> PhactoryApi for Rpc
19461946
let receiver = try_decode_hex(&receiver).map_err(|_| from_display("Invalid receiver"))?;
19471947
let signature =
19481948
try_decode_hex(&signature).map_err(|_| from_display("Invalid signature"))?;
1949+
19491950
// Check the validity of the state request with the remote public key
1950-
if !sr25519::Pair::verify_weak(
1951+
if !crypto::verify::<sr25519::Pair>(
1952+
&receiver,
19511953
&signature,
1952-
wrap_content_to_sign(
1954+
&wrap_content_to_sign(
19531955
&min_block_number.to_be_bytes(),
19541956
SignedContentType::ClusterStateRequest,
19551957
),
1956-
&receiver,
19571958
) {
19581959
return Err(from_display("Invalid signature"));
19591960
}

crates/phala-crypto/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ edition = "2018"
55
resolver = "2"
66

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

1111
ring = { version = "0.16.20", default-features = false, features = ["alloc"] }
1212
curve25519-dalek = { version = "2.0", default-features = false }

crates/phala-mq/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ hex = { version = "0.4.3", default-features = false, features = ['alloc'] }
1212
derive_more = { version = "0.99", default-features = false, features = ["display"] }
1313
parity-scale-codec = { version = "3.3", default-features = false, features = ["derive"] }
1414
scale-info = { version = "2.3", default-features = false, features = ["derive"] }
15-
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41", default-features = false }
15+
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
1616
serde = { version = "1.0", default-features = false, features = ["derive"] }
1717

1818
spin = { version = "0.9", default-features = false, features = ["mutex", "use_ticket_mutex"], optional = true }

crates/phala-node-rpc-ext/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ codec = { package = "parity-scale-codec", version = "3.3" }
1919
scale-info = { version = "2.3", default-features = false }
2020

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

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

3131
phala-mq = { path = "../../crates/phala-mq" }
3232
phala-pallets = { path = "../../pallets/phala" }

crates/phala-serde-more/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2021"
55

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

crates/phala-trie-storage/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ repository = "https://github.com/Phala-Network/phala-blockchain"
1010
[dependencies]
1111
parity-scale-codec = { version = "3.3", default-features = false }
1212
scale-info = { version = "2.3", default-features = false, features = ["derive"] }
13-
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41", features = ["full_crypto"] }
14-
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
15-
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41", default-features = false }
13+
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", features = ["full_crypto"] }
14+
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
15+
sp-state-machine = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
1616

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

2323
[dev-dependencies]
24-
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
25-
sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41", features = ["full_crypto"] }
24+
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
25+
sp-application-crypto = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", features = ["full_crypto"] }
2626
hash256-std-hasher = { version = "0.15", default-features = false }
2727
hex = "0.4"
2828
serde_json = "1.0"

crates/phala-types/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ hex = { version = "0.4", default-features = false, features = ["alloc"] }
99
serde = { version = "1.0.101", default-features = false, optional = true }
1010
codec = { package = "parity-scale-codec", version = "3.3", default-features = false, features = ["full"] }
1111
scale-info = { version = "2.3", default-features = false, features = ["derive"] }
12-
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41", default-features = false }
12+
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
1313

1414
phala-mq = { path = "../../crates/phala-mq", default-features = false }
1515
prpc = { path = "../../crates/prpc", default-features = false }

crates/phaxt/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ phala-types = { path = "../phala-types" }
1717
phala-node-rpc-ext-types = { path = "../phala-node-rpc-ext/types" }
1818
phala-pallets = { path = "../../pallets/phala" }
1919
jsonrpsee = "0.16.2"
20-
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41", default-features = false }
21-
primitive-types = { version = "0.12.0", default-features = false }
20+
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false }
21+
primitive-types = { version = "0.12.1", default-features = false }

crates/pink-libs/subrpc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ base58 = { version = "0.2.0", default-features = false }
3232

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

3737
[features]
3838
default = ["std"]

crates/pink/capi/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
8-
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
7+
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
8+
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
99
pink-extension = { path = "../pink-extension" }
1010
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = [
1111
"derive",

crates/pink/pink-extension-runtime/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ edition = "2021"
99
[dependencies]
1010
pink-extension = { version = "0.4.2", path = "../pink-extension" }
1111
reqwest-env-proxy = { version = "0.1", path = "../../reqwest-env-proxy" }
12-
sp-core = { version = "7" }
12+
sp-core = { version = "7", features = ["full_crypto"] }
1313
sp-runtime-interface = { version = "7", features = ["disable_target_static_assertions"] }
1414
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "socks", "blocking"] }
1515
log = "0.4"

crates/pink/pink-extension-runtime/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,16 @@ impl<T: PinkRuntimeEnv, E: From<&'static str>> PinkExtBackend for DefaultPinkExt
158158
) -> Result<bool, Self::Error> {
159159
macro_rules! verify_with {
160160
($sigtype:ident) => {{
161-
sp_core::$sigtype::Pair::verify_weak(&signature, &message, &pubkey)
161+
let pubkey = sp_core::$sigtype::Public::from_slice(&pubkey).map_err(|_| "Invalid public key")?;
162+
let signature = sp_core::$sigtype::Signature::from_slice(&signature).ok_or("Invalid signature")?;
163+
Ok(sp_core::$sigtype::Pair::verify(&signature, message, &pubkey))
162164
}};
163165
}
164-
Ok(match sigtype {
166+
match sigtype {
165167
SigType::Sr25519 => verify_with!(sr25519),
166168
SigType::Ed25519 => verify_with!(ed25519),
167169
SigType::Ecdsa => verify_with!(ecdsa),
168-
})
170+
}
169171
}
170172

171173
fn derive_sr25519_key(&self, salt: Cow<[u8]>) -> Result<Vec<u8>, Self::Error> {

crates/pink/runner/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pink-capi = { path = "../capi" }
88
pink-extension-runtime = { path = "../pink-extension-runtime" }
99
phala-crypto = { path = "../../phala-crypto" }
1010
serde = { version = "1", features = ["derive"] }
11-
sp-weights = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
11+
sp-weights = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
1212
im = "15"
1313
once_cell = "1"
1414
libc = "0.2"
@@ -22,7 +22,7 @@ scale = { package = "parity-scale-codec", version = "3.1", default-features = fa
2222
"derive",
2323
] }
2424
insta = "1"
25-
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
26-
pallet-contracts-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.41" }
25+
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
26+
pallet-contracts-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" }
2727
env_logger = "0.10.0"
2828
assert_matches = "1.5.0"

crates/pink/runner/tests/snapshots/test_pink_contract__ink_cross_contract_instantiate.snap

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
---
22
source: crates/pink/runner/tests/test_pink_contract.rs
3+
assertion_line: 115
34
expression: result
45
---
56
ContractResult {
67
gas_consumed: Weight {
7-
ref_time: 1670460672,
8-
proof_size: 201180,
8+
ref_time: 1902834726,
9+
proof_size: 45015,
910
},
1011
gas_required: Weight {
11-
ref_time: 66475808693,
12-
proof_size: 10546826,
12+
ref_time: 79195633637,
13+
proof_size: 2113745,
1314
},
1415
storage_deposit: StorageDeposit::Charge(
1516
4,

crates/pink/runner/tests/snapshots/test_pink_contract__ink_flip.snap

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
---
22
source: crates/pink/runner/tests/test_pink_contract.rs
3+
assertion_line: 51
34
expression: result
45
---
56
ContractResult {
67
gas_consumed: Weight {
7-
ref_time: 897860439,
8-
proof_size: 139822,
8+
ref_time: 1065811083,
9+
proof_size: 28129,
910
},
1011
gas_required: Weight {
11-
ref_time: 65728937984,
12-
proof_size: 10485760,
12+
ref_time: 78387347456,
13+
proof_size: 2097152,
1314
},
1415
storage_deposit: StorageDeposit::Charge(
1516
2,

0 commit comments

Comments
 (0)