From 25ce4b2ec841f1ca5e3572de196e1a05113ee52c Mon Sep 17 00:00:00 2001 From: POA <33550681+poa@users.noreply.github.com> Date: Tue, 19 Oct 2021 11:25:32 +0300 Subject: [PATCH] Enable GetNodeData for AuRa chains and bump to v3.3.0-rc.11 --- CHANGELOG.md | 5 ++++ Cargo.lock | 4 +-- Cargo.toml | 2 +- crates/ethcore/src/client/client.rs | 5 ++++ crates/ethcore/src/client/traits.rs | 3 ++ crates/ethcore/sync/src/chain/supplier.rs | 34 ++++++++++++++++++++--- crates/util/version/Cargo.toml | 2 +- 7 files changed, 47 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0662afa7..1c0853001 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## OpenEthereum v3.3.0-rc.11 + +Bug fixes: +* Ignore GetNodeData requests only for non-AuRa chains + ## OpenEthereum v3.3.0-rc.10 Enhancements: diff --git a/Cargo.lock b/Cargo.lock index 17841567c..d82803b5a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2932,7 +2932,7 @@ checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" [[package]] name = "openethereum" -version = "3.3.0-rc.10" +version = "3.3.0-rc.11" dependencies = [ "ansi_term 0.10.2", "atty", @@ -3282,7 +3282,7 @@ dependencies = [ [[package]] name = "parity-version" -version = "3.3.0-rc.10" +version = "3.3.0-rc.11" dependencies = [ "parity-bytes", "rlp", diff --git a/Cargo.toml b/Cargo.toml index d2747fc10..4a9e1a624 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ description = "OpenEthereum" name = "openethereum" # NOTE Make sure to update util/version/Cargo.toml as well -version = "3.3.0-rc.10" +version = "3.3.0-rc.11" license = "GPL-3.0" authors = [ "OpenEthereum developers", diff --git a/crates/ethcore/src/client/client.rs b/crates/ethcore/src/client/client.rs index e0af43403..8a4110a8a 100644 --- a/crates/ethcore/src/client/client.rs +++ b/crates/ethcore/src/client/client.rs @@ -2234,6 +2234,11 @@ impl BlockChainClient for Client { } } + fn is_aura(&self) -> bool { + let engine = self.engine.clone(); + engine.name() == "AuthorityRound" + } + fn is_processing_fork(&self) -> bool { let chain = self.chain.read(); self.importer diff --git a/crates/ethcore/src/client/traits.rs b/crates/ethcore/src/client/traits.rs index 6d778c0ae..d3f3abcb2 100644 --- a/crates/ethcore/src/client/traits.rs +++ b/crates/ethcore/src/client/traits.rs @@ -258,6 +258,9 @@ pub trait BlockChainClient: /// Get block total difficulty. fn block_total_difficulty(&self, id: BlockId) -> Option; + /// Is it AuRa engine? + fn is_aura(&self) -> bool; + /// Attempt to get address storage root at given block. /// May not fail on BlockId::Latest. fn storage_root(&self, address: &Address, id: BlockId) -> Option; diff --git a/crates/ethcore/sync/src/chain/supplier.rs b/crates/ethcore/sync/src/chain/supplier.rs index 0424b9aa9..a459365bb 100644 --- a/crates/ethcore/sync/src/chain/supplier.rs +++ b/crates/ethcore/sync/src/chain/supplier.rs @@ -351,10 +351,36 @@ impl SyncSupplier { } fn return_node_data(io: &dyn SyncIo, rlp: &Rlp, peer_id: PeerId) -> RlpResponseResult { - // GetNodeData requests are ignored since we don't have a correct - // implementation of the NodeData response, see issue #508 - debug!("Ignoring GetNodeData request"); - Ok(None) + if io.chain().is_aura() { + let count = cmp::min(rlp.item_count().unwrap_or(0), MAX_NODE_DATA_TO_SEND); + if count == 0 { + debug!(target: "sync", "Empty GetNodeData request, ignoring."); + return Ok(None); + } + + let mut data = Bytes::new(); + + let mut added = 0usize; + for i in 0..count { + if let Some(ref mut node_data) = io.chain().state_data(&rlp.val_at::(i)?) { + data.append(node_data); + added += 1; + if data.len() > PAYLOAD_SOFT_LIMIT { + break; + } + } + } + + let mut rlp = RlpStream::new_list(added); + rlp.append_raw(&data, added); + trace!(target: "sync", "{} -> GetNodeData: returned {} entries", peer_id, added); + Ok(Some((NodeDataPacket, rlp))) + } else { + // GetNodeData requests are ignored since we don't have a correct + // implementation of the NodeData response, see issue #508 + debug!("Ignoring GetNodeData request"); + Ok(None) + } } fn return_receipts(io: &dyn SyncIo, rlp: &Rlp, peer_id: PeerId) -> RlpResponseResult { diff --git a/crates/util/version/Cargo.toml b/crates/util/version/Cargo.toml index c813d71d9..8e024c6f1 100644 --- a/crates/util/version/Cargo.toml +++ b/crates/util/version/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "parity-version" # NOTE: this value is used for OpenEthereum version string (via env CARGO_PKG_VERSION) -version = "3.3.0-rc.10" +version = "3.3.0-rc.11" authors = ["Parity Technologies "] build = "build.rs"