2019-03-21 00:02:52 +00:00
|
|
|
use super::methods::*;
|
2019-11-27 01:47:46 +00:00
|
|
|
use crate::rpc::{
|
2021-06-17 00:40:16 +00:00
|
|
|
codec::{base::BaseInboundCodec, ssz_snappy::SSZSnappyInboundCodec, InboundCodec},
|
2020-10-11 22:45:33 +00:00
|
|
|
methods::{MaxErrorLen, ResponseTermination, MAX_ERROR_LEN},
|
2020-06-12 10:38:30 +00:00
|
|
|
MaxRequestBlocks, MAX_REQUEST_BLOCKS,
|
2019-07-15 08:41:05 +00:00
|
|
|
};
|
2020-07-28 01:39:42 +00:00
|
|
|
use futures::future::BoxFuture;
|
2020-05-17 11:16:48 +00:00
|
|
|
use futures::prelude::{AsyncRead, AsyncWrite};
|
2021-06-17 00:40:16 +00:00
|
|
|
use futures::{FutureExt, StreamExt};
|
|
|
|
use libp2p::core::{InboundUpgrade, ProtocolName, UpgradeInfo};
|
2020-06-12 10:38:30 +00:00
|
|
|
use ssz::Encode;
|
|
|
|
use ssz_types::VariableList;
|
2019-03-14 14:50:59 +00:00
|
|
|
use std::io;
|
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 std::marker::PhantomData;
|
2021-08-04 01:44:57 +00:00
|
|
|
use std::sync::Arc;
|
2019-07-09 05:44:23 +00:00
|
|
|
use std::time::Duration;
|
2021-01-19 06:33:58 +00:00
|
|
|
use strum::{AsStaticRef, AsStaticStr};
|
2019-08-29 11:23:28 +00:00
|
|
|
use tokio_io_timeout::TimeoutStream;
|
2020-05-17 11:16:48 +00:00
|
|
|
use tokio_util::{
|
|
|
|
codec::Framed,
|
|
|
|
compat::{Compat, FuturesAsyncReadCompatExt},
|
|
|
|
};
|
2021-08-04 01:44:57 +00:00
|
|
|
use types::{
|
|
|
|
BeaconBlock, BeaconBlockAltair, BeaconBlockBase, EthSpec, ForkContext, Hash256, MainnetEthSpec,
|
|
|
|
Signature, SignedBeaconBlock,
|
|
|
|
};
|
2020-06-12 10:38:30 +00:00
|
|
|
|
|
|
|
lazy_static! {
|
|
|
|
// Note: Hardcoding the `EthSpec` type for `SignedBeaconBlock` as min/max values is
|
|
|
|
// same across different `EthSpec` implementations.
|
2021-08-04 01:44:57 +00:00
|
|
|
pub static ref SIGNED_BEACON_BLOCK_BASE_MIN: usize = SignedBeaconBlock::<MainnetEthSpec>::from_block(
|
|
|
|
BeaconBlock::Base(BeaconBlockBase::<MainnetEthSpec>::empty(&MainnetEthSpec::default_spec())),
|
|
|
|
Signature::empty(),
|
|
|
|
)
|
|
|
|
.as_ssz_bytes()
|
|
|
|
.len();
|
|
|
|
pub static ref SIGNED_BEACON_BLOCK_BASE_MAX: usize = SignedBeaconBlock::<MainnetEthSpec>::from_block(
|
|
|
|
BeaconBlock::Base(BeaconBlockBase::full(&MainnetEthSpec::default_spec())),
|
|
|
|
Signature::empty(),
|
|
|
|
)
|
|
|
|
.as_ssz_bytes()
|
|
|
|
.len();
|
|
|
|
|
|
|
|
pub static ref SIGNED_BEACON_BLOCK_ALTAIR_MIN: usize = SignedBeaconBlock::<MainnetEthSpec>::from_block(
|
|
|
|
BeaconBlock::Altair(BeaconBlockAltair::<MainnetEthSpec>::empty(&MainnetEthSpec::default_spec())),
|
2021-07-09 06:15:32 +00:00
|
|
|
Signature::empty(),
|
|
|
|
)
|
2020-06-12 10:38:30 +00:00
|
|
|
.as_ssz_bytes()
|
|
|
|
.len();
|
2021-08-04 01:44:57 +00:00
|
|
|
pub static ref SIGNED_BEACON_BLOCK_ALTAIR_MAX: usize = SignedBeaconBlock::<MainnetEthSpec>::from_block(
|
|
|
|
BeaconBlock::Altair(BeaconBlockAltair::full(&MainnetEthSpec::default_spec())),
|
2021-07-09 06:15:32 +00:00
|
|
|
Signature::empty(),
|
|
|
|
)
|
2020-06-12 10:38:30 +00:00
|
|
|
.as_ssz_bytes()
|
|
|
|
.len();
|
2020-06-29 11:03:14 +00:00
|
|
|
pub static ref BLOCKS_BY_ROOT_REQUEST_MIN: usize =
|
|
|
|
VariableList::<Hash256, MaxRequestBlocks>::from(Vec::<Hash256>::new())
|
2020-06-12 10:38:30 +00:00
|
|
|
.as_ssz_bytes()
|
|
|
|
.len();
|
2020-06-29 11:03:14 +00:00
|
|
|
pub static ref BLOCKS_BY_ROOT_REQUEST_MAX: usize =
|
|
|
|
VariableList::<Hash256, MaxRequestBlocks>::from(vec![
|
2020-06-12 10:38:30 +00:00
|
|
|
Hash256::zero();
|
|
|
|
MAX_REQUEST_BLOCKS
|
|
|
|
as usize
|
|
|
|
])
|
|
|
|
.as_ssz_bytes()
|
|
|
|
.len();
|
2020-10-11 22:45:33 +00:00
|
|
|
pub static ref ERROR_TYPE_MIN: usize =
|
|
|
|
VariableList::<u8, MaxErrorLen>::from(Vec::<u8>::new())
|
|
|
|
.as_ssz_bytes()
|
|
|
|
.len();
|
|
|
|
pub static ref ERROR_TYPE_MAX: usize =
|
|
|
|
VariableList::<u8, MaxErrorLen>::from(vec![
|
|
|
|
0u8;
|
|
|
|
MAX_ERROR_LEN
|
|
|
|
as usize
|
|
|
|
])
|
|
|
|
.as_ssz_bytes()
|
|
|
|
.len();
|
|
|
|
|
2020-06-12 10:38:30 +00:00
|
|
|
}
|
2019-03-14 14:50:59 +00:00
|
|
|
|
|
|
|
/// The maximum bytes that can be sent across the RPC.
|
2021-11-16 22:23:39 +00:00
|
|
|
pub const MAX_RPC_SIZE: usize = 1_048_576; // 1M
|
2019-07-05 08:59:53 +00:00
|
|
|
/// The protocol prefix the RPC protocol id.
|
2019-08-29 11:23:28 +00:00
|
|
|
const PROTOCOL_PREFIX: &str = "/eth2/beacon_chain/req";
|
|
|
|
/// Time allowed for the first byte of a request to arrive before we time out (Time To First Byte).
|
|
|
|
const TTFB_TIMEOUT: u64 = 5;
|
|
|
|
/// The number of seconds to wait for the first bytes of a request once a protocol has been
|
|
|
|
/// established before the stream is terminated.
|
|
|
|
const REQUEST_TIMEOUT: u64 = 15;
|
2019-03-14 14:50:59 +00:00
|
|
|
|
2019-11-29 00:20:36 +00:00
|
|
|
/// Protocol names to be used.
|
2021-06-17 00:40:16 +00:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
2020-04-20 13:15:08 +00:00
|
|
|
pub enum Protocol {
|
|
|
|
/// The Status protocol name.
|
|
|
|
Status,
|
|
|
|
/// The Goodbye protocol name.
|
|
|
|
Goodbye,
|
|
|
|
/// The `BlocksByRange` protocol name.
|
|
|
|
BlocksByRange,
|
|
|
|
/// The `BlocksByRoot` protocol name.
|
|
|
|
BlocksByRoot,
|
|
|
|
/// The `Ping` protocol name.
|
|
|
|
Ping,
|
|
|
|
/// The `MetaData` protocol name.
|
|
|
|
MetaData,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// RPC Versions
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
|
|
pub enum Version {
|
|
|
|
/// Version 1 of RPC
|
|
|
|
V1,
|
2021-08-04 01:44:57 +00:00
|
|
|
/// Version 2 of RPC
|
|
|
|
V2,
|
2020-04-20 13:15:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// RPC Encondings supported.
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
|
|
pub enum Encoding {
|
|
|
|
SSZSnappy,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::fmt::Display for Protocol {
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
let repr = match self {
|
|
|
|
Protocol::Status => "status",
|
|
|
|
Protocol::Goodbye => "goodbye",
|
|
|
|
Protocol::BlocksByRange => "beacon_blocks_by_range",
|
|
|
|
Protocol::BlocksByRoot => "beacon_blocks_by_root",
|
|
|
|
Protocol::Ping => "ping",
|
|
|
|
Protocol::MetaData => "metadata",
|
|
|
|
};
|
|
|
|
f.write_str(repr)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::fmt::Display for Encoding {
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
let repr = match self {
|
|
|
|
Encoding::SSZSnappy => "ssz_snappy",
|
|
|
|
};
|
|
|
|
f.write_str(repr)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::fmt::Display for Version {
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
let repr = match self {
|
|
|
|
Version::V1 => "1",
|
2021-08-04 01:44:57 +00:00
|
|
|
Version::V2 => "2",
|
2020-04-20 13:15:08 +00:00
|
|
|
};
|
|
|
|
f.write_str(repr)
|
|
|
|
}
|
|
|
|
}
|
2019-11-29 00:20:36 +00:00
|
|
|
|
2019-03-14 14:50:59 +00:00
|
|
|
#[derive(Debug, Clone)]
|
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 struct RPCProtocol<TSpec: EthSpec> {
|
2021-08-04 01:44:57 +00:00
|
|
|
pub fork_context: Arc<ForkContext>,
|
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 phantom: PhantomData<TSpec>,
|
|
|
|
}
|
2019-03-14 14:50:59 +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
|
|
|
impl<TSpec: EthSpec> UpgradeInfo for RPCProtocol<TSpec> {
|
2019-08-10 01:44:17 +00:00
|
|
|
type Info = ProtocolId;
|
2019-07-05 08:59:53 +00:00
|
|
|
type InfoIter = Vec<Self::Info>;
|
2019-03-14 14:50:59 +00:00
|
|
|
|
2020-04-07 15:08:05 +00:00
|
|
|
/// The list of supported RPC protocols for Lighthouse.
|
2019-03-14 14:50:59 +00:00
|
|
|
fn protocol_info(&self) -> Self::InfoIter {
|
2019-07-05 08:59:53 +00:00
|
|
|
vec![
|
2020-04-20 13:15:08 +00:00
|
|
|
ProtocolId::new(Protocol::Status, Version::V1, Encoding::SSZSnappy),
|
|
|
|
ProtocolId::new(Protocol::Goodbye, Version::V1, Encoding::SSZSnappy),
|
2021-08-04 01:44:57 +00:00
|
|
|
// V2 variants have higher preference then V1
|
|
|
|
ProtocolId::new(Protocol::BlocksByRange, Version::V2, Encoding::SSZSnappy),
|
2020-04-20 13:15:08 +00:00
|
|
|
ProtocolId::new(Protocol::BlocksByRange, Version::V1, Encoding::SSZSnappy),
|
2021-08-04 01:44:57 +00:00
|
|
|
ProtocolId::new(Protocol::BlocksByRoot, Version::V2, Encoding::SSZSnappy),
|
2020-04-20 13:15:08 +00:00
|
|
|
ProtocolId::new(Protocol::BlocksByRoot, Version::V1, Encoding::SSZSnappy),
|
|
|
|
ProtocolId::new(Protocol::Ping, Version::V1, Encoding::SSZSnappy),
|
2021-08-04 01:44:57 +00:00
|
|
|
ProtocolId::new(Protocol::MetaData, Version::V2, Encoding::SSZSnappy),
|
2020-04-20 13:15:08 +00:00
|
|
|
ProtocolId::new(Protocol::MetaData, Version::V1, Encoding::SSZSnappy),
|
2019-07-05 08:59:53 +00:00
|
|
|
]
|
2019-03-14 14:50:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-11 22:45:33 +00:00
|
|
|
/// Represents the ssz length bounds for RPC messages.
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub struct RpcLimits {
|
2020-11-19 22:32:09 +00:00
|
|
|
pub min: usize,
|
|
|
|
pub max: usize,
|
2020-10-11 22:45:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl RpcLimits {
|
|
|
|
pub fn new(min: usize, max: usize) -> Self {
|
|
|
|
Self { min, max }
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Returns true if the given length is out of bounds, false otherwise.
|
|
|
|
pub fn is_out_of_bounds(&self, length: usize) -> bool {
|
|
|
|
length > self.max || length < self.min
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-05 08:59:53 +00:00
|
|
|
/// Tracks the types in a protocol id.
|
2020-04-07 15:08:05 +00:00
|
|
|
#[derive(Clone, Debug)]
|
2019-07-05 08:59:53 +00:00
|
|
|
pub struct ProtocolId {
|
2020-05-03 13:17:12 +00:00
|
|
|
/// The RPC message type/name.
|
2020-04-20 13:15:08 +00:00
|
|
|
pub message_name: Protocol,
|
2019-07-04 04:05:01 +00:00
|
|
|
|
2019-07-05 08:59:53 +00:00
|
|
|
/// The version of the RPC.
|
2020-04-20 13:15:08 +00:00
|
|
|
pub version: Version,
|
2019-07-04 04:05:01 +00:00
|
|
|
|
2019-07-05 08:59:53 +00:00
|
|
|
/// The encoding of the RPC.
|
2020-04-20 13:15:08 +00:00
|
|
|
pub encoding: Encoding,
|
2019-08-10 01:44:17 +00:00
|
|
|
|
|
|
|
/// The protocol id that is formed from the above fields.
|
|
|
|
protocol_id: String,
|
2019-07-05 08:59:53 +00:00
|
|
|
}
|
2019-07-04 04:05:01 +00:00
|
|
|
|
2020-10-11 22:45:33 +00:00
|
|
|
impl ProtocolId {
|
|
|
|
/// Returns min and max size for messages of given protocol id requests.
|
|
|
|
pub fn rpc_request_limits(&self) -> RpcLimits {
|
|
|
|
match self.message_name {
|
|
|
|
Protocol::Status => RpcLimits::new(
|
|
|
|
<StatusMessage as Encode>::ssz_fixed_len(),
|
|
|
|
<StatusMessage as Encode>::ssz_fixed_len(),
|
|
|
|
),
|
|
|
|
Protocol::Goodbye => RpcLimits::new(
|
|
|
|
<GoodbyeReason as Encode>::ssz_fixed_len(),
|
|
|
|
<GoodbyeReason as Encode>::ssz_fixed_len(),
|
|
|
|
),
|
|
|
|
Protocol::BlocksByRange => RpcLimits::new(
|
|
|
|
<BlocksByRangeRequest as Encode>::ssz_fixed_len(),
|
|
|
|
<BlocksByRangeRequest as Encode>::ssz_fixed_len(),
|
|
|
|
),
|
|
|
|
Protocol::BlocksByRoot => {
|
|
|
|
RpcLimits::new(*BLOCKS_BY_ROOT_REQUEST_MIN, *BLOCKS_BY_ROOT_REQUEST_MAX)
|
|
|
|
}
|
|
|
|
Protocol::Ping => RpcLimits::new(
|
|
|
|
<Ping as Encode>::ssz_fixed_len(),
|
|
|
|
<Ping as Encode>::ssz_fixed_len(),
|
|
|
|
),
|
|
|
|
Protocol::MetaData => RpcLimits::new(0, 0), // Metadata requests are empty
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Returns min and max size for messages of given protocol id responses.
|
|
|
|
pub fn rpc_response_limits<T: EthSpec>(&self) -> RpcLimits {
|
|
|
|
match self.message_name {
|
|
|
|
Protocol::Status => RpcLimits::new(
|
|
|
|
<StatusMessage as Encode>::ssz_fixed_len(),
|
|
|
|
<StatusMessage as Encode>::ssz_fixed_len(),
|
|
|
|
),
|
|
|
|
Protocol::Goodbye => RpcLimits::new(0, 0), // Goodbye request has no response
|
2021-08-04 01:44:57 +00:00
|
|
|
Protocol::BlocksByRange => RpcLimits::new(
|
|
|
|
std::cmp::min(
|
|
|
|
*SIGNED_BEACON_BLOCK_ALTAIR_MIN,
|
|
|
|
*SIGNED_BEACON_BLOCK_BASE_MIN,
|
|
|
|
),
|
|
|
|
std::cmp::max(
|
|
|
|
*SIGNED_BEACON_BLOCK_ALTAIR_MAX,
|
|
|
|
*SIGNED_BEACON_BLOCK_BASE_MAX,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Protocol::BlocksByRoot => RpcLimits::new(
|
|
|
|
std::cmp::min(
|
|
|
|
*SIGNED_BEACON_BLOCK_ALTAIR_MIN,
|
|
|
|
*SIGNED_BEACON_BLOCK_BASE_MIN,
|
|
|
|
),
|
|
|
|
std::cmp::max(
|
|
|
|
*SIGNED_BEACON_BLOCK_ALTAIR_MAX,
|
|
|
|
*SIGNED_BEACON_BLOCK_BASE_MAX,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
2020-10-11 22:45:33 +00:00
|
|
|
Protocol::Ping => RpcLimits::new(
|
|
|
|
<Ping as Encode>::ssz_fixed_len(),
|
|
|
|
<Ping as Encode>::ssz_fixed_len(),
|
|
|
|
),
|
|
|
|
Protocol::MetaData => RpcLimits::new(
|
2021-08-04 01:44:57 +00:00
|
|
|
<MetaDataV1<T> as Encode>::ssz_fixed_len(),
|
|
|
|
<MetaDataV2<T> as Encode>::ssz_fixed_len(),
|
2020-10-11 22:45:33 +00:00
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
2021-08-04 01:44:57 +00:00
|
|
|
|
|
|
|
/// Returns `true` if the given `ProtocolId` should expect `context_bytes` in the
|
|
|
|
/// beginning of the stream, else returns `false`.
|
|
|
|
pub fn has_context_bytes(&self) -> bool {
|
|
|
|
if self.version == Version::V2 {
|
|
|
|
match self.message_name {
|
|
|
|
Protocol::BlocksByRange | Protocol::BlocksByRoot => return true,
|
|
|
|
_ => return false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
false
|
|
|
|
}
|
2020-10-11 22:45:33 +00:00
|
|
|
}
|
|
|
|
|
2019-07-05 08:59:53 +00:00
|
|
|
/// An RPC protocol ID.
|
|
|
|
impl ProtocolId {
|
2020-04-20 13:15:08 +00:00
|
|
|
pub fn new(message_name: Protocol, version: Version, encoding: Encoding) -> Self {
|
2019-08-10 01:44:17 +00:00
|
|
|
let protocol_id = format!(
|
|
|
|
"{}/{}/{}/{}",
|
|
|
|
PROTOCOL_PREFIX, message_name, version, encoding
|
|
|
|
);
|
|
|
|
|
2019-07-05 08:59:53 +00:00
|
|
|
ProtocolId {
|
2020-04-20 13:15:08 +00:00
|
|
|
message_name,
|
2020-05-03 13:17:12 +00:00
|
|
|
version,
|
2020-04-20 13:15:08 +00:00
|
|
|
encoding,
|
2019-08-10 01:44:17 +00:00
|
|
|
protocol_id,
|
2019-07-05 08:59:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-03 05:23:09 +00:00
|
|
|
|
2019-08-10 01:44:17 +00:00
|
|
|
impl ProtocolName for ProtocolId {
|
|
|
|
fn protocol_name(&self) -> &[u8] {
|
|
|
|
self.protocol_id.as_bytes()
|
2019-07-05 08:59:53 +00:00
|
|
|
}
|
|
|
|
}
|
2019-03-14 14:50:59 +00:00
|
|
|
|
2019-07-09 05:44:23 +00:00
|
|
|
/* Inbound upgrade */
|
|
|
|
|
|
|
|
// The inbound protocol reads the request, decodes it and returns the stream to the protocol
|
|
|
|
// handler to respond to once ready.
|
|
|
|
|
2021-06-17 00:40:16 +00:00
|
|
|
pub type InboundOutput<TSocket, TSpec> = (InboundRequest<TSpec>, InboundFramed<TSocket, 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
|
|
|
pub type InboundFramed<TSocket, TSpec> =
|
2021-02-10 23:29:49 +00:00
|
|
|
Framed<std::pin::Pin<Box<TimeoutStream<Compat<TSocket>>>>, InboundCodec<TSpec>>;
|
2019-07-09 05:44:23 +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
|
|
|
impl<TSocket, TSpec> InboundUpgrade<TSocket> for RPCProtocol<TSpec>
|
2019-07-09 05:44:23 +00:00
|
|
|
where
|
2020-05-17 11:16:48 +00:00
|
|
|
TSocket: AsyncRead + AsyncWrite + Unpin + Send + 'static,
|
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-09 05:44:23 +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
|
|
|
type Output = InboundOutput<TSocket, TSpec>;
|
2019-07-09 05:44:23 +00:00
|
|
|
type Error = RPCError;
|
2020-07-28 01:39:42 +00:00
|
|
|
type Future = BoxFuture<'static, Result<Self::Output, Self::Error>>;
|
2019-07-15 07:07:23 +00:00
|
|
|
|
2020-05-17 11:16:48 +00:00
|
|
|
fn upgrade_inbound(self, socket: TSocket, protocol: ProtocolId) -> Self::Future {
|
2020-07-28 01:39:42 +00:00
|
|
|
async move {
|
|
|
|
let protocol_name = protocol.message_name;
|
|
|
|
// convert the socket to tokio compatible socket
|
|
|
|
let socket = socket.compat();
|
|
|
|
let codec = match protocol.encoding {
|
|
|
|
Encoding::SSZSnappy => {
|
2021-08-04 01:44:57 +00:00
|
|
|
let ssz_snappy_codec = BaseInboundCodec::new(SSZSnappyInboundCodec::new(
|
|
|
|
protocol,
|
|
|
|
MAX_RPC_SIZE,
|
|
|
|
self.fork_context.clone(),
|
|
|
|
));
|
2020-07-28 01:39:42 +00:00
|
|
|
InboundCodec::SSZSnappy(ssz_snappy_codec)
|
|
|
|
}
|
|
|
|
};
|
|
|
|
let mut timed_socket = TimeoutStream::new(socket);
|
|
|
|
timed_socket.set_read_timeout(Some(Duration::from_secs(TTFB_TIMEOUT)));
|
|
|
|
|
2021-02-10 23:29:49 +00:00
|
|
|
let socket = Framed::new(Box::pin(timed_socket), codec);
|
2020-07-28 01:39:42 +00:00
|
|
|
|
|
|
|
// MetaData requests should be empty, return the stream
|
|
|
|
match protocol_name {
|
2021-06-17 00:40:16 +00:00
|
|
|
Protocol::MetaData => Ok((InboundRequest::MetaData(PhantomData), socket)),
|
2020-07-28 01:39:42 +00:00
|
|
|
_ => {
|
|
|
|
match tokio::time::timeout(
|
|
|
|
Duration::from_secs(REQUEST_TIMEOUT),
|
|
|
|
socket.into_future(),
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
{
|
|
|
|
Err(e) => Err(RPCError::from(e)),
|
|
|
|
Ok((Some(Ok(request)), stream)) => Ok((request, stream)),
|
2020-10-11 22:45:33 +00:00
|
|
|
Ok((Some(Err(e)), _)) => Err(e),
|
|
|
|
Ok((None, _)) => Err(RPCError::IncompleteStream),
|
2020-07-28 01:39:42 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-15 07:07:23 +00:00
|
|
|
}
|
2020-07-28 01:39:42 +00:00
|
|
|
}
|
|
|
|
.boxed()
|
2019-07-09 05:44:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-27 01:47:46 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq)]
|
2021-06-17 00:40:16 +00:00
|
|
|
pub enum InboundRequest<TSpec: EthSpec> {
|
2019-11-27 01:47:46 +00:00
|
|
|
Status(StatusMessage),
|
2019-07-16 12:32:37 +00:00
|
|
|
Goodbye(GoodbyeReason),
|
2019-11-27 01:47:46 +00:00
|
|
|
BlocksByRange(BlocksByRangeRequest),
|
|
|
|
BlocksByRoot(BlocksByRootRequest),
|
2020-04-07 15:08:05 +00:00
|
|
|
Ping(Ping),
|
|
|
|
MetaData(PhantomData<TSpec>),
|
2019-07-05 08:59:53 +00:00
|
|
|
}
|
2019-03-14 14:50:59 +00:00
|
|
|
|
2021-06-17 00:40:16 +00:00
|
|
|
impl<TSpec: EthSpec> UpgradeInfo for InboundRequest<TSpec> {
|
2019-08-10 01:44:17 +00:00
|
|
|
type Info = ProtocolId;
|
2019-07-05 08:59:53 +00:00
|
|
|
type InfoIter = Vec<Self::Info>;
|
2019-07-04 04:05:01 +00:00
|
|
|
|
2019-07-05 08:59:53 +00:00
|
|
|
// add further protocols as we support more encodings/versions
|
|
|
|
fn protocol_info(&self) -> Self::InfoIter {
|
|
|
|
self.supported_protocols()
|
|
|
|
}
|
|
|
|
}
|
2019-07-04 04:05:01 +00:00
|
|
|
|
2020-05-03 13:17:12 +00:00
|
|
|
/// Implements the encoding per supported protocol for `RPCRequest`.
|
2021-06-17 00:40:16 +00:00
|
|
|
impl<TSpec: EthSpec> InboundRequest<TSpec> {
|
2019-08-10 01:44:17 +00:00
|
|
|
pub fn supported_protocols(&self) -> Vec<ProtocolId> {
|
2019-07-05 08:59:53 +00:00
|
|
|
match self {
|
|
|
|
// add more protocols when versions/encodings are supported
|
2021-06-17 00:40:16 +00:00
|
|
|
InboundRequest::Status(_) => vec![ProtocolId::new(
|
2020-08-06 04:29:19 +00:00
|
|
|
Protocol::Status,
|
|
|
|
Version::V1,
|
|
|
|
Encoding::SSZSnappy,
|
|
|
|
)],
|
2021-06-17 00:40:16 +00:00
|
|
|
InboundRequest::Goodbye(_) => vec![ProtocolId::new(
|
2020-08-06 04:29:19 +00:00
|
|
|
Protocol::Goodbye,
|
|
|
|
Version::V1,
|
|
|
|
Encoding::SSZSnappy,
|
|
|
|
)],
|
2021-08-04 01:44:57 +00:00
|
|
|
InboundRequest::BlocksByRange(_) => vec![
|
|
|
|
// V2 has higher preference when negotiating a stream
|
|
|
|
ProtocolId::new(Protocol::BlocksByRange, Version::V2, Encoding::SSZSnappy),
|
|
|
|
ProtocolId::new(Protocol::BlocksByRange, Version::V1, Encoding::SSZSnappy),
|
|
|
|
],
|
|
|
|
InboundRequest::BlocksByRoot(_) => vec![
|
|
|
|
// V2 has higher preference when negotiating a stream
|
|
|
|
ProtocolId::new(Protocol::BlocksByRoot, Version::V2, Encoding::SSZSnappy),
|
|
|
|
ProtocolId::new(Protocol::BlocksByRoot, Version::V1, Encoding::SSZSnappy),
|
|
|
|
],
|
2021-06-17 00:40:16 +00:00
|
|
|
InboundRequest::Ping(_) => vec![ProtocolId::new(
|
2020-08-06 04:29:19 +00:00
|
|
|
Protocol::Ping,
|
|
|
|
Version::V1,
|
|
|
|
Encoding::SSZSnappy,
|
|
|
|
)],
|
2021-08-04 01:44:57 +00:00
|
|
|
InboundRequest::MetaData(_) => vec![
|
|
|
|
ProtocolId::new(Protocol::MetaData, Version::V2, Encoding::SSZSnappy),
|
|
|
|
ProtocolId::new(Protocol::MetaData, Version::V1, Encoding::SSZSnappy),
|
|
|
|
],
|
2019-07-05 08:59:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-27 01:47:46 +00:00
|
|
|
/* These functions are used in the handler for stream management */
|
|
|
|
|
2020-06-05 03:07:59 +00:00
|
|
|
/// Number of responses expected for this request.
|
2020-07-23 12:30:43 +00:00
|
|
|
pub fn expected_responses(&self) -> u64 {
|
2019-07-05 08:59:53 +00:00
|
|
|
match self {
|
2021-06-17 00:40:16 +00:00
|
|
|
InboundRequest::Status(_) => 1,
|
|
|
|
InboundRequest::Goodbye(_) => 0,
|
|
|
|
InboundRequest::BlocksByRange(req) => req.count,
|
|
|
|
InboundRequest::BlocksByRoot(req) => req.block_roots.len() as u64,
|
|
|
|
InboundRequest::Ping(_) => 1,
|
|
|
|
InboundRequest::MetaData(_) => 1,
|
2019-11-27 01:47:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-05 03:07:59 +00:00
|
|
|
/// Gives the corresponding `Protocol` to this request.
|
2020-05-03 13:17:12 +00:00
|
|
|
pub fn protocol(&self) -> Protocol {
|
|
|
|
match self {
|
2021-06-17 00:40:16 +00:00
|
|
|
InboundRequest::Status(_) => Protocol::Status,
|
|
|
|
InboundRequest::Goodbye(_) => Protocol::Goodbye,
|
|
|
|
InboundRequest::BlocksByRange(_) => Protocol::BlocksByRange,
|
|
|
|
InboundRequest::BlocksByRoot(_) => Protocol::BlocksByRoot,
|
|
|
|
InboundRequest::Ping(_) => Protocol::Ping,
|
|
|
|
InboundRequest::MetaData(_) => Protocol::MetaData,
|
2020-05-03 13:17:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-27 01:47:46 +00:00
|
|
|
/// Returns the `ResponseTermination` type associated with the request if a stream gets
|
|
|
|
/// terminated.
|
|
|
|
pub fn stream_termination(&self) -> ResponseTermination {
|
|
|
|
match self {
|
|
|
|
// this only gets called after `multiple_responses()` returns true. Therefore, only
|
|
|
|
// variants that have `multiple_responses()` can have values.
|
2021-06-17 00:40:16 +00:00
|
|
|
InboundRequest::BlocksByRange(_) => ResponseTermination::BlocksByRange,
|
|
|
|
InboundRequest::BlocksByRoot(_) => ResponseTermination::BlocksByRoot,
|
|
|
|
InboundRequest::Status(_) => unreachable!(),
|
|
|
|
InboundRequest::Goodbye(_) => unreachable!(),
|
|
|
|
InboundRequest::Ping(_) => unreachable!(),
|
|
|
|
InboundRequest::MetaData(_) => unreachable!(),
|
2019-07-05 08:59:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Error in RPC Encoding/Decoding.
|
2021-01-19 06:33:58 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, AsStaticStr)]
|
|
|
|
#[strum(serialize_all = "snake_case")]
|
2019-07-05 08:59:53 +00:00
|
|
|
pub enum RPCError {
|
|
|
|
/// Error when decoding the raw buffer from ssz.
|
2020-05-03 13:17:12 +00:00
|
|
|
// NOTE: in the future a ssz::DecodeError should map to an InvalidData error
|
2021-01-19 06:33:58 +00:00
|
|
|
#[strum(serialize = "decode_error")]
|
2019-03-14 14:50:59 +00:00
|
|
|
SSZDecodeError(ssz::DecodeError),
|
2019-07-09 05:44:23 +00:00
|
|
|
/// IO Error.
|
2020-05-17 11:16:48 +00:00
|
|
|
IoError(String),
|
2020-05-03 13:17:12 +00:00
|
|
|
/// The peer returned a valid response but the response indicated an error.
|
2020-06-05 03:07:59 +00:00
|
|
|
ErrorResponse(RPCResponseErrorCode, String),
|
2020-05-03 13:17:12 +00:00
|
|
|
/// Timed out waiting for a response.
|
2019-07-09 05:44:23 +00:00
|
|
|
StreamTimeout,
|
2020-05-03 13:17:12 +00:00
|
|
|
/// Peer does not support the protocol.
|
|
|
|
UnsupportedProtocol,
|
|
|
|
/// Stream ended unexpectedly.
|
|
|
|
IncompleteStream,
|
|
|
|
/// Peer sent invalid data.
|
|
|
|
InvalidData,
|
|
|
|
/// An error occurred due to internal reasons. Ex: timer failure.
|
|
|
|
InternalError(&'static str),
|
2020-06-18 01:53:08 +00:00
|
|
|
/// Negotiation with this peer timed out.
|
2020-05-03 13:17:12 +00:00
|
|
|
NegotiationTimeout,
|
2020-06-18 01:53:08 +00:00
|
|
|
/// Handler rejected this request.
|
|
|
|
HandlerRejected,
|
2021-07-13 00:48:33 +00:00
|
|
|
/// We have intentionally disconnected.
|
|
|
|
Disconnected,
|
2019-03-14 14:50:59 +00:00
|
|
|
}
|
|
|
|
|
2019-07-05 08:59:53 +00:00
|
|
|
impl From<ssz::DecodeError> for RPCError {
|
2019-03-14 14:50:59 +00:00
|
|
|
#[inline]
|
|
|
|
fn from(err: ssz::DecodeError) -> Self {
|
2019-07-05 08:59:53 +00:00
|
|
|
RPCError::SSZDecodeError(err)
|
2019-03-14 14:50:59 +00:00
|
|
|
}
|
|
|
|
}
|
2020-11-28 05:30:57 +00:00
|
|
|
impl From<tokio::time::error::Elapsed> for RPCError {
|
|
|
|
fn from(_: tokio::time::error::Elapsed) -> Self {
|
2020-05-17 11:16:48 +00:00
|
|
|
RPCError::StreamTimeout
|
|
|
|
}
|
|
|
|
}
|
2019-11-27 01:47:46 +00:00
|
|
|
|
2019-07-09 05:44:23 +00:00
|
|
|
impl From<io::Error> for RPCError {
|
|
|
|
fn from(err: io::Error) -> Self {
|
2020-05-17 11:16:48 +00:00
|
|
|
RPCError::IoError(err.to_string())
|
2019-07-09 05:44:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Error trait is required for `ProtocolsHandler`
|
|
|
|
impl std::fmt::Display for RPCError {
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
match *self {
|
|
|
|
RPCError::SSZDecodeError(ref err) => write!(f, "Error while decoding ssz: {:?}", err),
|
2020-05-03 13:17:12 +00:00
|
|
|
RPCError::InvalidData => write!(f, "Peer sent unexpected data"),
|
2019-07-09 05:44:23 +00:00
|
|
|
RPCError::IoError(ref err) => write!(f, "IO Error: {}", err),
|
2020-06-05 03:07:59 +00:00
|
|
|
RPCError::ErrorResponse(ref code, ref reason) => write!(
|
|
|
|
f,
|
|
|
|
"RPC response was an error: {} with reason: {}",
|
|
|
|
code, reason
|
|
|
|
),
|
2019-07-09 05:44:23 +00:00
|
|
|
RPCError::StreamTimeout => write!(f, "Stream Timeout"),
|
2020-05-03 13:17:12 +00:00
|
|
|
RPCError::UnsupportedProtocol => write!(f, "Peer does not support the protocol"),
|
|
|
|
RPCError::IncompleteStream => write!(f, "Stream ended unexpectedly"),
|
|
|
|
RPCError::InternalError(ref err) => write!(f, "Internal error: {}", err),
|
|
|
|
RPCError::NegotiationTimeout => write!(f, "Negotiation timeout"),
|
2020-06-18 01:53:08 +00:00
|
|
|
RPCError::HandlerRejected => write!(f, "Handler rejected the request"),
|
2021-07-13 00:48:33 +00:00
|
|
|
RPCError::Disconnected => write!(f, "Gracefully Disconnected"),
|
2019-07-09 05:44:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::error::Error for RPCError {
|
|
|
|
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
|
|
|
match *self {
|
2020-05-03 13:17:12 +00:00
|
|
|
// NOTE: this does have a source
|
2019-07-16 12:32:37 +00:00
|
|
|
RPCError::SSZDecodeError(_) => None,
|
2020-05-17 11:16:48 +00:00
|
|
|
RPCError::IoError(_) => None,
|
2019-07-09 05:44:23 +00:00
|
|
|
RPCError::StreamTimeout => None,
|
2020-05-03 13:17:12 +00:00
|
|
|
RPCError::UnsupportedProtocol => None,
|
|
|
|
RPCError::IncompleteStream => None,
|
|
|
|
RPCError::InvalidData => None,
|
|
|
|
RPCError::InternalError(_) => None,
|
2020-06-05 03:07:59 +00:00
|
|
|
RPCError::ErrorResponse(_, _) => None,
|
2020-05-03 13:17:12 +00:00
|
|
|
RPCError::NegotiationTimeout => None,
|
2020-06-18 01:53:08 +00:00
|
|
|
RPCError::HandlerRejected => None,
|
2021-07-13 00:48:33 +00:00
|
|
|
RPCError::Disconnected => None,
|
2019-07-09 05:44:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-02 21:50:44 +00:00
|
|
|
|
2021-06-17 00:40:16 +00:00
|
|
|
impl<TSpec: EthSpec> std::fmt::Display for InboundRequest<TSpec> {
|
2019-09-02 21:50:44 +00:00
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
match self {
|
2021-06-17 00:40:16 +00:00
|
|
|
InboundRequest::Status(status) => write!(f, "Status Message: {}", status),
|
|
|
|
InboundRequest::Goodbye(reason) => write!(f, "Goodbye: {}", reason),
|
|
|
|
InboundRequest::BlocksByRange(req) => write!(f, "Blocks by range: {}", req),
|
|
|
|
InboundRequest::BlocksByRoot(req) => write!(f, "Blocks by root: {:?}", req),
|
|
|
|
InboundRequest::Ping(ping) => write!(f, "Ping: {}", ping.data),
|
|
|
|
InboundRequest::MetaData(_) => write!(f, "MetaData request"),
|
2019-09-02 21:50:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-12-08 03:55:50 +00:00
|
|
|
|
|
|
|
impl RPCError {
|
|
|
|
/// Get a `str` representation of the error.
|
|
|
|
/// Used for metrics.
|
|
|
|
pub fn as_static_str(&self) -> &'static str {
|
|
|
|
match self {
|
2021-01-19 06:33:58 +00:00
|
|
|
RPCError::ErrorResponse(ref code, ..) => code.as_static(),
|
|
|
|
e => e.as_static(),
|
2020-12-08 03:55:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|