2019-11-29 11:25:36 +00:00
|
|
|
#![allow(clippy::type_complexity)]
|
|
|
|
#![allow(clippy::cognitive_complexity)]
|
|
|
|
|
2020-05-18 08:13:03 +00:00
|
|
|
use super::methods::{RPCCodedResponse, RequestId, ResponseTermination};
|
2020-05-03 13:17:12 +00:00
|
|
|
use super::protocol::{Protocol, RPCError, RPCProtocol, RPCRequest};
|
2020-06-05 03:07:59 +00:00
|
|
|
use super::{RPCReceived, RPCSend};
|
2019-07-16 12:32:37 +00:00
|
|
|
use crate::rpc::protocol::{InboundFramed, OutboundFramed};
|
2019-07-09 05:44:23 +00:00
|
|
|
use fnv::FnvHashMap;
|
|
|
|
use futures::prelude::*;
|
2020-05-03 13:17:12 +00:00
|
|
|
use libp2p::core::upgrade::{
|
|
|
|
InboundUpgrade, NegotiationError, OutboundUpgrade, ProtocolError, UpgradeError,
|
|
|
|
};
|
2019-08-10 01:44:17 +00:00
|
|
|
use libp2p::swarm::protocols_handler::{
|
2019-07-09 05:44:23 +00:00
|
|
|
KeepAlive, ProtocolsHandler, ProtocolsHandlerEvent, ProtocolsHandlerUpgrErr, SubstreamProtocol,
|
2019-07-06 11:32:32 +00:00
|
|
|
};
|
2020-05-17 11:16:48 +00:00
|
|
|
use libp2p::swarm::NegotiatedSubstream;
|
2020-04-09 04:28:37 +00:00
|
|
|
use slog::{crit, debug, error, trace, warn};
|
2019-07-06 11:32:32 +00:00
|
|
|
use smallvec::SmallVec;
|
2020-05-17 11:16:48 +00:00
|
|
|
use std::{
|
|
|
|
collections::hash_map::Entry,
|
|
|
|
pin::Pin,
|
|
|
|
task::{Context, Poll},
|
|
|
|
time::{Duration, Instant},
|
|
|
|
};
|
2020-06-18 01:53:08 +00:00
|
|
|
use tokio::time::{delay_queue, delay_until, Delay, DelayQueue, Instant as TInstant};
|
Initial work towards v0.2.0 (#924)
* Remove ping protocol
* Initial renaming of network services
* Correct rebasing relative to latest master
* Start updating types
* Adds HashMapDelay struct to utils
* Initial network restructure
* Network restructure. Adds new types for v0.2.0
* Removes build artefacts
* Shift validation to beacon chain
* Temporarily remove gossip validation
This is to be updated to match current optimisation efforts.
* Adds AggregateAndProof
* Begin rebuilding pubsub encoding/decoding
* Signature hacking
* Shift gossipsup decoding into eth2_libp2p
* Existing EF tests passing with fake_crypto
* Shifts block encoding/decoding into RPC
* Delete outdated API spec
* All release tests passing bar genesis state parsing
* Update and test YamlConfig
* Update to spec v0.10 compatible BLS
* Updates to BLS EF tests
* Add EF test for AggregateVerify
And delete unused hash2curve tests for uncompressed points
* Update EF tests to v0.10.1
* Use optional block root correctly in block proc
* Use genesis fork in deposit domain. All tests pass
* Fast aggregate verify test
* Update REST API docs
* Fix unused import
* Bump spec tags to v0.10.1
* Add `seconds_per_eth1_block` to chainspec
* Update to timestamp based eth1 voting scheme
* Return None from `get_votes_to_consider` if block cache is empty
* Handle overflows in `is_candidate_block`
* Revert to failing tests
* Fix eth1 data sets test
* Choose default vote according to spec
* Fix collect_valid_votes tests
* Fix `get_votes_to_consider` to choose all eligible blocks
* Uncomment winning_vote tests
* Add comments; remove unused code
* Reduce seconds_per_eth1_block for simulation
* Addressed review comments
* Add test for default vote case
* Fix logs
* Remove unused functions
* Meter default eth1 votes
* Fix comments
* Progress on attestation service
* Address review comments; remove unused dependency
* Initial work on removing libp2p lock
* Add LRU caches to store (rollup)
* Update attestation validation for DB changes (WIP)
* Initial version of should_forward_block
* Scaffold
* Progress on attestation validation
Also, consolidate prod+testing slot clocks so that they share much
of the same implementation and can both handle sub-slot time changes.
* Removes lock from libp2p service
* Completed network lock removal
* Finish(?) attestation processing
* Correct network termination future
* Add slot check to block check
* Correct fmt issues
* Remove Drop implementation for network service
* Add first attempt at attestation proc. re-write
* Add version 2 of attestation processing
* Minor fixes
* Add validator pubkey cache
* Make get_indexed_attestation take a committee
* Link signature processing into new attn verification
* First working version
* Ensure pubkey cache is updated
* Add more metrics, slight optimizations
* Clone committee cache during attestation processing
* Update shuffling cache during block processing
* Remove old commented-out code
* Fix shuffling cache insert bug
* Used indexed attestation in fork choice
* Restructure attn processing, add metrics
* Add more detailed metrics
* Tidy, fix failing tests
* Fix failing tests, tidy
* Address reviewers suggestions
* Disable/delete two outdated tests
* Modification of validator for subscriptions
* Add slot signing to validator client
* Further progress on validation subscription
* Adds necessary validator subscription functionality
* Add new Pubkeys struct to signature_sets
* Refactor with functional approach
* Update beacon chain
* Clean up validator <-> beacon node http types
* Add aggregator status to ValidatorDuty
* Impl Clone for manual slot clock
* Fix minor errors
* Further progress validator client subscription
* Initial subscription and aggregation handling
* Remove decompressed member from pubkey bytes
* Progress to modifying val client for attestation aggregation
* First draft of validator client upgrade for aggregate attestations
* Add hashmap for indices lookup
* Add state cache, remove store cache
* Only build the head committee cache
* Removes lock on a network channel
* Partially implement beacon node subscription http api
* Correct compilation issues
* Change `get_attesting_indices` to use Vec
* Fix failing test
* Partial implementation of timer
* Adds timer, removes exit_future, http api to op pool
* Partial multiple aggregate attestation handling
* Permits bulk messages accross gossipsub network channel
* Correct compile issues
* Improve gosispsub messaging and correct rest api helpers
* Added global gossipsub subscriptions
* Update validator subscriptions data structs
* Tidy
* Re-structure validator subscriptions
* Initial handling of subscriptions
* Re-structure network service
* Add pubkey cache persistence file
* Add more comments
* Integrate persistence file into builder
* Add pubkey cache tests
* Add HashSetDelay and introduce into attestation service
* Handles validator subscriptions
* Add data_dir to beacon chain builder
* Remove Option in pubkey cache persistence file
* Ensure consistency between datadir/data_dir
* Fix failing network test
* Peer subnet discovery gets queued for future subscriptions
* Reorganise attestation service functions
* Initial wiring of attestation service
* First draft of attestation service timing logic
* Correct minor typos
* Tidy
* Fix todos
* Improve tests
* Add PeerInfo to connected peers mapping
* Fix compile error
* Fix compile error from merge
* Split up block processing metrics
* Tidy
* Refactor get_pubkey_from_state
* Remove commented-out code
* Rename state_cache -> checkpoint_cache
* Rename Checkpoint -> Snapshot
* Tidy, add comments
* Tidy up find_head function
* Change some checkpoint -> snapshot
* Add tests
* Expose max_len
* Remove dead code
* Tidy
* Fix bug
* Add sync-speed metric
* Add first attempt at VerifiableBlock
* Start integrating into beacon chain
* Integrate VerifiableBlock
* Rename VerifableBlock -> PartialBlockVerification
* Add start of typed methods
* Add progress
* Add further progress
* Rename structs
* Add full block verification to block_processing.rs
* Further beacon chain integration
* Update checks for gossip
* Add todo
* Start adding segement verification
* Add passing chain segement test
* Initial integration with batch sync
* Minor changes
* Tidy, add more error checking
* Start adding chain_segment tests
* Finish invalid signature tests
* Include single and gossip verified blocks in tests
* Add gossip verification tests
* Start adding docs
* Finish adding comments to block_processing.rs
* Rename block_processing.rs -> block_verification
* Start removing old block processing code
* Fixes beacon_chain compilation
* Fix project-wide compile errors
* Remove old code
* Correct code to pass all tests
* Fix bug with beacon proposer index
* Fix shim for BlockProcessingError
* Only process one epoch at a time
* Fix loop in chain segment processing
* Correct tests from master merge
* Add caching for state.eth1_data_votes
* Add BeaconChain::validator_pubkey
* Revert "Add caching for state.eth1_data_votes"
This reverts commit cd73dcd6434fb8d8e6bf30c5356355598ea7b78e.
Co-authored-by: Grant Wuerker <gwuerker@gmail.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
Co-authored-by: Michael Sproul <micsproul@gmail.com>
Co-authored-by: pawan <pawandhananjay@gmail.com>
Co-authored-by: Paul Hauner <paul@paulhauner.com>
2020-03-17 06:24:44 +00:00
|
|
|
use types::EthSpec;
|
2019-11-27 01:47:46 +00:00
|
|
|
|
|
|
|
//TODO: Implement check_timeout() on the substream types
|
2019-07-06 11:32:32 +00:00
|
|
|
|
2019-08-29 11:23:28 +00:00
|
|
|
/// The time (in seconds) before a substream that is awaiting a response from the user times out.
|
|
|
|
pub const RESPONSE_TIMEOUT: u64 = 10;
|
2019-07-06 11:32:32 +00:00
|
|
|
|
2019-12-09 07:50:21 +00:00
|
|
|
/// The number of times to retry an outbound upgrade in the case of IO errors.
|
|
|
|
const IO_ERROR_RETRIES: u8 = 3;
|
|
|
|
|
2020-06-18 01:53:08 +00:00
|
|
|
/// Maximum time given to the handler to perform shutdown operations.
|
|
|
|
const SHUTDOWN_TIMEOUT_SECS: u8 = 15;
|
|
|
|
|
2020-06-05 03:07:59 +00:00
|
|
|
/// Identifier of inbound and outbound substreams from the handler's perspective.
|
|
|
|
#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq)]
|
|
|
|
pub struct SubstreamId(usize);
|
|
|
|
|
|
|
|
/// An error encoutered by the handler.
|
|
|
|
pub enum HandlerErr {
|
|
|
|
/// An error ocurred for this peer's request. This can occurr during protocol negotiation,
|
|
|
|
/// message passing, or if the handler identifies that we are sending an error reponse to the peer.
|
|
|
|
Inbound {
|
|
|
|
/// Id of the peer's request for which an error occurred.
|
|
|
|
id: SubstreamId,
|
|
|
|
/// Information of the negotiated protocol.
|
|
|
|
proto: Protocol,
|
|
|
|
/// The error that ocurred.
|
|
|
|
error: RPCError,
|
|
|
|
},
|
|
|
|
/// An error ocurred for this request. Such error can occurr during protocol negotiation,
|
|
|
|
/// message passing, or if we successfully received a response from the peer, but this response
|
|
|
|
/// indicates an error.
|
|
|
|
Outbound {
|
|
|
|
/// Application-given Id of the request for which an error occurred.
|
|
|
|
id: RequestId,
|
|
|
|
/// Information of the protocol.
|
|
|
|
proto: Protocol,
|
|
|
|
/// The error that ocurred.
|
|
|
|
error: RPCError,
|
|
|
|
},
|
|
|
|
}
|
2019-11-27 01:47:46 +00:00
|
|
|
|
2019-07-06 11:32:32 +00:00
|
|
|
/// Implementation of `ProtocolsHandler` for the RPC protocol.
|
2020-05-17 11:16:48 +00:00
|
|
|
pub struct RPCHandler<TSpec>
|
2019-07-16 12:32:37 +00:00
|
|
|
where
|
Initial work towards v0.2.0 (#924)
* Remove ping protocol
* Initial renaming of network services
* Correct rebasing relative to latest master
* Start updating types
* Adds HashMapDelay struct to utils
* Initial network restructure
* Network restructure. Adds new types for v0.2.0
* Removes build artefacts
* Shift validation to beacon chain
* Temporarily remove gossip validation
This is to be updated to match current optimisation efforts.
* Adds AggregateAndProof
* Begin rebuilding pubsub encoding/decoding
* Signature hacking
* Shift gossipsup decoding into eth2_libp2p
* Existing EF tests passing with fake_crypto
* Shifts block encoding/decoding into RPC
* Delete outdated API spec
* All release tests passing bar genesis state parsing
* Update and test YamlConfig
* Update to spec v0.10 compatible BLS
* Updates to BLS EF tests
* Add EF test for AggregateVerify
And delete unused hash2curve tests for uncompressed points
* Update EF tests to v0.10.1
* Use optional block root correctly in block proc
* Use genesis fork in deposit domain. All tests pass
* Fast aggregate verify test
* Update REST API docs
* Fix unused import
* Bump spec tags to v0.10.1
* Add `seconds_per_eth1_block` to chainspec
* Update to timestamp based eth1 voting scheme
* Return None from `get_votes_to_consider` if block cache is empty
* Handle overflows in `is_candidate_block`
* Revert to failing tests
* Fix eth1 data sets test
* Choose default vote according to spec
* Fix collect_valid_votes tests
* Fix `get_votes_to_consider` to choose all eligible blocks
* Uncomment winning_vote tests
* Add comments; remove unused code
* Reduce seconds_per_eth1_block for simulation
* Addressed review comments
* Add test for default vote case
* Fix logs
* Remove unused functions
* Meter default eth1 votes
* Fix comments
* Progress on attestation service
* Address review comments; remove unused dependency
* Initial work on removing libp2p lock
* Add LRU caches to store (rollup)
* Update attestation validation for DB changes (WIP)
* Initial version of should_forward_block
* Scaffold
* Progress on attestation validation
Also, consolidate prod+testing slot clocks so that they share much
of the same implementation and can both handle sub-slot time changes.
* Removes lock from libp2p service
* Completed network lock removal
* Finish(?) attestation processing
* Correct network termination future
* Add slot check to block check
* Correct fmt issues
* Remove Drop implementation for network service
* Add first attempt at attestation proc. re-write
* Add version 2 of attestation processing
* Minor fixes
* Add validator pubkey cache
* Make get_indexed_attestation take a committee
* Link signature processing into new attn verification
* First working version
* Ensure pubkey cache is updated
* Add more metrics, slight optimizations
* Clone committee cache during attestation processing
* Update shuffling cache during block processing
* Remove old commented-out code
* Fix shuffling cache insert bug
* Used indexed attestation in fork choice
* Restructure attn processing, add metrics
* Add more detailed metrics
* Tidy, fix failing tests
* Fix failing tests, tidy
* Address reviewers suggestions
* Disable/delete two outdated tests
* Modification of validator for subscriptions
* Add slot signing to validator client
* Further progress on validation subscription
* Adds necessary validator subscription functionality
* Add new Pubkeys struct to signature_sets
* Refactor with functional approach
* Update beacon chain
* Clean up validator <-> beacon node http types
* Add aggregator status to ValidatorDuty
* Impl Clone for manual slot clock
* Fix minor errors
* Further progress validator client subscription
* Initial subscription and aggregation handling
* Remove decompressed member from pubkey bytes
* Progress to modifying val client for attestation aggregation
* First draft of validator client upgrade for aggregate attestations
* Add hashmap for indices lookup
* Add state cache, remove store cache
* Only build the head committee cache
* Removes lock on a network channel
* Partially implement beacon node subscription http api
* Correct compilation issues
* Change `get_attesting_indices` to use Vec
* Fix failing test
* Partial implementation of timer
* Adds timer, removes exit_future, http api to op pool
* Partial multiple aggregate attestation handling
* Permits bulk messages accross gossipsub network channel
* Correct compile issues
* Improve gosispsub messaging and correct rest api helpers
* Added global gossipsub subscriptions
* Update validator subscriptions data structs
* Tidy
* Re-structure validator subscriptions
* Initial handling of subscriptions
* Re-structure network service
* Add pubkey cache persistence file
* Add more comments
* Integrate persistence file into builder
* Add pubkey cache tests
* Add HashSetDelay and introduce into attestation service
* Handles validator subscriptions
* Add data_dir to beacon chain builder
* Remove Option in pubkey cache persistence file
* Ensure consistency between datadir/data_dir
* Fix failing network test
* Peer subnet discovery gets queued for future subscriptions
* Reorganise attestation service functions
* Initial wiring of attestation service
* First draft of attestation service timing logic
* Correct minor typos
* Tidy
* Fix todos
* Improve tests
* Add PeerInfo to connected peers mapping
* Fix compile error
* Fix compile error from merge
* Split up block processing metrics
* Tidy
* Refactor get_pubkey_from_state
* Remove commented-out code
* Rename state_cache -> checkpoint_cache
* Rename Checkpoint -> Snapshot
* Tidy, add comments
* Tidy up find_head function
* Change some checkpoint -> snapshot
* Add tests
* Expose max_len
* Remove dead code
* Tidy
* Fix bug
* Add sync-speed metric
* Add first attempt at VerifiableBlock
* Start integrating into beacon chain
* Integrate VerifiableBlock
* Rename VerifableBlock -> PartialBlockVerification
* Add start of typed methods
* Add progress
* Add further progress
* Rename structs
* Add full block verification to block_processing.rs
* Further beacon chain integration
* Update checks for gossip
* Add todo
* Start adding segement verification
* Add passing chain segement test
* Initial integration with batch sync
* Minor changes
* Tidy, add more error checking
* Start adding chain_segment tests
* Finish invalid signature tests
* Include single and gossip verified blocks in tests
* Add gossip verification tests
* Start adding docs
* Finish adding comments to block_processing.rs
* Rename block_processing.rs -> block_verification
* Start removing old block processing code
* Fixes beacon_chain compilation
* Fix project-wide compile errors
* Remove old code
* Correct code to pass all tests
* Fix bug with beacon proposer index
* Fix shim for BlockProcessingError
* Only process one epoch at a time
* Fix loop in chain segment processing
* Correct tests from master merge
* Add caching for state.eth1_data_votes
* Add BeaconChain::validator_pubkey
* Revert "Add caching for state.eth1_data_votes"
This reverts commit cd73dcd6434fb8d8e6bf30c5356355598ea7b78e.
Co-authored-by: Grant Wuerker <gwuerker@gmail.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
Co-authored-by: Michael Sproul <micsproul@gmail.com>
Co-authored-by: pawan <pawandhananjay@gmail.com>
Co-authored-by: Paul Hauner <paul@paulhauner.com>
2020-03-17 06:24:44 +00:00
|
|
|
TSpec: EthSpec,
|
2019-07-16 12:32:37 +00:00
|
|
|
{
|
2019-07-06 11:32:32 +00:00
|
|
|
/// The upgrade for inbound substreams.
|
Initial work towards v0.2.0 (#924)
* Remove ping protocol
* Initial renaming of network services
* Correct rebasing relative to latest master
* Start updating types
* Adds HashMapDelay struct to utils
* Initial network restructure
* Network restructure. Adds new types for v0.2.0
* Removes build artefacts
* Shift validation to beacon chain
* Temporarily remove gossip validation
This is to be updated to match current optimisation efforts.
* Adds AggregateAndProof
* Begin rebuilding pubsub encoding/decoding
* Signature hacking
* Shift gossipsup decoding into eth2_libp2p
* Existing EF tests passing with fake_crypto
* Shifts block encoding/decoding into RPC
* Delete outdated API spec
* All release tests passing bar genesis state parsing
* Update and test YamlConfig
* Update to spec v0.10 compatible BLS
* Updates to BLS EF tests
* Add EF test for AggregateVerify
And delete unused hash2curve tests for uncompressed points
* Update EF tests to v0.10.1
* Use optional block root correctly in block proc
* Use genesis fork in deposit domain. All tests pass
* Fast aggregate verify test
* Update REST API docs
* Fix unused import
* Bump spec tags to v0.10.1
* Add `seconds_per_eth1_block` to chainspec
* Update to timestamp based eth1 voting scheme
* Return None from `get_votes_to_consider` if block cache is empty
* Handle overflows in `is_candidate_block`
* Revert to failing tests
* Fix eth1 data sets test
* Choose default vote according to spec
* Fix collect_valid_votes tests
* Fix `get_votes_to_consider` to choose all eligible blocks
* Uncomment winning_vote tests
* Add comments; remove unused code
* Reduce seconds_per_eth1_block for simulation
* Addressed review comments
* Add test for default vote case
* Fix logs
* Remove unused functions
* Meter default eth1 votes
* Fix comments
* Progress on attestation service
* Address review comments; remove unused dependency
* Initial work on removing libp2p lock
* Add LRU caches to store (rollup)
* Update attestation validation for DB changes (WIP)
* Initial version of should_forward_block
* Scaffold
* Progress on attestation validation
Also, consolidate prod+testing slot clocks so that they share much
of the same implementation and can both handle sub-slot time changes.
* Removes lock from libp2p service
* Completed network lock removal
* Finish(?) attestation processing
* Correct network termination future
* Add slot check to block check
* Correct fmt issues
* Remove Drop implementation for network service
* Add first attempt at attestation proc. re-write
* Add version 2 of attestation processing
* Minor fixes
* Add validator pubkey cache
* Make get_indexed_attestation take a committee
* Link signature processing into new attn verification
* First working version
* Ensure pubkey cache is updated
* Add more metrics, slight optimizations
* Clone committee cache during attestation processing
* Update shuffling cache during block processing
* Remove old commented-out code
* Fix shuffling cache insert bug
* Used indexed attestation in fork choice
* Restructure attn processing, add metrics
* Add more detailed metrics
* Tidy, fix failing tests
* Fix failing tests, tidy
* Address reviewers suggestions
* Disable/delete two outdated tests
* Modification of validator for subscriptions
* Add slot signing to validator client
* Further progress on validation subscription
* Adds necessary validator subscription functionality
* Add new Pubkeys struct to signature_sets
* Refactor with functional approach
* Update beacon chain
* Clean up validator <-> beacon node http types
* Add aggregator status to ValidatorDuty
* Impl Clone for manual slot clock
* Fix minor errors
* Further progress validator client subscription
* Initial subscription and aggregation handling
* Remove decompressed member from pubkey bytes
* Progress to modifying val client for attestation aggregation
* First draft of validator client upgrade for aggregate attestations
* Add hashmap for indices lookup
* Add state cache, remove store cache
* Only build the head committee cache
* Removes lock on a network channel
* Partially implement beacon node subscription http api
* Correct compilation issues
* Change `get_attesting_indices` to use Vec
* Fix failing test
* Partial implementation of timer
* Adds timer, removes exit_future, http api to op pool
* Partial multiple aggregate attestation handling
* Permits bulk messages accross gossipsub network channel
* Correct compile issues
* Improve gosispsub messaging and correct rest api helpers
* Added global gossipsub subscriptions
* Update validator subscriptions data structs
* Tidy
* Re-structure validator subscriptions
* Initial handling of subscriptions
* Re-structure network service
* Add pubkey cache persistence file
* Add more comments
* Integrate persistence file into builder
* Add pubkey cache tests
* Add HashSetDelay and introduce into attestation service
* Handles validator subscriptions
* Add data_dir to beacon chain builder
* Remove Option in pubkey cache persistence file
* Ensure consistency between datadir/data_dir
* Fix failing network test
* Peer subnet discovery gets queued for future subscriptions
* Reorganise attestation service functions
* Initial wiring of attestation service
* First draft of attestation service timing logic
* Correct minor typos
* Tidy
* Fix todos
* Improve tests
* Add PeerInfo to connected peers mapping
* Fix compile error
* Fix compile error from merge
* Split up block processing metrics
* Tidy
* Refactor get_pubkey_from_state
* Remove commented-out code
* Rename state_cache -> checkpoint_cache
* Rename Checkpoint -> Snapshot
* Tidy, add comments
* Tidy up find_head function
* Change some checkpoint -> snapshot
* Add tests
* Expose max_len
* Remove dead code
* Tidy
* Fix bug
* Add sync-speed metric
* Add first attempt at VerifiableBlock
* Start integrating into beacon chain
* Integrate VerifiableBlock
* Rename VerifableBlock -> PartialBlockVerification
* Add start of typed methods
* Add progress
* Add further progress
* Rename structs
* Add full block verification to block_processing.rs
* Further beacon chain integration
* Update checks for gossip
* Add todo
* Start adding segement verification
* Add passing chain segement test
* Initial integration with batch sync
* Minor changes
* Tidy, add more error checking
* Start adding chain_segment tests
* Finish invalid signature tests
* Include single and gossip verified blocks in tests
* Add gossip verification tests
* Start adding docs
* Finish adding comments to block_processing.rs
* Rename block_processing.rs -> block_verification
* Start removing old block processing code
* Fixes beacon_chain compilation
* Fix project-wide compile errors
* Remove old code
* Correct code to pass all tests
* Fix bug with beacon proposer index
* Fix shim for BlockProcessingError
* Only process one epoch at a time
* Fix loop in chain segment processing
* Correct tests from master merge
* Add caching for state.eth1_data_votes
* Add BeaconChain::validator_pubkey
* Revert "Add caching for state.eth1_data_votes"
This reverts commit cd73dcd6434fb8d8e6bf30c5356355598ea7b78e.
Co-authored-by: Grant Wuerker <gwuerker@gmail.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
Co-authored-by: Michael Sproul <micsproul@gmail.com>
Co-authored-by: pawan <pawandhananjay@gmail.com>
Co-authored-by: Paul Hauner <paul@paulhauner.com>
2020-03-17 06:24:44 +00:00
|
|
|
listen_protocol: SubstreamProtocol<RPCProtocol<TSpec>>,
|
2019-07-06 11:32:32 +00:00
|
|
|
|
2020-06-05 03:07:59 +00:00
|
|
|
/// Errors ocurring on outbound and inbound connections queued for reporting back.
|
|
|
|
pending_errors: Vec<HandlerErr>,
|
2019-07-06 11:32:32 +00:00
|
|
|
|
|
|
|
/// Queue of events to produce in `poll()`.
|
2020-06-05 03:07:59 +00:00
|
|
|
events_out: SmallVec<[RPCReceived<TSpec>; 4]>,
|
2019-07-06 11:32:32 +00:00
|
|
|
|
|
|
|
/// Queue of outbound substreams to open.
|
2020-05-03 13:17:12 +00:00
|
|
|
dial_queue: SmallVec<[(RequestId, RPCRequest<TSpec>); 4]>,
|
2019-07-06 11:32:32 +00:00
|
|
|
|
|
|
|
/// Current number of concurrent outbound substreams being opened.
|
|
|
|
dial_negotiated: u32,
|
|
|
|
|
2019-11-27 01:47:46 +00:00
|
|
|
/// Current inbound substreams awaiting processing.
|
Initial work towards v0.2.0 (#924)
* Remove ping protocol
* Initial renaming of network services
* Correct rebasing relative to latest master
* Start updating types
* Adds HashMapDelay struct to utils
* Initial network restructure
* Network restructure. Adds new types for v0.2.0
* Removes build artefacts
* Shift validation to beacon chain
* Temporarily remove gossip validation
This is to be updated to match current optimisation efforts.
* Adds AggregateAndProof
* Begin rebuilding pubsub encoding/decoding
* Signature hacking
* Shift gossipsup decoding into eth2_libp2p
* Existing EF tests passing with fake_crypto
* Shifts block encoding/decoding into RPC
* Delete outdated API spec
* All release tests passing bar genesis state parsing
* Update and test YamlConfig
* Update to spec v0.10 compatible BLS
* Updates to BLS EF tests
* Add EF test for AggregateVerify
And delete unused hash2curve tests for uncompressed points
* Update EF tests to v0.10.1
* Use optional block root correctly in block proc
* Use genesis fork in deposit domain. All tests pass
* Fast aggregate verify test
* Update REST API docs
* Fix unused import
* Bump spec tags to v0.10.1
* Add `seconds_per_eth1_block` to chainspec
* Update to timestamp based eth1 voting scheme
* Return None from `get_votes_to_consider` if block cache is empty
* Handle overflows in `is_candidate_block`
* Revert to failing tests
* Fix eth1 data sets test
* Choose default vote according to spec
* Fix collect_valid_votes tests
* Fix `get_votes_to_consider` to choose all eligible blocks
* Uncomment winning_vote tests
* Add comments; remove unused code
* Reduce seconds_per_eth1_block for simulation
* Addressed review comments
* Add test for default vote case
* Fix logs
* Remove unused functions
* Meter default eth1 votes
* Fix comments
* Progress on attestation service
* Address review comments; remove unused dependency
* Initial work on removing libp2p lock
* Add LRU caches to store (rollup)
* Update attestation validation for DB changes (WIP)
* Initial version of should_forward_block
* Scaffold
* Progress on attestation validation
Also, consolidate prod+testing slot clocks so that they share much
of the same implementation and can both handle sub-slot time changes.
* Removes lock from libp2p service
* Completed network lock removal
* Finish(?) attestation processing
* Correct network termination future
* Add slot check to block check
* Correct fmt issues
* Remove Drop implementation for network service
* Add first attempt at attestation proc. re-write
* Add version 2 of attestation processing
* Minor fixes
* Add validator pubkey cache
* Make get_indexed_attestation take a committee
* Link signature processing into new attn verification
* First working version
* Ensure pubkey cache is updated
* Add more metrics, slight optimizations
* Clone committee cache during attestation processing
* Update shuffling cache during block processing
* Remove old commented-out code
* Fix shuffling cache insert bug
* Used indexed attestation in fork choice
* Restructure attn processing, add metrics
* Add more detailed metrics
* Tidy, fix failing tests
* Fix failing tests, tidy
* Address reviewers suggestions
* Disable/delete two outdated tests
* Modification of validator for subscriptions
* Add slot signing to validator client
* Further progress on validation subscription
* Adds necessary validator subscription functionality
* Add new Pubkeys struct to signature_sets
* Refactor with functional approach
* Update beacon chain
* Clean up validator <-> beacon node http types
* Add aggregator status to ValidatorDuty
* Impl Clone for manual slot clock
* Fix minor errors
* Further progress validator client subscription
* Initial subscription and aggregation handling
* Remove decompressed member from pubkey bytes
* Progress to modifying val client for attestation aggregation
* First draft of validator client upgrade for aggregate attestations
* Add hashmap for indices lookup
* Add state cache, remove store cache
* Only build the head committee cache
* Removes lock on a network channel
* Partially implement beacon node subscription http api
* Correct compilation issues
* Change `get_attesting_indices` to use Vec
* Fix failing test
* Partial implementation of timer
* Adds timer, removes exit_future, http api to op pool
* Partial multiple aggregate attestation handling
* Permits bulk messages accross gossipsub network channel
* Correct compile issues
* Improve gosispsub messaging and correct rest api helpers
* Added global gossipsub subscriptions
* Update validator subscriptions data structs
* Tidy
* Re-structure validator subscriptions
* Initial handling of subscriptions
* Re-structure network service
* Add pubkey cache persistence file
* Add more comments
* Integrate persistence file into builder
* Add pubkey cache tests
* Add HashSetDelay and introduce into attestation service
* Handles validator subscriptions
* Add data_dir to beacon chain builder
* Remove Option in pubkey cache persistence file
* Ensure consistency between datadir/data_dir
* Fix failing network test
* Peer subnet discovery gets queued for future subscriptions
* Reorganise attestation service functions
* Initial wiring of attestation service
* First draft of attestation service timing logic
* Correct minor typos
* Tidy
* Fix todos
* Improve tests
* Add PeerInfo to connected peers mapping
* Fix compile error
* Fix compile error from merge
* Split up block processing metrics
* Tidy
* Refactor get_pubkey_from_state
* Remove commented-out code
* Rename state_cache -> checkpoint_cache
* Rename Checkpoint -> Snapshot
* Tidy, add comments
* Tidy up find_head function
* Change some checkpoint -> snapshot
* Add tests
* Expose max_len
* Remove dead code
* Tidy
* Fix bug
* Add sync-speed metric
* Add first attempt at VerifiableBlock
* Start integrating into beacon chain
* Integrate VerifiableBlock
* Rename VerifableBlock -> PartialBlockVerification
* Add start of typed methods
* Add progress
* Add further progress
* Rename structs
* Add full block verification to block_processing.rs
* Further beacon chain integration
* Update checks for gossip
* Add todo
* Start adding segement verification
* Add passing chain segement test
* Initial integration with batch sync
* Minor changes
* Tidy, add more error checking
* Start adding chain_segment tests
* Finish invalid signature tests
* Include single and gossip verified blocks in tests
* Add gossip verification tests
* Start adding docs
* Finish adding comments to block_processing.rs
* Rename block_processing.rs -> block_verification
* Start removing old block processing code
* Fixes beacon_chain compilation
* Fix project-wide compile errors
* Remove old code
* Correct code to pass all tests
* Fix bug with beacon proposer index
* Fix shim for BlockProcessingError
* Only process one epoch at a time
* Fix loop in chain segment processing
* Correct tests from master merge
* Add caching for state.eth1_data_votes
* Add BeaconChain::validator_pubkey
* Revert "Add caching for state.eth1_data_votes"
This reverts commit cd73dcd6434fb8d8e6bf30c5356355598ea7b78e.
Co-authored-by: Grant Wuerker <gwuerker@gmail.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
Co-authored-by: Michael Sproul <micsproul@gmail.com>
Co-authored-by: pawan <pawandhananjay@gmail.com>
Co-authored-by: Paul Hauner <paul@paulhauner.com>
2020-03-17 06:24:44 +00:00
|
|
|
inbound_substreams: FnvHashMap<
|
2020-06-05 03:07:59 +00:00
|
|
|
SubstreamId,
|
Initial work towards v0.2.0 (#924)
* Remove ping protocol
* Initial renaming of network services
* Correct rebasing relative to latest master
* Start updating types
* Adds HashMapDelay struct to utils
* Initial network restructure
* Network restructure. Adds new types for v0.2.0
* Removes build artefacts
* Shift validation to beacon chain
* Temporarily remove gossip validation
This is to be updated to match current optimisation efforts.
* Adds AggregateAndProof
* Begin rebuilding pubsub encoding/decoding
* Signature hacking
* Shift gossipsup decoding into eth2_libp2p
* Existing EF tests passing with fake_crypto
* Shifts block encoding/decoding into RPC
* Delete outdated API spec
* All release tests passing bar genesis state parsing
* Update and test YamlConfig
* Update to spec v0.10 compatible BLS
* Updates to BLS EF tests
* Add EF test for AggregateVerify
And delete unused hash2curve tests for uncompressed points
* Update EF tests to v0.10.1
* Use optional block root correctly in block proc
* Use genesis fork in deposit domain. All tests pass
* Fast aggregate verify test
* Update REST API docs
* Fix unused import
* Bump spec tags to v0.10.1
* Add `seconds_per_eth1_block` to chainspec
* Update to timestamp based eth1 voting scheme
* Return None from `get_votes_to_consider` if block cache is empty
* Handle overflows in `is_candidate_block`
* Revert to failing tests
* Fix eth1 data sets test
* Choose default vote according to spec
* Fix collect_valid_votes tests
* Fix `get_votes_to_consider` to choose all eligible blocks
* Uncomment winning_vote tests
* Add comments; remove unused code
* Reduce seconds_per_eth1_block for simulation
* Addressed review comments
* Add test for default vote case
* Fix logs
* Remove unused functions
* Meter default eth1 votes
* Fix comments
* Progress on attestation service
* Address review comments; remove unused dependency
* Initial work on removing libp2p lock
* Add LRU caches to store (rollup)
* Update attestation validation for DB changes (WIP)
* Initial version of should_forward_block
* Scaffold
* Progress on attestation validation
Also, consolidate prod+testing slot clocks so that they share much
of the same implementation and can both handle sub-slot time changes.
* Removes lock from libp2p service
* Completed network lock removal
* Finish(?) attestation processing
* Correct network termination future
* Add slot check to block check
* Correct fmt issues
* Remove Drop implementation for network service
* Add first attempt at attestation proc. re-write
* Add version 2 of attestation processing
* Minor fixes
* Add validator pubkey cache
* Make get_indexed_attestation take a committee
* Link signature processing into new attn verification
* First working version
* Ensure pubkey cache is updated
* Add more metrics, slight optimizations
* Clone committee cache during attestation processing
* Update shuffling cache during block processing
* Remove old commented-out code
* Fix shuffling cache insert bug
* Used indexed attestation in fork choice
* Restructure attn processing, add metrics
* Add more detailed metrics
* Tidy, fix failing tests
* Fix failing tests, tidy
* Address reviewers suggestions
* Disable/delete two outdated tests
* Modification of validator for subscriptions
* Add slot signing to validator client
* Further progress on validation subscription
* Adds necessary validator subscription functionality
* Add new Pubkeys struct to signature_sets
* Refactor with functional approach
* Update beacon chain
* Clean up validator <-> beacon node http types
* Add aggregator status to ValidatorDuty
* Impl Clone for manual slot clock
* Fix minor errors
* Further progress validator client subscription
* Initial subscription and aggregation handling
* Remove decompressed member from pubkey bytes
* Progress to modifying val client for attestation aggregation
* First draft of validator client upgrade for aggregate attestations
* Add hashmap for indices lookup
* Add state cache, remove store cache
* Only build the head committee cache
* Removes lock on a network channel
* Partially implement beacon node subscription http api
* Correct compilation issues
* Change `get_attesting_indices` to use Vec
* Fix failing test
* Partial implementation of timer
* Adds timer, removes exit_future, http api to op pool
* Partial multiple aggregate attestation handling
* Permits bulk messages accross gossipsub network channel
* Correct compile issues
* Improve gosispsub messaging and correct rest api helpers
* Added global gossipsub subscriptions
* Update validator subscriptions data structs
* Tidy
* Re-structure validator subscriptions
* Initial handling of subscriptions
* Re-structure network service
* Add pubkey cache persistence file
* Add more comments
* Integrate persistence file into builder
* Add pubkey cache tests
* Add HashSetDelay and introduce into attestation service
* Handles validator subscriptions
* Add data_dir to beacon chain builder
* Remove Option in pubkey cache persistence file
* Ensure consistency between datadir/data_dir
* Fix failing network test
* Peer subnet discovery gets queued for future subscriptions
* Reorganise attestation service functions
* Initial wiring of attestation service
* First draft of attestation service timing logic
* Correct minor typos
* Tidy
* Fix todos
* Improve tests
* Add PeerInfo to connected peers mapping
* Fix compile error
* Fix compile error from merge
* Split up block processing metrics
* Tidy
* Refactor get_pubkey_from_state
* Remove commented-out code
* Rename state_cache -> checkpoint_cache
* Rename Checkpoint -> Snapshot
* Tidy, add comments
* Tidy up find_head function
* Change some checkpoint -> snapshot
* Add tests
* Expose max_len
* Remove dead code
* Tidy
* Fix bug
* Add sync-speed metric
* Add first attempt at VerifiableBlock
* Start integrating into beacon chain
* Integrate VerifiableBlock
* Rename VerifableBlock -> PartialBlockVerification
* Add start of typed methods
* Add progress
* Add further progress
* Rename structs
* Add full block verification to block_processing.rs
* Further beacon chain integration
* Update checks for gossip
* Add todo
* Start adding segement verification
* Add passing chain segement test
* Initial integration with batch sync
* Minor changes
* Tidy, add more error checking
* Start adding chain_segment tests
* Finish invalid signature tests
* Include single and gossip verified blocks in tests
* Add gossip verification tests
* Start adding docs
* Finish adding comments to block_processing.rs
* Rename block_processing.rs -> block_verification
* Start removing old block processing code
* Fixes beacon_chain compilation
* Fix project-wide compile errors
* Remove old code
* Correct code to pass all tests
* Fix bug with beacon proposer index
* Fix shim for BlockProcessingError
* Only process one epoch at a time
* Fix loop in chain segment processing
* Correct tests from master merge
* Add caching for state.eth1_data_votes
* Add BeaconChain::validator_pubkey
* Revert "Add caching for state.eth1_data_votes"
This reverts commit cd73dcd6434fb8d8e6bf30c5356355598ea7b78e.
Co-authored-by: Grant Wuerker <gwuerker@gmail.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
Co-authored-by: Michael Sproul <micsproul@gmail.com>
Co-authored-by: pawan <pawandhananjay@gmail.com>
Co-authored-by: Paul Hauner <paul@paulhauner.com>
2020-03-17 06:24:44 +00:00
|
|
|
(
|
2020-05-17 11:16:48 +00:00
|
|
|
InboundSubstreamState<TSpec>,
|
Initial work towards v0.2.0 (#924)
* Remove ping protocol
* Initial renaming of network services
* Correct rebasing relative to latest master
* Start updating types
* Adds HashMapDelay struct to utils
* Initial network restructure
* Network restructure. Adds new types for v0.2.0
* Removes build artefacts
* Shift validation to beacon chain
* Temporarily remove gossip validation
This is to be updated to match current optimisation efforts.
* Adds AggregateAndProof
* Begin rebuilding pubsub encoding/decoding
* Signature hacking
* Shift gossipsup decoding into eth2_libp2p
* Existing EF tests passing with fake_crypto
* Shifts block encoding/decoding into RPC
* Delete outdated API spec
* All release tests passing bar genesis state parsing
* Update and test YamlConfig
* Update to spec v0.10 compatible BLS
* Updates to BLS EF tests
* Add EF test for AggregateVerify
And delete unused hash2curve tests for uncompressed points
* Update EF tests to v0.10.1
* Use optional block root correctly in block proc
* Use genesis fork in deposit domain. All tests pass
* Fast aggregate verify test
* Update REST API docs
* Fix unused import
* Bump spec tags to v0.10.1
* Add `seconds_per_eth1_block` to chainspec
* Update to timestamp based eth1 voting scheme
* Return None from `get_votes_to_consider` if block cache is empty
* Handle overflows in `is_candidate_block`
* Revert to failing tests
* Fix eth1 data sets test
* Choose default vote according to spec
* Fix collect_valid_votes tests
* Fix `get_votes_to_consider` to choose all eligible blocks
* Uncomment winning_vote tests
* Add comments; remove unused code
* Reduce seconds_per_eth1_block for simulation
* Addressed review comments
* Add test for default vote case
* Fix logs
* Remove unused functions
* Meter default eth1 votes
* Fix comments
* Progress on attestation service
* Address review comments; remove unused dependency
* Initial work on removing libp2p lock
* Add LRU caches to store (rollup)
* Update attestation validation for DB changes (WIP)
* Initial version of should_forward_block
* Scaffold
* Progress on attestation validation
Also, consolidate prod+testing slot clocks so that they share much
of the same implementation and can both handle sub-slot time changes.
* Removes lock from libp2p service
* Completed network lock removal
* Finish(?) attestation processing
* Correct network termination future
* Add slot check to block check
* Correct fmt issues
* Remove Drop implementation for network service
* Add first attempt at attestation proc. re-write
* Add version 2 of attestation processing
* Minor fixes
* Add validator pubkey cache
* Make get_indexed_attestation take a committee
* Link signature processing into new attn verification
* First working version
* Ensure pubkey cache is updated
* Add more metrics, slight optimizations
* Clone committee cache during attestation processing
* Update shuffling cache during block processing
* Remove old commented-out code
* Fix shuffling cache insert bug
* Used indexed attestation in fork choice
* Restructure attn processing, add metrics
* Add more detailed metrics
* Tidy, fix failing tests
* Fix failing tests, tidy
* Address reviewers suggestions
* Disable/delete two outdated tests
* Modification of validator for subscriptions
* Add slot signing to validator client
* Further progress on validation subscription
* Adds necessary validator subscription functionality
* Add new Pubkeys struct to signature_sets
* Refactor with functional approach
* Update beacon chain
* Clean up validator <-> beacon node http types
* Add aggregator status to ValidatorDuty
* Impl Clone for manual slot clock
* Fix minor errors
* Further progress validator client subscription
* Initial subscription and aggregation handling
* Remove decompressed member from pubkey bytes
* Progress to modifying val client for attestation aggregation
* First draft of validator client upgrade for aggregate attestations
* Add hashmap for indices lookup
* Add state cache, remove store cache
* Only build the head committee cache
* Removes lock on a network channel
* Partially implement beacon node subscription http api
* Correct compilation issues
* Change `get_attesting_indices` to use Vec
* Fix failing test
* Partial implementation of timer
* Adds timer, removes exit_future, http api to op pool
* Partial multiple aggregate attestation handling
* Permits bulk messages accross gossipsub network channel
* Correct compile issues
* Improve gosispsub messaging and correct rest api helpers
* Added global gossipsub subscriptions
* Update validator subscriptions data structs
* Tidy
* Re-structure validator subscriptions
* Initial handling of subscriptions
* Re-structure network service
* Add pubkey cache persistence file
* Add more comments
* Integrate persistence file into builder
* Add pubkey cache tests
* Add HashSetDelay and introduce into attestation service
* Handles validator subscriptions
* Add data_dir to beacon chain builder
* Remove Option in pubkey cache persistence file
* Ensure consistency between datadir/data_dir
* Fix failing network test
* Peer subnet discovery gets queued for future subscriptions
* Reorganise attestation service functions
* Initial wiring of attestation service
* First draft of attestation service timing logic
* Correct minor typos
* Tidy
* Fix todos
* Improve tests
* Add PeerInfo to connected peers mapping
* Fix compile error
* Fix compile error from merge
* Split up block processing metrics
* Tidy
* Refactor get_pubkey_from_state
* Remove commented-out code
* Rename state_cache -> checkpoint_cache
* Rename Checkpoint -> Snapshot
* Tidy, add comments
* Tidy up find_head function
* Change some checkpoint -> snapshot
* Add tests
* Expose max_len
* Remove dead code
* Tidy
* Fix bug
* Add sync-speed metric
* Add first attempt at VerifiableBlock
* Start integrating into beacon chain
* Integrate VerifiableBlock
* Rename VerifableBlock -> PartialBlockVerification
* Add start of typed methods
* Add progress
* Add further progress
* Rename structs
* Add full block verification to block_processing.rs
* Further beacon chain integration
* Update checks for gossip
* Add todo
* Start adding segement verification
* Add passing chain segement test
* Initial integration with batch sync
* Minor changes
* Tidy, add more error checking
* Start adding chain_segment tests
* Finish invalid signature tests
* Include single and gossip verified blocks in tests
* Add gossip verification tests
* Start adding docs
* Finish adding comments to block_processing.rs
* Rename block_processing.rs -> block_verification
* Start removing old block processing code
* Fixes beacon_chain compilation
* Fix project-wide compile errors
* Remove old code
* Correct code to pass all tests
* Fix bug with beacon proposer index
* Fix shim for BlockProcessingError
* Only process one epoch at a time
* Fix loop in chain segment processing
* Correct tests from master merge
* Add caching for state.eth1_data_votes
* Add BeaconChain::validator_pubkey
* Revert "Add caching for state.eth1_data_votes"
This reverts commit cd73dcd6434fb8d8e6bf30c5356355598ea7b78e.
Co-authored-by: Grant Wuerker <gwuerker@gmail.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
Co-authored-by: Michael Sproul <micsproul@gmail.com>
Co-authored-by: pawan <pawandhananjay@gmail.com>
Co-authored-by: Paul Hauner <paul@paulhauner.com>
2020-03-17 06:24:44 +00:00
|
|
|
Option<delay_queue::Key>,
|
2020-05-03 13:17:12 +00:00
|
|
|
Protocol,
|
Initial work towards v0.2.0 (#924)
* Remove ping protocol
* Initial renaming of network services
* Correct rebasing relative to latest master
* Start updating types
* Adds HashMapDelay struct to utils
* Initial network restructure
* Network restructure. Adds new types for v0.2.0
* Removes build artefacts
* Shift validation to beacon chain
* Temporarily remove gossip validation
This is to be updated to match current optimisation efforts.
* Adds AggregateAndProof
* Begin rebuilding pubsub encoding/decoding
* Signature hacking
* Shift gossipsup decoding into eth2_libp2p
* Existing EF tests passing with fake_crypto
* Shifts block encoding/decoding into RPC
* Delete outdated API spec
* All release tests passing bar genesis state parsing
* Update and test YamlConfig
* Update to spec v0.10 compatible BLS
* Updates to BLS EF tests
* Add EF test for AggregateVerify
And delete unused hash2curve tests for uncompressed points
* Update EF tests to v0.10.1
* Use optional block root correctly in block proc
* Use genesis fork in deposit domain. All tests pass
* Fast aggregate verify test
* Update REST API docs
* Fix unused import
* Bump spec tags to v0.10.1
* Add `seconds_per_eth1_block` to chainspec
* Update to timestamp based eth1 voting scheme
* Return None from `get_votes_to_consider` if block cache is empty
* Handle overflows in `is_candidate_block`
* Revert to failing tests
* Fix eth1 data sets test
* Choose default vote according to spec
* Fix collect_valid_votes tests
* Fix `get_votes_to_consider` to choose all eligible blocks
* Uncomment winning_vote tests
* Add comments; remove unused code
* Reduce seconds_per_eth1_block for simulation
* Addressed review comments
* Add test for default vote case
* Fix logs
* Remove unused functions
* Meter default eth1 votes
* Fix comments
* Progress on attestation service
* Address review comments; remove unused dependency
* Initial work on removing libp2p lock
* Add LRU caches to store (rollup)
* Update attestation validation for DB changes (WIP)
* Initial version of should_forward_block
* Scaffold
* Progress on attestation validation
Also, consolidate prod+testing slot clocks so that they share much
of the same implementation and can both handle sub-slot time changes.
* Removes lock from libp2p service
* Completed network lock removal
* Finish(?) attestation processing
* Correct network termination future
* Add slot check to block check
* Correct fmt issues
* Remove Drop implementation for network service
* Add first attempt at attestation proc. re-write
* Add version 2 of attestation processing
* Minor fixes
* Add validator pubkey cache
* Make get_indexed_attestation take a committee
* Link signature processing into new attn verification
* First working version
* Ensure pubkey cache is updated
* Add more metrics, slight optimizations
* Clone committee cache during attestation processing
* Update shuffling cache during block processing
* Remove old commented-out code
* Fix shuffling cache insert bug
* Used indexed attestation in fork choice
* Restructure attn processing, add metrics
* Add more detailed metrics
* Tidy, fix failing tests
* Fix failing tests, tidy
* Address reviewers suggestions
* Disable/delete two outdated tests
* Modification of validator for subscriptions
* Add slot signing to validator client
* Further progress on validation subscription
* Adds necessary validator subscription functionality
* Add new Pubkeys struct to signature_sets
* Refactor with functional approach
* Update beacon chain
* Clean up validator <-> beacon node http types
* Add aggregator status to ValidatorDuty
* Impl Clone for manual slot clock
* Fix minor errors
* Further progress validator client subscription
* Initial subscription and aggregation handling
* Remove decompressed member from pubkey bytes
* Progress to modifying val client for attestation aggregation
* First draft of validator client upgrade for aggregate attestations
* Add hashmap for indices lookup
* Add state cache, remove store cache
* Only build the head committee cache
* Removes lock on a network channel
* Partially implement beacon node subscription http api
* Correct compilation issues
* Change `get_attesting_indices` to use Vec
* Fix failing test
* Partial implementation of timer
* Adds timer, removes exit_future, http api to op pool
* Partial multiple aggregate attestation handling
* Permits bulk messages accross gossipsub network channel
* Correct compile issues
* Improve gosispsub messaging and correct rest api helpers
* Added global gossipsub subscriptions
* Update validator subscriptions data structs
* Tidy
* Re-structure validator subscriptions
* Initial handling of subscriptions
* Re-structure network service
* Add pubkey cache persistence file
* Add more comments
* Integrate persistence file into builder
* Add pubkey cache tests
* Add HashSetDelay and introduce into attestation service
* Handles validator subscriptions
* Add data_dir to beacon chain builder
* Remove Option in pubkey cache persistence file
* Ensure consistency between datadir/data_dir
* Fix failing network test
* Peer subnet discovery gets queued for future subscriptions
* Reorganise attestation service functions
* Initial wiring of attestation service
* First draft of attestation service timing logic
* Correct minor typos
* Tidy
* Fix todos
* Improve tests
* Add PeerInfo to connected peers mapping
* Fix compile error
* Fix compile error from merge
* Split up block processing metrics
* Tidy
* Refactor get_pubkey_from_state
* Remove commented-out code
* Rename state_cache -> checkpoint_cache
* Rename Checkpoint -> Snapshot
* Tidy, add comments
* Tidy up find_head function
* Change some checkpoint -> snapshot
* Add tests
* Expose max_len
* Remove dead code
* Tidy
* Fix bug
* Add sync-speed metric
* Add first attempt at VerifiableBlock
* Start integrating into beacon chain
* Integrate VerifiableBlock
* Rename VerifableBlock -> PartialBlockVerification
* Add start of typed methods
* Add progress
* Add further progress
* Rename structs
* Add full block verification to block_processing.rs
* Further beacon chain integration
* Update checks for gossip
* Add todo
* Start adding segement verification
* Add passing chain segement test
* Initial integration with batch sync
* Minor changes
* Tidy, add more error checking
* Start adding chain_segment tests
* Finish invalid signature tests
* Include single and gossip verified blocks in tests
* Add gossip verification tests
* Start adding docs
* Finish adding comments to block_processing.rs
* Rename block_processing.rs -> block_verification
* Start removing old block processing code
* Fixes beacon_chain compilation
* Fix project-wide compile errors
* Remove old code
* Correct code to pass all tests
* Fix bug with beacon proposer index
* Fix shim for BlockProcessingError
* Only process one epoch at a time
* Fix loop in chain segment processing
* Correct tests from master merge
* Add caching for state.eth1_data_votes
* Add BeaconChain::validator_pubkey
* Revert "Add caching for state.eth1_data_votes"
This reverts commit cd73dcd6434fb8d8e6bf30c5356355598ea7b78e.
Co-authored-by: Grant Wuerker <gwuerker@gmail.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
Co-authored-by: Michael Sproul <micsproul@gmail.com>
Co-authored-by: pawan <pawandhananjay@gmail.com>
Co-authored-by: Paul Hauner <paul@paulhauner.com>
2020-03-17 06:24:44 +00:00
|
|
|
),
|
|
|
|
>,
|
2019-11-27 01:47:46 +00:00
|
|
|
|
|
|
|
/// Inbound substream `DelayQueue` which keeps track of when an inbound substream will timeout.
|
2020-06-05 03:07:59 +00:00
|
|
|
inbound_substreams_delay: DelayQueue<SubstreamId>,
|
2019-11-27 01:47:46 +00:00
|
|
|
|
2020-06-05 03:07:59 +00:00
|
|
|
/// Map of outbound substreams that need to be driven to completion.
|
|
|
|
outbound_substreams: FnvHashMap<SubstreamId, OutboundInfo<TSpec>>,
|
2019-07-16 12:32:37 +00:00
|
|
|
|
2019-11-27 01:47:46 +00:00
|
|
|
/// Inbound substream `DelayQueue` which keeps track of when an inbound substream will timeout.
|
2020-06-05 03:07:59 +00:00
|
|
|
outbound_substreams_delay: DelayQueue<SubstreamId>,
|
2019-11-27 01:47:46 +00:00
|
|
|
|
|
|
|
/// Map of outbound items that are queued as the stream processes them.
|
2020-06-05 03:07:59 +00:00
|
|
|
queued_outbound_items: FnvHashMap<SubstreamId, Vec<RPCCodedResponse<TSpec>>>,
|
2019-07-06 11:32:32 +00:00
|
|
|
|
2020-01-08 03:18:06 +00:00
|
|
|
/// Sequential ID for waiting substreams. For inbound substreams, this is also the inbound request ID.
|
2020-06-05 03:07:59 +00:00
|
|
|
current_inbound_substream_id: SubstreamId,
|
|
|
|
|
|
|
|
/// Sequential ID for outbound substreams.
|
|
|
|
current_outbound_substream_id: SubstreamId,
|
2019-07-06 11:32:32 +00:00
|
|
|
|
|
|
|
/// Maximum number of concurrent outbound substreams being opened. Value is never modified.
|
|
|
|
max_dial_negotiated: u32,
|
|
|
|
|
|
|
|
/// Value to return from `connection_keep_alive`.
|
|
|
|
keep_alive: KeepAlive,
|
|
|
|
|
2020-06-18 01:53:08 +00:00
|
|
|
/// State of the handler.
|
|
|
|
state: HandlerState,
|
|
|
|
|
2019-07-06 11:32:32 +00:00
|
|
|
/// After the given duration has elapsed, an inactive connection will shutdown.
|
|
|
|
inactive_timeout: Duration,
|
Update to frozen spec ❄️ (v0.8.1) (#444)
* types: first updates for v0.8
* state_processing: epoch processing v0.8.0
* state_processing: block processing v0.8.0
* tree_hash_derive: support generics in SignedRoot
* types v0.8: update to use ssz_types
* state_processing v0.8: use ssz_types
* ssz_types: add bitwise methods and from_elem
* types: fix v0.8 FIXMEs
* ssz_types: add bitfield shift_up
* ssz_types: iterators and DerefMut for VariableList
* types,state_processing: use VariableList
* ssz_types: fix BitVector Decode impl
Fixed a typo in the implementation of ssz::Decode for BitVector, which caused it
to be considered variable length!
* types: fix test modules for v0.8 update
* types: remove slow type-level arithmetic
* state_processing: fix tests for v0.8
* op_pool: update for v0.8
* ssz_types: Bitfield difference length-independent
Allow computing the difference of two bitfields of different lengths.
* Implement compact committee support
* epoch_processing: committee & active index roots
* state_processing: genesis state builder v0.8
* state_processing: implement v0.8.1
* Further improve tree_hash
* Strip examples, tests from cached_tree_hash
* Update TreeHash, un-impl CachedTreeHash
* Update bitfield TreeHash, un-impl CachedTreeHash
* Update FixedLenVec TreeHash, unimpl CachedTreeHash
* Update update tree_hash_derive for new TreeHash
* Fix TreeHash, un-impl CachedTreeHash for ssz_types
* Remove fixed_len_vec, ssz benches
SSZ benches relied upon fixed_len_vec -- it is easier to just delete
them and rebuild them later (when necessary)
* Remove boolean_bitfield crate
* Fix fake_crypto BLS compile errors
* Update ef_tests for new v.8 type params
* Update ef_tests submodule to v0.8.1 tag
* Make fixes to support parsing ssz ef_tests
* `compact_committee...` to `compact_committees...`
* Derive more traits for `CompactCommittee`
* Flip bitfield byte-endianness
* Fix tree_hash for bitfields
* Modify CLI output for ef_tests
* Bump ssz crate version
* Update ssz_types doc comment
* Del cached tree hash tests from ssz_static tests
* Tidy SSZ dependencies
* Rename ssz_types crate to eth2_ssz_types
* validator_client: update for v0.8
* ssz_types: update union/difference for bit order swap
* beacon_node: update for v0.8, EthSpec
* types: disable cached tree hash, update min spec
* state_processing: fix slot bug in committee update
* tests: temporarily disable fork choice harness test
See #447
* committee cache: prevent out-of-bounds access
In the case where we tried to access the committee of a shard that didn't have a committee in the
current epoch, we were accessing elements beyond the end of the shuffling vector and panicking! This
commit adds a check to make the failure safe and explicit.
* fix bug in get_indexed_attestation and simplify
There was a bug in our implementation of get_indexed_attestation whereby
incorrect "committee indices" were used to index into the custody bitfield. The
bug was only observable in the case where some bits of the custody bitfield were
set to 1. The implementation has been simplified to remove the bug, and a test
added.
* state_proc: workaround for compact committees bug
https://github.com/ethereum/eth2.0-specs/issues/1315
* v0.8: updates to make the EF tests pass
* Remove redundant max operation checks.
* Always supply both messages when checking attestation signatures -- allowing
verification of an attestation with no signatures.
* Swap the order of the fork and domain constant in `get_domain`, to match
the spec.
* rustfmt
* ef_tests: add new epoch processing tests
* Integrate v0.8 into master (compiles)
* Remove unused crates, fix clippy lints
* Replace v0.6.3 tags w/ v0.8.1
* Remove old comment
* Ensure lmd ghost tests only run in release
* Update readme
2019-07-30 02:44:51 +00:00
|
|
|
|
2019-12-09 07:50:21 +00:00
|
|
|
/// Try to negotiate the outbound upgrade a few times if there is an IO error before reporting the request as failed.
|
|
|
|
/// This keeps track of the number of attempts.
|
|
|
|
outbound_io_error_retries: u8,
|
|
|
|
|
2019-11-27 01:47:46 +00:00
|
|
|
/// Logger for handling RPC streams
|
|
|
|
log: slog::Logger,
|
2019-07-06 11:32:32 +00:00
|
|
|
}
|
|
|
|
|
2020-06-18 01:53:08 +00:00
|
|
|
enum HandlerState {
|
|
|
|
/// The handler is active. All messages are sent and received.
|
|
|
|
Active,
|
|
|
|
/// The handler is shutting_down.
|
|
|
|
///
|
|
|
|
/// While in this state the handler rejects new requests but tries to finish existing ones.
|
|
|
|
ShuttingDown(Delay),
|
|
|
|
/// The handler is deactivated. A goodbye has been sent and no more messages are sent or
|
|
|
|
/// received.
|
|
|
|
Deactivated,
|
|
|
|
}
|
|
|
|
|
2020-06-05 03:07:59 +00:00
|
|
|
/// Contains the information the handler keeps on established outbound substreams.
|
|
|
|
struct OutboundInfo<TSpec: EthSpec> {
|
|
|
|
/// State of the substream.
|
|
|
|
state: OutboundSubstreamState<TSpec>,
|
|
|
|
/// Key to keep track of the substream's timeout via `self.outbound_substreams_delay`.
|
|
|
|
delay_key: delay_queue::Key,
|
|
|
|
/// Info over the protocol this substream is handling.
|
|
|
|
proto: Protocol,
|
|
|
|
/// Number of chunks to be seen from the peer's response.
|
|
|
|
// TODO: removing the option could allow clossing the streams after the number of
|
|
|
|
// expected responses is met for all protocols.
|
|
|
|
// TODO: the type of this is wrong
|
|
|
|
remaining_chunks: Option<usize>,
|
|
|
|
/// RequestId as given by the application that sent the request.
|
|
|
|
req_id: RequestId,
|
|
|
|
}
|
|
|
|
|
2020-05-17 11:16:48 +00:00
|
|
|
pub enum InboundSubstreamState<TSpec>
|
2019-07-16 12:32:37 +00:00
|
|
|
where
|
Initial work towards v0.2.0 (#924)
* Remove ping protocol
* Initial renaming of network services
* Correct rebasing relative to latest master
* Start updating types
* Adds HashMapDelay struct to utils
* Initial network restructure
* Network restructure. Adds new types for v0.2.0
* Removes build artefacts
* Shift validation to beacon chain
* Temporarily remove gossip validation
This is to be updated to match current optimisation efforts.
* Adds AggregateAndProof
* Begin rebuilding pubsub encoding/decoding
* Signature hacking
* Shift gossipsup decoding into eth2_libp2p
* Existing EF tests passing with fake_crypto
* Shifts block encoding/decoding into RPC
* Delete outdated API spec
* All release tests passing bar genesis state parsing
* Update and test YamlConfig
* Update to spec v0.10 compatible BLS
* Updates to BLS EF tests
* Add EF test for AggregateVerify
And delete unused hash2curve tests for uncompressed points
* Update EF tests to v0.10.1
* Use optional block root correctly in block proc
* Use genesis fork in deposit domain. All tests pass
* Fast aggregate verify test
* Update REST API docs
* Fix unused import
* Bump spec tags to v0.10.1
* Add `seconds_per_eth1_block` to chainspec
* Update to timestamp based eth1 voting scheme
* Return None from `get_votes_to_consider` if block cache is empty
* Handle overflows in `is_candidate_block`
* Revert to failing tests
* Fix eth1 data sets test
* Choose default vote according to spec
* Fix collect_valid_votes tests
* Fix `get_votes_to_consider` to choose all eligible blocks
* Uncomment winning_vote tests
* Add comments; remove unused code
* Reduce seconds_per_eth1_block for simulation
* Addressed review comments
* Add test for default vote case
* Fix logs
* Remove unused functions
* Meter default eth1 votes
* Fix comments
* Progress on attestation service
* Address review comments; remove unused dependency
* Initial work on removing libp2p lock
* Add LRU caches to store (rollup)
* Update attestation validation for DB changes (WIP)
* Initial version of should_forward_block
* Scaffold
* Progress on attestation validation
Also, consolidate prod+testing slot clocks so that they share much
of the same implementation and can both handle sub-slot time changes.
* Removes lock from libp2p service
* Completed network lock removal
* Finish(?) attestation processing
* Correct network termination future
* Add slot check to block check
* Correct fmt issues
* Remove Drop implementation for network service
* Add first attempt at attestation proc. re-write
* Add version 2 of attestation processing
* Minor fixes
* Add validator pubkey cache
* Make get_indexed_attestation take a committee
* Link signature processing into new attn verification
* First working version
* Ensure pubkey cache is updated
* Add more metrics, slight optimizations
* Clone committee cache during attestation processing
* Update shuffling cache during block processing
* Remove old commented-out code
* Fix shuffling cache insert bug
* Used indexed attestation in fork choice
* Restructure attn processing, add metrics
* Add more detailed metrics
* Tidy, fix failing tests
* Fix failing tests, tidy
* Address reviewers suggestions
* Disable/delete two outdated tests
* Modification of validator for subscriptions
* Add slot signing to validator client
* Further progress on validation subscription
* Adds necessary validator subscription functionality
* Add new Pubkeys struct to signature_sets
* Refactor with functional approach
* Update beacon chain
* Clean up validator <-> beacon node http types
* Add aggregator status to ValidatorDuty
* Impl Clone for manual slot clock
* Fix minor errors
* Further progress validator client subscription
* Initial subscription and aggregation handling
* Remove decompressed member from pubkey bytes
* Progress to modifying val client for attestation aggregation
* First draft of validator client upgrade for aggregate attestations
* Add hashmap for indices lookup
* Add state cache, remove store cache
* Only build the head committee cache
* Removes lock on a network channel
* Partially implement beacon node subscription http api
* Correct compilation issues
* Change `get_attesting_indices` to use Vec
* Fix failing test
* Partial implementation of timer
* Adds timer, removes exit_future, http api to op pool
* Partial multiple aggregate attestation handling
* Permits bulk messages accross gossipsub network channel
* Correct compile issues
* Improve gosispsub messaging and correct rest api helpers
* Added global gossipsub subscriptions
* Update validator subscriptions data structs
* Tidy
* Re-structure validator subscriptions
* Initial handling of subscriptions
* Re-structure network service
* Add pubkey cache persistence file
* Add more comments
* Integrate persistence file into builder
* Add pubkey cache tests
* Add HashSetDelay and introduce into attestation service
* Handles validator subscriptions
* Add data_dir to beacon chain builder
* Remove Option in pubkey cache persistence file
* Ensure consistency between datadir/data_dir
* Fix failing network test
* Peer subnet discovery gets queued for future subscriptions
* Reorganise attestation service functions
* Initial wiring of attestation service
* First draft of attestation service timing logic
* Correct minor typos
* Tidy
* Fix todos
* Improve tests
* Add PeerInfo to connected peers mapping
* Fix compile error
* Fix compile error from merge
* Split up block processing metrics
* Tidy
* Refactor get_pubkey_from_state
* Remove commented-out code
* Rename state_cache -> checkpoint_cache
* Rename Checkpoint -> Snapshot
* Tidy, add comments
* Tidy up find_head function
* Change some checkpoint -> snapshot
* Add tests
* Expose max_len
* Remove dead code
* Tidy
* Fix bug
* Add sync-speed metric
* Add first attempt at VerifiableBlock
* Start integrating into beacon chain
* Integrate VerifiableBlock
* Rename VerifableBlock -> PartialBlockVerification
* Add start of typed methods
* Add progress
* Add further progress
* Rename structs
* Add full block verification to block_processing.rs
* Further beacon chain integration
* Update checks for gossip
* Add todo
* Start adding segement verification
* Add passing chain segement test
* Initial integration with batch sync
* Minor changes
* Tidy, add more error checking
* Start adding chain_segment tests
* Finish invalid signature tests
* Include single and gossip verified blocks in tests
* Add gossip verification tests
* Start adding docs
* Finish adding comments to block_processing.rs
* Rename block_processing.rs -> block_verification
* Start removing old block processing code
* Fixes beacon_chain compilation
* Fix project-wide compile errors
* Remove old code
* Correct code to pass all tests
* Fix bug with beacon proposer index
* Fix shim for BlockProcessingError
* Only process one epoch at a time
* Fix loop in chain segment processing
* Correct tests from master merge
* Add caching for state.eth1_data_votes
* Add BeaconChain::validator_pubkey
* Revert "Add caching for state.eth1_data_votes"
This reverts commit cd73dcd6434fb8d8e6bf30c5356355598ea7b78e.
Co-authored-by: Grant Wuerker <gwuerker@gmail.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
Co-authored-by: Michael Sproul <micsproul@gmail.com>
Co-authored-by: pawan <pawandhananjay@gmail.com>
Co-authored-by: Paul Hauner <paul@paulhauner.com>
2020-03-17 06:24:44 +00:00
|
|
|
TSpec: EthSpec,
|
2019-07-16 12:32:37 +00:00
|
|
|
{
|
2020-05-17 11:16:48 +00:00
|
|
|
/// A response has been sent, pending writing.
|
2019-07-16 12:32:37 +00:00
|
|
|
ResponsePendingSend {
|
2019-11-27 01:47:46 +00:00
|
|
|
/// The substream used to send the response
|
2020-05-17 11:16:48 +00:00
|
|
|
substream: InboundFramed<NegotiatedSubstream, TSpec>,
|
|
|
|
/// The message that is attempting to be sent.
|
|
|
|
message: RPCCodedResponse<TSpec>,
|
|
|
|
/// Whether a stream termination is requested. If true the stream will be closed after
|
|
|
|
/// this send. Otherwise it will transition to an idle state until a stream termination is
|
|
|
|
/// requested or a timeout is reached.
|
|
|
|
closing: bool,
|
|
|
|
},
|
|
|
|
/// A response has been sent, pending flush.
|
|
|
|
ResponsePendingFlush {
|
|
|
|
/// The substream used to send the response
|
|
|
|
substream: InboundFramed<NegotiatedSubstream, TSpec>,
|
2019-11-27 01:47:46 +00:00
|
|
|
/// Whether a stream termination is requested. If true the stream will be closed after
|
|
|
|
/// this send. Otherwise it will transition to an idle state until a stream termination is
|
|
|
|
/// requested or a timeout is reached.
|
|
|
|
closing: bool,
|
2019-07-16 12:32:37 +00:00
|
|
|
},
|
2019-11-27 01:47:46 +00:00
|
|
|
/// The response stream is idle and awaiting input from the application to send more chunked
|
|
|
|
/// responses.
|
2020-05-17 11:16:48 +00:00
|
|
|
ResponseIdle(InboundFramed<NegotiatedSubstream, TSpec>),
|
2019-11-27 01:47:46 +00:00
|
|
|
/// The substream is attempting to shutdown.
|
2020-05-17 11:16:48 +00:00
|
|
|
Closing(InboundFramed<NegotiatedSubstream, TSpec>),
|
2019-11-27 01:47:46 +00:00
|
|
|
/// Temporary state during processing
|
|
|
|
Poisoned,
|
|
|
|
}
|
|
|
|
|
2020-05-17 11:16:48 +00:00
|
|
|
/// State of an outbound substream. Either waiting for a response, or in the process of sending.
|
|
|
|
pub enum OutboundSubstreamState<TSpec: EthSpec> {
|
2019-07-16 12:32:37 +00:00
|
|
|
/// A request has been sent, and we are awaiting a response. This future is driven in the
|
|
|
|
/// handler because GOODBYE requests can be handled and responses dropped instantly.
|
|
|
|
RequestPendingResponse {
|
|
|
|
/// The framed negotiated substream.
|
2020-05-17 11:16:48 +00:00
|
|
|
substream: OutboundFramed<NegotiatedSubstream, TSpec>,
|
2019-11-27 01:47:46 +00:00
|
|
|
/// Keeps track of the actual request sent.
|
Initial work towards v0.2.0 (#924)
* Remove ping protocol
* Initial renaming of network services
* Correct rebasing relative to latest master
* Start updating types
* Adds HashMapDelay struct to utils
* Initial network restructure
* Network restructure. Adds new types for v0.2.0
* Removes build artefacts
* Shift validation to beacon chain
* Temporarily remove gossip validation
This is to be updated to match current optimisation efforts.
* Adds AggregateAndProof
* Begin rebuilding pubsub encoding/decoding
* Signature hacking
* Shift gossipsup decoding into eth2_libp2p
* Existing EF tests passing with fake_crypto
* Shifts block encoding/decoding into RPC
* Delete outdated API spec
* All release tests passing bar genesis state parsing
* Update and test YamlConfig
* Update to spec v0.10 compatible BLS
* Updates to BLS EF tests
* Add EF test for AggregateVerify
And delete unused hash2curve tests for uncompressed points
* Update EF tests to v0.10.1
* Use optional block root correctly in block proc
* Use genesis fork in deposit domain. All tests pass
* Fast aggregate verify test
* Update REST API docs
* Fix unused import
* Bump spec tags to v0.10.1
* Add `seconds_per_eth1_block` to chainspec
* Update to timestamp based eth1 voting scheme
* Return None from `get_votes_to_consider` if block cache is empty
* Handle overflows in `is_candidate_block`
* Revert to failing tests
* Fix eth1 data sets test
* Choose default vote according to spec
* Fix collect_valid_votes tests
* Fix `get_votes_to_consider` to choose all eligible blocks
* Uncomment winning_vote tests
* Add comments; remove unused code
* Reduce seconds_per_eth1_block for simulation
* Addressed review comments
* Add test for default vote case
* Fix logs
* Remove unused functions
* Meter default eth1 votes
* Fix comments
* Progress on attestation service
* Address review comments; remove unused dependency
* Initial work on removing libp2p lock
* Add LRU caches to store (rollup)
* Update attestation validation for DB changes (WIP)
* Initial version of should_forward_block
* Scaffold
* Progress on attestation validation
Also, consolidate prod+testing slot clocks so that they share much
of the same implementation and can both handle sub-slot time changes.
* Removes lock from libp2p service
* Completed network lock removal
* Finish(?) attestation processing
* Correct network termination future
* Add slot check to block check
* Correct fmt issues
* Remove Drop implementation for network service
* Add first attempt at attestation proc. re-write
* Add version 2 of attestation processing
* Minor fixes
* Add validator pubkey cache
* Make get_indexed_attestation take a committee
* Link signature processing into new attn verification
* First working version
* Ensure pubkey cache is updated
* Add more metrics, slight optimizations
* Clone committee cache during attestation processing
* Update shuffling cache during block processing
* Remove old commented-out code
* Fix shuffling cache insert bug
* Used indexed attestation in fork choice
* Restructure attn processing, add metrics
* Add more detailed metrics
* Tidy, fix failing tests
* Fix failing tests, tidy
* Address reviewers suggestions
* Disable/delete two outdated tests
* Modification of validator for subscriptions
* Add slot signing to validator client
* Further progress on validation subscription
* Adds necessary validator subscription functionality
* Add new Pubkeys struct to signature_sets
* Refactor with functional approach
* Update beacon chain
* Clean up validator <-> beacon node http types
* Add aggregator status to ValidatorDuty
* Impl Clone for manual slot clock
* Fix minor errors
* Further progress validator client subscription
* Initial subscription and aggregation handling
* Remove decompressed member from pubkey bytes
* Progress to modifying val client for attestation aggregation
* First draft of validator client upgrade for aggregate attestations
* Add hashmap for indices lookup
* Add state cache, remove store cache
* Only build the head committee cache
* Removes lock on a network channel
* Partially implement beacon node subscription http api
* Correct compilation issues
* Change `get_attesting_indices` to use Vec
* Fix failing test
* Partial implementation of timer
* Adds timer, removes exit_future, http api to op pool
* Partial multiple aggregate attestation handling
* Permits bulk messages accross gossipsub network channel
* Correct compile issues
* Improve gosispsub messaging and correct rest api helpers
* Added global gossipsub subscriptions
* Update validator subscriptions data structs
* Tidy
* Re-structure validator subscriptions
* Initial handling of subscriptions
* Re-structure network service
* Add pubkey cache persistence file
* Add more comments
* Integrate persistence file into builder
* Add pubkey cache tests
* Add HashSetDelay and introduce into attestation service
* Handles validator subscriptions
* Add data_dir to beacon chain builder
* Remove Option in pubkey cache persistence file
* Ensure consistency between datadir/data_dir
* Fix failing network test
* Peer subnet discovery gets queued for future subscriptions
* Reorganise attestation service functions
* Initial wiring of attestation service
* First draft of attestation service timing logic
* Correct minor typos
* Tidy
* Fix todos
* Improve tests
* Add PeerInfo to connected peers mapping
* Fix compile error
* Fix compile error from merge
* Split up block processing metrics
* Tidy
* Refactor get_pubkey_from_state
* Remove commented-out code
* Rename state_cache -> checkpoint_cache
* Rename Checkpoint -> Snapshot
* Tidy, add comments
* Tidy up find_head function
* Change some checkpoint -> snapshot
* Add tests
* Expose max_len
* Remove dead code
* Tidy
* Fix bug
* Add sync-speed metric
* Add first attempt at VerifiableBlock
* Start integrating into beacon chain
* Integrate VerifiableBlock
* Rename VerifableBlock -> PartialBlockVerification
* Add start of typed methods
* Add progress
* Add further progress
* Rename structs
* Add full block verification to block_processing.rs
* Further beacon chain integration
* Update checks for gossip
* Add todo
* Start adding segement verification
* Add passing chain segement test
* Initial integration with batch sync
* Minor changes
* Tidy, add more error checking
* Start adding chain_segment tests
* Finish invalid signature tests
* Include single and gossip verified blocks in tests
* Add gossip verification tests
* Start adding docs
* Finish adding comments to block_processing.rs
* Rename block_processing.rs -> block_verification
* Start removing old block processing code
* Fixes beacon_chain compilation
* Fix project-wide compile errors
* Remove old code
* Correct code to pass all tests
* Fix bug with beacon proposer index
* Fix shim for BlockProcessingError
* Only process one epoch at a time
* Fix loop in chain segment processing
* Correct tests from master merge
* Add caching for state.eth1_data_votes
* Add BeaconChain::validator_pubkey
* Revert "Add caching for state.eth1_data_votes"
This reverts commit cd73dcd6434fb8d8e6bf30c5356355598ea7b78e.
Co-authored-by: Grant Wuerker <gwuerker@gmail.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
Co-authored-by: Michael Sproul <micsproul@gmail.com>
Co-authored-by: pawan <pawandhananjay@gmail.com>
Co-authored-by: Paul Hauner <paul@paulhauner.com>
2020-03-17 06:24:44 +00:00
|
|
|
request: RPCRequest<TSpec>,
|
2019-07-09 05:44:23 +00:00
|
|
|
},
|
2019-11-27 01:47:46 +00:00
|
|
|
/// Closing an outbound substream>
|
2020-05-17 11:16:48 +00:00
|
|
|
Closing(OutboundFramed<NegotiatedSubstream, TSpec>),
|
2019-11-27 01:47:46 +00:00
|
|
|
/// Temporary state during processing
|
|
|
|
Poisoned,
|
2019-07-06 11:32:32 +00:00
|
|
|
}
|
|
|
|
|
2020-05-17 11:16:48 +00:00
|
|
|
impl<TSpec> InboundSubstreamState<TSpec>
|
2020-01-15 04:50:01 +00:00
|
|
|
where
|
Initial work towards v0.2.0 (#924)
* Remove ping protocol
* Initial renaming of network services
* Correct rebasing relative to latest master
* Start updating types
* Adds HashMapDelay struct to utils
* Initial network restructure
* Network restructure. Adds new types for v0.2.0
* Removes build artefacts
* Shift validation to beacon chain
* Temporarily remove gossip validation
This is to be updated to match current optimisation efforts.
* Adds AggregateAndProof
* Begin rebuilding pubsub encoding/decoding
* Signature hacking
* Shift gossipsup decoding into eth2_libp2p
* Existing EF tests passing with fake_crypto
* Shifts block encoding/decoding into RPC
* Delete outdated API spec
* All release tests passing bar genesis state parsing
* Update and test YamlConfig
* Update to spec v0.10 compatible BLS
* Updates to BLS EF tests
* Add EF test for AggregateVerify
And delete unused hash2curve tests for uncompressed points
* Update EF tests to v0.10.1
* Use optional block root correctly in block proc
* Use genesis fork in deposit domain. All tests pass
* Fast aggregate verify test
* Update REST API docs
* Fix unused import
* Bump spec tags to v0.10.1
* Add `seconds_per_eth1_block` to chainspec
* Update to timestamp based eth1 voting scheme
* Return None from `get_votes_to_consider` if block cache is empty
* Handle overflows in `is_candidate_block`
* Revert to failing tests
* Fix eth1 data sets test
* Choose default vote according to spec
* Fix collect_valid_votes tests
* Fix `get_votes_to_consider` to choose all eligible blocks
* Uncomment winning_vote tests
* Add comments; remove unused code
* Reduce seconds_per_eth1_block for simulation
* Addressed review comments
* Add test for default vote case
* Fix logs
* Remove unused functions
* Meter default eth1 votes
* Fix comments
* Progress on attestation service
* Address review comments; remove unused dependency
* Initial work on removing libp2p lock
* Add LRU caches to store (rollup)
* Update attestation validation for DB changes (WIP)
* Initial version of should_forward_block
* Scaffold
* Progress on attestation validation
Also, consolidate prod+testing slot clocks so that they share much
of the same implementation and can both handle sub-slot time changes.
* Removes lock from libp2p service
* Completed network lock removal
* Finish(?) attestation processing
* Correct network termination future
* Add slot check to block check
* Correct fmt issues
* Remove Drop implementation for network service
* Add first attempt at attestation proc. re-write
* Add version 2 of attestation processing
* Minor fixes
* Add validator pubkey cache
* Make get_indexed_attestation take a committee
* Link signature processing into new attn verification
* First working version
* Ensure pubkey cache is updated
* Add more metrics, slight optimizations
* Clone committee cache during attestation processing
* Update shuffling cache during block processing
* Remove old commented-out code
* Fix shuffling cache insert bug
* Used indexed attestation in fork choice
* Restructure attn processing, add metrics
* Add more detailed metrics
* Tidy, fix failing tests
* Fix failing tests, tidy
* Address reviewers suggestions
* Disable/delete two outdated tests
* Modification of validator for subscriptions
* Add slot signing to validator client
* Further progress on validation subscription
* Adds necessary validator subscription functionality
* Add new Pubkeys struct to signature_sets
* Refactor with functional approach
* Update beacon chain
* Clean up validator <-> beacon node http types
* Add aggregator status to ValidatorDuty
* Impl Clone for manual slot clock
* Fix minor errors
* Further progress validator client subscription
* Initial subscription and aggregation handling
* Remove decompressed member from pubkey bytes
* Progress to modifying val client for attestation aggregation
* First draft of validator client upgrade for aggregate attestations
* Add hashmap for indices lookup
* Add state cache, remove store cache
* Only build the head committee cache
* Removes lock on a network channel
* Partially implement beacon node subscription http api
* Correct compilation issues
* Change `get_attesting_indices` to use Vec
* Fix failing test
* Partial implementation of timer
* Adds timer, removes exit_future, http api to op pool
* Partial multiple aggregate attestation handling
* Permits bulk messages accross gossipsub network channel
* Correct compile issues
* Improve gosispsub messaging and correct rest api helpers
* Added global gossipsub subscriptions
* Update validator subscriptions data structs
* Tidy
* Re-structure validator subscriptions
* Initial handling of subscriptions
* Re-structure network service
* Add pubkey cache persistence file
* Add more comments
* Integrate persistence file into builder
* Add pubkey cache tests
* Add HashSetDelay and introduce into attestation service
* Handles validator subscriptions
* Add data_dir to beacon chain builder
* Remove Option in pubkey cache persistence file
* Ensure consistency between datadir/data_dir
* Fix failing network test
* Peer subnet discovery gets queued for future subscriptions
* Reorganise attestation service functions
* Initial wiring of attestation service
* First draft of attestation service timing logic
* Correct minor typos
* Tidy
* Fix todos
* Improve tests
* Add PeerInfo to connected peers mapping
* Fix compile error
* Fix compile error from merge
* Split up block processing metrics
* Tidy
* Refactor get_pubkey_from_state
* Remove commented-out code
* Rename state_cache -> checkpoint_cache
* Rename Checkpoint -> Snapshot
* Tidy, add comments
* Tidy up find_head function
* Change some checkpoint -> snapshot
* Add tests
* Expose max_len
* Remove dead code
* Tidy
* Fix bug
* Add sync-speed metric
* Add first attempt at VerifiableBlock
* Start integrating into beacon chain
* Integrate VerifiableBlock
* Rename VerifableBlock -> PartialBlockVerification
* Add start of typed methods
* Add progress
* Add further progress
* Rename structs
* Add full block verification to block_processing.rs
* Further beacon chain integration
* Update checks for gossip
* Add todo
* Start adding segement verification
* Add passing chain segement test
* Initial integration with batch sync
* Minor changes
* Tidy, add more error checking
* Start adding chain_segment tests
* Finish invalid signature tests
* Include single and gossip verified blocks in tests
* Add gossip verification tests
* Start adding docs
* Finish adding comments to block_processing.rs
* Rename block_processing.rs -> block_verification
* Start removing old block processing code
* Fixes beacon_chain compilation
* Fix project-wide compile errors
* Remove old code
* Correct code to pass all tests
* Fix bug with beacon proposer index
* Fix shim for BlockProcessingError
* Only process one epoch at a time
* Fix loop in chain segment processing
* Correct tests from master merge
* Add caching for state.eth1_data_votes
* Add BeaconChain::validator_pubkey
* Revert "Add caching for state.eth1_data_votes"
This reverts commit cd73dcd6434fb8d8e6bf30c5356355598ea7b78e.
Co-authored-by: Grant Wuerker <gwuerker@gmail.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
Co-authored-by: Michael Sproul <micsproul@gmail.com>
Co-authored-by: pawan <pawandhananjay@gmail.com>
Co-authored-by: Paul Hauner <paul@paulhauner.com>
2020-03-17 06:24:44 +00:00
|
|
|
TSpec: EthSpec,
|
2020-01-15 04:50:01 +00:00
|
|
|
{
|
|
|
|
/// Moves the substream state to closing and informs the connected peer. The
|
|
|
|
/// `queued_outbound_items` must be given as a parameter to add stream termination messages to
|
|
|
|
/// the outbound queue.
|
2020-05-03 13:17:12 +00:00
|
|
|
pub fn close(&mut self, outbound_queue: &mut Vec<RPCCodedResponse<TSpec>>) {
|
2020-01-15 04:50:01 +00:00
|
|
|
// When terminating a stream, report the stream termination to the requesting user via
|
|
|
|
// an RPC error
|
2020-05-18 08:13:03 +00:00
|
|
|
let error = RPCCodedResponse::ServerError("Request timed out".into());
|
2020-01-15 04:50:01 +00:00
|
|
|
|
|
|
|
// The stream termination type is irrelevant, this will terminate the
|
|
|
|
// stream
|
|
|
|
let stream_termination =
|
2020-05-03 13:17:12 +00:00
|
|
|
RPCCodedResponse::StreamTermination(ResponseTermination::BlocksByRange);
|
2020-01-15 04:50:01 +00:00
|
|
|
|
|
|
|
match std::mem::replace(self, InboundSubstreamState::Poisoned) {
|
2020-05-17 11:16:48 +00:00
|
|
|
// if we are busy awaiting a send/flush add the termination to the queue
|
|
|
|
InboundSubstreamState::ResponsePendingSend {
|
|
|
|
substream,
|
|
|
|
message,
|
|
|
|
closing,
|
|
|
|
} => {
|
2020-01-15 04:50:01 +00:00
|
|
|
if !closing {
|
|
|
|
outbound_queue.push(error);
|
|
|
|
outbound_queue.push(stream_termination);
|
|
|
|
}
|
|
|
|
// if the stream is closing after the send, allow it to finish
|
|
|
|
|
2020-05-17 11:16:48 +00:00
|
|
|
*self = InboundSubstreamState::ResponsePendingSend {
|
|
|
|
substream,
|
|
|
|
message,
|
|
|
|
closing,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// if we are busy awaiting a send/flush add the termination to the queue
|
|
|
|
InboundSubstreamState::ResponsePendingFlush { substream, closing } => {
|
|
|
|
if !closing {
|
|
|
|
outbound_queue.push(error);
|
|
|
|
outbound_queue.push(stream_termination);
|
|
|
|
}
|
|
|
|
// if the stream is closing after the send, allow it to finish
|
|
|
|
*self = InboundSubstreamState::ResponsePendingFlush { substream, closing }
|
2020-01-15 04:50:01 +00:00
|
|
|
}
|
Initial work towards v0.2.0 (#924)
* Remove ping protocol
* Initial renaming of network services
* Correct rebasing relative to latest master
* Start updating types
* Adds HashMapDelay struct to utils
* Initial network restructure
* Network restructure. Adds new types for v0.2.0
* Removes build artefacts
* Shift validation to beacon chain
* Temporarily remove gossip validation
This is to be updated to match current optimisation efforts.
* Adds AggregateAndProof
* Begin rebuilding pubsub encoding/decoding
* Signature hacking
* Shift gossipsup decoding into eth2_libp2p
* Existing EF tests passing with fake_crypto
* Shifts block encoding/decoding into RPC
* Delete outdated API spec
* All release tests passing bar genesis state parsing
* Update and test YamlConfig
* Update to spec v0.10 compatible BLS
* Updates to BLS EF tests
* Add EF test for AggregateVerify
And delete unused hash2curve tests for uncompressed points
* Update EF tests to v0.10.1
* Use optional block root correctly in block proc
* Use genesis fork in deposit domain. All tests pass
* Fast aggregate verify test
* Update REST API docs
* Fix unused import
* Bump spec tags to v0.10.1
* Add `seconds_per_eth1_block` to chainspec
* Update to timestamp based eth1 voting scheme
* Return None from `get_votes_to_consider` if block cache is empty
* Handle overflows in `is_candidate_block`
* Revert to failing tests
* Fix eth1 data sets test
* Choose default vote according to spec
* Fix collect_valid_votes tests
* Fix `get_votes_to_consider` to choose all eligible blocks
* Uncomment winning_vote tests
* Add comments; remove unused code
* Reduce seconds_per_eth1_block for simulation
* Addressed review comments
* Add test for default vote case
* Fix logs
* Remove unused functions
* Meter default eth1 votes
* Fix comments
* Progress on attestation service
* Address review comments; remove unused dependency
* Initial work on removing libp2p lock
* Add LRU caches to store (rollup)
* Update attestation validation for DB changes (WIP)
* Initial version of should_forward_block
* Scaffold
* Progress on attestation validation
Also, consolidate prod+testing slot clocks so that they share much
of the same implementation and can both handle sub-slot time changes.
* Removes lock from libp2p service
* Completed network lock removal
* Finish(?) attestation processing
* Correct network termination future
* Add slot check to block check
* Correct fmt issues
* Remove Drop implementation for network service
* Add first attempt at attestation proc. re-write
* Add version 2 of attestation processing
* Minor fixes
* Add validator pubkey cache
* Make get_indexed_attestation take a committee
* Link signature processing into new attn verification
* First working version
* Ensure pubkey cache is updated
* Add more metrics, slight optimizations
* Clone committee cache during attestation processing
* Update shuffling cache during block processing
* Remove old commented-out code
* Fix shuffling cache insert bug
* Used indexed attestation in fork choice
* Restructure attn processing, add metrics
* Add more detailed metrics
* Tidy, fix failing tests
* Fix failing tests, tidy
* Address reviewers suggestions
* Disable/delete two outdated tests
* Modification of validator for subscriptions
* Add slot signing to validator client
* Further progress on validation subscription
* Adds necessary validator subscription functionality
* Add new Pubkeys struct to signature_sets
* Refactor with functional approach
* Update beacon chain
* Clean up validator <-> beacon node http types
* Add aggregator status to ValidatorDuty
* Impl Clone for manual slot clock
* Fix minor errors
* Further progress validator client subscription
* Initial subscription and aggregation handling
* Remove decompressed member from pubkey bytes
* Progress to modifying val client for attestation aggregation
* First draft of validator client upgrade for aggregate attestations
* Add hashmap for indices lookup
* Add state cache, remove store cache
* Only build the head committee cache
* Removes lock on a network channel
* Partially implement beacon node subscription http api
* Correct compilation issues
* Change `get_attesting_indices` to use Vec
* Fix failing test
* Partial implementation of timer
* Adds timer, removes exit_future, http api to op pool
* Partial multiple aggregate attestation handling
* Permits bulk messages accross gossipsub network channel
* Correct compile issues
* Improve gosispsub messaging and correct rest api helpers
* Added global gossipsub subscriptions
* Update validator subscriptions data structs
* Tidy
* Re-structure validator subscriptions
* Initial handling of subscriptions
* Re-structure network service
* Add pubkey cache persistence file
* Add more comments
* Integrate persistence file into builder
* Add pubkey cache tests
* Add HashSetDelay and introduce into attestation service
* Handles validator subscriptions
* Add data_dir to beacon chain builder
* Remove Option in pubkey cache persistence file
* Ensure consistency between datadir/data_dir
* Fix failing network test
* Peer subnet discovery gets queued for future subscriptions
* Reorganise attestation service functions
* Initial wiring of attestation service
* First draft of attestation service timing logic
* Correct minor typos
* Tidy
* Fix todos
* Improve tests
* Add PeerInfo to connected peers mapping
* Fix compile error
* Fix compile error from merge
* Split up block processing metrics
* Tidy
* Refactor get_pubkey_from_state
* Remove commented-out code
* Rename state_cache -> checkpoint_cache
* Rename Checkpoint -> Snapshot
* Tidy, add comments
* Tidy up find_head function
* Change some checkpoint -> snapshot
* Add tests
* Expose max_len
* Remove dead code
* Tidy
* Fix bug
* Add sync-speed metric
* Add first attempt at VerifiableBlock
* Start integrating into beacon chain
* Integrate VerifiableBlock
* Rename VerifableBlock -> PartialBlockVerification
* Add start of typed methods
* Add progress
* Add further progress
* Rename structs
* Add full block verification to block_processing.rs
* Further beacon chain integration
* Update checks for gossip
* Add todo
* Start adding segement verification
* Add passing chain segement test
* Initial integration with batch sync
* Minor changes
* Tidy, add more error checking
* Start adding chain_segment tests
* Finish invalid signature tests
* Include single and gossip verified blocks in tests
* Add gossip verification tests
* Start adding docs
* Finish adding comments to block_processing.rs
* Rename block_processing.rs -> block_verification
* Start removing old block processing code
* Fixes beacon_chain compilation
* Fix project-wide compile errors
* Remove old code
* Correct code to pass all tests
* Fix bug with beacon proposer index
* Fix shim for BlockProcessingError
* Only process one epoch at a time
* Fix loop in chain segment processing
* Correct tests from master merge
* Add caching for state.eth1_data_votes
* Add BeaconChain::validator_pubkey
* Revert "Add caching for state.eth1_data_votes"
This reverts commit cd73dcd6434fb8d8e6bf30c5356355598ea7b78e.
Co-authored-by: Grant Wuerker <gwuerker@gmail.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
Co-authored-by: Michael Sproul <micsproul@gmail.com>
Co-authored-by: pawan <pawandhananjay@gmail.com>
Co-authored-by: Paul Hauner <paul@paulhauner.com>
2020-03-17 06:24:44 +00:00
|
|
|
InboundSubstreamState::ResponseIdle(substream) => {
|
|
|
|
*self = InboundSubstreamState::ResponsePendingSend {
|
2020-06-05 03:07:59 +00:00
|
|
|
substream,
|
2020-05-17 11:16:48 +00:00
|
|
|
message: error,
|
Initial work towards v0.2.0 (#924)
* Remove ping protocol
* Initial renaming of network services
* Correct rebasing relative to latest master
* Start updating types
* Adds HashMapDelay struct to utils
* Initial network restructure
* Network restructure. Adds new types for v0.2.0
* Removes build artefacts
* Shift validation to beacon chain
* Temporarily remove gossip validation
This is to be updated to match current optimisation efforts.
* Adds AggregateAndProof
* Begin rebuilding pubsub encoding/decoding
* Signature hacking
* Shift gossipsup decoding into eth2_libp2p
* Existing EF tests passing with fake_crypto
* Shifts block encoding/decoding into RPC
* Delete outdated API spec
* All release tests passing bar genesis state parsing
* Update and test YamlConfig
* Update to spec v0.10 compatible BLS
* Updates to BLS EF tests
* Add EF test for AggregateVerify
And delete unused hash2curve tests for uncompressed points
* Update EF tests to v0.10.1
* Use optional block root correctly in block proc
* Use genesis fork in deposit domain. All tests pass
* Fast aggregate verify test
* Update REST API docs
* Fix unused import
* Bump spec tags to v0.10.1
* Add `seconds_per_eth1_block` to chainspec
* Update to timestamp based eth1 voting scheme
* Return None from `get_votes_to_consider` if block cache is empty
* Handle overflows in `is_candidate_block`
* Revert to failing tests
* Fix eth1 data sets test
* Choose default vote according to spec
* Fix collect_valid_votes tests
* Fix `get_votes_to_consider` to choose all eligible blocks
* Uncomment winning_vote tests
* Add comments; remove unused code
* Reduce seconds_per_eth1_block for simulation
* Addressed review comments
* Add test for default vote case
* Fix logs
* Remove unused functions
* Meter default eth1 votes
* Fix comments
* Progress on attestation service
* Address review comments; remove unused dependency
* Initial work on removing libp2p lock
* Add LRU caches to store (rollup)
* Update attestation validation for DB changes (WIP)
* Initial version of should_forward_block
* Scaffold
* Progress on attestation validation
Also, consolidate prod+testing slot clocks so that they share much
of the same implementation and can both handle sub-slot time changes.
* Removes lock from libp2p service
* Completed network lock removal
* Finish(?) attestation processing
* Correct network termination future
* Add slot check to block check
* Correct fmt issues
* Remove Drop implementation for network service
* Add first attempt at attestation proc. re-write
* Add version 2 of attestation processing
* Minor fixes
* Add validator pubkey cache
* Make get_indexed_attestation take a committee
* Link signature processing into new attn verification
* First working version
* Ensure pubkey cache is updated
* Add more metrics, slight optimizations
* Clone committee cache during attestation processing
* Update shuffling cache during block processing
* Remove old commented-out code
* Fix shuffling cache insert bug
* Used indexed attestation in fork choice
* Restructure attn processing, add metrics
* Add more detailed metrics
* Tidy, fix failing tests
* Fix failing tests, tidy
* Address reviewers suggestions
* Disable/delete two outdated tests
* Modification of validator for subscriptions
* Add slot signing to validator client
* Further progress on validation subscription
* Adds necessary validator subscription functionality
* Add new Pubkeys struct to signature_sets
* Refactor with functional approach
* Update beacon chain
* Clean up validator <-> beacon node http types
* Add aggregator status to ValidatorDuty
* Impl Clone for manual slot clock
* Fix minor errors
* Further progress validator client subscription
* Initial subscription and aggregation handling
* Remove decompressed member from pubkey bytes
* Progress to modifying val client for attestation aggregation
* First draft of validator client upgrade for aggregate attestations
* Add hashmap for indices lookup
* Add state cache, remove store cache
* Only build the head committee cache
* Removes lock on a network channel
* Partially implement beacon node subscription http api
* Correct compilation issues
* Change `get_attesting_indices` to use Vec
* Fix failing test
* Partial implementation of timer
* Adds timer, removes exit_future, http api to op pool
* Partial multiple aggregate attestation handling
* Permits bulk messages accross gossipsub network channel
* Correct compile issues
* Improve gosispsub messaging and correct rest api helpers
* Added global gossipsub subscriptions
* Update validator subscriptions data structs
* Tidy
* Re-structure validator subscriptions
* Initial handling of subscriptions
* Re-structure network service
* Add pubkey cache persistence file
* Add more comments
* Integrate persistence file into builder
* Add pubkey cache tests
* Add HashSetDelay and introduce into attestation service
* Handles validator subscriptions
* Add data_dir to beacon chain builder
* Remove Option in pubkey cache persistence file
* Ensure consistency between datadir/data_dir
* Fix failing network test
* Peer subnet discovery gets queued for future subscriptions
* Reorganise attestation service functions
* Initial wiring of attestation service
* First draft of attestation service timing logic
* Correct minor typos
* Tidy
* Fix todos
* Improve tests
* Add PeerInfo to connected peers mapping
* Fix compile error
* Fix compile error from merge
* Split up block processing metrics
* Tidy
* Refactor get_pubkey_from_state
* Remove commented-out code
* Rename state_cache -> checkpoint_cache
* Rename Checkpoint -> Snapshot
* Tidy, add comments
* Tidy up find_head function
* Change some checkpoint -> snapshot
* Add tests
* Expose max_len
* Remove dead code
* Tidy
* Fix bug
* Add sync-speed metric
* Add first attempt at VerifiableBlock
* Start integrating into beacon chain
* Integrate VerifiableBlock
* Rename VerifableBlock -> PartialBlockVerification
* Add start of typed methods
* Add progress
* Add further progress
* Rename structs
* Add full block verification to block_processing.rs
* Further beacon chain integration
* Update checks for gossip
* Add todo
* Start adding segement verification
* Add passing chain segement test
* Initial integration with batch sync
* Minor changes
* Tidy, add more error checking
* Start adding chain_segment tests
* Finish invalid signature tests
* Include single and gossip verified blocks in tests
* Add gossip verification tests
* Start adding docs
* Finish adding comments to block_processing.rs
* Rename block_processing.rs -> block_verification
* Start removing old block processing code
* Fixes beacon_chain compilation
* Fix project-wide compile errors
* Remove old code
* Correct code to pass all tests
* Fix bug with beacon proposer index
* Fix shim for BlockProcessingError
* Only process one epoch at a time
* Fix loop in chain segment processing
* Correct tests from master merge
* Add caching for state.eth1_data_votes
* Add BeaconChain::validator_pubkey
* Revert "Add caching for state.eth1_data_votes"
This reverts commit cd73dcd6434fb8d8e6bf30c5356355598ea7b78e.
Co-authored-by: Grant Wuerker <gwuerker@gmail.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
Co-authored-by: Michael Sproul <micsproul@gmail.com>
Co-authored-by: pawan <pawandhananjay@gmail.com>
Co-authored-by: Paul Hauner <paul@paulhauner.com>
2020-03-17 06:24:44 +00:00
|
|
|
closing: true,
|
|
|
|
};
|
2020-01-15 04:50:01 +00:00
|
|
|
}
|
|
|
|
InboundSubstreamState::Closing(substream) => {
|
|
|
|
// let the stream close
|
|
|
|
*self = InboundSubstreamState::Closing(substream);
|
|
|
|
}
|
|
|
|
InboundSubstreamState::Poisoned => {
|
|
|
|
unreachable!("Coding error: Timeout poisoned substream")
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-17 11:16:48 +00:00
|
|
|
impl<TSpec> RPCHandler<TSpec>
|
2019-07-16 12:32:37 +00:00
|
|
|
where
|
Initial work towards v0.2.0 (#924)
* Remove ping protocol
* Initial renaming of network services
* Correct rebasing relative to latest master
* Start updating types
* Adds HashMapDelay struct to utils
* Initial network restructure
* Network restructure. Adds new types for v0.2.0
* Removes build artefacts
* Shift validation to beacon chain
* Temporarily remove gossip validation
This is to be updated to match current optimisation efforts.
* Adds AggregateAndProof
* Begin rebuilding pubsub encoding/decoding
* Signature hacking
* Shift gossipsup decoding into eth2_libp2p
* Existing EF tests passing with fake_crypto
* Shifts block encoding/decoding into RPC
* Delete outdated API spec
* All release tests passing bar genesis state parsing
* Update and test YamlConfig
* Update to spec v0.10 compatible BLS
* Updates to BLS EF tests
* Add EF test for AggregateVerify
And delete unused hash2curve tests for uncompressed points
* Update EF tests to v0.10.1
* Use optional block root correctly in block proc
* Use genesis fork in deposit domain. All tests pass
* Fast aggregate verify test
* Update REST API docs
* Fix unused import
* Bump spec tags to v0.10.1
* Add `seconds_per_eth1_block` to chainspec
* Update to timestamp based eth1 voting scheme
* Return None from `get_votes_to_consider` if block cache is empty
* Handle overflows in `is_candidate_block`
* Revert to failing tests
* Fix eth1 data sets test
* Choose default vote according to spec
* Fix collect_valid_votes tests
* Fix `get_votes_to_consider` to choose all eligible blocks
* Uncomment winning_vote tests
* Add comments; remove unused code
* Reduce seconds_per_eth1_block for simulation
* Addressed review comments
* Add test for default vote case
* Fix logs
* Remove unused functions
* Meter default eth1 votes
* Fix comments
* Progress on attestation service
* Address review comments; remove unused dependency
* Initial work on removing libp2p lock
* Add LRU caches to store (rollup)
* Update attestation validation for DB changes (WIP)
* Initial version of should_forward_block
* Scaffold
* Progress on attestation validation
Also, consolidate prod+testing slot clocks so that they share much
of the same implementation and can both handle sub-slot time changes.
* Removes lock from libp2p service
* Completed network lock removal
* Finish(?) attestation processing
* Correct network termination future
* Add slot check to block check
* Correct fmt issues
* Remove Drop implementation for network service
* Add first attempt at attestation proc. re-write
* Add version 2 of attestation processing
* Minor fixes
* Add validator pubkey cache
* Make get_indexed_attestation take a committee
* Link signature processing into new attn verification
* First working version
* Ensure pubkey cache is updated
* Add more metrics, slight optimizations
* Clone committee cache during attestation processing
* Update shuffling cache during block processing
* Remove old commented-out code
* Fix shuffling cache insert bug
* Used indexed attestation in fork choice
* Restructure attn processing, add metrics
* Add more detailed metrics
* Tidy, fix failing tests
* Fix failing tests, tidy
* Address reviewers suggestions
* Disable/delete two outdated tests
* Modification of validator for subscriptions
* Add slot signing to validator client
* Further progress on validation subscription
* Adds necessary validator subscription functionality
* Add new Pubkeys struct to signature_sets
* Refactor with functional approach
* Update beacon chain
* Clean up validator <-> beacon node http types
* Add aggregator status to ValidatorDuty
* Impl Clone for manual slot clock
* Fix minor errors
* Further progress validator client subscription
* Initial subscription and aggregation handling
* Remove decompressed member from pubkey bytes
* Progress to modifying val client for attestation aggregation
* First draft of validator client upgrade for aggregate attestations
* Add hashmap for indices lookup
* Add state cache, remove store cache
* Only build the head committee cache
* Removes lock on a network channel
* Partially implement beacon node subscription http api
* Correct compilation issues
* Change `get_attesting_indices` to use Vec
* Fix failing test
* Partial implementation of timer
* Adds timer, removes exit_future, http api to op pool
* Partial multiple aggregate attestation handling
* Permits bulk messages accross gossipsub network channel
* Correct compile issues
* Improve gosispsub messaging and correct rest api helpers
* Added global gossipsub subscriptions
* Update validator subscriptions data structs
* Tidy
* Re-structure validator subscriptions
* Initial handling of subscriptions
* Re-structure network service
* Add pubkey cache persistence file
* Add more comments
* Integrate persistence file into builder
* Add pubkey cache tests
* Add HashSetDelay and introduce into attestation service
* Handles validator subscriptions
* Add data_dir to beacon chain builder
* Remove Option in pubkey cache persistence file
* Ensure consistency between datadir/data_dir
* Fix failing network test
* Peer subnet discovery gets queued for future subscriptions
* Reorganise attestation service functions
* Initial wiring of attestation service
* First draft of attestation service timing logic
* Correct minor typos
* Tidy
* Fix todos
* Improve tests
* Add PeerInfo to connected peers mapping
* Fix compile error
* Fix compile error from merge
* Split up block processing metrics
* Tidy
* Refactor get_pubkey_from_state
* Remove commented-out code
* Rename state_cache -> checkpoint_cache
* Rename Checkpoint -> Snapshot
* Tidy, add comments
* Tidy up find_head function
* Change some checkpoint -> snapshot
* Add tests
* Expose max_len
* Remove dead code
* Tidy
* Fix bug
* Add sync-speed metric
* Add first attempt at VerifiableBlock
* Start integrating into beacon chain
* Integrate VerifiableBlock
* Rename VerifableBlock -> PartialBlockVerification
* Add start of typed methods
* Add progress
* Add further progress
* Rename structs
* Add full block verification to block_processing.rs
* Further beacon chain integration
* Update checks for gossip
* Add todo
* Start adding segement verification
* Add passing chain segement test
* Initial integration with batch sync
* Minor changes
* Tidy, add more error checking
* Start adding chain_segment tests
* Finish invalid signature tests
* Include single and gossip verified blocks in tests
* Add gossip verification tests
* Start adding docs
* Finish adding comments to block_processing.rs
* Rename block_processing.rs -> block_verification
* Start removing old block processing code
* Fixes beacon_chain compilation
* Fix project-wide compile errors
* Remove old code
* Correct code to pass all tests
* Fix bug with beacon proposer index
* Fix shim for BlockProcessingError
* Only process one epoch at a time
* Fix loop in chain segment processing
* Correct tests from master merge
* Add caching for state.eth1_data_votes
* Add BeaconChain::validator_pubkey
* Revert "Add caching for state.eth1_data_votes"
This reverts commit cd73dcd6434fb8d8e6bf30c5356355598ea7b78e.
Co-authored-by: Grant Wuerker <gwuerker@gmail.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
Co-authored-by: Michael Sproul <micsproul@gmail.com>
Co-authored-by: pawan <pawandhananjay@gmail.com>
Co-authored-by: Paul Hauner <paul@paulhauner.com>
2020-03-17 06:24:44 +00:00
|
|
|
TSpec: EthSpec,
|
2019-07-16 12:32:37 +00:00
|
|
|
{
|
2019-07-06 11:32:32 +00:00
|
|
|
pub fn new(
|
Initial work towards v0.2.0 (#924)
* Remove ping protocol
* Initial renaming of network services
* Correct rebasing relative to latest master
* Start updating types
* Adds HashMapDelay struct to utils
* Initial network restructure
* Network restructure. Adds new types for v0.2.0
* Removes build artefacts
* Shift validation to beacon chain
* Temporarily remove gossip validation
This is to be updated to match current optimisation efforts.
* Adds AggregateAndProof
* Begin rebuilding pubsub encoding/decoding
* Signature hacking
* Shift gossipsup decoding into eth2_libp2p
* Existing EF tests passing with fake_crypto
* Shifts block encoding/decoding into RPC
* Delete outdated API spec
* All release tests passing bar genesis state parsing
* Update and test YamlConfig
* Update to spec v0.10 compatible BLS
* Updates to BLS EF tests
* Add EF test for AggregateVerify
And delete unused hash2curve tests for uncompressed points
* Update EF tests to v0.10.1
* Use optional block root correctly in block proc
* Use genesis fork in deposit domain. All tests pass
* Fast aggregate verify test
* Update REST API docs
* Fix unused import
* Bump spec tags to v0.10.1
* Add `seconds_per_eth1_block` to chainspec
* Update to timestamp based eth1 voting scheme
* Return None from `get_votes_to_consider` if block cache is empty
* Handle overflows in `is_candidate_block`
* Revert to failing tests
* Fix eth1 data sets test
* Choose default vote according to spec
* Fix collect_valid_votes tests
* Fix `get_votes_to_consider` to choose all eligible blocks
* Uncomment winning_vote tests
* Add comments; remove unused code
* Reduce seconds_per_eth1_block for simulation
* Addressed review comments
* Add test for default vote case
* Fix logs
* Remove unused functions
* Meter default eth1 votes
* Fix comments
* Progress on attestation service
* Address review comments; remove unused dependency
* Initial work on removing libp2p lock
* Add LRU caches to store (rollup)
* Update attestation validation for DB changes (WIP)
* Initial version of should_forward_block
* Scaffold
* Progress on attestation validation
Also, consolidate prod+testing slot clocks so that they share much
of the same implementation and can both handle sub-slot time changes.
* Removes lock from libp2p service
* Completed network lock removal
* Finish(?) attestation processing
* Correct network termination future
* Add slot check to block check
* Correct fmt issues
* Remove Drop implementation for network service
* Add first attempt at attestation proc. re-write
* Add version 2 of attestation processing
* Minor fixes
* Add validator pubkey cache
* Make get_indexed_attestation take a committee
* Link signature processing into new attn verification
* First working version
* Ensure pubkey cache is updated
* Add more metrics, slight optimizations
* Clone committee cache during attestation processing
* Update shuffling cache during block processing
* Remove old commented-out code
* Fix shuffling cache insert bug
* Used indexed attestation in fork choice
* Restructure attn processing, add metrics
* Add more detailed metrics
* Tidy, fix failing tests
* Fix failing tests, tidy
* Address reviewers suggestions
* Disable/delete two outdated tests
* Modification of validator for subscriptions
* Add slot signing to validator client
* Further progress on validation subscription
* Adds necessary validator subscription functionality
* Add new Pubkeys struct to signature_sets
* Refactor with functional approach
* Update beacon chain
* Clean up validator <-> beacon node http types
* Add aggregator status to ValidatorDuty
* Impl Clone for manual slot clock
* Fix minor errors
* Further progress validator client subscription
* Initial subscription and aggregation handling
* Remove decompressed member from pubkey bytes
* Progress to modifying val client for attestation aggregation
* First draft of validator client upgrade for aggregate attestations
* Add hashmap for indices lookup
* Add state cache, remove store cache
* Only build the head committee cache
* Removes lock on a network channel
* Partially implement beacon node subscription http api
* Correct compilation issues
* Change `get_attesting_indices` to use Vec
* Fix failing test
* Partial implementation of timer
* Adds timer, removes exit_future, http api to op pool
* Partial multiple aggregate attestation handling
* Permits bulk messages accross gossipsub network channel
* Correct compile issues
* Improve gosispsub messaging and correct rest api helpers
* Added global gossipsub subscriptions
* Update validator subscriptions data structs
* Tidy
* Re-structure validator subscriptions
* Initial handling of subscriptions
* Re-structure network service
* Add pubkey cache persistence file
* Add more comments
* Integrate persistence file into builder
* Add pubkey cache tests
* Add HashSetDelay and introduce into attestation service
* Handles validator subscriptions
* Add data_dir to beacon chain builder
* Remove Option in pubkey cache persistence file
* Ensure consistency between datadir/data_dir
* Fix failing network test
* Peer subnet discovery gets queued for future subscriptions
* Reorganise attestation service functions
* Initial wiring of attestation service
* First draft of attestation service timing logic
* Correct minor typos
* Tidy
* Fix todos
* Improve tests
* Add PeerInfo to connected peers mapping
* Fix compile error
* Fix compile error from merge
* Split up block processing metrics
* Tidy
* Refactor get_pubkey_from_state
* Remove commented-out code
* Rename state_cache -> checkpoint_cache
* Rename Checkpoint -> Snapshot
* Tidy, add comments
* Tidy up find_head function
* Change some checkpoint -> snapshot
* Add tests
* Expose max_len
* Remove dead code
* Tidy
* Fix bug
* Add sync-speed metric
* Add first attempt at VerifiableBlock
* Start integrating into beacon chain
* Integrate VerifiableBlock
* Rename VerifableBlock -> PartialBlockVerification
* Add start of typed methods
* Add progress
* Add further progress
* Rename structs
* Add full block verification to block_processing.rs
* Further beacon chain integration
* Update checks for gossip
* Add todo
* Start adding segement verification
* Add passing chain segement test
* Initial integration with batch sync
* Minor changes
* Tidy, add more error checking
* Start adding chain_segment tests
* Finish invalid signature tests
* Include single and gossip verified blocks in tests
* Add gossip verification tests
* Start adding docs
* Finish adding comments to block_processing.rs
* Rename block_processing.rs -> block_verification
* Start removing old block processing code
* Fixes beacon_chain compilation
* Fix project-wide compile errors
* Remove old code
* Correct code to pass all tests
* Fix bug with beacon proposer index
* Fix shim for BlockProcessingError
* Only process one epoch at a time
* Fix loop in chain segment processing
* Correct tests from master merge
* Add caching for state.eth1_data_votes
* Add BeaconChain::validator_pubkey
* Revert "Add caching for state.eth1_data_votes"
This reverts commit cd73dcd6434fb8d8e6bf30c5356355598ea7b78e.
Co-authored-by: Grant Wuerker <gwuerker@gmail.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
Co-authored-by: Michael Sproul <micsproul@gmail.com>
Co-authored-by: pawan <pawandhananjay@gmail.com>
Co-authored-by: Paul Hauner <paul@paulhauner.com>
2020-03-17 06:24:44 +00:00
|
|
|
listen_protocol: SubstreamProtocol<RPCProtocol<TSpec>>,
|
2019-07-09 05:44:23 +00:00
|
|
|
inactive_timeout: Duration,
|
2019-11-27 01:47:46 +00:00
|
|
|
log: &slog::Logger,
|
2019-07-06 11:32:32 +00:00
|
|
|
) -> Self {
|
|
|
|
RPCHandler {
|
|
|
|
listen_protocol,
|
2020-06-05 03:07:59 +00:00
|
|
|
pending_errors: Vec::new(),
|
2019-07-06 11:32:32 +00:00
|
|
|
events_out: SmallVec::new(),
|
|
|
|
dial_queue: SmallVec::new(),
|
|
|
|
dial_negotiated: 0,
|
2019-11-27 01:47:46 +00:00
|
|
|
queued_outbound_items: FnvHashMap::default(),
|
|
|
|
inbound_substreams: FnvHashMap::default(),
|
|
|
|
outbound_substreams: FnvHashMap::default(),
|
|
|
|
inbound_substreams_delay: DelayQueue::new(),
|
|
|
|
outbound_substreams_delay: DelayQueue::new(),
|
2020-06-05 03:07:59 +00:00
|
|
|
current_inbound_substream_id: SubstreamId(0),
|
|
|
|
current_outbound_substream_id: SubstreamId(0),
|
2020-06-18 01:53:08 +00:00
|
|
|
state: HandlerState::Active,
|
2019-07-06 11:32:32 +00:00
|
|
|
max_dial_negotiated: 8,
|
|
|
|
keep_alive: KeepAlive::Yes,
|
|
|
|
inactive_timeout,
|
2019-12-09 07:50:21 +00:00
|
|
|
outbound_io_error_retries: 0,
|
2019-11-27 01:47:46 +00:00
|
|
|
log: log.clone(),
|
2019-07-06 11:32:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Returns a reference to the listen protocol configuration.
|
|
|
|
///
|
|
|
|
/// > **Note**: If you modify the protocol, modifications will only applies to future inbound
|
|
|
|
/// > substreams, not the ones already being negotiated.
|
Initial work towards v0.2.0 (#924)
* Remove ping protocol
* Initial renaming of network services
* Correct rebasing relative to latest master
* Start updating types
* Adds HashMapDelay struct to utils
* Initial network restructure
* Network restructure. Adds new types for v0.2.0
* Removes build artefacts
* Shift validation to beacon chain
* Temporarily remove gossip validation
This is to be updated to match current optimisation efforts.
* Adds AggregateAndProof
* Begin rebuilding pubsub encoding/decoding
* Signature hacking
* Shift gossipsup decoding into eth2_libp2p
* Existing EF tests passing with fake_crypto
* Shifts block encoding/decoding into RPC
* Delete outdated API spec
* All release tests passing bar genesis state parsing
* Update and test YamlConfig
* Update to spec v0.10 compatible BLS
* Updates to BLS EF tests
* Add EF test for AggregateVerify
And delete unused hash2curve tests for uncompressed points
* Update EF tests to v0.10.1
* Use optional block root correctly in block proc
* Use genesis fork in deposit domain. All tests pass
* Fast aggregate verify test
* Update REST API docs
* Fix unused import
* Bump spec tags to v0.10.1
* Add `seconds_per_eth1_block` to chainspec
* Update to timestamp based eth1 voting scheme
* Return None from `get_votes_to_consider` if block cache is empty
* Handle overflows in `is_candidate_block`
* Revert to failing tests
* Fix eth1 data sets test
* Choose default vote according to spec
* Fix collect_valid_votes tests
* Fix `get_votes_to_consider` to choose all eligible blocks
* Uncomment winning_vote tests
* Add comments; remove unused code
* Reduce seconds_per_eth1_block for simulation
* Addressed review comments
* Add test for default vote case
* Fix logs
* Remove unused functions
* Meter default eth1 votes
* Fix comments
* Progress on attestation service
* Address review comments; remove unused dependency
* Initial work on removing libp2p lock
* Add LRU caches to store (rollup)
* Update attestation validation for DB changes (WIP)
* Initial version of should_forward_block
* Scaffold
* Progress on attestation validation
Also, consolidate prod+testing slot clocks so that they share much
of the same implementation and can both handle sub-slot time changes.
* Removes lock from libp2p service
* Completed network lock removal
* Finish(?) attestation processing
* Correct network termination future
* Add slot check to block check
* Correct fmt issues
* Remove Drop implementation for network service
* Add first attempt at attestation proc. re-write
* Add version 2 of attestation processing
* Minor fixes
* Add validator pubkey cache
* Make get_indexed_attestation take a committee
* Link signature processing into new attn verification
* First working version
* Ensure pubkey cache is updated
* Add more metrics, slight optimizations
* Clone committee cache during attestation processing
* Update shuffling cache during block processing
* Remove old commented-out code
* Fix shuffling cache insert bug
* Used indexed attestation in fork choice
* Restructure attn processing, add metrics
* Add more detailed metrics
* Tidy, fix failing tests
* Fix failing tests, tidy
* Address reviewers suggestions
* Disable/delete two outdated tests
* Modification of validator for subscriptions
* Add slot signing to validator client
* Further progress on validation subscription
* Adds necessary validator subscription functionality
* Add new Pubkeys struct to signature_sets
* Refactor with functional approach
* Update beacon chain
* Clean up validator <-> beacon node http types
* Add aggregator status to ValidatorDuty
* Impl Clone for manual slot clock
* Fix minor errors
* Further progress validator client subscription
* Initial subscription and aggregation handling
* Remove decompressed member from pubkey bytes
* Progress to modifying val client for attestation aggregation
* First draft of validator client upgrade for aggregate attestations
* Add hashmap for indices lookup
* Add state cache, remove store cache
* Only build the head committee cache
* Removes lock on a network channel
* Partially implement beacon node subscription http api
* Correct compilation issues
* Change `get_attesting_indices` to use Vec
* Fix failing test
* Partial implementation of timer
* Adds timer, removes exit_future, http api to op pool
* Partial multiple aggregate attestation handling
* Permits bulk messages accross gossipsub network channel
* Correct compile issues
* Improve gosispsub messaging and correct rest api helpers
* Added global gossipsub subscriptions
* Update validator subscriptions data structs
* Tidy
* Re-structure validator subscriptions
* Initial handling of subscriptions
* Re-structure network service
* Add pubkey cache persistence file
* Add more comments
* Integrate persistence file into builder
* Add pubkey cache tests
* Add HashSetDelay and introduce into attestation service
* Handles validator subscriptions
* Add data_dir to beacon chain builder
* Remove Option in pubkey cache persistence file
* Ensure consistency between datadir/data_dir
* Fix failing network test
* Peer subnet discovery gets queued for future subscriptions
* Reorganise attestation service functions
* Initial wiring of attestation service
* First draft of attestation service timing logic
* Correct minor typos
* Tidy
* Fix todos
* Improve tests
* Add PeerInfo to connected peers mapping
* Fix compile error
* Fix compile error from merge
* Split up block processing metrics
* Tidy
* Refactor get_pubkey_from_state
* Remove commented-out code
* Rename state_cache -> checkpoint_cache
* Rename Checkpoint -> Snapshot
* Tidy, add comments
* Tidy up find_head function
* Change some checkpoint -> snapshot
* Add tests
* Expose max_len
* Remove dead code
* Tidy
* Fix bug
* Add sync-speed metric
* Add first attempt at VerifiableBlock
* Start integrating into beacon chain
* Integrate VerifiableBlock
* Rename VerifableBlock -> PartialBlockVerification
* Add start of typed methods
* Add progress
* Add further progress
* Rename structs
* Add full block verification to block_processing.rs
* Further beacon chain integration
* Update checks for gossip
* Add todo
* Start adding segement verification
* Add passing chain segement test
* Initial integration with batch sync
* Minor changes
* Tidy, add more error checking
* Start adding chain_segment tests
* Finish invalid signature tests
* Include single and gossip verified blocks in tests
* Add gossip verification tests
* Start adding docs
* Finish adding comments to block_processing.rs
* Rename block_processing.rs -> block_verification
* Start removing old block processing code
* Fixes beacon_chain compilation
* Fix project-wide compile errors
* Remove old code
* Correct code to pass all tests
* Fix bug with beacon proposer index
* Fix shim for BlockProcessingError
* Only process one epoch at a time
* Fix loop in chain segment processing
* Correct tests from master merge
* Add caching for state.eth1_data_votes
* Add BeaconChain::validator_pubkey
* Revert "Add caching for state.eth1_data_votes"
This reverts commit cd73dcd6434fb8d8e6bf30c5356355598ea7b78e.
Co-authored-by: Grant Wuerker <gwuerker@gmail.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
Co-authored-by: Michael Sproul <micsproul@gmail.com>
Co-authored-by: pawan <pawandhananjay@gmail.com>
Co-authored-by: Paul Hauner <paul@paulhauner.com>
2020-03-17 06:24:44 +00:00
|
|
|
pub fn listen_protocol_ref(&self) -> &SubstreamProtocol<RPCProtocol<TSpec>> {
|
2019-07-06 11:32:32 +00:00
|
|
|
&self.listen_protocol
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Returns a mutable reference to the listen protocol configuration.
|
|
|
|
///
|
2020-05-29 02:03:13 +00:00
|
|
|
/// > **Note**: If you modify the protocol, modifications will only apply to future inbound
|
2019-07-06 11:32:32 +00:00
|
|
|
/// > substreams, not the ones already being negotiated.
|
Initial work towards v0.2.0 (#924)
* Remove ping protocol
* Initial renaming of network services
* Correct rebasing relative to latest master
* Start updating types
* Adds HashMapDelay struct to utils
* Initial network restructure
* Network restructure. Adds new types for v0.2.0
* Removes build artefacts
* Shift validation to beacon chain
* Temporarily remove gossip validation
This is to be updated to match current optimisation efforts.
* Adds AggregateAndProof
* Begin rebuilding pubsub encoding/decoding
* Signature hacking
* Shift gossipsup decoding into eth2_libp2p
* Existing EF tests passing with fake_crypto
* Shifts block encoding/decoding into RPC
* Delete outdated API spec
* All release tests passing bar genesis state parsing
* Update and test YamlConfig
* Update to spec v0.10 compatible BLS
* Updates to BLS EF tests
* Add EF test for AggregateVerify
And delete unused hash2curve tests for uncompressed points
* Update EF tests to v0.10.1
* Use optional block root correctly in block proc
* Use genesis fork in deposit domain. All tests pass
* Fast aggregate verify test
* Update REST API docs
* Fix unused import
* Bump spec tags to v0.10.1
* Add `seconds_per_eth1_block` to chainspec
* Update to timestamp based eth1 voting scheme
* Return None from `get_votes_to_consider` if block cache is empty
* Handle overflows in `is_candidate_block`
* Revert to failing tests
* Fix eth1 data sets test
* Choose default vote according to spec
* Fix collect_valid_votes tests
* Fix `get_votes_to_consider` to choose all eligible blocks
* Uncomment winning_vote tests
* Add comments; remove unused code
* Reduce seconds_per_eth1_block for simulation
* Addressed review comments
* Add test for default vote case
* Fix logs
* Remove unused functions
* Meter default eth1 votes
* Fix comments
* Progress on attestation service
* Address review comments; remove unused dependency
* Initial work on removing libp2p lock
* Add LRU caches to store (rollup)
* Update attestation validation for DB changes (WIP)
* Initial version of should_forward_block
* Scaffold
* Progress on attestation validation
Also, consolidate prod+testing slot clocks so that they share much
of the same implementation and can both handle sub-slot time changes.
* Removes lock from libp2p service
* Completed network lock removal
* Finish(?) attestation processing
* Correct network termination future
* Add slot check to block check
* Correct fmt issues
* Remove Drop implementation for network service
* Add first attempt at attestation proc. re-write
* Add version 2 of attestation processing
* Minor fixes
* Add validator pubkey cache
* Make get_indexed_attestation take a committee
* Link signature processing into new attn verification
* First working version
* Ensure pubkey cache is updated
* Add more metrics, slight optimizations
* Clone committee cache during attestation processing
* Update shuffling cache during block processing
* Remove old commented-out code
* Fix shuffling cache insert bug
* Used indexed attestation in fork choice
* Restructure attn processing, add metrics
* Add more detailed metrics
* Tidy, fix failing tests
* Fix failing tests, tidy
* Address reviewers suggestions
* Disable/delete two outdated tests
* Modification of validator for subscriptions
* Add slot signing to validator client
* Further progress on validation subscription
* Adds necessary validator subscription functionality
* Add new Pubkeys struct to signature_sets
* Refactor with functional approach
* Update beacon chain
* Clean up validator <-> beacon node http types
* Add aggregator status to ValidatorDuty
* Impl Clone for manual slot clock
* Fix minor errors
* Further progress validator client subscription
* Initial subscription and aggregation handling
* Remove decompressed member from pubkey bytes
* Progress to modifying val client for attestation aggregation
* First draft of validator client upgrade for aggregate attestations
* Add hashmap for indices lookup
* Add state cache, remove store cache
* Only build the head committee cache
* Removes lock on a network channel
* Partially implement beacon node subscription http api
* Correct compilation issues
* Change `get_attesting_indices` to use Vec
* Fix failing test
* Partial implementation of timer
* Adds timer, removes exit_future, http api to op pool
* Partial multiple aggregate attestation handling
* Permits bulk messages accross gossipsub network channel
* Correct compile issues
* Improve gosispsub messaging and correct rest api helpers
* Added global gossipsub subscriptions
* Update validator subscriptions data structs
* Tidy
* Re-structure validator subscriptions
* Initial handling of subscriptions
* Re-structure network service
* Add pubkey cache persistence file
* Add more comments
* Integrate persistence file into builder
* Add pubkey cache tests
* Add HashSetDelay and introduce into attestation service
* Handles validator subscriptions
* Add data_dir to beacon chain builder
* Remove Option in pubkey cache persistence file
* Ensure consistency between datadir/data_dir
* Fix failing network test
* Peer subnet discovery gets queued for future subscriptions
* Reorganise attestation service functions
* Initial wiring of attestation service
* First draft of attestation service timing logic
* Correct minor typos
* Tidy
* Fix todos
* Improve tests
* Add PeerInfo to connected peers mapping
* Fix compile error
* Fix compile error from merge
* Split up block processing metrics
* Tidy
* Refactor get_pubkey_from_state
* Remove commented-out code
* Rename state_cache -> checkpoint_cache
* Rename Checkpoint -> Snapshot
* Tidy, add comments
* Tidy up find_head function
* Change some checkpoint -> snapshot
* Add tests
* Expose max_len
* Remove dead code
* Tidy
* Fix bug
* Add sync-speed metric
* Add first attempt at VerifiableBlock
* Start integrating into beacon chain
* Integrate VerifiableBlock
* Rename VerifableBlock -> PartialBlockVerification
* Add start of typed methods
* Add progress
* Add further progress
* Rename structs
* Add full block verification to block_processing.rs
* Further beacon chain integration
* Update checks for gossip
* Add todo
* Start adding segement verification
* Add passing chain segement test
* Initial integration with batch sync
* Minor changes
* Tidy, add more error checking
* Start adding chain_segment tests
* Finish invalid signature tests
* Include single and gossip verified blocks in tests
* Add gossip verification tests
* Start adding docs
* Finish adding comments to block_processing.rs
* Rename block_processing.rs -> block_verification
* Start removing old block processing code
* Fixes beacon_chain compilation
* Fix project-wide compile errors
* Remove old code
* Correct code to pass all tests
* Fix bug with beacon proposer index
* Fix shim for BlockProcessingError
* Only process one epoch at a time
* Fix loop in chain segment processing
* Correct tests from master merge
* Add caching for state.eth1_data_votes
* Add BeaconChain::validator_pubkey
* Revert "Add caching for state.eth1_data_votes"
This reverts commit cd73dcd6434fb8d8e6bf30c5356355598ea7b78e.
Co-authored-by: Grant Wuerker <gwuerker@gmail.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
Co-authored-by: Michael Sproul <micsproul@gmail.com>
Co-authored-by: pawan <pawandhananjay@gmail.com>
Co-authored-by: Paul Hauner <paul@paulhauner.com>
2020-03-17 06:24:44 +00:00
|
|
|
pub fn listen_protocol_mut(&mut self) -> &mut SubstreamProtocol<RPCProtocol<TSpec>> {
|
2019-07-06 11:32:32 +00:00
|
|
|
&mut self.listen_protocol
|
|
|
|
}
|
|
|
|
|
2020-06-18 01:53:08 +00:00
|
|
|
/// Initiates the handler's shutdown process, sending an optional last message to the peer.
|
|
|
|
pub fn shutdown(&mut self, final_msg: Option<(RequestId, RPCRequest<TSpec>)>) {
|
|
|
|
if matches!(self.state, HandlerState::Active) {
|
|
|
|
debug!(self.log, "Starting handler shutdown"; "unsent_queued_requests" => self.dial_queue.len());
|
|
|
|
// we now drive to completion communications already dialed/established
|
2020-06-24 07:44:28 +00:00
|
|
|
while let Some((id, req)) = self.dial_queue.pop() {
|
2020-06-18 01:53:08 +00:00
|
|
|
self.pending_errors.push(HandlerErr::Outbound {
|
|
|
|
id,
|
|
|
|
proto: req.protocol(),
|
|
|
|
error: RPCError::HandlerRejected,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// Queue our final message, if any
|
|
|
|
if let Some((id, req)) = final_msg {
|
|
|
|
self.dial_queue.push((id, req));
|
|
|
|
}
|
|
|
|
|
|
|
|
self.state = HandlerState::ShuttingDown(delay_until(
|
|
|
|
TInstant::now() + Duration::from_secs(SHUTDOWN_TIMEOUT_SECS as u64),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
self.update_keep_alive();
|
|
|
|
}
|
|
|
|
|
2019-07-16 12:32:37 +00:00
|
|
|
/// Opens an outbound substream with a request.
|
2020-05-29 02:03:13 +00:00
|
|
|
fn send_request(&mut self, id: RequestId, req: RPCRequest<TSpec>) {
|
2020-06-18 01:53:08 +00:00
|
|
|
match self.state {
|
|
|
|
HandlerState::Active => {
|
|
|
|
self.dial_queue.push((id, req));
|
|
|
|
self.update_keep_alive();
|
|
|
|
}
|
|
|
|
_ => {
|
|
|
|
self.pending_errors.push(HandlerErr::Outbound {
|
|
|
|
id,
|
|
|
|
proto: req.protocol(),
|
|
|
|
error: RPCError::HandlerRejected,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Sends a response to a peer's request.
|
|
|
|
// NOTE: If the substream has closed due to inactivity, or the substream is in the
|
|
|
|
// wrong state a response will fail silently.
|
|
|
|
fn send_response(&mut self, inbound_id: SubstreamId, response: RPCCodedResponse<TSpec>) {
|
|
|
|
// Variables indicating if the response is an error response or a multi-part
|
|
|
|
// response
|
|
|
|
let res_is_error = response.is_error();
|
|
|
|
let res_is_multiple = response.multiple_responses();
|
|
|
|
|
|
|
|
// check if the stream matching the response still exists
|
|
|
|
let (substream_state, protocol) = match self.inbound_substreams.get_mut(&inbound_id) {
|
|
|
|
Some((substream_state, _, protocol)) => (substream_state, protocol),
|
|
|
|
None => {
|
|
|
|
warn!(self.log, "Stream has expired. Response not sent";
|
|
|
|
"response" => response.to_string(), "id" => inbound_id);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// If the response we are sending is an error, report back for handling
|
|
|
|
match response {
|
|
|
|
RPCCodedResponse::InvalidRequest(ref reason)
|
|
|
|
| RPCCodedResponse::ServerError(ref reason)
|
|
|
|
| RPCCodedResponse::Unknown(ref reason) => {
|
|
|
|
let code = &response
|
|
|
|
.error_code()
|
|
|
|
.expect("Error response should map to an error code");
|
|
|
|
let err = HandlerErr::Inbound {
|
|
|
|
id: inbound_id,
|
|
|
|
proto: *protocol,
|
|
|
|
error: RPCError::ErrorResponse(*code, reason.clone()),
|
|
|
|
};
|
|
|
|
self.pending_errors.push(err);
|
|
|
|
}
|
|
|
|
_ => {} // not an error, continue.
|
|
|
|
}
|
|
|
|
|
|
|
|
if matches!(self.state, HandlerState::Deactivated) {
|
|
|
|
// we no longer send responses after the handler is deactivated
|
|
|
|
debug!(self.log, "Response not sent. Deactivated handler";
|
|
|
|
"response" => response.to_string(), "id" => inbound_id);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
match std::mem::replace(substream_state, InboundSubstreamState::Poisoned) {
|
|
|
|
InboundSubstreamState::ResponseIdle(substream) => {
|
|
|
|
// close the stream if there is no response
|
|
|
|
if let RPCCodedResponse::StreamTermination(_) = response {
|
|
|
|
*substream_state = InboundSubstreamState::Closing(substream);
|
|
|
|
} else {
|
|
|
|
// send the response
|
|
|
|
// if it's a single rpc request or an error close the stream after.
|
|
|
|
*substream_state = InboundSubstreamState::ResponsePendingSend {
|
|
|
|
substream,
|
|
|
|
message: response,
|
|
|
|
closing: !res_is_multiple | res_is_error,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
InboundSubstreamState::ResponsePendingSend {
|
|
|
|
substream,
|
|
|
|
message,
|
|
|
|
closing,
|
|
|
|
} if res_is_multiple => {
|
|
|
|
// the stream is in use, add the request to a pending queue if active
|
|
|
|
self.queued_outbound_items
|
|
|
|
.entry(inbound_id)
|
|
|
|
.or_insert_with(Vec::new)
|
|
|
|
.push(response);
|
|
|
|
|
|
|
|
// return the state
|
|
|
|
*substream_state = InboundSubstreamState::ResponsePendingSend {
|
|
|
|
substream,
|
|
|
|
message,
|
|
|
|
closing,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
InboundSubstreamState::ResponsePendingFlush { substream, closing }
|
|
|
|
if res_is_multiple =>
|
|
|
|
{
|
|
|
|
// the stream is in use, add the request to a pending queue
|
|
|
|
self.queued_outbound_items
|
|
|
|
.entry(inbound_id)
|
|
|
|
.or_insert_with(Vec::new)
|
|
|
|
.push(response);
|
|
|
|
|
|
|
|
// return the state
|
|
|
|
*substream_state =
|
|
|
|
InboundSubstreamState::ResponsePendingFlush { substream, closing };
|
|
|
|
}
|
|
|
|
InboundSubstreamState::Closing(substream) => {
|
|
|
|
*substream_state = InboundSubstreamState::Closing(substream);
|
|
|
|
debug!(self.log, "Response not sent. Stream is closing"; "response" => response.to_string());
|
|
|
|
}
|
|
|
|
InboundSubstreamState::ResponsePendingSend {
|
|
|
|
substream, message, ..
|
|
|
|
} => {
|
|
|
|
*substream_state = InboundSubstreamState::ResponsePendingSend {
|
|
|
|
substream,
|
|
|
|
message,
|
|
|
|
closing: true,
|
|
|
|
};
|
|
|
|
error!(
|
|
|
|
self.log,
|
|
|
|
"Attempted sending multiple responses to a single response request"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
InboundSubstreamState::ResponsePendingFlush { substream, .. } => {
|
|
|
|
*substream_state = InboundSubstreamState::ResponsePendingFlush {
|
|
|
|
substream,
|
|
|
|
closing: true,
|
|
|
|
};
|
|
|
|
error!(
|
|
|
|
self.log,
|
|
|
|
"Attempted sending multiple responses to a single response request"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
InboundSubstreamState::Poisoned => {
|
|
|
|
crit!(self.log, "Poisoned inbound substream");
|
|
|
|
unreachable!("Coding error: Poisoned substream");
|
|
|
|
}
|
|
|
|
}
|
2020-05-29 02:03:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Updates the `KeepAlive` returned by `connection_keep_alive`.
|
|
|
|
///
|
|
|
|
/// The handler stays alive as long as there are inbound/outbound substreams established and no
|
|
|
|
/// items dialing/to be dialed. Otherwise it is given a grace period of inactivity of
|
|
|
|
/// `self.inactive_timeout`.
|
|
|
|
fn update_keep_alive(&mut self) {
|
|
|
|
// Check that we don't have outbound items pending for dialing, nor dialing, nor
|
|
|
|
// established. Also check that there are no established inbound substreams.
|
2020-06-18 01:53:08 +00:00
|
|
|
// Errors and events need to be reported back, so check those too.
|
2020-05-29 02:03:13 +00:00
|
|
|
let should_shutdown = self.dial_queue.is_empty()
|
|
|
|
&& self.outbound_substreams.is_empty()
|
2020-06-18 01:53:08 +00:00
|
|
|
&& self.inbound_substreams.is_empty()
|
|
|
|
&& self.pending_errors.is_empty()
|
|
|
|
&& self.events_out.is_empty()
|
|
|
|
&& self.dial_negotiated == 0;
|
|
|
|
|
|
|
|
match self.keep_alive {
|
|
|
|
KeepAlive::Yes if should_shutdown => {
|
|
|
|
self.keep_alive = KeepAlive::Until(Instant::now() + self.inactive_timeout);
|
|
|
|
}
|
|
|
|
KeepAlive::Yes => {} // We continue being active
|
|
|
|
KeepAlive::Until(_) if should_shutdown => {} // Already deemed inactive
|
|
|
|
KeepAlive::Until(_) => {
|
|
|
|
// No longer idle
|
|
|
|
self.keep_alive = KeepAlive::Yes;
|
|
|
|
}
|
|
|
|
KeepAlive::No => {} // currently not used
|
2020-05-29 02:03:13 +00:00
|
|
|
}
|
2019-07-06 11:32:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-17 11:16:48 +00:00
|
|
|
impl<TSpec> ProtocolsHandler for RPCHandler<TSpec>
|
2019-07-09 05:44:23 +00:00
|
|
|
where
|
Initial work towards v0.2.0 (#924)
* Remove ping protocol
* Initial renaming of network services
* Correct rebasing relative to latest master
* Start updating types
* Adds HashMapDelay struct to utils
* Initial network restructure
* Network restructure. Adds new types for v0.2.0
* Removes build artefacts
* Shift validation to beacon chain
* Temporarily remove gossip validation
This is to be updated to match current optimisation efforts.
* Adds AggregateAndProof
* Begin rebuilding pubsub encoding/decoding
* Signature hacking
* Shift gossipsup decoding into eth2_libp2p
* Existing EF tests passing with fake_crypto
* Shifts block encoding/decoding into RPC
* Delete outdated API spec
* All release tests passing bar genesis state parsing
* Update and test YamlConfig
* Update to spec v0.10 compatible BLS
* Updates to BLS EF tests
* Add EF test for AggregateVerify
And delete unused hash2curve tests for uncompressed points
* Update EF tests to v0.10.1
* Use optional block root correctly in block proc
* Use genesis fork in deposit domain. All tests pass
* Fast aggregate verify test
* Update REST API docs
* Fix unused import
* Bump spec tags to v0.10.1
* Add `seconds_per_eth1_block` to chainspec
* Update to timestamp based eth1 voting scheme
* Return None from `get_votes_to_consider` if block cache is empty
* Handle overflows in `is_candidate_block`
* Revert to failing tests
* Fix eth1 data sets test
* Choose default vote according to spec
* Fix collect_valid_votes tests
* Fix `get_votes_to_consider` to choose all eligible blocks
* Uncomment winning_vote tests
* Add comments; remove unused code
* Reduce seconds_per_eth1_block for simulation
* Addressed review comments
* Add test for default vote case
* Fix logs
* Remove unused functions
* Meter default eth1 votes
* Fix comments
* Progress on attestation service
* Address review comments; remove unused dependency
* Initial work on removing libp2p lock
* Add LRU caches to store (rollup)
* Update attestation validation for DB changes (WIP)
* Initial version of should_forward_block
* Scaffold
* Progress on attestation validation
Also, consolidate prod+testing slot clocks so that they share much
of the same implementation and can both handle sub-slot time changes.
* Removes lock from libp2p service
* Completed network lock removal
* Finish(?) attestation processing
* Correct network termination future
* Add slot check to block check
* Correct fmt issues
* Remove Drop implementation for network service
* Add first attempt at attestation proc. re-write
* Add version 2 of attestation processing
* Minor fixes
* Add validator pubkey cache
* Make get_indexed_attestation take a committee
* Link signature processing into new attn verification
* First working version
* Ensure pubkey cache is updated
* Add more metrics, slight optimizations
* Clone committee cache during attestation processing
* Update shuffling cache during block processing
* Remove old commented-out code
* Fix shuffling cache insert bug
* Used indexed attestation in fork choice
* Restructure attn processing, add metrics
* Add more detailed metrics
* Tidy, fix failing tests
* Fix failing tests, tidy
* Address reviewers suggestions
* Disable/delete two outdated tests
* Modification of validator for subscriptions
* Add slot signing to validator client
* Further progress on validation subscription
* Adds necessary validator subscription functionality
* Add new Pubkeys struct to signature_sets
* Refactor with functional approach
* Update beacon chain
* Clean up validator <-> beacon node http types
* Add aggregator status to ValidatorDuty
* Impl Clone for manual slot clock
* Fix minor errors
* Further progress validator client subscription
* Initial subscription and aggregation handling
* Remove decompressed member from pubkey bytes
* Progress to modifying val client for attestation aggregation
* First draft of validator client upgrade for aggregate attestations
* Add hashmap for indices lookup
* Add state cache, remove store cache
* Only build the head committee cache
* Removes lock on a network channel
* Partially implement beacon node subscription http api
* Correct compilation issues
* Change `get_attesting_indices` to use Vec
* Fix failing test
* Partial implementation of timer
* Adds timer, removes exit_future, http api to op pool
* Partial multiple aggregate attestation handling
* Permits bulk messages accross gossipsub network channel
* Correct compile issues
* Improve gosispsub messaging and correct rest api helpers
* Added global gossipsub subscriptions
* Update validator subscriptions data structs
* Tidy
* Re-structure validator subscriptions
* Initial handling of subscriptions
* Re-structure network service
* Add pubkey cache persistence file
* Add more comments
* Integrate persistence file into builder
* Add pubkey cache tests
* Add HashSetDelay and introduce into attestation service
* Handles validator subscriptions
* Add data_dir to beacon chain builder
* Remove Option in pubkey cache persistence file
* Ensure consistency between datadir/data_dir
* Fix failing network test
* Peer subnet discovery gets queued for future subscriptions
* Reorganise attestation service functions
* Initial wiring of attestation service
* First draft of attestation service timing logic
* Correct minor typos
* Tidy
* Fix todos
* Improve tests
* Add PeerInfo to connected peers mapping
* Fix compile error
* Fix compile error from merge
* Split up block processing metrics
* Tidy
* Refactor get_pubkey_from_state
* Remove commented-out code
* Rename state_cache -> checkpoint_cache
* Rename Checkpoint -> Snapshot
* Tidy, add comments
* Tidy up find_head function
* Change some checkpoint -> snapshot
* Add tests
* Expose max_len
* Remove dead code
* Tidy
* Fix bug
* Add sync-speed metric
* Add first attempt at VerifiableBlock
* Start integrating into beacon chain
* Integrate VerifiableBlock
* Rename VerifableBlock -> PartialBlockVerification
* Add start of typed methods
* Add progress
* Add further progress
* Rename structs
* Add full block verification to block_processing.rs
* Further beacon chain integration
* Update checks for gossip
* Add todo
* Start adding segement verification
* Add passing chain segement test
* Initial integration with batch sync
* Minor changes
* Tidy, add more error checking
* Start adding chain_segment tests
* Finish invalid signature tests
* Include single and gossip verified blocks in tests
* Add gossip verification tests
* Start adding docs
* Finish adding comments to block_processing.rs
* Rename block_processing.rs -> block_verification
* Start removing old block processing code
* Fixes beacon_chain compilation
* Fix project-wide compile errors
* Remove old code
* Correct code to pass all tests
* Fix bug with beacon proposer index
* Fix shim for BlockProcessingError
* Only process one epoch at a time
* Fix loop in chain segment processing
* Correct tests from master merge
* Add caching for state.eth1_data_votes
* Add BeaconChain::validator_pubkey
* Revert "Add caching for state.eth1_data_votes"
This reverts commit cd73dcd6434fb8d8e6bf30c5356355598ea7b78e.
Co-authored-by: Grant Wuerker <gwuerker@gmail.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
Co-authored-by: Michael Sproul <micsproul@gmail.com>
Co-authored-by: pawan <pawandhananjay@gmail.com>
Co-authored-by: Paul Hauner <paul@paulhauner.com>
2020-03-17 06:24:44 +00:00
|
|
|
TSpec: EthSpec,
|
2019-07-06 11:32:32 +00:00
|
|
|
{
|
2020-06-05 03:07:59 +00:00
|
|
|
type InEvent = RPCSend<TSpec>;
|
|
|
|
type OutEvent = Result<RPCReceived<TSpec>, HandlerErr>;
|
2020-05-17 11:16:48 +00:00
|
|
|
type Error = RPCError;
|
Initial work towards v0.2.0 (#924)
* Remove ping protocol
* Initial renaming of network services
* Correct rebasing relative to latest master
* Start updating types
* Adds HashMapDelay struct to utils
* Initial network restructure
* Network restructure. Adds new types for v0.2.0
* Removes build artefacts
* Shift validation to beacon chain
* Temporarily remove gossip validation
This is to be updated to match current optimisation efforts.
* Adds AggregateAndProof
* Begin rebuilding pubsub encoding/decoding
* Signature hacking
* Shift gossipsup decoding into eth2_libp2p
* Existing EF tests passing with fake_crypto
* Shifts block encoding/decoding into RPC
* Delete outdated API spec
* All release tests passing bar genesis state parsing
* Update and test YamlConfig
* Update to spec v0.10 compatible BLS
* Updates to BLS EF tests
* Add EF test for AggregateVerify
And delete unused hash2curve tests for uncompressed points
* Update EF tests to v0.10.1
* Use optional block root correctly in block proc
* Use genesis fork in deposit domain. All tests pass
* Fast aggregate verify test
* Update REST API docs
* Fix unused import
* Bump spec tags to v0.10.1
* Add `seconds_per_eth1_block` to chainspec
* Update to timestamp based eth1 voting scheme
* Return None from `get_votes_to_consider` if block cache is empty
* Handle overflows in `is_candidate_block`
* Revert to failing tests
* Fix eth1 data sets test
* Choose default vote according to spec
* Fix collect_valid_votes tests
* Fix `get_votes_to_consider` to choose all eligible blocks
* Uncomment winning_vote tests
* Add comments; remove unused code
* Reduce seconds_per_eth1_block for simulation
* Addressed review comments
* Add test for default vote case
* Fix logs
* Remove unused functions
* Meter default eth1 votes
* Fix comments
* Progress on attestation service
* Address review comments; remove unused dependency
* Initial work on removing libp2p lock
* Add LRU caches to store (rollup)
* Update attestation validation for DB changes (WIP)
* Initial version of should_forward_block
* Scaffold
* Progress on attestation validation
Also, consolidate prod+testing slot clocks so that they share much
of the same implementation and can both handle sub-slot time changes.
* Removes lock from libp2p service
* Completed network lock removal
* Finish(?) attestation processing
* Correct network termination future
* Add slot check to block check
* Correct fmt issues
* Remove Drop implementation for network service
* Add first attempt at attestation proc. re-write
* Add version 2 of attestation processing
* Minor fixes
* Add validator pubkey cache
* Make get_indexed_attestation take a committee
* Link signature processing into new attn verification
* First working version
* Ensure pubkey cache is updated
* Add more metrics, slight optimizations
* Clone committee cache during attestation processing
* Update shuffling cache during block processing
* Remove old commented-out code
* Fix shuffling cache insert bug
* Used indexed attestation in fork choice
* Restructure attn processing, add metrics
* Add more detailed metrics
* Tidy, fix failing tests
* Fix failing tests, tidy
* Address reviewers suggestions
* Disable/delete two outdated tests
* Modification of validator for subscriptions
* Add slot signing to validator client
* Further progress on validation subscription
* Adds necessary validator subscription functionality
* Add new Pubkeys struct to signature_sets
* Refactor with functional approach
* Update beacon chain
* Clean up validator <-> beacon node http types
* Add aggregator status to ValidatorDuty
* Impl Clone for manual slot clock
* Fix minor errors
* Further progress validator client subscription
* Initial subscription and aggregation handling
* Remove decompressed member from pubkey bytes
* Progress to modifying val client for attestation aggregation
* First draft of validator client upgrade for aggregate attestations
* Add hashmap for indices lookup
* Add state cache, remove store cache
* Only build the head committee cache
* Removes lock on a network channel
* Partially implement beacon node subscription http api
* Correct compilation issues
* Change `get_attesting_indices` to use Vec
* Fix failing test
* Partial implementation of timer
* Adds timer, removes exit_future, http api to op pool
* Partial multiple aggregate attestation handling
* Permits bulk messages accross gossipsub network channel
* Correct compile issues
* Improve gosispsub messaging and correct rest api helpers
* Added global gossipsub subscriptions
* Update validator subscriptions data structs
* Tidy
* Re-structure validator subscriptions
* Initial handling of subscriptions
* Re-structure network service
* Add pubkey cache persistence file
* Add more comments
* Integrate persistence file into builder
* Add pubkey cache tests
* Add HashSetDelay and introduce into attestation service
* Handles validator subscriptions
* Add data_dir to beacon chain builder
* Remove Option in pubkey cache persistence file
* Ensure consistency between datadir/data_dir
* Fix failing network test
* Peer subnet discovery gets queued for future subscriptions
* Reorganise attestation service functions
* Initial wiring of attestation service
* First draft of attestation service timing logic
* Correct minor typos
* Tidy
* Fix todos
* Improve tests
* Add PeerInfo to connected peers mapping
* Fix compile error
* Fix compile error from merge
* Split up block processing metrics
* Tidy
* Refactor get_pubkey_from_state
* Remove commented-out code
* Rename state_cache -> checkpoint_cache
* Rename Checkpoint -> Snapshot
* Tidy, add comments
* Tidy up find_head function
* Change some checkpoint -> snapshot
* Add tests
* Expose max_len
* Remove dead code
* Tidy
* Fix bug
* Add sync-speed metric
* Add first attempt at VerifiableBlock
* Start integrating into beacon chain
* Integrate VerifiableBlock
* Rename VerifableBlock -> PartialBlockVerification
* Add start of typed methods
* Add progress
* Add further progress
* Rename structs
* Add full block verification to block_processing.rs
* Further beacon chain integration
* Update checks for gossip
* Add todo
* Start adding segement verification
* Add passing chain segement test
* Initial integration with batch sync
* Minor changes
* Tidy, add more error checking
* Start adding chain_segment tests
* Finish invalid signature tests
* Include single and gossip verified blocks in tests
* Add gossip verification tests
* Start adding docs
* Finish adding comments to block_processing.rs
* Rename block_processing.rs -> block_verification
* Start removing old block processing code
* Fixes beacon_chain compilation
* Fix project-wide compile errors
* Remove old code
* Correct code to pass all tests
* Fix bug with beacon proposer index
* Fix shim for BlockProcessingError
* Only process one epoch at a time
* Fix loop in chain segment processing
* Correct tests from master merge
* Add caching for state.eth1_data_votes
* Add BeaconChain::validator_pubkey
* Revert "Add caching for state.eth1_data_votes"
This reverts commit cd73dcd6434fb8d8e6bf30c5356355598ea7b78e.
Co-authored-by: Grant Wuerker <gwuerker@gmail.com>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
Co-authored-by: Michael Sproul <micsproul@gmail.com>
Co-authored-by: pawan <pawandhananjay@gmail.com>
Co-authored-by: Paul Hauner <paul@paulhauner.com>
2020-03-17 06:24:44 +00:00
|
|
|
type InboundProtocol = RPCProtocol<TSpec>;
|
|
|
|
type OutboundProtocol = RPCRequest<TSpec>;
|
2020-05-03 13:17:12 +00:00
|
|
|
type OutboundOpenInfo = (RequestId, RPCRequest<TSpec>); // Keep track of the id and the request
|
2019-07-06 11:32:32 +00:00
|
|
|
|
|
|
|
fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol> {
|
|
|
|
self.listen_protocol.clone()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn inject_fully_negotiated_inbound(
|
|
|
|
&mut self,
|
2020-05-17 11:16:48 +00:00
|
|
|
substream: <Self::InboundProtocol as InboundUpgrade<NegotiatedSubstream>>::Output,
|
2019-07-06 11:32:32 +00:00
|
|
|
) {
|
2020-06-18 01:53:08 +00:00
|
|
|
// only accept new peer requests when active
|
|
|
|
if !matches!(self.state, HandlerState::Active) {
|
2019-07-09 05:44:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-07-06 11:32:32 +00:00
|
|
|
|
2020-06-18 01:53:08 +00:00
|
|
|
let (req, substream) = substream;
|
|
|
|
|
|
|
|
// store requests that expect responses
|
|
|
|
if req.expected_responses() > 0 {
|
|
|
|
// Store the stream and tag the output.
|
|
|
|
let delay_key = self.inbound_substreams_delay.insert(
|
|
|
|
self.current_inbound_substream_id,
|
|
|
|
Duration::from_secs(RESPONSE_TIMEOUT),
|
|
|
|
);
|
|
|
|
let awaiting_stream = InboundSubstreamState::ResponseIdle(substream);
|
|
|
|
self.inbound_substreams.insert(
|
|
|
|
self.current_inbound_substream_id,
|
|
|
|
(awaiting_stream, Some(delay_key), req.protocol()),
|
|
|
|
);
|
|
|
|
}
|
2019-07-09 05:44:23 +00:00
|
|
|
|
|
|
|
self.events_out
|
2020-06-05 03:07:59 +00:00
|
|
|
.push(RPCReceived::Request(self.current_inbound_substream_id, req));
|
|
|
|
self.current_inbound_substream_id.0 += 1;
|
2020-06-18 01:53:08 +00:00
|
|
|
|
|
|
|
self.update_keep_alive();
|
2019-07-06 11:32:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn inject_fully_negotiated_outbound(
|
|
|
|
&mut self,
|
2020-05-17 11:16:48 +00:00
|
|
|
out: <Self::OutboundProtocol as OutboundUpgrade<NegotiatedSubstream>>::Output,
|
2020-05-03 13:17:12 +00:00
|
|
|
request_info: Self::OutboundOpenInfo,
|
2019-07-06 11:32:32 +00:00
|
|
|
) {
|
|
|
|
self.dial_negotiated -= 1;
|
2020-06-18 01:53:08 +00:00
|
|
|
let (id, request) = request_info;
|
|
|
|
let proto = request.protocol();
|
|
|
|
|
|
|
|
// accept outbound connections only if the handler is not deactivated
|
|
|
|
if matches!(self.state, HandlerState::Deactivated) {
|
|
|
|
self.pending_errors.push(HandlerErr::Outbound {
|
|
|
|
id,
|
|
|
|
proto,
|
|
|
|
error: RPCError::HandlerRejected,
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
2019-07-06 11:32:32 +00:00
|
|
|
|
2019-07-16 12:32:37 +00:00
|
|
|
// add the stream to substreams if we expect a response, otherwise drop the stream.
|
2020-06-05 03:07:59 +00:00
|
|
|
let expected_responses = request.expected_responses();
|
|
|
|
if expected_responses > 0 {
|
2020-05-03 13:17:12 +00:00
|
|
|
// new outbound request. Store the stream and tag the output.
|
2020-06-05 03:07:59 +00:00
|
|
|
let delay_key = self.outbound_substreams_delay.insert(
|
|
|
|
self.current_outbound_substream_id,
|
|
|
|
Duration::from_secs(RESPONSE_TIMEOUT),
|
|
|
|
);
|
2020-05-03 13:17:12 +00:00
|
|
|
let awaiting_stream = OutboundSubstreamState::RequestPendingResponse {
|
|
|
|
substream: out,
|
2020-06-05 03:07:59 +00:00
|
|
|
request,
|
2020-05-03 13:17:12 +00:00
|
|
|
};
|
2020-06-05 03:07:59 +00:00
|
|
|
let expected_responses = if expected_responses > 1 {
|
|
|
|
// Currently enforced only for multiple responses
|
|
|
|
Some(expected_responses)
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
};
|
|
|
|
if self
|
|
|
|
.outbound_substreams
|
|
|
|
.insert(
|
|
|
|
self.current_outbound_substream_id,
|
|
|
|
OutboundInfo {
|
|
|
|
state: awaiting_stream,
|
|
|
|
delay_key,
|
|
|
|
proto,
|
|
|
|
remaining_chunks: expected_responses,
|
|
|
|
req_id: id,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
.is_some()
|
|
|
|
{
|
|
|
|
crit!(self.log, "Duplicate outbound substream id"; "id" => format!("{:?}", self.current_outbound_substream_id));
|
2019-07-16 12:32:37 +00:00
|
|
|
}
|
2020-06-05 03:07:59 +00:00
|
|
|
self.current_outbound_substream_id.0 += 1;
|
2019-07-16 12:32:37 +00:00
|
|
|
}
|
2020-05-29 02:03:13 +00:00
|
|
|
|
|
|
|
self.update_keep_alive();
|
2019-07-06 11:32:32 +00:00
|
|
|
}
|
|
|
|
|
2019-07-06 13:43:44 +00:00
|
|
|
fn inject_event(&mut self, rpc_event: Self::InEvent) {
|
|
|
|
match rpc_event {
|
2020-06-05 03:07:59 +00:00
|
|
|
RPCSend::Request(id, req) => self.send_request(id, req),
|
2020-06-18 01:53:08 +00:00
|
|
|
RPCSend::Response(inbound_id, response) => self.send_response(inbound_id, response),
|
2019-07-06 13:43:44 +00:00
|
|
|
}
|
2019-07-06 11:32:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn inject_dial_upgrade_error(
|
|
|
|
&mut self,
|
2020-05-03 13:17:12 +00:00
|
|
|
request_info: Self::OutboundOpenInfo,
|
2019-07-06 11:32:32 +00:00
|
|
|
error: ProtocolsHandlerUpgrErr<
|
2020-05-17 11:16:48 +00:00
|
|
|
<Self::OutboundProtocol as OutboundUpgrade<NegotiatedSubstream>>::Error,
|
2019-07-06 11:32:32 +00:00
|
|
|
>,
|
|
|
|
) {
|
2020-05-03 13:17:12 +00:00
|
|
|
let (id, req) = request_info;
|
2019-12-09 07:50:21 +00:00
|
|
|
if let ProtocolsHandlerUpgrErr::Upgrade(UpgradeError::Apply(RPCError::IoError(_))) = error {
|
|
|
|
self.outbound_io_error_retries += 1;
|
|
|
|
if self.outbound_io_error_retries < IO_ERROR_RETRIES {
|
2020-05-03 13:17:12 +00:00
|
|
|
self.send_request(id, req);
|
2019-12-09 07:50:21 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2020-05-03 13:17:12 +00:00
|
|
|
|
2020-06-18 01:53:08 +00:00
|
|
|
// This dialing is now considered failed
|
|
|
|
self.dial_negotiated -= 1;
|
|
|
|
self.update_keep_alive();
|
|
|
|
|
2019-12-09 07:50:21 +00:00
|
|
|
self.outbound_io_error_retries = 0;
|
2020-05-03 13:17:12 +00:00
|
|
|
// map the error
|
2020-06-05 03:07:59 +00:00
|
|
|
let error = match error {
|
2020-05-03 13:17:12 +00:00
|
|
|
ProtocolsHandlerUpgrErr::Timer => RPCError::InternalError("Timer failed"),
|
|
|
|
ProtocolsHandlerUpgrErr::Timeout => RPCError::NegotiationTimeout,
|
|
|
|
ProtocolsHandlerUpgrErr::Upgrade(UpgradeError::Apply(e)) => e,
|
|
|
|
ProtocolsHandlerUpgrErr::Upgrade(UpgradeError::Select(NegotiationError::Failed)) => {
|
|
|
|
RPCError::UnsupportedProtocol
|
2019-12-09 07:50:21 +00:00
|
|
|
}
|
2020-05-03 13:17:12 +00:00
|
|
|
ProtocolsHandlerUpgrErr::Upgrade(UpgradeError::Select(
|
|
|
|
NegotiationError::ProtocolError(e),
|
|
|
|
)) => match e {
|
2020-05-17 11:16:48 +00:00
|
|
|
ProtocolError::IoError(io_err) => RPCError::IoError(io_err.to_string()),
|
2020-05-03 13:17:12 +00:00
|
|
|
ProtocolError::InvalidProtocol => {
|
|
|
|
RPCError::InternalError("Protocol was deemed invalid")
|
|
|
|
}
|
|
|
|
ProtocolError::InvalidMessage | ProtocolError::TooManyProtocols => {
|
|
|
|
// Peer is sending invalid data during the negotiation phase, not
|
|
|
|
// participating in the protocol
|
|
|
|
RPCError::InvalidData
|
|
|
|
}
|
|
|
|
},
|
2019-12-09 07:50:21 +00:00
|
|
|
};
|
2020-06-05 03:07:59 +00:00
|
|
|
self.pending_errors.push(HandlerErr::Outbound {
|
|
|
|
id,
|
|
|
|
proto: req.protocol(),
|
|
|
|
error,
|
|
|
|
});
|
2019-07-06 11:32:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn connection_keep_alive(&self) -> KeepAlive {
|
|
|
|
self.keep_alive
|
|
|
|
}
|
|
|
|
|
|
|
|
fn poll(
|
|
|
|
&mut self,
|
2020-05-17 11:16:48 +00:00
|
|
|
cx: &mut Context<'_>,
|
2019-07-06 11:32:32 +00:00
|
|
|
) -> Poll<
|
2020-05-17 11:16:48 +00:00
|
|
|
ProtocolsHandlerEvent<
|
|
|
|
Self::OutboundProtocol,
|
|
|
|
Self::OutboundOpenInfo,
|
|
|
|
Self::OutEvent,
|
|
|
|
Self::Error,
|
|
|
|
>,
|
2019-07-06 11:32:32 +00:00
|
|
|
> {
|
2020-06-05 03:07:59 +00:00
|
|
|
// report failures
|
|
|
|
if !self.pending_errors.is_empty() {
|
|
|
|
let err_info = self.pending_errors.remove(0);
|
|
|
|
return Poll::Ready(ProtocolsHandlerEvent::Custom(Err(err_info)));
|
2019-07-06 11:32:32 +00:00
|
|
|
}
|
|
|
|
|
2019-07-16 12:32:37 +00:00
|
|
|
// return any events that need to be reported
|
2019-07-06 11:32:32 +00:00
|
|
|
if !self.events_out.is_empty() {
|
2020-06-05 03:07:59 +00:00
|
|
|
return Poll::Ready(ProtocolsHandlerEvent::Custom(Ok(self.events_out.remove(0))));
|
2019-07-06 11:32:32 +00:00
|
|
|
} else {
|
|
|
|
self.events_out.shrink_to_fit();
|
|
|
|
}
|
|
|
|
|
2020-06-18 01:53:08 +00:00
|
|
|
// Check if we are shutting down, and if the timer ran out
|
|
|
|
if let HandlerState::ShuttingDown(delay) = &self.state {
|
|
|
|
if delay.is_elapsed() {
|
|
|
|
self.state = HandlerState::Deactivated;
|
|
|
|
debug!(self.log, "Handler deactivated");
|
|
|
|
// Drain queued responses
|
|
|
|
for (inbound_id, queued_responses) in self.queued_outbound_items.drain() {
|
|
|
|
for response in queued_responses {
|
|
|
|
debug!(self.log, "Response not sent. Deactivated handler";
|
|
|
|
"response" => response.to_string(), "id" => inbound_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-08 03:18:06 +00:00
|
|
|
// purge expired inbound substreams and send an error
|
2020-05-17 11:16:48 +00:00
|
|
|
loop {
|
|
|
|
match self.inbound_substreams_delay.poll_next_unpin(cx) {
|
2020-06-05 03:07:59 +00:00
|
|
|
Poll::Ready(Some(Ok(inbound_id))) => {
|
2020-05-17 11:16:48 +00:00
|
|
|
// handle a stream timeout for various states
|
2020-06-05 03:07:59 +00:00
|
|
|
if let Some((substream_state, delay_key, protocol)) =
|
|
|
|
self.inbound_substreams.get_mut(inbound_id.get_ref())
|
2020-05-17 11:16:48 +00:00
|
|
|
{
|
|
|
|
// the delay has been removed
|
|
|
|
*delay_key = None;
|
|
|
|
|
2020-06-05 03:07:59 +00:00
|
|
|
self.pending_errors.push(HandlerErr::Inbound {
|
|
|
|
id: *inbound_id.get_ref(),
|
|
|
|
proto: *protocol,
|
|
|
|
error: RPCError::StreamTimeout,
|
|
|
|
});
|
|
|
|
|
2020-05-17 11:16:48 +00:00
|
|
|
let outbound_queue = self
|
|
|
|
.queued_outbound_items
|
2020-06-05 03:07:59 +00:00
|
|
|
.entry(inbound_id.into_inner())
|
2020-05-17 11:16:48 +00:00
|
|
|
.or_insert_with(Vec::new);
|
|
|
|
substream_state.close(outbound_queue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Poll::Ready(Some(Err(e))) => {
|
|
|
|
warn!(self.log, "Inbound substream poll failed"; "error" => format!("{:?}", e));
|
|
|
|
// drops the peer if we cannot read the delay queue
|
|
|
|
return Poll::Ready(ProtocolsHandlerEvent::Close(RPCError::InternalError(
|
|
|
|
"Could not poll inbound stream timer",
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
Poll::Pending | Poll::Ready(None) => break,
|
2020-01-08 03:18:06 +00:00
|
|
|
}
|
2019-11-27 01:47:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// purge expired outbound substreams
|
2020-05-17 11:16:48 +00:00
|
|
|
loop {
|
|
|
|
match self.outbound_substreams_delay.poll_next_unpin(cx) {
|
2020-06-05 03:07:59 +00:00
|
|
|
Poll::Ready(Some(Ok(outbound_id))) => {
|
|
|
|
if let Some(OutboundInfo { proto, req_id, .. }) =
|
|
|
|
self.outbound_substreams.remove(outbound_id.get_ref())
|
2020-05-17 11:16:48 +00:00
|
|
|
{
|
2020-05-29 02:03:13 +00:00
|
|
|
self.update_keep_alive();
|
|
|
|
|
2020-06-05 03:07:59 +00:00
|
|
|
let outbound_err = HandlerErr::Outbound {
|
|
|
|
id: req_id,
|
|
|
|
proto,
|
|
|
|
error: RPCError::StreamTimeout,
|
|
|
|
};
|
2020-05-17 11:16:48 +00:00
|
|
|
// notify the user
|
2020-06-05 03:07:59 +00:00
|
|
|
return Poll::Ready(ProtocolsHandlerEvent::Custom(Err(outbound_err)));
|
2020-05-17 11:16:48 +00:00
|
|
|
} else {
|
2020-06-05 03:07:59 +00:00
|
|
|
crit!(self.log, "timed out substream not in the books"; "stream_id" => outbound_id.get_ref());
|
2020-05-17 11:16:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Poll::Ready(Some(Err(e))) => {
|
|
|
|
warn!(self.log, "Outbound substream poll failed"; "error" => format!("{:?}", e));
|
|
|
|
return Poll::Ready(ProtocolsHandlerEvent::Close(RPCError::InternalError(
|
|
|
|
"Could not poll outbound stream timer",
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
Poll::Pending | Poll::Ready(None) => break,
|
2020-05-03 13:17:12 +00:00
|
|
|
}
|
2019-11-27 01:47:46 +00:00
|
|
|
}
|
|
|
|
|
2020-06-18 01:53:08 +00:00
|
|
|
// when deactivated, close all streams
|
|
|
|
let deactivated = matches!(self.state, HandlerState::Deactivated);
|
|
|
|
|
2019-11-27 01:47:46 +00:00
|
|
|
// drive inbound streams that need to be processed
|
|
|
|
for request_id in self.inbound_substreams.keys().copied().collect::<Vec<_>>() {
|
|
|
|
// Drain all queued items until all messages have been processed for this stream
|
|
|
|
// TODO Improve this code logic
|
2020-05-29 02:04:08 +00:00
|
|
|
let mut drive_stream_further = true;
|
|
|
|
while drive_stream_further {
|
|
|
|
drive_stream_further = false;
|
2019-11-27 01:47:46 +00:00
|
|
|
match self.inbound_substreams.entry(request_id) {
|
|
|
|
Entry::Occupied(mut entry) => {
|
|
|
|
match std::mem::replace(
|
|
|
|
&mut entry.get_mut().0,
|
|
|
|
InboundSubstreamState::Poisoned,
|
|
|
|
) {
|
|
|
|
InboundSubstreamState::ResponsePendingSend {
|
|
|
|
mut substream,
|
2020-05-17 11:16:48 +00:00
|
|
|
message,
|
2019-11-27 01:47:46 +00:00
|
|
|
closing,
|
|
|
|
} => {
|
2020-06-18 01:53:08 +00:00
|
|
|
if deactivated {
|
|
|
|
if !closing {
|
|
|
|
// inform back to cancel this request's processing
|
|
|
|
self.pending_errors.push(HandlerErr::Inbound {
|
|
|
|
id: request_id,
|
|
|
|
proto: entry.get().2,
|
|
|
|
error: RPCError::HandlerRejected,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
entry.get_mut().0 = InboundSubstreamState::Closing(substream);
|
|
|
|
drive_stream_further = true;
|
|
|
|
} else {
|
|
|
|
match Sink::poll_ready(Pin::new(&mut substream), cx) {
|
|
|
|
Poll::Ready(Ok(())) => {
|
|
|
|
// stream is ready to send data
|
|
|
|
match Sink::start_send(
|
|
|
|
Pin::new(&mut substream),
|
|
|
|
message,
|
|
|
|
) {
|
|
|
|
Ok(()) => {
|
|
|
|
// await flush
|
|
|
|
entry.get_mut().0 =
|
2020-05-17 11:16:48 +00:00
|
|
|
InboundSubstreamState::ResponsePendingFlush {
|
|
|
|
substream,
|
|
|
|
closing,
|
2020-05-29 02:04:08 +00:00
|
|
|
};
|
|
|
|
drive_stream_further = true;
|
2020-06-18 01:53:08 +00:00
|
|
|
}
|
|
|
|
Err(e) => {
|
|
|
|
// error with sending in the codec
|
|
|
|
warn!(self.log, "Error sending RPC message"; "error" => e.to_string());
|
|
|
|
// keep connection with the peer and return the
|
|
|
|
// stream to awaiting response if this message
|
|
|
|
// wasn't closing the stream
|
|
|
|
if closing {
|
|
|
|
entry.get_mut().0 =
|
|
|
|
InboundSubstreamState::Closing(
|
|
|
|
substream,
|
|
|
|
);
|
|
|
|
drive_stream_further = true;
|
|
|
|
} else {
|
|
|
|
// check for queued chunks and update the stream
|
|
|
|
entry.get_mut().0 = apply_queued_responses(
|
|
|
|
substream,
|
|
|
|
&mut self
|
|
|
|
.queued_outbound_items
|
|
|
|
.get_mut(&request_id),
|
|
|
|
&mut drive_stream_further,
|
|
|
|
);
|
|
|
|
}
|
2020-05-17 11:16:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-18 01:53:08 +00:00
|
|
|
Poll::Ready(Err(e)) => {
|
|
|
|
error!(
|
|
|
|
self.log,
|
|
|
|
"Outbound substream error while sending RPC message: {:?}",
|
|
|
|
e
|
|
|
|
);
|
|
|
|
entry.remove();
|
|
|
|
self.update_keep_alive();
|
|
|
|
return Poll::Ready(ProtocolsHandlerEvent::Close(e));
|
|
|
|
}
|
|
|
|
Poll::Pending => {
|
|
|
|
// the stream is not yet ready, continue waiting
|
|
|
|
entry.get_mut().0 =
|
|
|
|
InboundSubstreamState::ResponsePendingSend {
|
|
|
|
substream,
|
|
|
|
message,
|
|
|
|
closing,
|
|
|
|
};
|
|
|
|
}
|
2020-05-17 11:16:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
InboundSubstreamState::ResponsePendingFlush {
|
|
|
|
mut substream,
|
|
|
|
closing,
|
|
|
|
} => {
|
|
|
|
match Sink::poll_flush(Pin::new(&mut substream), cx) {
|
|
|
|
Poll::Ready(Ok(())) => {
|
|
|
|
// finished flushing
|
|
|
|
// TODO: Duplicate code
|
2020-06-18 01:53:08 +00:00
|
|
|
if closing | deactivated {
|
|
|
|
if !closing {
|
|
|
|
// inform back to cancel this request's processing
|
|
|
|
self.pending_errors.push(HandlerErr::Inbound {
|
|
|
|
id: request_id,
|
|
|
|
proto: entry.get().2,
|
|
|
|
error: RPCError::HandlerRejected,
|
|
|
|
});
|
|
|
|
}
|
2019-11-27 01:47:46 +00:00
|
|
|
entry.get_mut().0 =
|
2020-05-29 02:04:08 +00:00
|
|
|
InboundSubstreamState::Closing(substream);
|
|
|
|
drive_stream_further = true;
|
2019-11-27 01:47:46 +00:00
|
|
|
} else {
|
|
|
|
// check for queued chunks and update the stream
|
|
|
|
entry.get_mut().0 = apply_queued_responses(
|
2020-05-17 11:16:48 +00:00
|
|
|
substream,
|
2019-11-27 01:47:46 +00:00
|
|
|
&mut self
|
|
|
|
.queued_outbound_items
|
|
|
|
.get_mut(&request_id),
|
2020-05-29 02:04:08 +00:00
|
|
|
&mut drive_stream_further,
|
2019-11-27 01:47:46 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2020-05-17 11:16:48 +00:00
|
|
|
Poll::Ready(Err(e)) => {
|
|
|
|
// error during flush
|
|
|
|
trace!(self.log, "Error sending flushing RPC message"; "error" => e.to_string());
|
|
|
|
// we drop the stream on error and inform the user, remove
|
|
|
|
// any pending requests
|
|
|
|
// TODO: Duplicate code
|
|
|
|
if let Some(delay_key) = &entry.get().1 {
|
|
|
|
self.inbound_substreams_delay.remove(delay_key);
|
|
|
|
}
|
|
|
|
self.queued_outbound_items.remove(&request_id);
|
|
|
|
entry.remove();
|
|
|
|
|
2020-05-29 02:03:13 +00:00
|
|
|
self.update_keep_alive();
|
2020-05-17 11:16:48 +00:00
|
|
|
}
|
|
|
|
Poll::Pending => {
|
2019-11-27 01:47:46 +00:00
|
|
|
entry.get_mut().0 =
|
2020-05-17 11:16:48 +00:00
|
|
|
InboundSubstreamState::ResponsePendingFlush {
|
2019-11-27 01:47:46 +00:00
|
|
|
substream,
|
|
|
|
closing,
|
|
|
|
};
|
|
|
|
}
|
2020-05-17 11:16:48 +00:00
|
|
|
}
|
2019-11-27 01:47:46 +00:00
|
|
|
}
|
|
|
|
InboundSubstreamState::ResponseIdle(substream) => {
|
2020-06-18 01:53:08 +00:00
|
|
|
if !deactivated {
|
|
|
|
entry.get_mut().0 = apply_queued_responses(
|
|
|
|
substream,
|
|
|
|
&mut self.queued_outbound_items.get_mut(&request_id),
|
|
|
|
&mut drive_stream_further,
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
entry.get_mut().0 = InboundSubstreamState::Closing(substream);
|
|
|
|
drive_stream_further = true;
|
|
|
|
}
|
2019-11-27 01:47:46 +00:00
|
|
|
}
|
|
|
|
InboundSubstreamState::Closing(mut substream) => {
|
2020-05-17 11:16:48 +00:00
|
|
|
match Sink::poll_close(Pin::new(&mut substream), cx) {
|
|
|
|
Poll::Ready(Ok(())) => {
|
2020-01-15 04:50:01 +00:00
|
|
|
if let Some(delay_key) = &entry.get().1 {
|
|
|
|
self.inbound_substreams_delay.remove(delay_key);
|
|
|
|
}
|
2019-11-27 01:47:46 +00:00
|
|
|
self.queued_outbound_items.remove(&request_id);
|
|
|
|
entry.remove();
|
2020-02-19 04:39:20 +00:00
|
|
|
|
2020-05-29 02:03:13 +00:00
|
|
|
self.update_keep_alive();
|
2019-11-27 01:47:46 +00:00
|
|
|
} // drop the stream
|
2020-05-17 11:16:48 +00:00
|
|
|
Poll::Ready(Err(e)) => {
|
|
|
|
error!(self.log, "Error closing inbound stream"; "error" => e.to_string());
|
|
|
|
// drop the stream anyway
|
|
|
|
// TODO: Duplicate code
|
|
|
|
if let Some(delay_key) = &entry.get().1 {
|
|
|
|
self.inbound_substreams_delay.remove(delay_key);
|
|
|
|
}
|
|
|
|
self.queued_outbound_items.remove(&request_id);
|
|
|
|
entry.remove();
|
|
|
|
|
2020-05-29 02:03:13 +00:00
|
|
|
self.update_keep_alive();
|
2020-05-17 11:16:48 +00:00
|
|
|
}
|
|
|
|
Poll::Pending => {
|
2019-11-27 01:47:46 +00:00
|
|
|
entry.get_mut().0 =
|
|
|
|
InboundSubstreamState::Closing(substream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
InboundSubstreamState::Poisoned => {
|
|
|
|
crit!(self.log, "Poisoned outbound substream");
|
|
|
|
unreachable!("Coding Error: Inbound Substream is poisoned");
|
|
|
|
}
|
2020-05-17 11:16:48 +00:00
|
|
|
}
|
2019-07-16 12:32:37 +00:00
|
|
|
}
|
2019-11-27 01:47:46 +00:00
|
|
|
Entry::Vacant(_) => unreachable!(),
|
2019-07-16 12:32:37 +00:00
|
|
|
}
|
2019-11-27 01:47:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// drive outbound streams that need to be processed
|
2020-06-05 03:07:59 +00:00
|
|
|
for outbound_id in self.outbound_substreams.keys().copied().collect::<Vec<_>>() {
|
|
|
|
// get the state and mark it as poisoned
|
|
|
|
let (mut entry, state) = match self.outbound_substreams.entry(outbound_id) {
|
2019-11-27 01:47:46 +00:00
|
|
|
Entry::Occupied(mut entry) => {
|
2020-06-05 03:07:59 +00:00
|
|
|
let state = std::mem::replace(
|
|
|
|
&mut entry.get_mut().state,
|
2019-11-27 01:47:46 +00:00
|
|
|
OutboundSubstreamState::Poisoned,
|
2020-06-05 03:07:59 +00:00
|
|
|
);
|
|
|
|
(entry, state)
|
|
|
|
}
|
|
|
|
Entry::Vacant(_) => unreachable!(),
|
|
|
|
};
|
2020-01-08 03:18:06 +00:00
|
|
|
|
2020-06-05 03:07:59 +00:00
|
|
|
match state {
|
2020-06-18 01:53:08 +00:00
|
|
|
OutboundSubstreamState::RequestPendingResponse {
|
|
|
|
substream,
|
|
|
|
request: _,
|
|
|
|
} if deactivated => {
|
|
|
|
// the handler is deactivated. Close the stream
|
|
|
|
entry.get_mut().state = OutboundSubstreamState::Closing(substream);
|
|
|
|
self.pending_errors.push(HandlerErr::Outbound {
|
|
|
|
id: entry.get().req_id,
|
|
|
|
proto: entry.get().proto,
|
|
|
|
error: RPCError::HandlerRejected,
|
|
|
|
})
|
|
|
|
}
|
2020-06-05 03:07:59 +00:00
|
|
|
OutboundSubstreamState::RequestPendingResponse {
|
|
|
|
mut substream,
|
|
|
|
request,
|
|
|
|
} => match substream.poll_next_unpin(cx) {
|
|
|
|
Poll::Ready(Some(Ok(response))) => {
|
|
|
|
if request.expected_responses() > 1 && !response.is_error() {
|
|
|
|
let substream_entry = entry.get_mut();
|
|
|
|
let delay_key = &substream_entry.delay_key;
|
|
|
|
// chunks left after this one
|
|
|
|
let remaining_chunks = substream_entry
|
|
|
|
.remaining_chunks
|
|
|
|
.map(|count| count.saturating_sub(1))
|
|
|
|
.unwrap_or_else(|| 0);
|
|
|
|
if remaining_chunks == 0 {
|
|
|
|
// this is the last expected message, close the stream as all expected chunks have been received
|
|
|
|
substream_entry.state = OutboundSubstreamState::Closing(substream);
|
|
|
|
} else {
|
|
|
|
// If the response chunk was expected update the remaining number of chunks expected and reset the Timeout
|
|
|
|
substream_entry.state =
|
|
|
|
OutboundSubstreamState::RequestPendingResponse {
|
|
|
|
substream,
|
|
|
|
request,
|
|
|
|
};
|
|
|
|
substream_entry.remaining_chunks = Some(remaining_chunks);
|
|
|
|
self.outbound_substreams_delay
|
|
|
|
.reset(delay_key, Duration::from_secs(RESPONSE_TIMEOUT));
|
2019-11-27 01:47:46 +00:00
|
|
|
}
|
2020-06-05 03:07:59 +00:00
|
|
|
} else {
|
|
|
|
// either this is a single response request or we received an
|
|
|
|
// error only expect a single response, close the stream
|
|
|
|
entry.get_mut().state = OutboundSubstreamState::Closing(substream);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check what type of response we got and report it accordingly
|
|
|
|
let id = entry.get().req_id;
|
|
|
|
let proto = entry.get().proto;
|
|
|
|
|
|
|
|
let received = match response {
|
|
|
|
RPCCodedResponse::StreamTermination(t) => {
|
|
|
|
Ok(RPCReceived::EndOfStream(id, t))
|
2019-11-27 01:47:46 +00:00
|
|
|
}
|
2020-06-05 03:07:59 +00:00
|
|
|
RPCCodedResponse::Success(resp) => Ok(RPCReceived::Response(id, resp)),
|
|
|
|
RPCCodedResponse::InvalidRequest(ref r)
|
|
|
|
| RPCCodedResponse::ServerError(ref r)
|
|
|
|
| RPCCodedResponse::Unknown(ref r) => {
|
|
|
|
let code = response.error_code().expect(
|
|
|
|
"Response indicating and error should map to an error code",
|
|
|
|
);
|
|
|
|
Err(HandlerErr::Outbound {
|
|
|
|
id,
|
|
|
|
proto,
|
|
|
|
error: RPCError::ErrorResponse(code, r.clone()),
|
|
|
|
})
|
2019-11-27 01:47:46 +00:00
|
|
|
}
|
2020-06-05 03:07:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return Poll::Ready(ProtocolsHandlerEvent::Custom(received));
|
|
|
|
}
|
|
|
|
Poll::Ready(None) => {
|
|
|
|
// stream closed
|
|
|
|
// if we expected multiple streams send a stream termination,
|
|
|
|
// else report the stream terminating only.
|
|
|
|
//trace!(self.log, "RPC Response - stream closed by remote");
|
|
|
|
// drop the stream
|
|
|
|
let delay_key = &entry.get().delay_key;
|
|
|
|
let request_id = *&entry.get().req_id;
|
|
|
|
self.outbound_substreams_delay.remove(delay_key);
|
|
|
|
entry.remove_entry();
|
|
|
|
self.update_keep_alive();
|
|
|
|
// notify the application error
|
|
|
|
if request.expected_responses() > 1 {
|
|
|
|
// return an end of stream result
|
|
|
|
return Poll::Ready(ProtocolsHandlerEvent::Custom(Ok(
|
|
|
|
RPCReceived::EndOfStream(request_id, request.stream_termination()),
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
|
|
|
// else we return an error, stream should not have closed early.
|
|
|
|
let outbound_err = HandlerErr::Outbound {
|
|
|
|
id: request_id,
|
|
|
|
proto: request.protocol(),
|
|
|
|
error: RPCError::IncompleteStream,
|
|
|
|
};
|
|
|
|
return Poll::Ready(ProtocolsHandlerEvent::Custom(Err(outbound_err)));
|
|
|
|
}
|
|
|
|
Poll::Pending => {
|
|
|
|
entry.get_mut().state =
|
|
|
|
OutboundSubstreamState::RequestPendingResponse { substream, request }
|
|
|
|
}
|
|
|
|
Poll::Ready(Some(Err(e))) => {
|
|
|
|
// drop the stream
|
|
|
|
let delay_key = &entry.get().delay_key;
|
|
|
|
self.outbound_substreams_delay.remove(delay_key);
|
|
|
|
let outbound_err = HandlerErr::Outbound {
|
|
|
|
id: entry.get().req_id,
|
|
|
|
proto: entry.get().proto,
|
|
|
|
error: e,
|
|
|
|
};
|
|
|
|
entry.remove_entry();
|
|
|
|
self.update_keep_alive();
|
|
|
|
return Poll::Ready(ProtocolsHandlerEvent::Custom(Err(outbound_err)));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
OutboundSubstreamState::Closing(mut substream) => {
|
|
|
|
match Sink::poll_close(Pin::new(&mut substream), cx) {
|
|
|
|
Poll::Ready(_) => {
|
|
|
|
// drop the stream and its corresponding timeout
|
|
|
|
let delay_key = &entry.get().delay_key;
|
|
|
|
let protocol = entry.get().proto;
|
|
|
|
let request_id = entry.get().req_id;
|
|
|
|
self.outbound_substreams_delay.remove(delay_key);
|
|
|
|
entry.remove_entry();
|
|
|
|
self.update_keep_alive();
|
|
|
|
|
|
|
|
// report the stream termination to the user
|
|
|
|
//
|
|
|
|
// Streams can be terminated here if a responder tries to
|
|
|
|
// continue sending responses beyond what we would expect. Here
|
|
|
|
// we simply terminate the stream and report a stream
|
|
|
|
// termination to the application
|
|
|
|
let termination = match protocol {
|
|
|
|
Protocol::BlocksByRange => Some(ResponseTermination::BlocksByRange),
|
|
|
|
Protocol::BlocksByRoot => Some(ResponseTermination::BlocksByRoot),
|
|
|
|
_ => None, // all other protocols are do not have multiple responses and we do not inform the user, we simply drop the stream.
|
|
|
|
};
|
|
|
|
|
|
|
|
if let Some(termination) = termination {
|
|
|
|
return Poll::Ready(ProtocolsHandlerEvent::Custom(Ok(
|
|
|
|
RPCReceived::EndOfStream(request_id, termination),
|
|
|
|
)));
|
2019-11-27 01:47:46 +00:00
|
|
|
}
|
2020-05-17 11:16:48 +00:00
|
|
|
}
|
2020-06-05 03:07:59 +00:00
|
|
|
Poll::Pending => {
|
|
|
|
entry.get_mut().state = OutboundSubstreamState::Closing(substream);
|
2019-07-16 12:32:37 +00:00
|
|
|
}
|
|
|
|
}
|
2019-11-27 01:47:46 +00:00
|
|
|
}
|
2020-06-05 03:07:59 +00:00
|
|
|
OutboundSubstreamState::Poisoned => {
|
|
|
|
crit!(self.log, "Poisoned outbound substream");
|
|
|
|
unreachable!("Coding Error: Outbound substream is poisoned")
|
|
|
|
}
|
2019-07-16 12:32:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-06 13:43:44 +00:00
|
|
|
// establish outbound substreams
|
2020-01-23 06:30:49 +00:00
|
|
|
if !self.dial_queue.is_empty() && self.dial_negotiated < self.max_dial_negotiated {
|
|
|
|
self.dial_negotiated += 1;
|
2020-05-03 13:17:12 +00:00
|
|
|
let (id, req) = self.dial_queue.remove(0);
|
2019-07-06 11:32:32 +00:00
|
|
|
self.dial_queue.shrink_to_fit();
|
2020-05-29 02:03:13 +00:00
|
|
|
self.update_keep_alive();
|
2020-05-17 11:16:48 +00:00
|
|
|
return Poll::Ready(ProtocolsHandlerEvent::OutboundSubstreamRequest {
|
|
|
|
protocol: SubstreamProtocol::new(req.clone()),
|
|
|
|
info: (id, req),
|
|
|
|
});
|
2019-07-06 11:32:32 +00:00
|
|
|
}
|
2020-05-17 11:16:48 +00:00
|
|
|
Poll::Pending
|
2019-07-06 11:32:32 +00:00
|
|
|
}
|
|
|
|
}
|
2019-11-27 01:47:46 +00:00
|
|
|
|
|
|
|
// Check for new items to send to the peer and update the underlying stream
|
2020-05-17 11:16:48 +00:00
|
|
|
fn apply_queued_responses<TSpec: EthSpec>(
|
|
|
|
substream: InboundFramed<NegotiatedSubstream, TSpec>,
|
2020-05-03 13:17:12 +00:00
|
|
|
queued_outbound_items: &mut Option<&mut Vec<RPCCodedResponse<TSpec>>>,
|
2019-11-27 01:47:46 +00:00
|
|
|
new_items_to_send: &mut bool,
|
2020-05-17 11:16:48 +00:00
|
|
|
) -> InboundSubstreamState<TSpec> {
|
2019-11-27 01:47:46 +00:00
|
|
|
match queued_outbound_items {
|
|
|
|
Some(ref mut queue) if !queue.is_empty() => {
|
|
|
|
*new_items_to_send = true;
|
|
|
|
// we have queued items
|
|
|
|
match queue.remove(0) {
|
2020-05-03 13:17:12 +00:00
|
|
|
RPCCodedResponse::StreamTermination(_) => {
|
2019-11-27 01:47:46 +00:00
|
|
|
// close the stream if this is a stream termination
|
2020-05-17 11:16:48 +00:00
|
|
|
InboundSubstreamState::Closing(substream)
|
2019-11-27 01:47:46 +00:00
|
|
|
}
|
|
|
|
chunk => InboundSubstreamState::ResponsePendingSend {
|
2020-06-05 03:07:59 +00:00
|
|
|
substream,
|
2020-05-17 11:16:48 +00:00
|
|
|
message: chunk,
|
2019-11-27 01:47:46 +00:00
|
|
|
closing: false,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_ => {
|
|
|
|
// no items queued set to idle
|
2020-05-17 11:16:48 +00:00
|
|
|
InboundSubstreamState::ResponseIdle(substream)
|
2019-11-27 01:47:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-05 03:07:59 +00:00
|
|
|
|
|
|
|
impl slog::Value for SubstreamId {
|
|
|
|
fn serialize(
|
|
|
|
&self,
|
|
|
|
record: &slog::Record,
|
|
|
|
key: slog::Key,
|
|
|
|
serializer: &mut dyn slog::Serializer,
|
|
|
|
) -> slog::Result {
|
|
|
|
slog::Value::serialize(&self.0, record, key, serializer)
|
|
|
|
}
|
|
|
|
}
|