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

Commit

Permalink
Backporting to beta (#3525)
Browse files Browse the repository at this point in the history
* v1.4.4

* Fixing tests, fixing refreshing precompiled (#3483)

* Fixing tests, fixing refreshing precompiled

* Commit only js and Cargo.lock

* Moving commands to the right place

* Adding js content as well

* Wallet names shouldn't include address.

(Actually wallet files shouldn't contain it either, but we'll
leave that for a later PR).

* sudo -c Is not supported on Mac

* Add trace_{call, rawTransaction, replayTransaction}

* Remove dangling only

* check for sanity

* Better Erros Snackbar in UI #3473

* Sync bandwidth optimization

* Updated sync algo desription

* Check transaction signature when adding to the queue

* Limit sync reorg to 20 blocks (#3519)

* Limit sync reorg

* Fixed tests

* updated the european warp bootnode addresses (#3528)

* Fix dapp account selection (#3399)

* Fix GHH accounts (filter non accounts)

* SignatureReg handle undefined ABI names gracefully

* SignatureReg fix accounts (filter non accounts)

* TokenReg fix accounts (filter non accounts)

* Registry fix accounts (filter non accounts)

* Remove addresses, display non-refundable warning (#3403)

* Use Contract owner for unregistering Token #3440

* Make tokenreg dapp fast again (#3474)

* Using proper TokenReg Instance in TokenReg dApp #3371

* remove unnecessary logs in tokereg dapp

* Improved Redux managment in TokeReg dApp #3371

* Fixfing linting
  • Loading branch information
arkpar committed Nov 18, 2016
1 parent a1a03a6 commit 3e0d033
Show file tree
Hide file tree
Showing 52 changed files with 668 additions and 346 deletions.
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
description = "Ethcore client."
name = "parity"
version = "1.4.3"
version = "1.4.4"
license = "GPL-3.0"
authors = ["Ethcore <admin@ethcore.io>"]
build = "build.rs"
Expand Down
4 changes: 2 additions & 2 deletions ethcore/res/ethereum/frontier.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@
"enode://89d5dc2a81e574c19d0465f497c1af96732d1b61a41de89c2a37f35707689ac416529fae1038809852b235c2d30fd325abdc57c122feeefbeaaf802cc7e9580d@45.55.33.62:30303",
"enode://605e04a43b1156966b3a3b66b980c87b7f18522f7f712035f84576016be909a2798a438b2b17b1a8c58db314d88539a77419ca4be36148c086900fba487c9d39@188.166.255.12:30303",
"enode://016b20125f447a3b203a3cae953b2ede8ffe51290c071e7599294be84317635730c397b8ff74404d6be412d539ee5bb5c3c700618723d3b53958c92bd33eaa82@159.203.210.80:30303",
"enode://01f76fa0561eca2b9a7e224378dd854278735f1449793c46ad0c4e79e8775d080c21dcc455be391e90a98153c3b05dcc8935c8440de7b56fe6d67251e33f4e3c@10.6.6.117:30303",
"enode://fe11ef89fc5ac9da358fc160857855f25bbf9e332c79b9ca7089330c02b728b2349988c6062f10982041702110745e203d26975a6b34bcc97144f9fe439034e8@10.1.72.117:30303"
"enode://01f76fa0561eca2b9a7e224378dd854278735f1449793c46ad0c4e79e8775d080c21dcc455be391e90a98153c3b05dcc8935c8440de7b56fe6d67251e33f4e3c@51.15.42.252:30303",
"enode://8d91c8137890d29110b9463882f17ae4e279cd2c90cf56573187ed1c8546fca5f590a9f05e9f108eb1bd91767ed01ede4daad9e001b61727885eaa246ddb39c2@163.172.171.38:30303"
],
"accounts": {
"0000000000000000000000000000000000000001": { "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } },
Expand Down
10 changes: 10 additions & 0 deletions ethcore/src/miner/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use util::*;
use util::using_queue::{UsingQueue, GetAction};
use account_provider::AccountProvider;
use views::{BlockView, HeaderView};
use header::Header;
use state::{State, CleanupMode};
use client::{MiningBlockChainClient, Executive, Executed, EnvInfo, TransactOptions, BlockID, CallAnalytics};
use executive::contract_address;
Expand Down Expand Up @@ -564,7 +565,16 @@ impl Miner {

let schedule = chain.latest_schedule();
let gas_required = |tx: &SignedTransaction| tx.gas_required(&schedule).into();
let best_block_header: Header = ::rlp::decode(&chain.best_block_header());
transactions.into_iter()
.filter(|tx| match self.engine.verify_transaction_basic(tx, &best_block_header) {
Ok(()) => true,
Err(e) => {
debug!(target: "miner", "Rejected tx {:?} with invalid signature: {:?}", tx.hash(), e);
false
}
}
)
.map(|tx| match origin {
TransactionOrigin::Local | TransactionOrigin::RetractedBlock => {
transaction_queue.add(tx, origin, &fetch_account, &gas_required)
Expand Down
43 changes: 40 additions & 3 deletions ethcrypto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,43 @@ pub const KEY_LENGTH: usize = 32;
pub const KEY_ITERATIONS: usize = 10240;
pub const KEY_LENGTH_AES: usize = KEY_LENGTH / 2;

#[derive(PartialEq, Debug)]
pub enum ScryptError {
// log(N) < r / 16
InvalidN,
// p <= (2^31-1 * 32)/(128 * r)
InvalidP,
}

impl fmt::Display for ScryptError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
let s = match *self {
ScryptError::InvalidN => "Invalid N argument of the scrypt encryption" ,
ScryptError::InvalidP => "Invalid p argument of the scrypt encryption",
};

write!(f, "{}", s)
}
}

#[derive(PartialEq, Debug)]
pub enum Error {
Secp(SecpError),
Scrypt(ScryptError),
InvalidMessage,
}

impl From<ScryptError> for Error {
fn from(err: ScryptError) -> Self {
Error::Scrypt(err)
}
}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
let s = match *self {
Error::Secp(ref err) => err.to_string(),
Error::Scrypt(ref err) => err.to_string(),
Error::InvalidMessage => "Invalid message".into(),
};

Expand Down Expand Up @@ -80,13 +107,23 @@ pub fn derive_key_iterations(password: &str, salt: &[u8; 32], c: u32) -> (Vec<u8
(derived_right_bits.to_vec(), derived_left_bits.to_vec())
}

pub fn derive_key_scrypt(password: &str, salt: &[u8; 32], n: u32, p: u32, r: u32) -> (Vec<u8>, Vec<u8>) {
pub fn derive_key_scrypt(password: &str, salt: &[u8; 32], n: u32, p: u32, r: u32) -> Result<(Vec<u8>, Vec<u8>), Error> {
// sanity checks
let log_n = (32 - n.leading_zeros() - 1) as u8;
if log_n as u32 >= r * 16 {
return Err(Error::Scrypt(ScryptError::InvalidN));
}

if p as u64 > ((u32::max_value() as u64 - 1) * 32)/(128 * (r as u64)) {
return Err(Error::Scrypt(ScryptError::InvalidP));
}

let mut derived_key = vec![0u8; KEY_LENGTH];
let scrypt_params = ScryptParams::new(n.trailing_zeros() as u8, r, p);
let scrypt_params = ScryptParams::new(log_n, r, p);
scrypt(password.as_bytes(), salt, &scrypt_params, &mut derived_key);
let derived_right_bits = &derived_key[0..KEY_LENGTH_AES];
let derived_left_bits = &derived_key[KEY_LENGTH_AES..KEY_LENGTH];
(derived_right_bits.to_vec(), derived_left_bits.to_vec())
Ok((derived_right_bits.to_vec(), derived_left_bits.to_vec()))
}

pub fn derive_mac(derived_left_bits: &[u8], cipher_text: &[u8]) -> Vec<u8> {
Expand Down
2 changes: 1 addition & 1 deletion ethstore/src/account/safe_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl Crypto {

let (derived_left_bits, derived_right_bits) = match self.kdf {
Kdf::Pbkdf2(ref params) => crypto::derive_key_iterations(password, &params.salt, params.c),
Kdf::Scrypt(ref params) => crypto::derive_key_scrypt(password, &params.salt, params.n, params.p, params.r),
Kdf::Scrypt(ref params) => try!(crypto::derive_key_scrypt(password, &params.salt, params.n, params.p, params.r)),
};

let mac = crypto::derive_mac(&derived_right_bits, &self.ciphertext).keccak256();
Expand Down
3 changes: 2 additions & 1 deletion ethstore/src/dir/disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use std::collections::HashMap;
use time;
use ethkey::Address;
use {json, SafeAccount, Error};
use json::UUID;
use super::KeyDirectory;

const IGNORED_FILES: &'static [&'static str] = &["thumbs.db", "address_book.json"];
Expand Down Expand Up @@ -112,7 +113,7 @@ impl KeyDirectory for DiskDirectory {
// build file path
let filename = account.filename.as_ref().cloned().unwrap_or_else(|| {
let timestamp = time::strftime("%Y-%m-%dT%H-%M-%S", &time::now_utc()).expect("Time-format string is valid.");
format!("UTC--{}Z--{:?}", timestamp, account.address)
format!("UTC--{}Z--{}", timestamp, UUID::from(account.id))
});

// update account filename
Expand Down
4 changes: 3 additions & 1 deletion js/scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ if [ "$BRANCH" == "master" ]; then
fi

echo "*** Updating cargo parity-ui-precompiled#$PRECOMPILED_HASH"
git submodule update
cargo update -p parity-ui-precompiled
# --precise "$PRECOMPILED_HASH"

echo "*** Committing updated files"
git add .
git add js
git add Cargo.lock
git commit -m "[ci skip] js-precompiled $UTCDATE"
git push origin HEAD:refs/heads/$BRANCH 2>$GITLOG

Expand Down
8 changes: 8 additions & 0 deletions js/src/api/format/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,11 @@ export function inTraceFilter (filterObject) {

return filterObject;
}

export function inTraceType (whatTrace) {
if (isString(whatTrace)) {
return [whatTrace];
}

return whatTrace;
}
14 changes: 13 additions & 1 deletion js/src/api/format/input.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import BigNumber from 'bignumber.js';

import { inAddress, inBlockNumber, inData, inFilter, inHex, inNumber10, inNumber16, inOptions } from './input';
import { inAddress, inBlockNumber, inData, inFilter, inHex, inNumber10, inNumber16, inOptions, inTraceType } from './input';
import { isAddress } from '../../../test/types';

describe('api/format/input', () => {
Expand Down Expand Up @@ -242,4 +242,16 @@ describe('api/format/input', () => {
});
});
});

describe('inTraceType', () => {
it('returns array of types as is', () => {
const types = ['vmTrace', 'trace', 'stateDiff'];
expect(inTraceType(types)).to.deep.equal(types);
});

it('formats single string type into array', () => {
const type = 'vmTrace';
expect(inTraceType(type)).to.deep.equal([type]);
});
});
});
22 changes: 22 additions & 0 deletions js/src/api/format/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,25 @@ export function outTrace (trace) {

return trace;
}

export function outTraces (traces) {
if (traces) {
return traces.map(outTrace);
}

return traces;
}

export function outTraceReplay (trace) {
if (trace) {
Object.keys(trace).forEach((key) => {
switch (key) {
case 'trace':
trace[key] = outTraces(trace[key]);
break;
}
});
}

return trace;
}
22 changes: 16 additions & 6 deletions js/src/api/rpc/trace/trace.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,25 @@ describe('ethapi.trace', () => {
const ethapi = createHttpApi();

describe('block', () => {
it('returns the latest block', () => {
return ethapi.trace.block().then((block) => {
expect(block).to.be.ok;
it('returns the latest block traces', () => {
return ethapi.trace.block().then((traces) => {
expect(traces).to.be.ok;
});
});

it('returns a specified block', () => {
return ethapi.trace.block('0x65432').then((block) => {
expect(block).to.be.ok;
it('returns traces for a specified block', () => {
return ethapi.trace.block('0x65432').then((traces) => {
expect(traces).to.be.ok;
});
});
});

describe('replayTransaction', () => {
it('returns traces for a specific transaction', () => {
return ethapi.eth.getBlockByNumber().then((latestBlock) => {
return ethapi.trace.replayTransaction(latestBlock.transactions[0]).then((traces) => {
expect(traces).to.be.ok;
});
});
});
});
Expand Down
Loading

0 comments on commit 3e0d033

Please sign in to comment.