parent
6d81fce451
commit
bbecb0415e
@ -31,8 +31,7 @@ use std::{
|
|||||||
|
|
||||||
use chain::{
|
use chain::{
|
||||||
fork_filter::ForkFilterApi, ChainSyncApi, SyncState, SyncStatus as EthSyncStatus,
|
fork_filter::ForkFilterApi, ChainSyncApi, SyncState, SyncStatus as EthSyncStatus,
|
||||||
ETH_PROTOCOL_VERSION_63, ETH_PROTOCOL_VERSION_64, PAR_PROTOCOL_VERSION_1,
|
ETH_PROTOCOL_VERSION_64, PAR_PROTOCOL_VERSION_1, PAR_PROTOCOL_VERSION_2,
|
||||||
PAR_PROTOCOL_VERSION_2,
|
|
||||||
};
|
};
|
||||||
use ethcore::{
|
use ethcore::{
|
||||||
client::{BlockChainClient, ChainMessageType, ChainNotify, NewBlocks},
|
client::{BlockChainClient, ChainMessageType, ChainNotify, NewBlocks},
|
||||||
@ -576,7 +575,7 @@ impl ChainNotify for EthSync {
|
|||||||
.register_protocol(
|
.register_protocol(
|
||||||
self.eth_handler.clone(),
|
self.eth_handler.clone(),
|
||||||
self.subprotocol_name,
|
self.subprotocol_name,
|
||||||
&[ETH_PROTOCOL_VERSION_63, ETH_PROTOCOL_VERSION_64],
|
&[ETH_PROTOCOL_VERSION_64],
|
||||||
)
|
)
|
||||||
.unwrap_or_else(|e| warn!("Error registering ethereum protocol: {:?}", e));
|
.unwrap_or_else(|e| warn!("Error registering ethereum protocol: {:?}", e));
|
||||||
// register the warp sync subprotocol
|
// register the warp sync subprotocol
|
||||||
|
@ -42,8 +42,8 @@ use super::sync_packet::{
|
|||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
BlockSet, ChainSync, ForkConfirmation, PacketProcessError, PeerAsking, PeerInfo, SyncRequester,
|
BlockSet, ChainSync, ForkConfirmation, PacketProcessError, PeerAsking, PeerInfo, SyncRequester,
|
||||||
SyncState, ETH_PROTOCOL_VERSION_63, ETH_PROTOCOL_VERSION_64, MAX_NEW_BLOCK_AGE, MAX_NEW_HASHES,
|
SyncState, ETH_PROTOCOL_VERSION_64, MAX_NEW_BLOCK_AGE, MAX_NEW_HASHES, PAR_PROTOCOL_VERSION_1,
|
||||||
PAR_PROTOCOL_VERSION_1, PAR_PROTOCOL_VERSION_2,
|
PAR_PROTOCOL_VERSION_2,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The Chain Sync Handler: handles responses from peers
|
/// The Chain Sync Handler: handles responses from peers
|
||||||
@ -669,7 +669,7 @@ impl SyncHandler {
|
|||||||
.next()
|
.next()
|
||||||
.ok_or(rlp::DecoderError::RlpIsTooShort)?
|
.ok_or(rlp::DecoderError::RlpIsTooShort)?
|
||||||
.as_val()?;
|
.as_val()?;
|
||||||
let eth_protocol_version = io.protocol_version(Ð_PROTOCOL, peer_id);
|
let _eth_protocol_version = io.protocol_version(Ð_PROTOCOL, peer_id);
|
||||||
let warp_protocol_version = io.protocol_version(&PAR_PROTOCOL, peer_id);
|
let warp_protocol_version = io.protocol_version(&PAR_PROTOCOL, peer_id);
|
||||||
let warp_protocol = warp_protocol_version != 0;
|
let warp_protocol = warp_protocol_version != 0;
|
||||||
|
|
||||||
@ -692,16 +692,12 @@ impl SyncHandler {
|
|||||||
.ok_or(rlp::DecoderError::RlpIsTooShort)?
|
.ok_or(rlp::DecoderError::RlpIsTooShort)?
|
||||||
.as_val()?;
|
.as_val()?;
|
||||||
let forkid_validation_error = {
|
let forkid_validation_error = {
|
||||||
if eth_protocol_version >= ETH_PROTOCOL_VERSION_64.0 {
|
let fork_id = rlp04::Rlp::new(r.as_raw()).val_at(5)?;
|
||||||
let fork_id = rlp04::Rlp::new(r.as_raw()).val_at(5)?;
|
r_iter.next().ok_or(rlp::DecoderError::RlpIsTooShort)?;
|
||||||
r_iter.next().ok_or(rlp::DecoderError::RlpIsTooShort)?;
|
sync.fork_filter
|
||||||
sync.fork_filter
|
.is_compatible(io.chain(), fork_id)
|
||||||
.is_compatible(io.chain(), fork_id)
|
.err()
|
||||||
.err()
|
.map(|e| (fork_id, e))
|
||||||
.map(|e| (fork_id, e))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
let snapshot_hash = if warp_protocol {
|
let snapshot_hash = if warp_protocol {
|
||||||
Some(
|
Some(
|
||||||
@ -790,9 +786,7 @@ impl SyncHandler {
|
|||||||
|| (warp_protocol
|
|| (warp_protocol
|
||||||
&& (peer.protocol_version < PAR_PROTOCOL_VERSION_1.0
|
&& (peer.protocol_version < PAR_PROTOCOL_VERSION_1.0
|
||||||
|| peer.protocol_version > PAR_PROTOCOL_VERSION_2.0))
|
|| peer.protocol_version > PAR_PROTOCOL_VERSION_2.0))
|
||||||
|| (!warp_protocol
|
|| (!warp_protocol && peer.protocol_version != ETH_PROTOCOL_VERSION_64.0)
|
||||||
&& (peer.protocol_version < ETH_PROTOCOL_VERSION_63.0
|
|
||||||
|| peer.protocol_version > ETH_PROTOCOL_VERSION_64.0))
|
|
||||||
{
|
{
|
||||||
trace!(target: "sync", "Peer {} unsupported eth protocol ({})", peer_id, peer.protocol_version);
|
trace!(target: "sync", "Peer {} unsupported eth protocol ({})", peer_id, peer.protocol_version);
|
||||||
return Err(DownloaderImportError::Invalid);
|
return Err(DownloaderImportError::Invalid);
|
||||||
|
@ -155,8 +155,6 @@ impl From<DecoderError> for PacketProcessError {
|
|||||||
|
|
||||||
/// 64 version of Ethereum protocol.
|
/// 64 version of Ethereum protocol.
|
||||||
pub const ETH_PROTOCOL_VERSION_64: (u8, u8) = (64, 0x11);
|
pub const ETH_PROTOCOL_VERSION_64: (u8, u8) = (64, 0x11);
|
||||||
/// 63 version of Ethereum protocol.
|
|
||||||
pub const ETH_PROTOCOL_VERSION_63: (u8, u8) = (63, 0x11);
|
|
||||||
/// 1 version of OpenEthereum protocol and the packet count.
|
/// 1 version of OpenEthereum protocol and the packet count.
|
||||||
pub const PAR_PROTOCOL_VERSION_1: (u8, u8) = (1, 0x15);
|
pub const PAR_PROTOCOL_VERSION_1: (u8, u8) = (1, 0x15);
|
||||||
/// 2 version of OpenEthereum protocol (consensus messages added).
|
/// 2 version of OpenEthereum protocol (consensus messages added).
|
||||||
@ -1292,9 +1290,8 @@ impl ChainSync {
|
|||||||
packet.append(&primitive_types07::U256(chain.total_difficulty.0));
|
packet.append(&primitive_types07::U256(chain.total_difficulty.0));
|
||||||
packet.append(&primitive_types07::H256(chain.best_block_hash.0));
|
packet.append(&primitive_types07::H256(chain.best_block_hash.0));
|
||||||
packet.append(&primitive_types07::H256(chain.genesis_hash.0));
|
packet.append(&primitive_types07::H256(chain.genesis_hash.0));
|
||||||
if eth_protocol_version >= ETH_PROTOCOL_VERSION_64.0 {
|
packet.append(&self.fork_filter.current(io.chain()));
|
||||||
packet.append(&self.fork_filter.current(io.chain()));
|
|
||||||
}
|
|
||||||
if warp_protocol {
|
if warp_protocol {
|
||||||
let manifest = io.snapshot_service().manifest();
|
let manifest = io.snapshot_service().manifest();
|
||||||
let block_number = manifest.as_ref().map_or(0, |m| m.block_number);
|
let block_number = manifest.as_ref().map_or(0, |m| m.block_number);
|
||||||
|
Loading…
Reference in New Issue
Block a user