Skip to content

Commit

Permalink
substrate-offchain: upgrade hyper to v1
Browse files Browse the repository at this point in the history
  • Loading branch information
ShoyuVanilla committed Oct 11, 2024
1 parent 439b31e commit 5e798a3
Show file tree
Hide file tree
Showing 12 changed files with 208 additions and 143 deletions.
67 changes: 42 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -799,10 +799,8 @@ http = { version = "1.1" }
http-body = { version = "1", default-features = false }
http-body-util = { version = "0.1.2", default-features = false }
hyper = { version = "1.3.1", default-features = false }
hyper-rustls = { version = "0.24.2" }
hyper-rustls = { version = "0.27.3", default-features = false, features = ["http1", "http2", "logging", "ring", "rustls-native-certs", "tls12"] }
hyper-util = { version = "0.1.5", default-features = false }
# TODO: remove hyper v0.14 https://github.com/paritytech/polkadot-sdk/issues/4896
hyperv14 = { package = "hyper", version = "0.14.29", default-features = false }
impl-serde = { version = "0.4.0", default-features = false }
impl-trait-for-tuples = { version = "0.2.2" }
indexmap = { version = "2.0.0" }
Expand Down Expand Up @@ -1117,6 +1115,7 @@ rstest = { version = "0.18.2" }
rustc-hash = { version = "1.1.0" }
rustc-hex = { version = "2.1.0", default-features = false }
rustix = { version = "0.36.7", default-features = false }
rustls = { version = "0.23.14", default-features = false, features = ["logging", "ring", "std", "tls12"] }
rustversion = { version = "1.0.17" }
rusty-fork = { version = "0.3.0", default-features = false }
safe-mix = { version = "1.0", default-features = false }
Expand Down
6 changes: 3 additions & 3 deletions polkadot/node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ pub fn new_full<
is_validator: role.is_authority(),
enable_http_requests: false,
custom_extensions: move |_| vec![],
})
})?
.run(client.clone(), task_manager.spawn_handle())
.boxed(),
);
Expand Down Expand Up @@ -1434,7 +1434,7 @@ pub fn new_chain_ops(
} else if config.chain_spec.is_kusama() {
chain_ops!(config, None)
} else if config.chain_spec.is_westend() {
return chain_ops!(config, None)
return chain_ops!(config, None);
} else {
chain_ops!(config, None)
}
Expand Down Expand Up @@ -1486,7 +1486,7 @@ pub fn revert_backend(
let revertible = blocks.min(best_number - finalized);

if revertible == 0 {
return Ok(())
return Ok(());
}

let number = best_number - revertible;
Expand Down
19 changes: 19 additions & 0 deletions prdoc/pr_5919.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: "substrate-offchain: upgrade hyper to v1"

doc:
- audience: Node Dev
description: |
Bump depencency `hyper` of `substrait-offchain` for http from `0.14` to `1`.
This changed APIs a bit;
- `sc_offchain::Offchainworker::new()` now returns `std::io::Result<Self>` (Previously was `Self`)

crates:
- name: sc-offchain
bump: minor
- name: polkadot-service
bump: patch
- name: staging-node-cli
bump: patch
14 changes: 7 additions & 7 deletions substrate/bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -783,9 +783,7 @@ pub fn new_full_base<N: NetworkBackend<Block, <Block as BlockT>::Hash>>(
);

if enable_offchain_worker {
task_manager.spawn_handle().spawn(
"offchain-workers-runner",
"offchain-work",
let offchain_workers =
sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions {
runtime_api_provider: client.clone(),
keystore: Some(keystore_container.keystore()),
Expand All @@ -799,9 +797,11 @@ pub fn new_full_base<N: NetworkBackend<Block, <Block as BlockT>::Hash>>(
custom_extensions: move |_| {
vec![Box::new(statement_store.clone().as_statement_store_ext()) as Box<_>]
},
})
.run(client.clone(), task_manager.spawn_handle())
.boxed(),
})?;
task_manager.spawn_handle().spawn(
"offchain-workers-runner",
"offchain-work",
offchain_workers.run(client.clone(), task_manager.spawn_handle()).boxed(),
);
}

Expand Down Expand Up @@ -985,7 +985,7 @@ mod tests {
sc_consensus_babe::authorship::claim_slot(slot.into(), &epoch, &keystore)
.map(|(digest, _)| digest)
{
break (babe_pre_digest, epoch_descriptor)
break (babe_pre_digest, epoch_descriptor);
}

slot += 1;
Expand Down
8 changes: 4 additions & 4 deletions substrate/client/offchain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ codec = { features = ["derive"], workspace = true, default-features = true }
fnv = { workspace = true }
futures = { workspace = true }
futures-timer = { workspace = true }
hyperv14 = { features = [
"http2",
"stream",
], workspace = true, default-features = true }
http-body-util = { workspace = true }
hyper = { features = ["http2"], workspace = true, default-features = true }
hyper-rustls = { features = ["http2"], workspace = true }
hyper-util = { features = ["client-legacy"], workspace = true }
num_cpus = { workspace = true }
once_cell = { workspace = true }
parking_lot = { workspace = true, default-features = true }
rand = { workspace = true, default-features = true }
rustls = { workspace = true }
threadpool = { workspace = true }
tracing = { workspace = true, default-features = true }
sc-client-api = { workspace = true, default-features = true }
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/offchain/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ mod tests {
fn offchain_api() -> (Api, AsyncApi) {
sp_tracing::try_init_simple();
let mock = Arc::new(TestNetwork());
let shared_client = SharedClient::new();
let shared_client = SharedClient::new().unwrap();

AsyncApi::new(mock, false, shared_client)
}
Expand Down
Loading

0 comments on commit 5e798a3

Please sign in to comment.