Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit 8f6911a

Browse files
niklasad1soc1c
authored andcommitted
2.4.4 more beta backports (#10554)
* fix(rpc-types): replace uint and hash with `ethereum_types v0.4` (#10217) * fix(rpc-types): remove uint and hash wrappers * fix(tests) * fix(cleanup) * grumbles(rpc-api): revert `verify_signature` * revert change of `U64` -> `u64` * fix(cleanup after bad merge) * chore(bump ethereum-types) * fix(bad merge) * feat(tests ethereum-types): add tests * chore(update `ethereum-types` to 0.4.2) * feat(tests for h256) * chore(rpc): remove `ethbloom` import Use re-export from `ethereum-types` instead * fix(bad merge): remove `DefaultAccount` type * doc(add TODO with issue link) * chore(bump ethereum-types) (#10396) Fixes a de-serialization bug in `ethereum-tyes` * fix(light eth_gasPrice): ask network if not in cache (#10535) * fix(light eth_gasPrice): ask N/W if not in cache * fix(bad rebase) * fix(light account response): update `tx_queue` (#10545) * fix(bump dependencies) (#10540) * cargo update -p log:0.4.5 * cargo update -p regex:1.0.5 * cargo update -p parking_lot * cargo update -p serde_derive * cargo update -p serde_json * cargo update -p serde * cargo update -p lazy_static * cargo update -p num_cpus * cargo update -p toml # Conflicts: # Cargo.lock * tx-pool: check transaction readiness before replacing (#10526) * Update to vanilla tx pool error * Prevent a non ready tx replacing a ready tx * Make tests compile * Test ready tx not replaced by future tx * Transaction indirection * Use StateReadiness to calculate Ready in `should_replace` * Test existing txs from same sender are used to compute Readiness * private-tx: Wire up ShouldReplace * Revert "Use StateReadiness to calculate Ready in `should_replace`" This reverts commit af9e69c * Make replace generic so it works with private-tx * Rename Replace and add missing docs * ShouldReplace no longer mutable * tx-pool: update to transaction-pool 2.0 from crates.io * tx-pool: generic error type alias * Exit early for first unmatching nonce * Fix private-tx test, use existing write lock * Use read lock for pool scoring * fix #10390 (#10391) * private-tx: replace error_chain (#10510) * Update to vanilla tx pool error * private-tx: remove error-chain, implement Error, derive Display * private-tx: replace ErrorKind and bail! * private-tx: add missing From impls and other compiler errors * private-tx: use original tx-pool error * Don't be silly cargo
1 parent d306106 commit 8f6911a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1367
-1353
lines changed

Cargo.lock

Lines changed: 325 additions & 312 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli-signer/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ name = "cli-signer"
77
version = "1.4.0"
88

99
[dependencies]
10+
ethereum-types = "0.4"
1011
futures = "0.1"
1112
rpassword = "1.0"
1213
parity-rpc = { path = "../rpc" }

cli-signer/rpc-client/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ name = "parity-rpc-client"
77
version = "1.4.0"
88

99
[dependencies]
10+
ethereum-types = "0.4"
1011
futures = "0.1"
1112
log = "0.4"
1213
serde = "1.0"

cli-signer/rpc-client/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
pub mod client;
1818
pub mod signer_client;
1919

20+
extern crate ethereum_types;
2021
extern crate futures;
2122
extern crate jsonrpc_core;
2223
extern crate jsonrpc_ws_server as ws;

cli-signer/rpc-client/src/signer_client.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
1616

1717
use client::{Rpc, RpcError};
18-
use rpc::signer::{ConfirmationRequest, TransactionModification, U256, TransactionCondition};
18+
use ethereum_types::U256;
19+
use rpc::signer::{ConfirmationRequest, TransactionModification, TransactionCondition};
1920
use serde;
2021
use serde_json::{Value as JsonValue, to_value};
2122
use std::path::PathBuf;

cli-signer/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
1616

17+
extern crate ethereum_types;
1718
extern crate futures;
1819
extern crate rpassword;
1920

2021
extern crate parity_rpc as rpc;
2122
extern crate parity_rpc_client as client;
2223

23-
use rpc::signer::{U256, ConfirmationRequest};
24+
use ethereum_types::U256;
25+
use rpc::signer::ConfirmationRequest;
2426
use client::signer_client::SignerRpc;
2527
use std::io::{Write, BufRead, BufReader, stdout, stdin};
2628
use std::path::PathBuf;

ethcore/private-tx/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
77

88
[dependencies]
99
common-types = { path = "../types" }
10-
error-chain = { version = "0.12", default-features = false }
10+
derive_more = "0.14.0"
1111
ethabi = "6.0"
1212
ethabi-contract = "6.0"
1313
ethabi-derive = "6.0"
@@ -36,7 +36,7 @@ serde = "1.0"
3636
serde_derive = "1.0"
3737
serde_json = "1.0"
3838
tiny-keccak = "1.4"
39-
transaction-pool = "1.13.2"
39+
transaction-pool = "2.0"
4040
url = "1"
4141

4242
[dev-dependencies]

ethcore/private-tx/src/encryptor.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crypto;
3131
use futures::Future;
3232
use fetch::{Fetch, Client as FetchClient, Method, BodyReader, Request};
3333
use bytes::{Bytes, ToPretty};
34-
use error::{Error, ErrorKind};
34+
use error::Error;
3535
use url::Url;
3636
use super::Signer;
3737
use super::key_server_keys::address_to_key;
@@ -111,11 +111,11 @@ impl SecretStoreEncryptor {
111111
return Ok(key);
112112
}
113113
let contract_address_signature = self.sign_contract_address(contract_address)?;
114-
let requester = self.config.key_server_account.ok_or_else(|| ErrorKind::KeyServerAccountNotSet)?;
114+
let requester = self.config.key_server_account.ok_or_else(|| Error::KeyServerAccountNotSet)?;
115115

116116
// key id in SS is H256 && we have H160 here => expand with assitional zeros
117117
let contract_address_extended: H256 = contract_address.into();
118-
let base_url = self.config.base_url.clone().ok_or_else(|| ErrorKind::KeyServerNotSet)?;
118+
let base_url = self.config.base_url.clone().ok_or_else(|| Error::KeyServerNotSet)?;
119119

120120
// prepare request url
121121
let url = format!("{}/{}/{}{}",
@@ -132,24 +132,24 @@ impl SecretStoreEncryptor {
132132
Method::GET
133133
};
134134

135-
let url = Url::from_str(&url).map_err(|e| ErrorKind::Encrypt(e.to_string()))?;
135+
let url = Url::from_str(&url).map_err(|e| Error::Encrypt(e.to_string()))?;
136136
let response = self.client.fetch(Request::new(url, method), Default::default()).wait()
137-
.map_err(|e| ErrorKind::Encrypt(e.to_string()))?;
137+
.map_err(|e| Error::Encrypt(e.to_string()))?;
138138

139139
if response.is_not_found() {
140-
bail!(ErrorKind::EncryptionKeyNotFound(*contract_address));
140+
return Err(Error::EncryptionKeyNotFound(*contract_address));
141141
}
142142

143143
if !response.is_success() {
144-
bail!(ErrorKind::Encrypt(response.status().canonical_reason().unwrap_or("unknown").into()));
144+
return Err(Error::Encrypt(response.status().canonical_reason().unwrap_or("unknown").into()));
145145
}
146146

147147
// read HTTP response
148148
let mut result = String::new();
149149
BodyReader::new(response).read_to_string(&mut result)?;
150150

151151
// response is JSON string (which is, in turn, hex-encoded, encrypted Public)
152-
let encrypted_bytes: ethjson::bytes::Bytes = result.trim_matches('\"').parse().map_err(|e| ErrorKind::Encrypt(e))?;
152+
let encrypted_bytes: ethjson::bytes::Bytes = result.trim_matches('\"').parse().map_err(|e| Error::Encrypt(e))?;
153153

154154
// decrypt Public
155155
let decrypted_bytes = self.signer.decrypt(requester, &crypto::DEFAULT_MAC, &encrypted_bytes)?;
@@ -189,7 +189,7 @@ impl SecretStoreEncryptor {
189189
}
190190

191191
fn sign_contract_address(&self, contract_address: &Address) -> Result<Signature, Error> {
192-
let key_server_account = self.config.key_server_account.ok_or_else(|| ErrorKind::KeyServerAccountNotSet)?;
192+
let key_server_account = self.config.key_server_account.ok_or_else(|| Error::KeyServerAccountNotSet)?;
193193
Ok(self.signer.sign(key_server_account, address_to_key(contract_address))?)
194194
}
195195
}
@@ -204,7 +204,7 @@ impl Encryptor for SecretStoreEncryptor {
204204
// retrieve the key, try to generate it if it doesn't exist yet
205205
let key = match self.retrieve_key("", false, contract_address) {
206206
Ok(key) => Ok(key),
207-
Err(Error(ErrorKind::EncryptionKeyNotFound(_), _)) => {
207+
Err(Error::EncryptionKeyNotFound(_)) => {
208208
trace!(target: "privatetx", "Key for account wasnt found in sstore. Creating. Address: {:?}", contract_address);
209209
self.retrieve_key(&format!("/{}", self.config.threshold), true, contract_address)
210210
}
@@ -215,7 +215,7 @@ impl Encryptor for SecretStoreEncryptor {
215215
let mut cypher = Vec::with_capacity(plain_data.len() + initialisation_vector.len());
216216
cypher.extend(repeat(0).take(plain_data.len()));
217217
crypto::aes::encrypt_128_ctr(&key, initialisation_vector, plain_data, &mut cypher)
218-
.map_err(|e| ErrorKind::Encrypt(e.to_string()))?;
218+
.map_err(|e| Error::Encrypt(e.to_string()))?;
219219
cypher.extend_from_slice(&initialisation_vector);
220220

221221
Ok(cypher)
@@ -230,7 +230,7 @@ impl Encryptor for SecretStoreEncryptor {
230230
// initialization vector takes INIT_VEC_LEN bytes
231231
let cypher_len = cypher.len();
232232
if cypher_len < INIT_VEC_LEN {
233-
bail!(ErrorKind::Decrypt("Invalid cypher".into()));
233+
return Err(Error::Decrypt("Invalid cypher".into()));
234234
}
235235

236236
// retrieve existing key
@@ -241,7 +241,7 @@ impl Encryptor for SecretStoreEncryptor {
241241
let mut plain_data = Vec::with_capacity(cypher_len - INIT_VEC_LEN);
242242
plain_data.extend(repeat(0).take(cypher_len - INIT_VEC_LEN));
243243
crypto::aes::decrypt_128_ctr(&key, &iv, cypher, &mut plain_data)
244-
.map_err(|e| ErrorKind::Decrypt(e.to_string()))?;
244+
.map_err(|e| Error::Decrypt(e.to_string()))?;
245245
Ok(plain_data)
246246
}
247247
}

0 commit comments

Comments
 (0)