mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 03:31:45 +00:00
Update to tokio 1.1 (#2172)
## Issue Addressed resolves #2129 resolves #2099 addresses some of #1712 unblocks #2076 unblocks #2153 ## Proposed Changes - Updates all the dependencies mentioned in #2129, except for web3. They haven't merged their tokio 1.0 update because they are waiting on some dependencies of their own. Since we only use web3 in tests, I think updating it in a separate issue is fine. If they are able to merge soon though, I can update in this PR. - Updates `tokio_util` to 0.6.2 and `bytes` to 1.0.1. - We haven't made a discv5 release since merging tokio 1.0 updates so I'm using a commit rather than release atm. **Edit:** I think we should merge an update of `tokio_util` to 0.6.2 into discv5 before this release because it has panic fixes in `DelayQueue` --> PR in discv5: https://github.com/sigp/discv5/pull/58 ## Additional Info tokio 1.0 changes that required some changes in lighthouse: - `interval.next().await.is_some()` -> `interval.tick().await` - `sleep` future is now `!Unpin` -> https://github.com/tokio-rs/tokio/issues/3028 - `try_recv` has been temporarily removed from `mpsc` -> https://github.com/tokio-rs/tokio/issues/3350 - stream features have moved to `tokio-stream` and `broadcast::Receiver::into_stream()` has been temporarily removed -> `https://github.com/tokio-rs/tokio/issues/2870 - I've copied over the `BroadcastStream` wrapper from this PR, but can update to use `tokio-stream` once it's merged https://github.com/tokio-rs/tokio/pull/3384 Co-authored-by: realbigsean <seananderson33@gmail.com>
This commit is contained in:
@@ -15,6 +15,7 @@ use eth2_libp2p::{
|
||||
Enr, EnrExt, NetworkGlobals, PeerId,
|
||||
};
|
||||
use futures::stream::{Stream, StreamExt};
|
||||
use futures::FutureExt;
|
||||
use http_api::{Config, Context};
|
||||
use network::NetworkMessage;
|
||||
use state_processing::per_slot_processing;
|
||||
@@ -25,7 +26,6 @@ use std::sync::Arc;
|
||||
use tokio::sync::mpsc;
|
||||
use tokio::sync::oneshot;
|
||||
use tokio::time::Duration;
|
||||
use tokio_compat_02::FutureExt;
|
||||
use tree_hash::TreeHash;
|
||||
use types::{
|
||||
test_utils::generate_deterministic_keypairs, AggregateSignature, BeaconState, BitList, Domain,
|
||||
@@ -933,7 +933,7 @@ impl ApiTester {
|
||||
self.client.post_beacon_blocks(next_block).await.unwrap();
|
||||
|
||||
assert!(
|
||||
self.network_rx.try_recv().is_ok(),
|
||||
self.network_rx.recv().await.is_some(),
|
||||
"valid blocks should be sent to network"
|
||||
);
|
||||
|
||||
@@ -947,7 +947,7 @@ impl ApiTester {
|
||||
assert!(self.client.post_beacon_blocks(&next_block).await.is_err());
|
||||
|
||||
assert!(
|
||||
self.network_rx.try_recv().is_ok(),
|
||||
self.network_rx.recv().await.is_some(),
|
||||
"invalid blocks should be sent to network"
|
||||
);
|
||||
|
||||
@@ -997,7 +997,7 @@ impl ApiTester {
|
||||
.unwrap();
|
||||
|
||||
assert!(
|
||||
self.network_rx.try_recv().is_ok(),
|
||||
self.network_rx.recv().await.is_some(),
|
||||
"valid attestation should be sent to network"
|
||||
);
|
||||
|
||||
@@ -1034,7 +1034,7 @@ impl ApiTester {
|
||||
}
|
||||
|
||||
assert!(
|
||||
self.network_rx.try_recv().is_ok(),
|
||||
self.network_rx.recv().await.is_some(),
|
||||
"if some attestations are valid, we should send them to the network"
|
||||
);
|
||||
|
||||
@@ -1064,7 +1064,7 @@ impl ApiTester {
|
||||
.unwrap();
|
||||
|
||||
assert!(
|
||||
self.network_rx.try_recv().is_ok(),
|
||||
self.network_rx.recv().await.is_some(),
|
||||
"valid attester slashing should be sent to network"
|
||||
);
|
||||
|
||||
@@ -1081,7 +1081,7 @@ impl ApiTester {
|
||||
.unwrap_err();
|
||||
|
||||
assert!(
|
||||
self.network_rx.try_recv().is_err(),
|
||||
self.network_rx.recv().now_or_never().is_none(),
|
||||
"invalid attester slashing should not be sent to network"
|
||||
);
|
||||
|
||||
@@ -1110,7 +1110,7 @@ impl ApiTester {
|
||||
.unwrap();
|
||||
|
||||
assert!(
|
||||
self.network_rx.try_recv().is_ok(),
|
||||
self.network_rx.recv().await.is_some(),
|
||||
"valid proposer slashing should be sent to network"
|
||||
);
|
||||
|
||||
@@ -1127,7 +1127,7 @@ impl ApiTester {
|
||||
.unwrap_err();
|
||||
|
||||
assert!(
|
||||
self.network_rx.try_recv().is_err(),
|
||||
self.network_rx.recv().now_or_never().is_none(),
|
||||
"invalid proposer slashing should not be sent to network"
|
||||
);
|
||||
|
||||
@@ -1156,7 +1156,7 @@ impl ApiTester {
|
||||
.unwrap();
|
||||
|
||||
assert!(
|
||||
self.network_rx.try_recv().is_ok(),
|
||||
self.network_rx.recv().await.is_some(),
|
||||
"valid exit should be sent to network"
|
||||
);
|
||||
|
||||
@@ -1173,7 +1173,7 @@ impl ApiTester {
|
||||
.unwrap_err();
|
||||
|
||||
assert!(
|
||||
self.network_rx.try_recv().is_err(),
|
||||
self.network_rx.recv().now_or_never().is_none(),
|
||||
"invalid exit should not be sent to network"
|
||||
);
|
||||
|
||||
@@ -1822,7 +1822,7 @@ impl ApiTester {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(self.network_rx.try_recv().is_ok());
|
||||
assert!(self.network_rx.recv().await.is_some());
|
||||
|
||||
self
|
||||
}
|
||||
@@ -1837,7 +1837,7 @@ impl ApiTester {
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
assert!(self.network_rx.try_recv().is_err());
|
||||
assert!(self.network_rx.recv().now_or_never().is_none());
|
||||
|
||||
self
|
||||
}
|
||||
@@ -1856,7 +1856,7 @@ impl ApiTester {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
self.network_rx.try_recv().unwrap();
|
||||
self.network_rx.recv().now_or_never().unwrap();
|
||||
|
||||
self
|
||||
}
|
||||
@@ -2127,83 +2127,71 @@ async fn poll_events<S: Stream<Item = Result<EventKind<T>, eth2::Error>> + Unpin
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn get_events() {
|
||||
ApiTester::new().test_get_events().compat().await;
|
||||
ApiTester::new().test_get_events().await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn get_events_from_genesis() {
|
||||
ApiTester::new_from_genesis()
|
||||
.test_get_events_from_genesis()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn beacon_get() {
|
||||
async {
|
||||
ApiTester::new()
|
||||
.test_beacon_genesis()
|
||||
.await
|
||||
.test_beacon_states_root()
|
||||
.await
|
||||
.test_beacon_states_fork()
|
||||
.await
|
||||
.test_beacon_states_finality_checkpoints()
|
||||
.await
|
||||
.test_beacon_states_validators()
|
||||
.await
|
||||
.test_beacon_states_validator_balances()
|
||||
.await
|
||||
.test_beacon_states_committees()
|
||||
.await
|
||||
.test_beacon_states_validator_id()
|
||||
.await
|
||||
.test_beacon_headers_all_slots()
|
||||
.await
|
||||
.test_beacon_headers_all_parents()
|
||||
.await
|
||||
.test_beacon_headers_block_id()
|
||||
.await
|
||||
.test_beacon_blocks()
|
||||
.await
|
||||
.test_beacon_blocks_attestations()
|
||||
.await
|
||||
.test_beacon_blocks_root()
|
||||
.await
|
||||
.test_get_beacon_pool_attestations()
|
||||
.await
|
||||
.test_get_beacon_pool_attester_slashings()
|
||||
.await
|
||||
.test_get_beacon_pool_proposer_slashings()
|
||||
.await
|
||||
.test_get_beacon_pool_voluntary_exits()
|
||||
.await;
|
||||
}
|
||||
.compat()
|
||||
.await;
|
||||
ApiTester::new()
|
||||
.test_beacon_genesis()
|
||||
.await
|
||||
.test_beacon_states_root()
|
||||
.await
|
||||
.test_beacon_states_fork()
|
||||
.await
|
||||
.test_beacon_states_finality_checkpoints()
|
||||
.await
|
||||
.test_beacon_states_validators()
|
||||
.await
|
||||
.test_beacon_states_validator_balances()
|
||||
.await
|
||||
.test_beacon_states_committees()
|
||||
.await
|
||||
.test_beacon_states_validator_id()
|
||||
.await
|
||||
.test_beacon_headers_all_slots()
|
||||
.await
|
||||
.test_beacon_headers_all_parents()
|
||||
.await
|
||||
.test_beacon_headers_block_id()
|
||||
.await
|
||||
.test_beacon_blocks()
|
||||
.await
|
||||
.test_beacon_blocks_attestations()
|
||||
.await
|
||||
.test_beacon_blocks_root()
|
||||
.await
|
||||
.test_get_beacon_pool_attestations()
|
||||
.await
|
||||
.test_get_beacon_pool_attester_slashings()
|
||||
.await
|
||||
.test_get_beacon_pool_proposer_slashings()
|
||||
.await
|
||||
.test_get_beacon_pool_voluntary_exits()
|
||||
.await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn post_beacon_blocks_valid() {
|
||||
ApiTester::new()
|
||||
.test_post_beacon_blocks_valid()
|
||||
.compat()
|
||||
.await;
|
||||
ApiTester::new().test_post_beacon_blocks_valid().await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn post_beacon_blocks_invalid() {
|
||||
ApiTester::new()
|
||||
.test_post_beacon_blocks_invalid()
|
||||
.compat()
|
||||
.await;
|
||||
ApiTester::new().test_post_beacon_blocks_invalid().await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn beacon_pools_post_attestations_valid() {
|
||||
ApiTester::new()
|
||||
.test_post_beacon_pool_attestations_valid()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -2211,7 +2199,6 @@ async fn beacon_pools_post_attestations_valid() {
|
||||
async fn beacon_pools_post_attestations_invalid() {
|
||||
ApiTester::new()
|
||||
.test_post_beacon_pool_attestations_invalid()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -2219,7 +2206,6 @@ async fn beacon_pools_post_attestations_invalid() {
|
||||
async fn beacon_pools_post_attester_slashings_valid() {
|
||||
ApiTester::new()
|
||||
.test_post_beacon_pool_attester_slashings_valid()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -2227,7 +2213,6 @@ async fn beacon_pools_post_attester_slashings_valid() {
|
||||
async fn beacon_pools_post_attester_slashings_invalid() {
|
||||
ApiTester::new()
|
||||
.test_post_beacon_pool_attester_slashings_invalid()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -2235,7 +2220,6 @@ async fn beacon_pools_post_attester_slashings_invalid() {
|
||||
async fn beacon_pools_post_proposer_slashings_valid() {
|
||||
ApiTester::new()
|
||||
.test_post_beacon_pool_proposer_slashings_valid()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -2243,7 +2227,6 @@ async fn beacon_pools_post_proposer_slashings_valid() {
|
||||
async fn beacon_pools_post_proposer_slashings_invalid() {
|
||||
ApiTester::new()
|
||||
.test_post_beacon_pool_proposer_slashings_invalid()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -2251,7 +2234,6 @@ async fn beacon_pools_post_proposer_slashings_invalid() {
|
||||
async fn beacon_pools_post_voluntary_exits_valid() {
|
||||
ApiTester::new()
|
||||
.test_post_beacon_pool_voluntary_exits_valid()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -2259,7 +2241,6 @@ async fn beacon_pools_post_voluntary_exits_valid() {
|
||||
async fn beacon_pools_post_voluntary_exits_invalid() {
|
||||
ApiTester::new()
|
||||
.test_post_beacon_pool_voluntary_exits_invalid()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -2267,13 +2248,10 @@ async fn beacon_pools_post_voluntary_exits_invalid() {
|
||||
async fn config_get() {
|
||||
ApiTester::new()
|
||||
.test_get_config_fork_schedule()
|
||||
.compat()
|
||||
.await
|
||||
.test_get_config_spec()
|
||||
.compat()
|
||||
.await
|
||||
.test_get_config_deposit_contract()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -2281,10 +2259,8 @@ async fn config_get() {
|
||||
async fn debug_get() {
|
||||
ApiTester::new()
|
||||
.test_get_debug_beacon_states()
|
||||
.compat()
|
||||
.await
|
||||
.test_get_debug_beacon_heads()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -2292,34 +2268,24 @@ async fn debug_get() {
|
||||
async fn node_get() {
|
||||
ApiTester::new()
|
||||
.test_get_node_version()
|
||||
.compat()
|
||||
.await
|
||||
.test_get_node_syncing()
|
||||
.compat()
|
||||
.await
|
||||
.test_get_node_identity()
|
||||
.compat()
|
||||
.await
|
||||
.test_get_node_health()
|
||||
.compat()
|
||||
.await
|
||||
.test_get_node_peers_by_id()
|
||||
.compat()
|
||||
.await
|
||||
.test_get_node_peers()
|
||||
.compat()
|
||||
.await
|
||||
.test_get_node_peer_count()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn get_validator_duties_attester() {
|
||||
ApiTester::new()
|
||||
.test_get_validator_duties_attester()
|
||||
.compat()
|
||||
.await;
|
||||
ApiTester::new().test_get_validator_duties_attester().await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
@@ -2327,16 +2293,12 @@ async fn get_validator_duties_attester_with_skip_slots() {
|
||||
ApiTester::new()
|
||||
.skip_slots(E::slots_per_epoch() * 2)
|
||||
.test_get_validator_duties_attester()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn get_validator_duties_proposer() {
|
||||
ApiTester::new()
|
||||
.test_get_validator_duties_proposer()
|
||||
.compat()
|
||||
.await;
|
||||
ApiTester::new().test_get_validator_duties_proposer().await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
@@ -2344,13 +2306,12 @@ async fn get_validator_duties_proposer_with_skip_slots() {
|
||||
ApiTester::new()
|
||||
.skip_slots(E::slots_per_epoch() * 2)
|
||||
.test_get_validator_duties_proposer()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn block_production() {
|
||||
ApiTester::new().test_block_production().compat().await;
|
||||
ApiTester::new().test_block_production().await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
@@ -2358,16 +2319,12 @@ async fn block_production_with_skip_slots() {
|
||||
ApiTester::new()
|
||||
.skip_slots(E::slots_per_epoch() * 2)
|
||||
.test_block_production()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn get_validator_attestation_data() {
|
||||
ApiTester::new()
|
||||
.test_get_validator_attestation_data()
|
||||
.compat()
|
||||
.await;
|
||||
ApiTester::new().test_get_validator_attestation_data().await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
@@ -2375,7 +2332,6 @@ async fn get_validator_attestation_data_with_skip_slots() {
|
||||
ApiTester::new()
|
||||
.skip_slots(E::slots_per_epoch() * 2)
|
||||
.test_get_validator_attestation_data()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -2383,7 +2339,6 @@ async fn get_validator_attestation_data_with_skip_slots() {
|
||||
async fn get_validator_aggregate_attestation() {
|
||||
ApiTester::new()
|
||||
.test_get_validator_aggregate_attestation()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -2392,7 +2347,6 @@ async fn get_validator_aggregate_attestation_with_skip_slots() {
|
||||
ApiTester::new()
|
||||
.skip_slots(E::slots_per_epoch() * 2)
|
||||
.test_get_validator_aggregate_attestation()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -2400,7 +2354,6 @@ async fn get_validator_aggregate_attestation_with_skip_slots() {
|
||||
async fn get_validator_aggregate_and_proofs_valid() {
|
||||
ApiTester::new()
|
||||
.test_get_validator_aggregate_and_proofs_valid()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -2409,7 +2362,6 @@ async fn get_validator_aggregate_and_proofs_valid_with_skip_slots() {
|
||||
ApiTester::new()
|
||||
.skip_slots(E::slots_per_epoch() * 2)
|
||||
.test_get_validator_aggregate_and_proofs_valid()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -2417,7 +2369,6 @@ async fn get_validator_aggregate_and_proofs_valid_with_skip_slots() {
|
||||
async fn get_validator_aggregate_and_proofs_invalid() {
|
||||
ApiTester::new()
|
||||
.test_get_validator_aggregate_and_proofs_invalid()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -2426,7 +2377,6 @@ async fn get_validator_aggregate_and_proofs_invalid_with_skip_slots() {
|
||||
ApiTester::new()
|
||||
.skip_slots(E::slots_per_epoch() * 2)
|
||||
.test_get_validator_aggregate_and_proofs_invalid()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -2434,7 +2384,6 @@ async fn get_validator_aggregate_and_proofs_invalid_with_skip_slots() {
|
||||
async fn get_validator_beacon_committee_subscriptions() {
|
||||
ApiTester::new()
|
||||
.test_get_validator_beacon_committee_subscriptions()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -2442,33 +2391,23 @@ async fn get_validator_beacon_committee_subscriptions() {
|
||||
async fn lighthouse_endpoints() {
|
||||
ApiTester::new()
|
||||
.test_get_lighthouse_health()
|
||||
.compat()
|
||||
.await
|
||||
.test_get_lighthouse_syncing()
|
||||
.compat()
|
||||
.await
|
||||
.test_get_lighthouse_proto_array()
|
||||
.compat()
|
||||
.await
|
||||
.test_get_lighthouse_validator_inclusion()
|
||||
.compat()
|
||||
.await
|
||||
.test_get_lighthouse_validator_inclusion_global()
|
||||
.compat()
|
||||
.await
|
||||
.test_get_lighthouse_eth1_syncing()
|
||||
.compat()
|
||||
.await
|
||||
.test_get_lighthouse_eth1_block_cache()
|
||||
.compat()
|
||||
.await
|
||||
.test_get_lighthouse_eth1_deposit_cache()
|
||||
.compat()
|
||||
.await
|
||||
.test_get_lighthouse_beacon_states_ssz()
|
||||
.compat()
|
||||
.await
|
||||
.test_get_lighthouse_staking()
|
||||
.compat()
|
||||
.await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user