From a39aaacb8a657e8880c37fe2dc10e1e457b22ef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?So=C4=8Dik?= <47772477+soc1c@users.noreply.github.com> Date: Fri, 22 Mar 2019 10:23:33 +0100 Subject: [PATCH] 2.3.8 stable backports (#10507) * version: bump stable * Add additional request tests (#10503) --- Cargo.lock | 12 ++-- Cargo.toml | 2 +- ethcore/light/src/types/request/batch.rs | 74 ++++++++++++++++++++++++ ethcore/light/src/types/request/mod.rs | 4 +- util/version/Cargo.toml | 2 +- 5 files changed, 84 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b2551b339..4a90b199a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2394,7 +2394,7 @@ dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "jni 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "panic_hook 0.1.0", - "parity-ethereum 2.3.7", + "parity-ethereum 2.3.8", "tokio 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-current-thread 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2412,7 +2412,7 @@ dependencies = [ [[package]] name = "parity-ethereum" -version = "2.3.7" +version = "2.3.8" dependencies = [ "ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2463,7 +2463,7 @@ dependencies = [ "parity-rpc 1.12.0", "parity-runtime 0.1.0", "parity-updater 1.12.0", - "parity-version 2.3.7", + "parity-version 2.3.8", "parity-whisper 0.1.0", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2615,7 +2615,7 @@ dependencies = [ "parity-crypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-runtime 0.1.0", "parity-updater 1.12.0", - "parity-version 2.3.7", + "parity-version 2.3.8", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2713,7 +2713,7 @@ dependencies = [ "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-hash-fetch 1.12.0", "parity-path 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-version 2.3.7", + "parity-version 2.3.8", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2723,7 +2723,7 @@ dependencies = [ [[package]] name = "parity-version" -version = "2.3.7" +version = "2.3.8" dependencies = [ "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 965308db6..f057c99d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ description = "Parity Ethereum client" name = "parity-ethereum" # NOTE Make sure to update util/version/Cargo.toml as well -version = "2.3.7" +version = "2.3.8" license = "GPL-3.0" authors = ["Parity Technologies "] diff --git a/ethcore/light/src/types/request/batch.rs b/ethcore/light/src/types/request/batch.rs index 6dc75c249..f99b49d2b 100644 --- a/ethcore/light/src/types/request/batch.rs +++ b/ethcore/light/src/types/request/batch.rs @@ -255,4 +255,78 @@ mod tests { hash: Field::BackReference(0, 0), })).unwrap(); } + + #[test] + fn batch_tx_index_backreference() { + let mut builder = Builder::default(); + builder.push(Request::HeaderProof(IncompleteHeaderProofRequest { + num: 100.into(), // header proof puts hash at output 0. + })).unwrap(); + builder.push(Request::TransactionIndex(IncompleteTransactionIndexRequest { + hash: Field::BackReference(0, 0), + })).unwrap(); + + let mut batch = builder.build(); + batch.requests[1].fill(|_req_idx, _out_idx| Ok(Output::Hash(42.into()))); + + assert!(batch.next_complete().is_some()); + batch.answered += 1; + assert!(batch.next_complete().is_some()); + } + + #[test] + #[should_panic] + fn batch_tx_index_backreference_wrong_output() { + let mut builder = Builder::default(); + builder.push(Request::HeaderProof(IncompleteHeaderProofRequest { + num: 100.into(), // header proof puts hash at output 0. + })).unwrap(); + builder.push(Request::TransactionIndex(IncompleteTransactionIndexRequest { + hash: Field::BackReference(0, 0), + })).unwrap(); + + let mut batch = builder.build(); + batch.requests[1].fill(|_req_idx, _out_idx| Ok(Output::Number(42))); + + batch.next_complete(); + batch.answered += 1; + batch.next_complete(); + } + + #[test] + fn batch_receipts_backreference() { + let mut builder = Builder::default(); + builder.push(Request::HeaderProof(IncompleteHeaderProofRequest { + num: 100.into(), // header proof puts hash at output 0. + })).unwrap(); + builder.push(Request::Receipts(IncompleteReceiptsRequest { + hash: Field::BackReference(0, 0), + })).unwrap(); + + let mut batch = builder.build(); + batch.requests[1].fill(|_req_idx, _out_idx| Ok(Output::Hash(42.into()))); + + assert!(batch.next_complete().is_some()); + batch.answered += 1; + assert!(batch.next_complete().is_some()); + } + + #[test] + #[should_panic] + fn batch_receipts_backreference_wrong_output() { + let mut builder = Builder::default(); + builder.push(Request::HeaderProof(IncompleteHeaderProofRequest { + num: 100.into(), // header proof puts hash at output 0. + })).unwrap(); + builder.push(Request::Receipts(IncompleteReceiptsRequest { + hash: Field::BackReference(0, 0), + })).unwrap(); + + let mut batch = builder.build(); + batch.requests[1].fill(|_req_idx, _out_idx| Ok(Output::Number(42))); + + batch.next_complete(); + batch.answered += 1; + batch.next_complete(); + } } diff --git a/ethcore/light/src/types/request/mod.rs b/ethcore/light/src/types/request/mod.rs index d43aa7263..cacfbcbe5 100644 --- a/ethcore/light/src/types/request/mod.rs +++ b/ethcore/light/src/types/request/mod.rs @@ -907,7 +907,7 @@ pub mod transaction_index { fn fill(&mut self, oracle: F) where F: Fn(usize, usize) -> Result { if let Field::BackReference(req, idx) = self.hash { self.hash = match oracle(req, idx) { - Ok(Output::Number(hash)) => Field::Scalar(hash.into()), + Ok(Output::Hash(hash)) => Field::Scalar(hash.into()), _ => Field::BackReference(req, idx), } } @@ -982,7 +982,7 @@ pub mod block_receipts { fn fill(&mut self, oracle: F) where F: Fn(usize, usize) -> Result { if let Field::BackReference(req, idx) = self.hash { self.hash = match oracle(req, idx) { - Ok(Output::Number(hash)) => Field::Scalar(hash.into()), + Ok(Output::Hash(hash)) => Field::Scalar(hash.into()), _ => Field::BackReference(req, idx), } } diff --git a/util/version/Cargo.toml b/util/version/Cargo.toml index d27c141b6..ab6234275 100644 --- a/util/version/Cargo.toml +++ b/util/version/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "parity-version" # NOTE: this value is used for Parity Ethereum version string (via env CARGO_PKG_VERSION) -version = "2.3.7" +version = "2.3.8" authors = ["Parity Technologies "] build = "build.rs"