Skip to content

Commit

Permalink
Upgrade polkadot sdk (#25)
Browse files Browse the repository at this point in the history
* Tiny refactoring

* Upgrade polkadot-sdk

* Make the log consistent with upstream

* Nit

* Add import_params to Run

* Add profiling profile

* Nit

* Add rocksdb feature into subcoin-node

* Avoid cloning the payload using into_payload()

* Update Cargo.lock

* Nit
  • Loading branch information
liuchengxu authored Jul 21, 2024
1 parent 19e6a7f commit bdf8582
Show file tree
Hide file tree
Showing 11 changed files with 783 additions and 524 deletions.
1,169 changes: 709 additions & 460 deletions Cargo.lock

Large diffs are not rendered by default.

100 changes: 52 additions & 48 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features =
fastrand = "2.0.2"
futures = "0.3"
futures-timer = "3.0.1"
jsonrpsee = { version = "0.22", features = ["server"] }
jsonrpsee = { version = "0.23", features = ["server"] }
hex = "0.4"
hex-literal = "0.4.1"
indexmap = "2.2.6"
Expand All @@ -47,62 +47,62 @@ log = { version = "0.4", default-features = false }
once_cell = "1.19.0"
parking_lot = "0.12"
scale-info = { version = "2.6.0", default-features = false }
serde = "1"
serde = "1.0.204"
serde_json = "1"
tempfile = "3.10.1"
thiserror = "1.0"
tokio = "1.37.0"
tracing = "0.1"

# Disable the default `rocksdb` feature
frame-benchmarking-cli = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
frame-support = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
frame-system = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
frame-system-rpc-runtime-api = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
frame-try-runtime = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
pallet-balances = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
pallet-transaction-payment = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
frame-benchmarking-cli = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
frame-support = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
frame-system = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
frame-system-rpc-runtime-api = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
frame-try-runtime = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
pallet-balances = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
pallet-transaction-payment = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
# Disable the default `rocksdb` feature
sc-cli = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
sc-client-api = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin" }
sc-consensus = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin" }
sc-executor = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin" }
sc-informant = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin" }
sc-network = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin" }
sc-network-sync = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin" }
sc-rpc = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin" }
sc-cli = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
sc-client-api = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1" }
sc-consensus = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1" }
sc-executor = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1" }
sc-informant = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1" }
sc-network = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1" }
sc-network-sync = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1" }
sc-rpc = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1" }
# Disable the default `rocksdb` feature
sc-service = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
sc-storage-monitor = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin" }
sc-sysinfo = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin" }
sc-telemetry = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin" }
sc-transaction-pool = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin" }
sc-transaction-pool-api = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin" }
sc-utils = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin" }
sp-api = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
sp-blockchain = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
sp-block-builder = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
sp-consensus = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
sp-core = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
sp-database = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
sp-genesis-builder = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
sp-keyring = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin" }
sp-keystore = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin" }
sp-inherents = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
sp-io = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
sp-rpc = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin" }
sp-runtime = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
sp-session = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
sp-state-machine = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin" }
sp-std = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
sp-storage = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
sp-tracing = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
sp-transaction-pool = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
sp-trie = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
sp-version = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin", default-features = false }
substrate-build-script-utils = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin" }
substrate-frame-rpc-system = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin" }
substrate-wasm-builder = { git = "https://github.com/liuchengxu/polkadot-sdk", branch = "subcoin" }
sc-service = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
sc-storage-monitor = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1" }
sc-sysinfo = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1" }
sc-telemetry = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1" }
sc-transaction-pool = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1" }
sc-transaction-pool-api = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1" }
sc-utils = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1" }
sp-api = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
sp-blockchain = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
sp-block-builder = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
sp-consensus = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
sp-core = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
sp-database = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
sp-genesis-builder = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
sp-keyring = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1" }
sp-keystore = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1" }
sp-inherents = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
sp-io = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
sp-rpc = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1" }
sp-runtime = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
sp-session = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
sp-state-machine = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1" }
sp-std = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
sp-storage = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
sp-tracing = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
sp-transaction-pool = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
sp-trie = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
sp-version = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1", default-features = false }
substrate-build-script-utils = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1" }
substrate-frame-rpc-system = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1" }
substrate-wasm-builder = { git = "https://github.com/subcoin-project/polkadot-sdk", branch = "subcoin-v1" }

pallet-bitcoin = { path = "crates/pallet-bitcoin", default-features = false }
pallet-executive = { path = "crates/pallet-executive", default-features = false }
Expand All @@ -126,3 +126,7 @@ inherits = "release"
# Sacrifice compile speed for execution speed by using optimization flags:
lto = "fat" # https://doc.rust-lang.org/rustc/linker-plugin-lto.html
codegen-units = 1 # https://doc.rust-lang.org/rustc/codegen-options/index.html#codegen-units

[profile.profiling]
inherits = "release"
debug = true
2 changes: 1 addition & 1 deletion crates/sc-consensus-nakamoto/src/import_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub struct VerifyNothing;
#[async_trait::async_trait]
impl<Block: BlockT> sc_consensus::Verifier<Block> for VerifyNothing {
async fn verify(
&mut self,
&self,
block: BlockImportParams<Block>,
) -> Result<BlockImportParams<Block>, String> {
Ok(BlockImportParams::new(block.origin, block.header))
Expand Down
2 changes: 1 addition & 1 deletion crates/subcoin-informant/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl<B: BlockT> InformantDisplay<B> {

tracing::info!(
target: "subcoin",
"{level} {}{target} ({} peers), best: #{} ({best_bitcoin_hash},{best_hash}), confirmed #{} ({finalized_bitcoin_hash},{finalized_hash}), {} {}",
"{level} {}{target} ({} peers), best: #{} ({best_bitcoin_hash},{best_hash}), finalized #{} ({finalized_bitcoin_hash},{finalized_hash}), {} {}",
self.format.print_with_color(Colour::White.bold(), status),
self.format.print_with_color(Colour::White.bold(), num_connected_peers),
self.format.print_with_color(Colour::White.bold(), best_number),
Expand Down
4 changes: 2 additions & 2 deletions crates/subcoin-network/src/block_downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ impl BlockDownloadManager {
{
tracing::debug!(
best_number,
self.best_queued_number,
"Too many blocks in the queue, pausing download",
best_queued_number = self.best_queued_number,
"⏸️ Pausing download: too many blocks in the queue",
);
self.last_overloaded_queue_log_time.replace(Instant::now());
}
Expand Down
5 changes: 1 addition & 4 deletions crates/subcoin-network/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,11 @@ async fn read_peer_messages(
decoder.input(&read_buffer[..n]);

while let Some(msg) = decoder.decode_next::<RawNetworkMessage>()? {
// TODO: patch upstream to avoid the clone?
let payload = msg.payload().clone();

network_event_sender
.send(Event::PeerMessage {
from: peer,
direction,
payload,
payload: msg.into_payload(),
})
.map_err(|_| Error::NetworkEventStreamError)?;
}
Expand Down
9 changes: 4 additions & 5 deletions crates/subcoin-network/src/peer_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,11 +622,10 @@ where
last_pong_at: Instant::now(),
};

tracing::debug!(
"Received pong from {peer_id}, average latency: {}ms",
peer_info.ping_latency.average()
);
let average_latency = peer_info.ping_latency.average();

tracing::debug!("Received pong from {peer_id} (Avg. Latency: {average_latency}ms)");

Ok(peer_info.ping_latency.average())
Ok(average_latency)
}
}
1 change: 1 addition & 0 deletions crates/subcoin-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ substrate-build-script-utils = { workspace = true }
runtime-benchmarks = [
"sc-service/runtime-benchmarks",
]
rocksdb = ["sc-cli/rocksdb"]
12 changes: 11 additions & 1 deletion crates/subcoin-node/src/commands/run.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::cli::params::{CommonParams, NetworkParams};
use clap::Parser;
use sc_cli::{DatabasePruningMode, NodeKeyParams, PruningParams, Role, SharedParams};
use sc_cli::{DatabasePruningMode, ImportParams, NodeKeyParams, PruningParams, Role, SharedParams};
use sc_client_api::UsageProvider;
use sc_consensus_nakamoto::{BitcoinBlockImporter, BlockVerification, ImportConfig};
use sc_service::{BlocksPruning, Configuration, TaskManager};
Expand Down Expand Up @@ -37,6 +37,10 @@ pub struct Run {
#[allow(missing_docs)]
#[clap(flatten)]
pub network_params: NetworkParams,

#[allow(missing_docs)]
#[clap(flatten)]
pub import_params: ImportParams,
}

impl Run {
Expand All @@ -58,6 +62,7 @@ impl Run {
pub struct RunCmd {
shared_params: SharedParams,
pruning_params: PruningParams,
import_params: ImportParams,
}

impl RunCmd {
Expand All @@ -70,6 +75,7 @@ impl RunCmd {
Self {
shared_params,
pruning_params,
import_params: run.import_params.clone(),
}
}

Expand Down Expand Up @@ -195,6 +201,10 @@ impl sc_cli::CliConfiguration for RunCmd {
&self.shared_params
}

fn import_params(&self) -> Option<&ImportParams> {
Some(&self.import_params)
}

fn pruning_params(&self) -> Option<&PruningParams> {
Some(&self.pruning_params)
}
Expand Down
1 change: 0 additions & 1 deletion crates/subcoin-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ use sp_core::{ConstU32, OpaqueMetadata};
use sp_inherents::{CheckInherentsResult, InherentData};
use sp_runtime::transaction_validity::{TransactionSource, TransactionValidity};
use sp_runtime::{ApplyExtrinsicResult, ExtrinsicInclusionMode};
use sp_std::boxed::Box;
use sp_std::vec;
use sp_std::vec::Vec;
#[cfg(feature = "std")]
Expand Down
2 changes: 1 addition & 1 deletion crates/subcoin-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ pub struct VerifyNothing;
#[async_trait::async_trait]
impl<Block: BlockT> Verifier<Block> for VerifyNothing {
async fn verify(
&mut self,
&self,
block: BlockImportParams<Block>,
) -> Result<BlockImportParams<Block>, String> {
Ok(BlockImportParams::new(block.origin, block.header))
Expand Down

0 comments on commit bdf8582

Please sign in to comment.