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

Commit 80e6bcd

Browse files
committed
Merge branch 'master' into light-filters
2 parents 60ce0ae + 89a4cb0 commit 80e6bcd

38 files changed

+513
-178
lines changed

.gitlab-ci.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ cache:
1414
untracked: true
1515
linux-stable:
1616
stage: build
17-
image: ethcore/rust:stable
17+
image: parity/rust:gitlab-ci
1818
only:
1919
- beta
2020
- tags
2121
- stable
2222
- triggers
2323
script:
24+
- rustup default stable
2425
- cargo build -j $(nproc) --release --features final $CARGOFLAGS
2526
- cargo build -j $(nproc) --release -p evmbin
2627
- cargo build -j $(nproc) --release -p ethstore
@@ -105,13 +106,14 @@ linux-stable-debian:
105106
name: "stable-x86_64-unknown-debian-gnu_parity"
106107
linux-beta:
107108
stage: build
108-
image: ethcore/rust:beta
109+
image: parity/rust:gitlab-ci
109110
only:
110111
- beta
111112
- tags
112113
- stable
113114
- triggers
114115
script:
116+
- rustup default beta
115117
- cargo build -j $(nproc) --release $CARGOFLAGS
116118
- strip target/release/parity
117119
tags:
@@ -124,13 +126,14 @@ linux-beta:
124126
allow_failure: true
125127
linux-nightly:
126128
stage: build
127-
image: ethcore/rust:nightly
129+
image: parity/rust:gitlab-ci
128130
only:
129131
- beta
130132
- tags
131133
- stable
132134
- triggers
133135
script:
136+
- rustup default nightly
134137
- cargo build -j $(nproc) --release $CARGOFLAGS
135138
- strip target/release/parity
136139
tags:
@@ -544,11 +547,12 @@ test-windows:
544547
allow_failure: true
545548
test-rust-stable:
546549
stage: test
547-
image: ethcore/rust:stable
550+
image: parity/rust:gitlab-ci
548551
before_script:
549552
- git submodule update --init --recursive
550553
- export RUST_FILES_MODIFIED=$(git --no-pager diff --name-only $CI_BUILD_REF^ $CI_BUILD_REF | grep -v -e ^js -e ^\\. -e ^LICENSE -e ^README.md -e ^appveyor.yml -e ^test.sh -e ^windows/ -e ^scripts/ -e^mac/ -e ^nsis/ | wc -l)
551554
script:
555+
- rustup show
552556
- export RUST_BACKTRACE=1
553557
- if [ $RUST_FILES_MODIFIED -eq 0 ]; then echo "Skipping Rust tests since no Rust files modified."; else ./test.sh $CARGOFLAGS; fi
554558
tags:

Cargo.lock

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# [Parity](https://ethcore.io/parity.html)
22
### Fast, light, and robust Ethereum implementation
33

4+
### [Download latest release](https://github.com/paritytech/parity/releases)
5+
46
[![build status](https://gitlab.ethcore.io/parity/parity/badges/master/build.svg)](https://gitlab.ethcore.io/parity/parity/commits/master) [![Coverage Status][coveralls-image]][coveralls-url] [![GPLv3][license-image]][license-url]
57

68
### Join the chat!
@@ -22,7 +24,6 @@ Be sure to check out [our wiki][wiki-url] for more information.
2224
[doc-url]: https://paritytech.github.io/parity/ethcore/index.html
2325
[wiki-url]: https://github.com/paritytech/parity/wiki
2426

25-
**Parity requires Rust version 1.15.0 to build**
2627

2728
----
2829

@@ -45,14 +46,14 @@ of RPC APIs.
4546
If you run into an issue while using parity, feel free to file one in this repository
4647
or hop on our [gitter chat room][gitter-url] to ask a question. We are glad to help!
4748

48-
Parity's current release is 1.5. You can download it at https://parity.io or follow the instructions
49+
Parity's current release is 1.6. You can download it at https://github.com/paritytech/parity/releases or follow the instructions
4950
below to build from source.
5051

5152
----
5253

5354
## Build dependencies
5455

55-
Parity is fully compatible with Stable Rust.
56+
**Parity requires Rust version 1.16.0 to build**
5657

5758
We recommend installing Rust through [rustup](https://www.rustup.rs/). If you don't already have rustup, you can install it like this:
5859

@@ -80,7 +81,7 @@ Once you have rustup, install parity or download and build from source
8081

8182
----
8283

83-
## Quick install
84+
## Quick build and install
8485

8586
```bash
8687
cargo install --git https://github.com/paritytech/parity.git parity

ethcore/light/src/client/header_chain.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl Decodable for Entry {
119119
}
120120

121121
fn cht_key(number: u64) -> String {
122-
format!("canonical_{}", number)
122+
format!("{:08x}_canonical", number)
123123
}
124124

125125
fn era_key(number: u64) -> String {

ethcore/light/src/on_demand/request.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,14 @@ impl TransactionProof {
244244
pub fn check_response(&self, state_items: &[DBValue]) -> ProvedExecution {
245245
let root = self.header.state_root();
246246

247+
let mut env_info = self.env_info.clone();
248+
env_info.gas_limit = self.tx.gas.clone();
247249
state::check_proof(
248250
state_items,
249251
root,
250252
&self.tx,
251253
&*self.engine,
252-
&self.env_info,
254+
&env_info,
253255
)
254256
}
255257
}

ethcore/native_contracts/build.rs

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use std::io::Write;
2323
// TODO: `include!` these from files where they're pretty-printed?
2424
const REGISTRY_ABI: &'static str = r#"[{"constant":true,"inputs":[{"name":"_data","type":"address"}],"name":"canReverse","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_new","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_key","type":"string"},{"name":"_value","type":"bytes32"}],"name":"setData","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"string"}],"name":"confirmReverse","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"}],"name":"reserve","outputs":[{"name":"success","type":"bool"}],"payable":true,"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"}],"name":"drop","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_key","type":"string"}],"name":"getAddress","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_amount","type":"uint256"}],"name":"setFee","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_to","type":"address"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_key","type":"string"}],"name":"getData","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"reserved","outputs":[{"name":"reserved","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"drain","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"string"},{"name":"_who","type":"address"}],"name":"proposeReverse","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"hasReverse","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_key","type":"string"}],"name":"getUint","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"fee","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"getOwner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_name","type":"bytes32"}],"name":"getReverse","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_data","type":"address"}],"name":"reverse","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_key","type":"string"},{"name":"_value","type":"uint256"}],"name":"setUint","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"string"},{"name":"_who","type":"address"}],"name":"confirmReverseAs","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"removeReverse","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"bytes32"},{"name":"_key","type":"string"},{"name":"_value","type":"address"}],"name":"setAddress","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"}]"#;
2525
const SERVICE_TRANSACTION_ABI: &'static str = r#"[{"constant":false,"inputs":[{"name":"_new","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_who","type":"address"}],"name":"certify","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_who","type":"address"},{"name":"_field","type":"string"}],"name":"getAddress","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_who","type":"address"}],"name":"revoke","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"delegate","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_who","type":"address"},{"name":"_field","type":"string"}],"name":"getUint","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_new","type":"address"}],"name":"setDelegate","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_who","type":"address"}],"name":"certified","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_who","type":"address"},{"name":"_field","type":"string"}],"name":"get","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"}]"#;
26+
const SECRETSTORE_ACL_STORAGE_ABI: &'static str = r#"[{"constant":true,"inputs":[{"name":"user","type":"address"},{"name":"document","type":"bytes32"}],"name":"checkPermissions","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"}]"#;
2627

2728
fn build_file(name: &str, abi: &str, filename: &str) {
2829
let code = ::native_contract_generator::generate_module(name, abi).unwrap();
@@ -37,4 +38,5 @@ fn build_file(name: &str, abi: &str, filename: &str) {
3738
fn main() {
3839
build_file("Registry", REGISTRY_ABI, "registry.rs");
3940
build_file("ServiceTransactionChecker", SERVICE_TRANSACTION_ABI, "service_transaction.rs");
41+
build_file("SecretStoreAclStorage", SECRETSTORE_ACL_STORAGE_ABI, "secretstore_acl_storage.rs");
4042
}

ethcore/native_contracts/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ extern crate ethcore_util as util;
2525

2626
mod registry;
2727
mod service_transaction;
28+
mod secretstore_acl_storage;
2829

2930
pub use self::registry::Registry;
3031
pub use self::service_transaction::ServiceTransactionChecker;
32+
pub use self::secretstore_acl_storage::SecretStoreAclStorage;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
2+
// This file is part of Parity.
3+
4+
// Parity is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// Parity is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
14+
// You should have received a copy of the GNU General Public License
15+
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
16+
17+
#![allow(unused_mut, unused_variables, unused_imports)]
18+
19+
//! Secret store ACL storage contract.
20+
// TODO: testing.
21+
22+
include!(concat!(env!("OUT_DIR"), "/secretstore_acl_storage.rs"));

ethcore/src/client/client.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ impl Client {
395395
if header.number() < self.engine().params().validate_receipts_transition && header.receipts_root() != locked_block.block().header().receipts_root() {
396396
locked_block = locked_block.strip_receipts();
397397
}
398-
398+
399399
// Final Verification
400400
if let Err(e) = self.verifier.verify_block_final(header, locked_block.block().header()) {
401401
warn!(target: "client", "Stage 4 block verification failed for #{} ({})\nError: {:?}", header.number(), header.hash(), e);
@@ -1627,10 +1627,12 @@ impl ::client::ProvingBlockChainClient for Client {
16271627
}
16281628

16291629
fn prove_transaction(&self, transaction: SignedTransaction, id: BlockId) -> Option<Vec<DBValue>> {
1630-
let (state, env_info) = match (self.state_at(id), self.env_info(id)) {
1630+
let (state, mut env_info) = match (self.state_at(id), self.env_info(id)) {
16311631
(Some(s), Some(e)) => (s, e),
16321632
_ => return None,
16331633
};
1634+
1635+
env_info.gas_limit = transaction.gas.clone();
16341636
let mut jdb = self.state_db.lock().journal_db().boxed_clone();
16351637
let backend = state::backend::Proving::new(jdb.as_hashdb_mut());
16361638

js/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "parity.js",
3-
"version": "1.7.43",
3+
"version": "1.7.47",
44
"main": "release/index.js",
55
"jsnext:main": "src/index.js",
66
"author": "Parity Team <[email protected]>",
@@ -176,7 +176,7 @@
176176
"geopattern": "1.2.3",
177177
"isomorphic-fetch": "2.2.1",
178178
"js-sha3": "0.5.5",
179-
"keythereum": "0.4.3",
179+
"keythereum": "0.4.6",
180180
"lodash": "4.17.2",
181181
"loglevel": "1.4.1",
182182
"marked": "0.3.6",

js/src/api/local/accounts/account.js

+21-17
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
1616

17-
import { keythereum } from '../ethkey';
17+
import { createKeyObject, decryptPrivateKey } from '../ethkey';
1818

1919
export default class Account {
2020
constructor (persist, data) {
@@ -31,12 +31,14 @@ export default class Account {
3131
}
3232

3333
isValidPassword (password) {
34-
try {
35-
keythereum.recover(Buffer.from(password), this._keyObject);
36-
return true;
37-
} catch (e) {
38-
return false;
39-
}
34+
return decryptPrivateKey(this._keyObject, password)
35+
.then((privateKey) => {
36+
if (!privateKey) {
37+
return false;
38+
}
39+
40+
return true;
41+
});
4042
}
4143

4244
get address () {
@@ -68,21 +70,23 @@ export default class Account {
6870
}
6971

7072
decryptPrivateKey (password) {
71-
return keythereum.recover(Buffer.from(password), this._keyObject);
73+
return decryptPrivateKey(this._keyObject, password);
7274
}
7375

74-
static fromPrivateKey (persist, key, password) {
75-
const iv = keythereum.crypto.randomBytes(16);
76-
const salt = keythereum.crypto.randomBytes(32);
77-
78-
// Keythereum will fail if `password` is an empty string
79-
password = Buffer.from(password);
76+
changePassword (key, password) {
77+
return createKeyObject(key, password).then((keyObject) => {
78+
this._keyObject = keyObject;
8079

81-
const keyObject = keythereum.dump(password, key, salt, iv);
80+
this._persist();
81+
});
82+
}
8283

83-
const account = new Account(persist, { keyObject });
84+
static fromPrivateKey (persist, key, password) {
85+
return createKeyObject(key, password).then((keyObject) => {
86+
const account = new Account(persist, { keyObject });
8487

85-
return account;
88+
return account;
89+
});
8690
}
8791

8892
toJSON () {

js/src/api/local/accounts/accounts.js

+38-16
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,23 @@ export default class Accounts {
3838

3939
create (secret, password) {
4040
const privateKey = Buffer.from(secret.slice(2), 'hex');
41-
const account = Account.fromPrivateKey(this.persist, privateKey, password);
4241

43-
this._store.push(account);
44-
this.lastAddress = account.address;
42+
return Account
43+
.fromPrivateKey(this.persist, privateKey, password)
44+
.then((account) => {
45+
const { address } = account;
4546

46-
this.persist();
47+
if (this._store.find((account) => account.address === address)) {
48+
throw new Error(`Account ${address} already exists!`);
49+
}
50+
51+
this._store.push(account);
52+
this.lastAddress = address;
53+
54+
this.persist();
4755

48-
return account.address;
56+
return account.address;
57+
});
4958
}
5059

5160
set lastAddress (value) {
@@ -73,28 +82,41 @@ export default class Accounts {
7382
remove (address, password) {
7483
address = address.toLowerCase();
7584

76-
const index = this._store.findIndex((account) => account.address === address);
85+
const account = this.get(address);
7786

78-
if (index === -1) {
87+
if (!account) {
7988
return false;
8089
}
8190

82-
const account = this._store[index];
91+
return account
92+
.isValidPassword(password)
93+
.then((isValid) => {
94+
if (!isValid) {
95+
return false;
96+
}
8397

84-
if (!account.isValidPassword(password)) {
85-
console.log('invalid password');
86-
return false;
87-
}
98+
if (address === this.lastAddress) {
99+
this.lastAddress = NULL_ADDRESS;
100+
}
101+
102+
this.removeUnsafe(address);
88103

89-
if (address === this.lastAddress) {
90-
this.lastAddress = NULL_ADDRESS;
104+
return true;
105+
});
106+
}
107+
108+
removeUnsafe (address) {
109+
address = address.toLowerCase();
110+
111+
const index = this._store.findIndex((account) => account.address === address);
112+
113+
if (index === -1) {
114+
return;
91115
}
92116

93117
this._store.splice(index, 1);
94118

95119
this.persist();
96-
97-
return true;
98120
}
99121

100122
mapArray (mapper) {

0 commit comments

Comments
 (0)