Revert "Remove eth/63 protocol version (#252)"

This reverts commit bbecb0415e.
This commit is contained in:
rakita 2021-03-22 12:22:21 +01:00
parent d030870220
commit 5eacff59e8
3 changed files with 17 additions and 9 deletions

View File

@ -32,7 +32,8 @@ use std::{
use chain::{
fork_filter::ForkFilterApi, ChainSyncApi, SyncState, SyncStatus as EthSyncStatus,
ETH_PROTOCOL_VERSION_64, PAR_PROTOCOL_VERSION_1, PAR_PROTOCOL_VERSION_2,
ETH_PROTOCOL_VERSION_63, ETH_PROTOCOL_VERSION_64, PAR_PROTOCOL_VERSION_1,
PAR_PROTOCOL_VERSION_2,
};
use ethcore::{
client::{BlockChainClient, ChainMessageType, ChainNotify, NewBlocks},
@ -563,7 +564,7 @@ impl ChainNotify for EthSync {
.register_protocol(
self.eth_handler.clone(),
self.subprotocol_name,
&[ETH_PROTOCOL_VERSION_64],
&[ETH_PROTOCOL_VERSION_63, ETH_PROTOCOL_VERSION_64],
)
.unwrap_or_else(|e| warn!("Error registering ethereum protocol: {:?}", e));
// register the warp sync subprotocol

View File

@ -42,8 +42,8 @@ use super::sync_packet::{
use super::{
BlockSet, ChainSync, ForkConfirmation, PacketProcessError, PeerAsking, PeerInfo, SyncRequester,
SyncState, ETH_PROTOCOL_VERSION_64, MAX_NEW_BLOCK_AGE, MAX_NEW_HASHES, PAR_PROTOCOL_VERSION_1,
PAR_PROTOCOL_VERSION_2,
SyncState, ETH_PROTOCOL_VERSION_63, ETH_PROTOCOL_VERSION_64, MAX_NEW_BLOCK_AGE, MAX_NEW_HASHES,
PAR_PROTOCOL_VERSION_1, PAR_PROTOCOL_VERSION_2,
};
/// The Chain Sync Handler: handles responses from peers
@ -669,7 +669,7 @@ impl SyncHandler {
.next()
.ok_or(rlp::DecoderError::RlpIsTooShort)?
.as_val()?;
let _eth_protocol_version = io.protocol_version(ETH_PROTOCOL, peer_id);
let eth_protocol_version = io.protocol_version(ETH_PROTOCOL, peer_id);
let warp_protocol_version = io.protocol_version(PAR_PROTOCOL, peer_id);
let warp_protocol = warp_protocol_version != 0;
@ -691,7 +691,7 @@ impl SyncHandler {
.next()
.ok_or(rlp::DecoderError::RlpIsTooShort)?
.as_val()?;
let forkid_validation_error = {
let forkid_validation_error = if eth_protocol_version >= ETH_PROTOCOL_VERSION_64.0 {
let fork_id = r_iter
.next()
.ok_or(rlp::DecoderError::RlpIsTooShort)?
@ -700,6 +700,8 @@ impl SyncHandler {
.is_compatible(io.chain(), fork_id)
.err()
.map(|e| (fork_id, e))
} else {
None
};
let snapshot_hash = if warp_protocol {
Some(
@ -788,7 +790,9 @@ impl SyncHandler {
|| (warp_protocol
&& (peer.protocol_version < PAR_PROTOCOL_VERSION_1.0
|| peer.protocol_version > PAR_PROTOCOL_VERSION_2.0))
|| (!warp_protocol && peer.protocol_version != ETH_PROTOCOL_VERSION_64.0)
|| (!warp_protocol
&& (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);
return Err(DownloaderImportError::Invalid);

View File

@ -158,6 +158,8 @@ impl From<DecoderError> for PacketProcessError {
/// 64 version of Ethereum protocol.
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.
pub const PAR_PROTOCOL_VERSION_1: (u8, u8) = (1, 0x15);
/// 2 version of OpenEthereum protocol (consensus messages added).
@ -1308,8 +1310,9 @@ impl ChainSync {
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.genesis_hash.0));
packet.append(&self.fork_filter.current(io.chain()));
if eth_protocol_version >= ETH_PROTOCOL_VERSION_64.0 {
packet.append(&self.fork_filter.current(io.chain()));
}
if warp_protocol {
let manifest = io.snapshot_service().manifest();
let block_number = manifest.as_ref().map_or(0, |m| m.block_number);