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

Commit

Permalink
Merge branch 'master' into dp/chore/kvdb-no-default-column
Browse files Browse the repository at this point in the history
* master:
  Add Nat PMP method to P2P module (#11210)
  Add randomness contract support to AuthorityRound. (#10946)
  ethcore/res: activate ecip-1061 on kotti and mordor (#11338)
  • Loading branch information
dvdplm committed Dec 19, 2019
2 parents d496b03 + e14d68e commit ad0bf92
Show file tree
Hide file tree
Showing 80 changed files with 1,872 additions and 493 deletions.
534 changes: 283 additions & 251 deletions Cargo.lock

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ futures = "0.1"
journaldb = { path = "util/journaldb" }
jsonrpc-core = "14.0.3"
keccak-hash = "0.4.0"
kvdb = "0.1"
kvdb-rocksdb = "0.2.0"
kvdb = "0.2"
kvdb-rocksdb = "0.3.0"
log = "0.4"
migration-rocksdb = { path = "util/migration-rocksdb" }
node-filter = { path = "ethcore/node-filter" }
Expand All @@ -57,7 +57,7 @@ parity-path = "0.1"
parity-rpc = { path = "rpc" }
parity-runtime = { path = "util/runtime" }
parity-updater = { path = "updater" }
parity-util-mem = { version = "0.2.1", features = ["jemalloc-global"] }
parity-util-mem = { version = "0.3.0", features = ["jemalloc-global"] }
parity-version = { path = "util/version" }
parking_lot = "0.9"
regex = "1.0"
Expand Down Expand Up @@ -137,14 +137,14 @@ members = [
]

# todo[dvdplm] remove before merge
[patch.crates-io]
kvdb = { git = "https://github.com/paritytech/parity-common", rev = "83c9ccdaa7c598a8afb2fe0baa76f6270e2b4637" }
kvdb-rocksdb = { git = "https://github.com/paritytech/parity-common", rev = "83c9ccdaa7c598a8afb2fe0baa76f6270e2b4637" }
kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev = "83c9ccdaa7c598a8afb2fe0baa76f6270e2b4637" }
parity-util-mem = { git = "https://github.com/paritytech/parity-common", rev = "83c9ccdaa7c598a8afb2fe0baa76f6270e2b4637" }
ethereum-types = { git = "https://github.com/paritytech/parity-common", rev = "83c9ccdaa7c598a8afb2fe0baa76f6270e2b4637" }
primitive-types = { git = "https://github.com/paritytech/parity-common", rev = "83c9ccdaa7c598a8afb2fe0baa76f6270e2b4637" }
rlp = { git = "https://github.com/paritytech/parity-common", rev = "83c9ccdaa7c598a8afb2fe0baa76f6270e2b4637" }
ethbloom = { git = "https://github.com/paritytech/parity-common", rev = "83c9ccdaa7c598a8afb2fe0baa76f6270e2b4637" }
triehash = { git = "https://github.com/paritytech/parity-common", rev = "83c9ccdaa7c598a8afb2fe0baa76f6270e2b4637" }
fixed-hash = { git = "https://github.com/paritytech/parity-common", rev = "83c9ccdaa7c598a8afb2fe0baa76f6270e2b4637" }
#[patch.crates-io]
#kvdb = { git = "https://github.com/paritytech/parity-common", rev = "83c9ccdaa7c598a8afb2fe0baa76f6270e2b4637" }
#kvdb-rocksdb = { git = "https://github.com/paritytech/parity-common", rev = "83c9ccdaa7c598a8afb2fe0baa76f6270e2b4637" }
#kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev = "83c9ccdaa7c598a8afb2fe0baa76f6270e2b4637" }
#parity-util-mem = { git = "https://github.com/paritytech/parity-common", rev = "83c9ccdaa7c598a8afb2fe0baa76f6270e2b4637" }
#ethereum-types = { git = "https://github.com/paritytech/parity-common", rev = "83c9ccdaa7c598a8afb2fe0baa76f6270e2b4637" }
#primitive-types = { git = "https://github.com/paritytech/parity-common", rev = "83c9ccdaa7c598a8afb2fe0baa76f6270e2b4637" }
#rlp = { git = "https://github.com/paritytech/parity-common", rev = "83c9ccdaa7c598a8afb2fe0baa76f6270e2b4637" }
#ethbloom = { git = "https://github.com/paritytech/parity-common", rev = "83c9ccdaa7c598a8afb2fe0baa76f6270e2b4637" }
#triehash = { git = "https://github.com/paritytech/parity-common", rev = "83c9ccdaa7c598a8afb2fe0baa76f6270e2b4637" }
#fixed-hash = { git = "https://github.com/paritytech/parity-common", rev = "83c9ccdaa7c598a8afb2fe0baa76f6270e2b4637" }
13 changes: 6 additions & 7 deletions ethcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ hash-db = "0.15.0"
itertools = "0.5"
journaldb = { path = "../util/journaldb" }
keccak-hash = "0.4.0"
kvdb = "0.1"
kvdb-memorydb = { version = "0.1.2", optional = true }
kvdb-rocksdb = { version = "0.2.0", optional = true }
kvdb = "0.2"
kvdb-memorydb = { version = "0.2.0", optional = true }
kvdb-rocksdb = { version = "0.3.0", optional = true }
lazy_static = { version = "1.3", optional = true }
log = "0.4"
macros = { path = "../util/macros", optional = true }
Expand All @@ -42,7 +42,7 @@ memory-cache = { path = "../util/memory-cache" }
parity-bytes = "0.1"
parking_lot = "0.9"
pod = { path = "pod", optional = true }
trie-db = "0.16.0"
trie-db = "0.18.0"
parity-crypto = { version = "0.4.2", features = ["publickey"], optional = true }
patricia-trie-ethereum = { path = "../util/patricia-trie-ethereum" }
rand = "0.7"
Expand Down Expand Up @@ -73,14 +73,13 @@ blooms-db = { path = "../util/blooms-db" }
criterion = "0.3"
engine = { path = "./engine", features = ["test-helpers"] }
env_logger = "0.5"
ethash = { path = "../ethash" }
ethcore-accounts = { path = "../accounts" }
ethcore-builtin = { path = "./builtin" }
ethjson = { path = "../json", features = ["test-helpers"] }
parity-crypto = { version = "0.4.2", features = ["publickey"] }
fetch = { path = "../util/fetch" }
kvdb-memorydb = "0.1.2"
kvdb-rocksdb = "0.2.0"
kvdb-memorydb = "0.2.0"
kvdb-rocksdb = "0.3.0"
lazy_static = "1.3"
machine = { path = "./machine", features = ["test-helpers"] }
macros = { path = "../util/macros" }
Expand Down
2 changes: 1 addition & 1 deletion ethcore/account-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ ethereum-types = "0.8.0"
hash-db = "0.15.0"
keccak-hash = "0.4.0"
keccak-hasher = { path = "../../util/keccak-hasher" }
kvdb = "0.1"
kvdb = "0.2"
rlp = "0.4"
10 changes: 5 additions & 5 deletions ethcore/account-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl<'db> AsHashDB<KeccakHasher, DBValue> for AccountDB<'db> {
impl<'db> HashDB<KeccakHasher, DBValue> for AccountDB<'db> {
fn get(&self, key: &H256, prefix: Prefix) -> Option<DBValue> {
if key == &KECCAK_NULL_RLP {
return Some(DBValue::from_slice(&NULL_RLP));
return Some(NULL_RLP.to_vec());
}
self.db.get(&combine_key(&self.address_hash, key), prefix)
}
Expand Down Expand Up @@ -139,7 +139,7 @@ impl<'db> AccountDBMut<'db> {
impl<'db> HashDB<KeccakHasher, DBValue> for AccountDBMut<'db>{
fn get(&self, key: &H256, prefix: Prefix) -> Option<DBValue> {
if key == &KECCAK_NULL_RLP {
return Some(DBValue::from_slice(&NULL_RLP));
return Some(NULL_RLP.to_vec());
}
self.db.get(&combine_key(&self.address_hash, key), prefix)
}
Expand All @@ -157,7 +157,7 @@ impl<'db> HashDB<KeccakHasher, DBValue> for AccountDBMut<'db>{
}
let k = keccak(value);
let ak = combine_key(&self.address_hash, &k);
self.db.emplace(ak, prefix, DBValue::from_slice(value));
self.db.emplace(ak, prefix, value.to_vec());
k
}

Expand Down Expand Up @@ -193,7 +193,7 @@ impl<'db> AsHashDB<KeccakHasher, DBValue> for Wrapping<'db> {
impl<'db> HashDB<KeccakHasher, DBValue> for Wrapping<'db> {
fn get(&self, key: &H256, prefix: Prefix) -> Option<DBValue> {
if key == &KECCAK_NULL_RLP {
return Some(DBValue::from_slice(&NULL_RLP));
return Some(NULL_RLP.to_vec());
}
self.0.get(key, prefix)
}
Expand Down Expand Up @@ -227,7 +227,7 @@ impl<'db> AsHashDB<KeccakHasher, DBValue> for WrappingMut<'db> {
impl<'db> HashDB<KeccakHasher, DBValue> for WrappingMut<'db>{
fn get(&self, key: &H256, prefix: Prefix) -> Option<DBValue> {
if key == &KECCAK_NULL_RLP {
return Some(DBValue::from_slice(&NULL_RLP));
return Some(NULL_RLP.to_vec());
}
self.0.get(key, prefix)
}
Expand Down
8 changes: 4 additions & 4 deletions ethcore/account-state/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ hash-db = "0.15.0"
journaldb = { path = "../../util/journaldb" }
keccak-hash = "0.4.0"
keccak-hasher = { path = "../../util/keccak-hasher" }
kvdb = "0.1"
kvdb = "0.2"
log = "0.4"
lru-cache = "0.1.2"
memory-db = "0.15.0"
memory-db = "0.18.0"
parity-bytes = "0.1.0"
parity-util-mem = "0.2.1"
parity-util-mem = "0.3.0"
parking_lot = "0.9"
pod = { path = "../pod" }
rlp = "0.4.0"
serde = { version = "1.0", features = ["derive"] }
trace = { path = "../trace" }
trie-db = "0.16.0"
trie-db = "0.18.0"

[dev-dependencies]
account-db = { path = "../account-db" }
Expand Down
4 changes: 2 additions & 2 deletions ethcore/account-state/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ impl Account {
match db.get(&self.code_hash, hash_db::EMPTY_PREFIX) {
Some(x) => {
self.code_size = Some(x.len());
self.code_cache = Arc::new(x.into_vec());
self.code_cache = Arc::new(x);
Some(self.code_cache.clone())
},
_ => {
Expand Down Expand Up @@ -530,7 +530,7 @@ impl Account {
self.code_filth = Filth::Clean;
},
(true, false) => {
db.emplace(self.code_hash.clone(), hash_db::EMPTY_PREFIX, DBValue::from_slice(&*self.code_cache));
db.emplace(self.code_hash.clone(), hash_db::EMPTY_PREFIX, self.code_cache.to_vec());
self.code_size = Some(self.code_cache.len());
self.code_filth = Filth::Clean;
},
Expand Down
6 changes: 3 additions & 3 deletions ethcore/blockchain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ common-types = { path = "../types" }
ethcore-db = { path = "../db" }
ethereum-types = "0.8.0"
keccak-hash = "0.4.0"
parity-util-mem = "0.2.1"
parity-util-mem = "0.3.0"
itertools = "0.5"
kvdb = "0.1"
kvdb = "0.2"
log = "0.4"
parity-bytes = "0.1"
rand = "0.7"
Expand All @@ -32,4 +32,4 @@ env_logger = "0.5"
parity-crypto = { version = "0.4.2", features = ["publickey"] }
rustc-hex = "1.0"
tempdir = "0.3"
kvdb-memorydb = "0.1.2"
kvdb-memorydb = "0.2.0"
4 changes: 2 additions & 2 deletions ethcore/blockchain/src/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,8 @@ impl BlockChain {
let best_block_number = bc.best_block.read().header.number();
// Fetch first and best ancient block details
let raw_first = bc.db.key_value().get(db::COL_EXTRA, b"first")
.expect("Low level database error when fetching 'first' block. Some issue with disk?")
.map(|v| v.into_vec());
.expect("Low level database error when fetching 'first' block. Some issue with disk?");
// .map(|v| v.into_vec());
let mut best_ancient = bc.db.key_value().get(db::COL_EXTRA, b"ancient")
.expect("Low level database error when fetching 'best ancient' block. Some issue with disk?")
.map(|h| H256::from_slice(&h));
Expand Down
2 changes: 1 addition & 1 deletion ethcore/client-traits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ common-types = { path = "../types" }
ethcore-db = { path = "../db" }
ethcore-miner = { path = "../../miner" }
ethereum-types = "0.8.0"
kvdb = "0.1"
kvdb = "0.2"
registrar = { path = "../../util/registrar" }
stats = { path = "../../util/stats" }
trace = { path = "../trace" }
Expand Down
64 changes: 61 additions & 3 deletions ethcore/client-traits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use common_types::{
pruning_info::PruningInfo,
receipt::LocalizedReceipt,
trace_filter::Filter as TraceFilter,
transaction::{self, LocalizedTransaction, CallError, SignedTransaction, UnverifiedTransaction},
transaction::{self, Action, LocalizedTransaction, CallError, SignedTransaction, UnverifiedTransaction},
tree_route::TreeRoute,
verification::{VerificationQueueInfo, Unverified},
};
Expand Down Expand Up @@ -395,8 +395,66 @@ pub trait BlockChainClient:
/// Returns information about pruning/data availability.
fn pruning_info(&self) -> PruningInfo;

/// Schedule state-altering transaction to be executed on the next pending block.
fn transact_contract(&self, address: Address, data: Bytes) -> Result<(), transaction::Error>;
/// Returns a transaction signed with the key configured in the engine signer.
fn create_transaction(&self, tx_request: TransactionRequest) -> Result<SignedTransaction, transaction::Error>;

/// Schedule state-altering transaction to be executed on the next pending
/// block with the given gas and nonce parameters.
fn transact(&self, tx_request: TransactionRequest) -> Result<(), transaction::Error>;
}

/// The data required for a `Client` to create a transaction.
///
/// Gas limit, gas price, or nonce can be set explicitly, e.g. to create service
/// transactions with zero gas price, or sequences of transactions with consecutive nonces.
pub struct TransactionRequest {
pub action: Action,
pub data: Bytes,
pub gas: Option<U256>,
pub gas_price: Option<U256>,
pub nonce: Option<U256>,
}

impl TransactionRequest {
/// Creates a request to call a contract at `address` with the specified call data.
pub fn call(address: Address, data: Bytes) -> TransactionRequest {
TransactionRequest {
action: Action::Call(address),
data,
gas: None,
gas_price: None,
nonce: None,
}
}

/// Creates a request to create a new contract, with the specified bytecode.
pub fn create(data: Bytes) -> TransactionRequest {
TransactionRequest {
action: Action::Create,
data,
gas: None,
gas_price: None,
nonce: None,
}
}

/// Sets a gas limit. If this is not specified, a sensible default is used.
pub fn gas(mut self, gas: U256) -> TransactionRequest {
self.gas = Some(gas);
self
}

/// Sets a gas price. If this is not specified, a sensible default is used.
pub fn gas_price(mut self, gas_price: U256) -> TransactionRequest {
self.gas_price = Some(gas_price);
self
}

/// Sets a nonce. If this is not specified, the appropriate latest nonce for the author is used.
pub fn nonce(mut self, nonce: U256) -> TransactionRequest {
self.nonce = Some(nonce);
self
}
}

/// resets the blockchain
Expand Down
4 changes: 2 additions & 2 deletions ethcore/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ edition = "2018"
[dependencies]
common-types = { path = "../types" }
ethereum-types = "0.8.0"
kvdb = "0.1"
parity-util-mem = "0.2.1"
kvdb = "0.2"
parity-util-mem = "0.3.0"
parking_lot = "0.9"
rlp = "0.4.0"
rlp_derive = { path = "../../util/rlp-derive" }
10 changes: 9 additions & 1 deletion ethcore/engine/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use common_types::{
},
errors::{EthcoreError as Error, EngineError},
snapshot::Snapshotting,
transaction::{self, UnverifiedTransaction},
transaction::{self, SignedTransaction, UnverifiedTransaction},
};
use client_traits::EngineClient;

Expand Down Expand Up @@ -185,6 +185,14 @@ pub trait Engine: Sync + Send {
/// Allow mutating the header during seal generation. Currently only used by Clique.
fn on_seal_block(&self, _block: &mut ExecutedBlock) -> Result<(), Error> { Ok(()) }

/// Returns a list of transactions for a new block if we are the author.
///
/// This is called when the miner prepares a new block that this node will author and seal. It returns a list of
/// transactions that will be added to the block before any other transactions from the queue.
fn generate_engine_transactions(&self, _block: &ExecutedBlock) -> Result<Vec<SignedTransaction>, Error> {
Ok(Vec::new())
}

/// Returns the engine's current sealing state.
fn sealing_state(&self) -> SealingState { SealingState::External }

Expand Down
16 changes: 15 additions & 1 deletion ethcore/engine/src/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! A signer used by Engines which need to sign messages.
use ethereum_types::{H256, Address};
use parity_crypto::publickey::{Signature, KeyPair, Error};
use parity_crypto::publickey::{ecies, Public, Signature, KeyPair, Error};

/// Everything that an Engine needs to sign messages.
pub trait EngineSigner: Send + Sync {
Expand All @@ -26,6 +26,12 @@ pub trait EngineSigner: Send + Sync {

/// Signing address
fn address(&self) -> Address;

/// Decrypt a message that was encrypted to this signer's key.
fn decrypt(&self, auth_data: &[u8], cipher: &[u8]) -> Result<Vec<u8>, Error>;

/// The signer's public key, if available.
fn public(&self) -> Option<Public>;
}

/// Creates a new `EngineSigner` from given key pair.
Expand All @@ -40,7 +46,15 @@ impl EngineSigner for Signer {
parity_crypto::publickey::sign(self.0.secret(), &hash)
}

fn decrypt(&self, auth_data: &[u8], cipher: &[u8]) -> Result<Vec<u8>, Error> {
ecies::decrypt(self.0.secret(), auth_data, cipher)
}

fn address(&self) -> Address {
self.0.address()
}

fn public(&self) -> Option<Public> {
Some(*self.0.public())
}
}
13 changes: 12 additions & 1 deletion ethcore/engine/src/test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::sync::Arc;

use ethereum_types::{Address, H256};
use ethkey::Password;
use parity_crypto::publickey::{Signature, Error};
use parity_crypto::publickey::{Public, Signature, Error};
use log::warn;
use accounts::{self, AccountProvider, SignError};

Expand All @@ -44,7 +44,18 @@ impl EngineSigner for (Arc<AccountProvider>, Address, Password) {
}
}

fn decrypt(&self, auth_data: &[u8], cipher: &[u8]) -> Result<Vec<u8>, Error> {
self.0.decrypt(self.1, None, auth_data, cipher).map_err(|e| {
warn!("Unable to decrypt message: {:?}", e);
Error::InvalidMessage
})
}

fn address(&self) -> Address {
self.1
}

fn public(&self) -> Option<Public> {
self.0.account_public(self.1, &self.2).ok()
}
}
Loading

0 comments on commit ad0bf92

Please sign in to comment.