Skip to content

Commit

Permalink
Bump tonic, prost, tarpc, tokio (solana-labs#15013)
Browse files Browse the repository at this point in the history
* Update tonic & prost, and regenerate proto

* Reignore doc code

* Revert pull solana-labs#14367, but pin tokio to v0.2 for jsonrpc

* Bump backoff and goauth -> and therefore tokio

* Bump tokio in faucet, net-utils

* Bump remaining tokio, plus tarpc
  • Loading branch information
CriesofCarrots authored Feb 5, 2021
1 parent 863f08f commit d1563f0
Show file tree
Hide file tree
Showing 33 changed files with 924 additions and 686 deletions.
857 changes: 506 additions & 351 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions banks-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ futures = "0.3"
mio = "0.7.6"
solana-banks-interface = { path = "../banks-interface", version = "1.6.0" }
solana-sdk = { path = "../sdk", version = "1.6.0" }
tarpc = { version = "0.23.0", features = ["full"] }
tokio = { version = "0.3.5", features = ["full"] }
tokio-serde = { version = "0.6", features = ["bincode"] }
tarpc = { version = "0.24.1", features = ["full"] }
tokio = { version = "1.1", features = ["full"] }
tokio-serde = { version = "0.8", features = ["bincode"] }

[dev-dependencies]
solana-runtime = { path = "../runtime", version = "1.6.0" }
Expand Down
4 changes: 2 additions & 2 deletions banks-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ edition = "2018"
mio = "0.7.6"
serde = { version = "1.0.118", features = ["derive"] }
solana-sdk = { path = "../sdk", version = "1.6.0" }
tarpc = { version = "0.23.0", features = ["full"] }
tarpc = { version = "0.24.1", features = ["full"] }

[dev-dependencies]
tokio = { version = "0.3.5", features = ["full"] }
tokio = { version = "1.1", features = ["full"] }

[lib]
crate-type = ["lib"]
Expand Down
7 changes: 4 additions & 3 deletions banks-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ solana-banks-interface = { path = "../banks-interface", version = "1.6.0" }
solana-runtime = { path = "../runtime", version = "1.6.0" }
solana-sdk = { path = "../sdk", version = "1.6.0" }
solana-metrics = { path = "../metrics", version = "1.6.0" }
tarpc = { version = "0.23.0", features = ["full"] }
tokio = { version = "0.3", features = ["full"] }
tokio-serde = { version = "0.6", features = ["bincode"] }
tarpc = { version = "0.24.1", features = ["full"] }
tokio = { version = "1.1", features = ["full"] }
tokio-serde = { version = "0.8", features = ["bincode"] }
tokio-stream = "0.1"

[lib]
crate-type = ["lib"]
Expand Down
3 changes: 2 additions & 1 deletion banks-server/src/rpc_banks_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use tokio::{
runtime::Runtime,
time::{self, Duration},
};
use tokio_stream::wrappers::IntervalStream;

pub struct RpcBanksService {
thread_hdl: JoinHandle<()>,
Expand All @@ -35,7 +36,7 @@ async fn start_abortable_tcp_server(
block_commitment_cache.clone(),
)
.fuse();
let interval = time::interval(Duration::from_millis(100)).fuse();
let interval = IntervalStream::new(time::interval(Duration::from_millis(100))).fuse();
pin_mut!(server, interval);
loop {
select! {
Expand Down
2 changes: 1 addition & 1 deletion clap-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ rpassword = "4.0"
solana-remote-wallet = { path = "../remote-wallet", version = "1.6.0" }
solana-sdk = { path = "../sdk", version = "1.6.0" }
thiserror = "1.0.21"
tiny-bip39 = "0.7.0"
tiny-bip39 = "0.8.0"
url = "2.1.0"
chrono = "0.4"

Expand Down
5 changes: 3 additions & 2 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ solana-vote-program = { path = "../programs/vote", version = "1.6.0" }
spl-token-v2-0 = { package = "spl-token", version = "=3.0.1", features = ["no-entrypoint"] }
tempfile = "3.1.0"
thiserror = "1.0"
tokio = { version = "0.2", features = ["full"] }
tokio-util = { version = "0.2", features = ["codec"] }
tokio = { version = "1.1", features = ["full"] }
tokio_02 = { version = "0.2", package = "tokio", features = ["full"] }
tokio-util = { version = "0.3", features = ["codec"] } # This crate needs to stay in sync with tokio_02, until that dependency can be removed
solana-rayon-threadlimit = { path = "../rayon-threadlimit", version = "1.6.0" }
trees = "0.2.1"

Expand Down
8 changes: 4 additions & 4 deletions core/src/bigtable_upload_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{
sync::{Arc, RwLock},
thread::{self, Builder, JoinHandle},
};
use tokio::runtime;
use tokio::runtime::Runtime;

// Delay uploading the largest confirmed root for this many slots. This is done in an attempt to
// ensure that the `CacheBlockTimeService` has had enough time to add the block time for the root
Expand All @@ -21,7 +21,7 @@ pub struct BigTableUploadService {

impl BigTableUploadService {
pub fn new(
runtime_handle: runtime::Handle,
runtime: Arc<Runtime>,
bigtable_ledger_storage: solana_storage_bigtable::LedgerStorage,
blockstore: Arc<Blockstore>,
block_commitment_cache: Arc<RwLock<BlockCommitmentCache>>,
Expand All @@ -32,7 +32,7 @@ impl BigTableUploadService {
.name("bigtable-upload".to_string())
.spawn(move || {
Self::run(
runtime_handle,
runtime,
bigtable_ledger_storage,
blockstore,
block_commitment_cache,
Expand All @@ -45,7 +45,7 @@ impl BigTableUploadService {
}

fn run(
runtime: runtime::Handle,
runtime: Arc<Runtime>,
bigtable_ledger_storage: solana_storage_bigtable::LedgerStorage,
blockstore: Arc<Blockstore>,
block_commitment_cache: Arc<RwLock<BlockCommitmentCache>>,
Expand Down
38 changes: 19 additions & 19 deletions core/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ use std::{
},
time::Duration,
};
use tokio::runtime;
use tokio::runtime::Runtime;

pub const MAX_REQUEST_PAYLOAD_SIZE: usize = 50 * (1 << 10); // 50kB
pub const PERFORMANCE_SAMPLES_LIMIT: usize = 720;
Expand Down Expand Up @@ -133,7 +133,7 @@ pub struct JsonRpcRequestProcessor {
cluster_info: Arc<ClusterInfo>,
genesis_hash: Hash,
transaction_sender: Arc<Mutex<Sender<TransactionInfo>>>,
runtime_handle: runtime::Handle,
runtime: Arc<Runtime>,
bigtable_ledger_storage: Option<solana_storage_bigtable::LedgerStorage>,
optimistically_confirmed_bank: Arc<RwLock<OptimisticallyConfirmedBank>>,
}
Expand Down Expand Up @@ -215,7 +215,7 @@ impl JsonRpcRequestProcessor {
health: Arc<RpcHealth>,
cluster_info: Arc<ClusterInfo>,
genesis_hash: Hash,
runtime: &runtime::Runtime,
runtime: Arc<Runtime>,
bigtable_ledger_storage: Option<solana_storage_bigtable::LedgerStorage>,
optimistically_confirmed_bank: Arc<RwLock<OptimisticallyConfirmedBank>>,
) -> (Self, Receiver<TransactionInfo>) {
Expand All @@ -232,7 +232,7 @@ impl JsonRpcRequestProcessor {
cluster_info,
genesis_hash,
transaction_sender: Arc::new(Mutex::new(sender)),
runtime_handle: runtime.handle().clone(),
runtime,
bigtable_ledger_storage,
optimistically_confirmed_bank,
},
Expand Down Expand Up @@ -269,7 +269,7 @@ impl JsonRpcRequestProcessor {
cluster_info,
genesis_hash,
transaction_sender: Arc::new(Mutex::new(sender)),
runtime_handle: runtime::Runtime::new().unwrap().handle().clone(),
runtime: Arc::new(Runtime::new().expect("Runtime")),
bigtable_ledger_storage: None,
optimistically_confirmed_bank: Arc::new(RwLock::new(OptimisticallyConfirmedBank {
bank: bank.clone(),
Expand Down Expand Up @@ -708,7 +708,7 @@ impl JsonRpcRequestProcessor {
if result.is_err() {
if let Some(bigtable_ledger_storage) = &self.bigtable_ledger_storage {
let bigtable_result = self
.runtime_handle
.runtime
.block_on(bigtable_ledger_storage.get_confirmed_block(slot));
self.check_bigtable_result(&bigtable_result)?;
return Ok(bigtable_result
Expand Down Expand Up @@ -753,7 +753,7 @@ impl JsonRpcRequestProcessor {
// [start_slot..end_slot] can be fetched from BigTable.
if let Some(bigtable_ledger_storage) = &self.bigtable_ledger_storage {
return self
.runtime_handle
.runtime
.block_on(
bigtable_ledger_storage
.get_confirmed_blocks(start_slot, (end_slot - start_slot) as usize + 1), // increment limit by 1 to ensure returned range is inclusive of both start_slot and end_slot
Expand Down Expand Up @@ -798,7 +798,7 @@ impl JsonRpcRequestProcessor {
// range can be fetched from BigTable.
if let Some(bigtable_ledger_storage) = &self.bigtable_ledger_storage {
return Ok(self
.runtime_handle
.runtime
.block_on(bigtable_ledger_storage.get_confirmed_blocks(start_slot, limit))
.unwrap_or_else(|_| vec![]));
}
Expand All @@ -825,7 +825,7 @@ impl JsonRpcRequestProcessor {
if result.is_err() || matches!(result, Ok(None)) {
if let Some(bigtable_ledger_storage) = &self.bigtable_ledger_storage {
let bigtable_result = self
.runtime_handle
.runtime
.block_on(bigtable_ledger_storage.get_confirmed_block(slot));
self.check_bigtable_result(&bigtable_result)?;
return Ok(bigtable_result
Expand Down Expand Up @@ -904,7 +904,7 @@ impl JsonRpcRequestProcessor {
})
.or_else(|| {
if let Some(bigtable_ledger_storage) = &self.bigtable_ledger_storage {
self.runtime_handle
self.runtime
.block_on(bigtable_ledger_storage.get_signature_status(&signature))
.map(Some)
.unwrap_or(None)
Expand Down Expand Up @@ -983,7 +983,7 @@ impl JsonRpcRequestProcessor {
None => {
if let Some(bigtable_ledger_storage) = &self.bigtable_ledger_storage {
return self
.runtime_handle
.runtime
.block_on(bigtable_ledger_storage.get_confirmed_transaction(&signature))
.unwrap_or(None)
.map(|confirmed| confirmed.encode(encoding));
Expand Down Expand Up @@ -1050,7 +1050,7 @@ impl JsonRpcRequestProcessor {
before = results.last().map(|x| x.signature);
}

let bigtable_results = self.runtime_handle.block_on(
let bigtable_results = self.runtime.block_on(
bigtable_ledger_storage.get_confirmed_signatures_for_address(
&address,
before.as_ref(),
Expand Down Expand Up @@ -1083,7 +1083,7 @@ impl JsonRpcRequestProcessor {

if let Some(bigtable_ledger_storage) = &self.bigtable_ledger_storage {
let bigtable_slot = self
.runtime_handle
.runtime
.block_on(bigtable_ledger_storage.get_first_available_block())
.unwrap_or(None)
.unwrap_or(slot);
Expand Down Expand Up @@ -3152,7 +3152,7 @@ pub mod tests {
RpcHealth::stub(),
cluster_info.clone(),
Hash::default(),
&runtime::Runtime::new().unwrap(),
Arc::new(tokio::runtime::Runtime::new().unwrap()),
None,
OptimisticallyConfirmedBank::locked_from_bank_forks_root(&bank_forks),
);
Expand Down Expand Up @@ -4561,7 +4561,7 @@ pub mod tests {
health.clone(),
cluster_info,
Hash::default(),
&runtime::Runtime::new().unwrap(),
Arc::new(tokio::runtime::Runtime::new().unwrap()),
None,
OptimisticallyConfirmedBank::locked_from_bank_forks_root(&bank_forks),
);
Expand Down Expand Up @@ -4757,7 +4757,7 @@ pub mod tests {
RpcHealth::stub(),
cluster_info,
Hash::default(),
&runtime::Runtime::new().unwrap(),
Arc::new(tokio::runtime::Runtime::new().unwrap()),
None,
OptimisticallyConfirmedBank::locked_from_bank_forks_root(&bank_forks),
);
Expand Down Expand Up @@ -4790,7 +4790,7 @@ pub mod tests {
RpcHealth::stub(),
cluster_info,
Hash::default(),
&runtime::Runtime::new().unwrap(),
Arc::new(tokio::runtime::Runtime::new().unwrap()),
None,
OptimisticallyConfirmedBank::locked_from_bank_forks_root(&bank_forks),
);
Expand Down Expand Up @@ -4882,7 +4882,7 @@ pub mod tests {
RpcHealth::stub(),
cluster_info,
Hash::default(),
&runtime::Runtime::new().unwrap(),
Arc::new(tokio::runtime::Runtime::new().unwrap()),
None,
OptimisticallyConfirmedBank::locked_from_bank_forks_root(&bank_forks),
);
Expand Down Expand Up @@ -6111,7 +6111,7 @@ pub mod tests {
RpcHealth::stub(),
cluster_info,
Hash::default(),
&runtime::Runtime::new().unwrap(),
Arc::new(tokio::runtime::Runtime::new().unwrap()),
None,
optimistically_confirmed_bank.clone(),
);
Expand Down
28 changes: 14 additions & 14 deletions core/src/rpc_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use std::{
sync::{mpsc::channel, Arc, Mutex, RwLock},
thread::{self, Builder, JoinHandle},
};
use tokio::{self, runtime};
use tokio::runtime;
use tokio_util::codec::{BytesCodec, FramedRead};

pub struct JsonRpcService {
Expand All @@ -42,7 +42,6 @@ pub struct JsonRpcService {
pub request_processor: JsonRpcRequestProcessor, // Used only by test_rpc_new()...

close_handle: Option<CloseHandle>,
runtime: runtime::Runtime,
}

struct RpcRequestMiddleware {
Expand Down Expand Up @@ -135,7 +134,8 @@ impl RpcRequestMiddleware {
RequestMiddlewareAction::Respond {
should_validate_hosts: true,
response: Box::pin(async {
match tokio::fs::File::open(filename).await {
// Stuck on tokio 0.2 until the jsonrpc crates upgrade
match tokio_02::fs::File::open(filename).await {
Err(_) => Ok(Self::internal_server_error()),
Ok(file) => {
let stream =
Expand Down Expand Up @@ -263,12 +263,13 @@ impl JsonRpcService {
));

let tpu_address = cluster_info.my_contact_info().tpu;
let mut runtime = runtime::Builder::new()
.threaded_scheduler()
.thread_name("rpc-runtime")
.enable_all()
.build()
.expect("Runtime");
let runtime = Arc::new(
runtime::Builder::new_multi_thread()
.thread_name("rpc-runtime")
.enable_all()
.build()
.expect("Runtime"),
);

let exit_bigtable_ledger_upload_service = Arc::new(AtomicBool::new(false));

Expand All @@ -285,7 +286,7 @@ impl JsonRpcService {
let bigtable_ledger_upload_service = if config.enable_bigtable_ledger_upload
{
Some(Arc::new(BigTableUploadService::new(
runtime.handle().clone(),
runtime.clone(),
bigtable_ledger_storage.clone(),
blockstore.clone(),
block_commitment_cache.clone(),
Expand Down Expand Up @@ -318,7 +319,7 @@ impl JsonRpcService {
health.clone(),
cluster_info.clone(),
genesis_hash,
&runtime,
runtime,
bigtable_ledger_storage,
optimistically_confirmed_bank,
);
Expand Down Expand Up @@ -346,7 +347,8 @@ impl JsonRpcService {
// so that we avoid the single-threaded event loops from being created automatically by
// jsonrpc for threads when .threads(N > 1) is given.
let event_loop = {
runtime::Builder::new()
// Stuck on tokio 0.2 until the jsonrpc crates upgrade
tokio_02::runtime::Builder::new()
.core_threads(rpc_threads)
.threaded_scheduler()
.enable_all()
Expand Down Expand Up @@ -409,7 +411,6 @@ impl JsonRpcService {
.register_exit(Box::new(move || close_handle_.close()));
Self {
thread_hdl,
runtime,
#[cfg(test)]
request_processor: test_request_processor,
close_handle: Some(close_handle),
Expand All @@ -423,7 +424,6 @@ impl JsonRpcService {
}

pub fn join(self) -> thread::Result<()> {
self.runtime.shutdown_background();
self.thread_hdl.join()
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/rpc_subscriptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@ pub(crate) mod tests {
use std::{fmt::Debug, sync::mpsc::channel};
use tokio::{
runtime::Runtime,
time::{delay_for, timeout},
time::{sleep, timeout},
};

pub(crate) fn robust_poll_or_panic<T: Debug + Send + 'static>(
Expand All @@ -1317,7 +1317,7 @@ pub(crate) mod tests {
(None, _) => panic!("unexpected end of stream"),
}

delay_for(Duration::from_millis(RECEIVE_DELAY_MILLIS * 2)).await;
sleep(Duration::from_millis(RECEIVE_DELAY_MILLIS * 2)).await;
});
inner_receiver.recv().expect("recv error")
}
Expand Down
Loading

0 comments on commit d1563f0

Please sign in to comment.