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)
This commit is contained in:
@@ -86,7 +86,7 @@ use jsonrpc_core::{BoxFuture, Result, Error};
|
||||
use jsonrpc_core::futures::{future, Future, IntoFuture};
|
||||
use v1::helpers::{TransactionRequest, FilledTransactionRequest, ConfirmationPayload};
|
||||
use v1::types::{
|
||||
H520 as RpcH520, Bytes as RpcBytes,
|
||||
Bytes as RpcBytes,
|
||||
RichRawTransaction as RpcRichRawTransaction,
|
||||
ConfirmationPayload as RpcConfirmationPayload,
|
||||
ConfirmationResponse,
|
||||
@@ -309,7 +309,6 @@ pub fn execute<D: Dispatcher + 'static>(
|
||||
let res = signer.sign_message(address, pass, SignMessage::Data(data))
|
||||
.map(|result| result
|
||||
.map(|s| H520(s.into_electrum()))
|
||||
.map(RpcH520::from)
|
||||
.map(ConfirmationResponse::Signature)
|
||||
);
|
||||
|
||||
@@ -319,7 +318,6 @@ pub fn execute<D: Dispatcher + 'static>(
|
||||
let res = signer.sign_message(address, pass, SignMessage::Hash(data))
|
||||
.map(|result| result
|
||||
.map(|rsv| H520(rsv.into_electrum()))
|
||||
.map(RpcH520::from)
|
||||
.map(ConfirmationResponse::Signature)
|
||||
);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use ethereum_types::U256;
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use super::oneshot;
|
||||
|
||||
@@ -16,12 +16,13 @@
|
||||
|
||||
use std::collections::BTreeSet;
|
||||
use rand::{Rng, OsRng};
|
||||
use ethereum_types::{H256, H512};
|
||||
use ethkey::{self, Public, Secret, Random, Generator, math};
|
||||
use crypto;
|
||||
use bytes::Bytes;
|
||||
use jsonrpc_core::Error;
|
||||
use v1::helpers::errors;
|
||||
use v1::types::{H256, H512, EncryptedDocumentKey};
|
||||
use v1::types::EncryptedDocumentKey;
|
||||
use tiny_keccak::Keccak;
|
||||
|
||||
/// Initialization vector length.
|
||||
|
||||
@@ -15,8 +15,9 @@
|
||||
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use ethkey::{recover, public_to_address, Signature};
|
||||
use ethereum_types::{H256, U64};
|
||||
use jsonrpc_core::Result;
|
||||
use v1::types::{Bytes, RecoveredAccount, H256, U64};
|
||||
use v1::types::{Bytes, RecoveredAccount};
|
||||
use v1::helpers::errors;
|
||||
use v1::helpers::dispatch::eth_data_hash;
|
||||
use hash::keccak;
|
||||
@@ -35,7 +36,7 @@ pub fn verify_signature(
|
||||
} else {
|
||||
keccak(message.0)
|
||||
};
|
||||
let v: u64 = v.into();
|
||||
let v = v.as_u64();
|
||||
let is_valid_for_current_chain = match (chain_id, v) {
|
||||
(None, v) if v == 0 || v == 1 => true,
|
||||
(Some(chain_id), v) if v >= 35 => (v - 35) / 2 == chain_id,
|
||||
@@ -54,7 +55,7 @@ pub fn verify_signature(
|
||||
mod tests {
|
||||
use super::*;
|
||||
use ethkey::Generator;
|
||||
use v1::types::H160;
|
||||
use ethereum_types::{H160, U64};
|
||||
|
||||
pub fn add_chain_replay_protection(v: u64, chain_id: Option<u64>) -> u64 {
|
||||
v + if let Some(n) = chain_id { 35 + n * 2 } else { 0 }
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
use std::{ops, str};
|
||||
use std::collections::HashMap;
|
||||
use jsonrpc_pubsub::{typed::{Subscriber, Sink}, SubscriptionId};
|
||||
use ethereum_types::H64;
|
||||
use rand::{Rng, StdRng};
|
||||
use v1::types::H64;
|
||||
|
||||
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
|
||||
pub struct Id(H64);
|
||||
@@ -36,8 +36,9 @@ impl str::FromStr for Id {
|
||||
}
|
||||
}
|
||||
impl Id {
|
||||
// TODO: replace `format!` see [#10412](https://github.com/paritytech/parity-ethereum/issues/10412)
|
||||
pub fn as_string(&self) -> String {
|
||||
format!("0x{:?}", self.0)
|
||||
format!("{:?}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,17 +20,13 @@ use std::sync::Arc;
|
||||
|
||||
use rlp;
|
||||
use ethcore::miner::{BlockChainClient, MinerService};
|
||||
use ethereum_types::{H64 as EthcoreH64, H256 as EthcoreH256};
|
||||
use ethereum_types::{H64, H256};
|
||||
use jsonrpc_core::Error;
|
||||
use v1::types::{H64, H256};
|
||||
use v1::helpers::errors;
|
||||
|
||||
// Submit a POW work and return the block's hash
|
||||
pub fn submit_work_detail<C: BlockChainClient, M: MinerService>(client: &Arc<C>, miner: &Arc<M>, nonce: H64, pow_hash: H256, mix_hash: H256) -> Result<H256, Error> {
|
||||
// TODO [ToDr] Should disallow submissions in case of PoA?
|
||||
let nonce: EthcoreH64 = nonce.into();
|
||||
let pow_hash: EthcoreH256 = pow_hash.into();
|
||||
let mix_hash: EthcoreH256 = mix_hash.into();
|
||||
trace!(target: "miner", "submit_work_detail: Decoded: nonce={}, pow_hash={}, mix_hash={}", nonce, pow_hash, mix_hash);
|
||||
let seal = vec![rlp::encode(&mix_hash), rlp::encode(&nonce)];
|
||||
let import = miner.submit_seal(pow_hash, seal)
|
||||
|
||||
Reference in New Issue
Block a user