Skip to content

Commit 7e03512

Browse files
committed
Merge branch 'devnet-ready' into feat/pending-childkeys
2 parents c596998 + 7f5bd9d commit 7e03512

Some content is hidden

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

45 files changed

+5007
-463
lines changed

Diff for: Cargo.lock

+723-222
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+24-4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ members = [
3434
"support/macros",
3535
"support/linting",
3636
"support/procedural-fork",
37+
"pallets/drand",
3738
]
3839
exclude = ["support/procedural-fork"]
3940
resolver = "2"
@@ -49,7 +50,7 @@ manual_inspect = "allow"
4950
async-trait = "0.1"
5051
cargo-husky = { version = "1", default-features = false }
5152
clap = "4.5.4"
52-
codec = { version = "3.2.2", default-features = false }
53+
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] }
5354
ed25519-dalek = { version = "2.1.0", default-features = false, features = ["alloc"] }
5455
enumflags2 = "0.7.9"
5556
futures = "0.3.30"
@@ -63,14 +64,14 @@ parity-util-mem = "0.12.0"
6364
rand = "0.8.5"
6465
scale-codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = ["derive"] }
6566
scale-info = { version = "2.11.2", default-features = false }
66-
serde = { version = "1.0.199", default-features = false }
67+
serde = { version = "1.0.214", default-features = false }
6768
serde-tuple-vec-map = { version = "1.0.1", default-features = false }
6869
serde_bytes = { version = "0.11.14", default-features = false }
6970
serde_json = { version = "1.0.121", default-features = false }
7071
serde_with = { version = "=2.0.0", default-features = false }
7172
smallvec = "1.13.2"
7273
litep2p = { git = "https://github.com/paritytech/litep2p", tag = "v0.7.0" }
73-
syn = { version = "2", features = [
74+
syn = { version = "2.0.87", features = [
7475
"full",
7576
"visit-mut",
7677
"visit",
@@ -142,7 +143,7 @@ sp-genesis-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", t
142143
sp-core = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
143144
sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
144145
sp-io = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
145-
sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409" }
146+
sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
146147
sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
147148
sp-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
148149
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
@@ -192,6 +193,25 @@ pallet-evm-precompile-sha3fips = { git = "https://github.com/gztensor/frontier",
192193
pallet-evm-precompile-simple = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false }
193194
pallet-hotfix-sufficients = { git = "https://github.com/gztensor/frontier", rev = "b8e3025", default-features = false }
194195

196+
#DRAND
197+
pallet-drand = { path = "pallets/drand", default-features = false }
198+
sp-crypto-ec-utils = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", features = ["bls12-381"] }
199+
getrandom = { version = "0.2.15", features = ["custom"], default-features = false }
200+
sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-stable2409", default-features = false }
201+
w3f-bls = { version = "=0.1.3", default-features = false }
202+
ark-crypto-primitives = { version = "0.4.0", default-features = false, features = [ "r1cs", "snark" ] }
203+
ark-scale = { version = "0.0.11", default-features = false, features = ["hazmat"] }
204+
sp-ark-bls12-381 = { git = "https://github.com/paritytech/substrate-curves", default-features = false }
205+
ark-bls12-381 = { version = "0.4.0", features = ["curve"], default-features = false }
206+
ark-serialize = { version = "0.4.0", features = [ "derive" ], default-features = false }
207+
ark-ff = { version = "0.4.0", default-features = false }
208+
ark-ec = { version = "0.4.0", default-features = false }
209+
ark-std = { version = "0.4.0", default-features = false }
210+
anyhow = "1.0.81"
211+
sha2 = { version = "0.10.8", default-features = false }
212+
rand_chacha = { version = "0.3.1", default-features = false }
213+
tle = { git = "https://github.com/ideal-lab5/timelock", rev = "5416406cfd32799e31e1795393d4916894de4468", default-features = false }
214+
195215
frame-metadata = "16"
196216

197217
[profile.release]

Diff for: node/Cargo.toml

+6
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ frame-metadata-hash-extension = { workspace = true }
6363
frame-system = { workspace = true }
6464
pallet-transaction-payment = { workspace = true }
6565
pallet-commitments = { path = "../pallets/commitments" }
66+
pallet-drand = { workspace = true }
67+
sp-crypto-ec-utils = { workspace = true }
68+
sp-keystore = { workspace = true, default-features = false }
69+
6670

6771
# These dependencies are used for the subtensor's RPCs
6872
jsonrpsee = { workspace = true, features = ["server"] }
@@ -128,6 +132,7 @@ runtime-benchmarks = [
128132
"sc-service/runtime-benchmarks",
129133
"sp-runtime/runtime-benchmarks",
130134
"pallet-commitments/runtime-benchmarks",
135+
"pallet-drand/runtime-benchmarks"
131136
]
132137
pow-faucet = []
133138

@@ -139,6 +144,7 @@ try-runtime = [
139144
"pallet-transaction-payment/try-runtime",
140145
"sp-runtime/try-runtime",
141146
"pallet-commitments/try-runtime",
147+
"pallet-drand/try-runtime"
142148
]
143149

144150
metadata-hash = ["node-subtensor-runtime/metadata-hash"]

Diff for: node/src/client.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ use sc_executor::WasmExecutor;
44
/// Full backend.
55
pub type FullBackend = sc_service::TFullBackend<Block>;
66
/// Full client.
7-
pub type FullClient = sc_service::TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>;
7+
pub type FullClient = sc_service::TFullClient<Block, RuntimeApi, RuntimeExecutor>;
88
/// Always enable runtime benchmark host functions, the genesis state
99
/// was built with them so we're stuck with them forever.
1010
///
1111
/// They're just a noop, never actually get used if the runtime was not compiled with
1212
/// `runtime-benchmarks`.
13-
type HostFunctions = (
13+
pub type HostFunctions = (
1414
sp_io::SubstrateHostFunctions,
1515
frame_benchmarking::benchmarking::HostFunctions,
16+
sp_crypto_ec_utils::bls12_381::host_calls::HostFunctions,
1617
);
18+
pub type RuntimeExecutor = WasmExecutor<HostFunctions>;

Diff for: node/src/service.rs

+28-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use std::{marker::PhantomData, sync::Arc, time::Duration};
2626
use substrate_prometheus_endpoint::Registry;
2727

2828
use crate::cli::Sealing;
29-
use crate::client::{FullBackend, FullClient};
29+
use crate::client::{FullBackend, FullClient, HostFunctions, RuntimeExecutor};
3030
use crate::ethereum::{
3131
db_config_dir, new_frontier_partial, spawn_frontier_tasks, BackendType, EthConfiguration,
3232
FrontierBackend, FrontierBlockImport, FrontierPartialComponents, StorageOverride,
@@ -84,13 +84,14 @@ where
8484
})
8585
.transpose()?;
8686

87-
let executor = sc_service::new_wasm_executor(&config.executor);
87+
let executor = sc_service::new_wasm_executor::<HostFunctions>(&config.executor);
8888
let (client, backend, keystore_container, task_manager) =
89-
sc_service::new_full_parts::<Block, RuntimeApi, _>(
89+
sc_service::new_full_parts::<Block, RuntimeApi, RuntimeExecutor>(
9090
config,
9191
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
9292
executor,
9393
)?;
94+
9495
let client = Arc::new(client);
9596

9697
let telemetry = telemetry.map(|(worker, telemetry)| {
@@ -427,10 +428,31 @@ where
427428
metrics,
428429
})?;
429430

430-
if config.offchain_worker.enabled {
431-
task_manager.spawn_handle().spawn(
431+
if config.offchain_worker.enabled && config.role.is_authority() {
432+
let public_keys = keystore_container
433+
.keystore()
434+
.sr25519_public_keys(pallet_drand::KEY_TYPE);
435+
436+
if public_keys.is_empty() {
437+
match sp_keystore::Keystore::sr25519_generate_new(
438+
&*keystore_container.keystore(),
439+
pallet_drand::KEY_TYPE,
440+
None,
441+
) {
442+
Ok(_) => {
443+
log::debug!("Offchain worker key generated");
444+
}
445+
Err(e) => {
446+
log::error!("Failed to create SR25519 key for offchain worker: {:?}", e);
447+
}
448+
}
449+
} else {
450+
log::debug!("Offchain worker key already exists");
451+
}
452+
453+
task_manager.spawn_essential_handle().spawn(
432454
"offchain-workers-runner",
433-
"offchain-worker",
455+
None,
434456
sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions {
435457
runtime_api_provider: client.clone(),
436458
is_validator: config.role.is_authority(),

Diff for: pallets/admin-utils/Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ log = { workspace = true }
2929
pallet-subtensor = { version = "4.0.0-dev", default-features = false, path = "../subtensor" }
3030
sp-weights = { workspace = true }
3131
substrate-fixed = { workspace = true }
32+
pallet-drand = { workspace = true, default-features = false }
3233

3334

3435
[dev-dependencies]
@@ -60,6 +61,7 @@ std = [
6061
"sp-io/std",
6162
"sp-std/std",
6263
"substrate-fixed/std",
64+
"pallet-drand/std"
6365
]
6466
runtime-benchmarks = [
6567
"frame-benchmarking/runtime-benchmarks",
@@ -69,12 +71,14 @@ runtime-benchmarks = [
6971
"sp-runtime/runtime-benchmarks",
7072
"pallet-subtensor/runtime-benchmarks",
7173
"pallet-scheduler/runtime-benchmarks",
74+
"pallet-drand/runtime-benchmarks"
7275
]
7376
try-runtime = [
7477
"frame-support/try-runtime",
7578
"frame-system/try-runtime",
7679
"pallet-balances/try-runtime",
7780
"pallet-scheduler/try-runtime",
7881
"sp-runtime/try-runtime",
79-
"pallet-subtensor/try-runtime"
82+
"pallet-subtensor/try-runtime",
83+
"pallet-drand/try-runtime"
8084
]

0 commit comments

Comments
 (0)