From 3192edbeca994e7c10bf5e17c447a46cd33f9379 Mon Sep 17 00:00:00 2001 From: Niklas Adofsson Date: Fri, 17 Aug 2018 11:57:44 +0200 Subject: [PATCH 1/4] =?UTF-8?q?Provide=20`default=5Fnonce`=20in=20tx`s=20w?= =?UTF-8?q?hen=20it=C2=B4s=20missing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When `nonce` is missing in a `EthTransaction` will cause it to fall in these cases provide `default_nonce` value instead! --- rpc/src/v1/helpers/light_fetch.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/rpc/src/v1/helpers/light_fetch.rs b/rpc/src/v1/helpers/light_fetch.rs index 14f08fe6c7a..7242e3bd629 100644 --- a/rpc/src/v1/helpers/light_fetch.rs +++ b/rpc/src/v1/helpers/light_fetch.rs @@ -47,7 +47,7 @@ use transaction::{Action, Transaction as EthTransaction, SignedTransaction, Loca use v1::helpers::{CallRequest as CallRequestHelper, errors, dispatch}; use v1::types::{BlockNumber, CallRequest, Log, Transaction}; -const NO_INVALID_BACK_REFS: &'static str = "Fails only on invalid back-references; back-references here known to be valid; qed"; +const NO_INVALID_BACK_REFS: &str = "Fails only on invalid back-references; back-references here known to be valid; qed"; /// Helper for fetching blockchain data either from the light client or the network /// as necessary. @@ -235,25 +235,25 @@ impl LightFetch { let action = req.to.map_or(Action::Create, Action::Call); let value = req.value.unwrap_or_else(U256::zero); let data = req.data.unwrap_or_default(); + let nonce = nonce.unwrap_or_default(); future::done(match (nonce, req.gas) { - (Some(n), Some(gas)) => Ok((true, EthTransaction { + (n, Some(gas)) => Ok((true, EthTransaction { nonce: n, - action: action, - gas: gas, - gas_price: gas_price, - value: value, - data: data, + action, + gas, + gas_price, + value, + data, })), - (Some(n), None) => Ok((false, EthTransaction { + (n, None) => Ok((false, EthTransaction { nonce: n, - action: action, + action, gas: START_GAS.into(), - gas_price: gas_price, - value: value, - data: data, + gas_price, + value, + data, })), - (None, _) => Err(errors::unknown_block()), }) }).join(header_fut).and_then(move |((gas_known, tx), hdr)| { // then request proved execution. From 949b9c85ca7a2f55027a3505a21da786bce5aaf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Kj=C3=A6rstad?= Date: Fri, 17 Aug 2018 12:19:15 +0200 Subject: [PATCH 2/4] Changed http:// to https:// on Yasm link (#9369) Changed http:// to https:// on Yasm link in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6c7378c5752..40c04dff727 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ We recommend installing Rust through [rustup](https://www.rustup.rs/). If you do Once you have rustup installed, then you need to install: * [Perl](https://www.perl.org) -* [Yasm](http://yasm.tortall.net) +* [Yasm](https://yasm.tortall.net) Make sure that these binaries are in your `PATH`. After that you should be able to build Parity-Ethereum from source. From 1e06c36d13abba83526981b9c9f856a16e95a1cc Mon Sep 17 00:00:00 2001 From: Niklas Adofsson Date: Fri, 17 Aug 2018 11:57:44 +0200 Subject: [PATCH 3/4] =?UTF-8?q?Provide=20`default=5Fnonce`=20in=20tx`s=20w?= =?UTF-8?q?hen=20it=C2=B4s=20missing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When `nonce` is missing in a `EthTransaction` will cause it to fall in these cases provide `default_nonce` value instead! --- rpc/src/v1/helpers/light_fetch.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/rpc/src/v1/helpers/light_fetch.rs b/rpc/src/v1/helpers/light_fetch.rs index 14f08fe6c7a..7242e3bd629 100644 --- a/rpc/src/v1/helpers/light_fetch.rs +++ b/rpc/src/v1/helpers/light_fetch.rs @@ -47,7 +47,7 @@ use transaction::{Action, Transaction as EthTransaction, SignedTransaction, Loca use v1::helpers::{CallRequest as CallRequestHelper, errors, dispatch}; use v1::types::{BlockNumber, CallRequest, Log, Transaction}; -const NO_INVALID_BACK_REFS: &'static str = "Fails only on invalid back-references; back-references here known to be valid; qed"; +const NO_INVALID_BACK_REFS: &str = "Fails only on invalid back-references; back-references here known to be valid; qed"; /// Helper for fetching blockchain data either from the light client or the network /// as necessary. @@ -235,25 +235,25 @@ impl LightFetch { let action = req.to.map_or(Action::Create, Action::Call); let value = req.value.unwrap_or_else(U256::zero); let data = req.data.unwrap_or_default(); + let nonce = nonce.unwrap_or_default(); future::done(match (nonce, req.gas) { - (Some(n), Some(gas)) => Ok((true, EthTransaction { + (n, Some(gas)) => Ok((true, EthTransaction { nonce: n, - action: action, - gas: gas, - gas_price: gas_price, - value: value, - data: data, + action, + gas, + gas_price, + value, + data, })), - (Some(n), None) => Ok((false, EthTransaction { + (n, None) => Ok((false, EthTransaction { nonce: n, - action: action, + action, gas: START_GAS.into(), - gas_price: gas_price, - value: value, - data: data, + gas_price, + value, + data, })), - (None, _) => Err(errors::unknown_block()), }) }).join(header_fut).and_then(move |((gas_known, tx), hdr)| { // then request proved execution. From 2fe54f4cb7aa435c38778c5216c14fa9a9bdc5c9 Mon Sep 17 00:00:00 2001 From: Niklas Adofsson Date: Fri, 17 Aug 2018 14:54:24 +0200 Subject: [PATCH 4/4] Address grumbles --- rpc/src/v1/helpers/light_fetch.rs | 33 ++++++++++--------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/rpc/src/v1/helpers/light_fetch.rs b/rpc/src/v1/helpers/light_fetch.rs index 7242e3bd629..51fb0a5f837 100644 --- a/rpc/src/v1/helpers/light_fetch.rs +++ b/rpc/src/v1/helpers/light_fetch.rs @@ -207,7 +207,7 @@ impl LightFetch { } }; - let from = req.from.unwrap_or(Address::zero()); + let from = req.from.unwrap_or_else(|| Address::zero()); let nonce_fut = match req.nonce { Some(nonce) => Either::A(future::ok(Some(nonce))), None => Either::B(self.account(from, id).map(|acc| acc.map(|a| a.nonce))), @@ -232,29 +232,16 @@ impl LightFetch { // fetch missing transaction fields from the network. Box::new(nonce_fut.join(gas_price_fut).and_then(move |(nonce, gas_price)| { - let action = req.to.map_or(Action::Create, Action::Call); - let value = req.value.unwrap_or_else(U256::zero); - let data = req.data.unwrap_or_default(); - let nonce = nonce.unwrap_or_default(); - - future::done(match (nonce, req.gas) { - (n, Some(gas)) => Ok((true, EthTransaction { - nonce: n, - action, - gas, + future::done( + Ok((req.gas.is_some(), EthTransaction { + nonce: nonce.unwrap_or_default(), + action: req.to.map_or(Action::Create, Action::Call), + gas: req.gas.unwrap_or_else(|| START_GAS.into()), gas_price, - value, - data, - })), - (n, None) => Ok((false, EthTransaction { - nonce: n, - action, - gas: START_GAS.into(), - gas_price, - value, - data, - })), - }) + value: req.value.unwrap_or_else(U256::zero), + data: req.data.unwrap_or_default(), + })) + ) }).join(header_fut).and_then(move |((gas_known, tx), hdr)| { // then request proved execution. // TODO: get last-hashes from network.