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

Commit bee2cb8

Browse files
authored
Backports: parity beta 2.1.4 (#9787)
* version: bump parity beta to 2.1.4 * ethcore: bump ropsten forkblock checkpoint (#9775) * ethcore: handle vm exception when estimating gas (#9615) * removed "rustup" & added new runner tag (#9731) * removed "rustup" & added new runner tag * exchanged tag "rust-windows" with "windows" * revert windows tag change * sync: retry different peer after empty subchain heads response (#9753) * If no subchain heads then try a different peer * Add log when useless chain head * Restrict ChainHead useless peer to ancient blocks * sync: replace `limit_reorg` with `block_set` condition * update jsonrpc-core to a1b2bb742ce16d1168669ffb13ffe856e8131228 * Allow zero chain id in EIP155 signing process (#9792) * Allow zero chain id in EIP155 signing process * Rename test * Fix test failure * Insert dev account before unlocking (#9813)
1 parent 18ddd7c commit bee2cb8

File tree

9 files changed

+88
-56
lines changed

9 files changed

+88
-56
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
description = "Parity Ethereum client"
33
name = "parity-ethereum"
44
# NOTE Make sure to update util/version/Cargo.toml as well
5-
version = "2.1.3"
5+
version = "2.1.4"
66
license = "GPL-3.0"
77
authors = ["Parity Technologies <admin@parity.io>"]
88

ethcore/res/ethereum/ropsten.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
"maximumExtraDataSize": "0x20",
2929
"minGasLimit": "0x1388",
3030
"networkID" : "0x3",
31-
"forkBlock": 3383558,
32-
"forkCanonHash": "0x6b4b80d65951375a70bc1ecf9a270d152dd355454d57869abbae2e42c213e0f3",
31+
"forkBlock": "0x40E80F",
32+
"forkCanonHash": "0x3e12d5c0f8d63fbc5831cc7f7273bd824fa4d0a9a4102d65d99a7ea5604abc00",
3333
"maxCodeSize": 24576,
3434
"maxCodeSizeTransition": 10,
3535
"eip150Transition": 0,

ethcore/src/client/client.rs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,30 +1495,36 @@ impl Call for Client {
14951495
let sender = t.sender();
14961496
let options = || TransactOptions::with_tracing().dont_check_nonce();
14971497

1498-
let cond = |gas| {
1498+
let exec = |gas| {
14991499
let mut tx = t.as_unsigned().clone();
15001500
tx.gas = gas;
15011501
let tx = tx.fake_sign(sender);
15021502

15031503
let mut clone = state.clone();
15041504
let machine = self.engine.machine();
15051505
let schedule = machine.schedule(env_info.number);
1506-
Ok(Executive::new(&mut clone, &env_info, &machine, &schedule)
1506+
Executive::new(&mut clone, &env_info, &machine, &schedule)
15071507
.transact_virtual(&tx, options())
1508+
.ok()
15081509
.map(|r| r.exception.is_none())
1509-
.unwrap_or(false))
15101510
};
15111511

1512-
if !cond(upper)? {
1512+
let cond = |gas| exec(gas).unwrap_or(false);
1513+
1514+
if !cond(upper) {
15131515
upper = max_upper;
1514-
if !cond(upper)? {
1515-
trace!(target: "estimate_gas", "estimate_gas failed with {}", upper);
1516-
let err = ExecutionError::Internal(format!("Requires higher than upper limit of {}", upper));
1517-
return Err(err.into())
1516+
match exec(upper) {
1517+
Some(false) => return Err(CallError::Exceptional),
1518+
None => {
1519+
trace!(target: "estimate_gas", "estimate_gas failed with {}", upper);
1520+
let err = ExecutionError::Internal(format!("Requires higher than upper limit of {}", upper));
1521+
return Err(err.into())
1522+
},
1523+
_ => {},
15181524
}
15191525
}
15201526
let lower = t.gas_required(&self.engine.schedule(env_info.number)).into();
1521-
if cond(lower)? {
1527+
if cond(lower) {
15221528
trace!(target: "estimate_gas", "estimate_gas succeeded with {}", lower);
15231529
return Ok(lower)
15241530
}
@@ -1527,12 +1533,12 @@ impl Call for Client {
15271533
/// Returns the lowest value between `lower` and `upper` for which `cond` returns true.
15281534
/// We assert: `cond(lower) = false`, `cond(upper) = true`
15291535
fn binary_chop<F, E>(mut lower: U256, mut upper: U256, mut cond: F) -> Result<U256, E>
1530-
where F: FnMut(U256) -> Result<bool, E>
1536+
where F: FnMut(U256) -> bool
15311537
{
15321538
while upper - lower > 1.into() {
15331539
let mid = (lower + upper) / 2;
15341540
trace!(target: "estimate_gas", "{} .. {} .. {}", lower, mid, upper);
1535-
let c = cond(mid)?;
1541+
let c = cond(mid);
15361542
match c {
15371543
true => upper = mid,
15381544
false => lower = mid,

ethcore/sync/src/block_sync.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,6 @@ pub struct BlockDownloader {
136136
target_hash: Option<H256>,
137137
/// Probing range for seeking common best block.
138138
retract_step: u64,
139-
/// Whether reorg should be limited.
140-
limit_reorg: bool,
141139
/// consecutive useless headers this round
142140
useless_headers_count: usize,
143141
}
@@ -146,12 +144,12 @@ impl BlockDownloader {
146144
/// Create a new instance of syncing strategy.
147145
/// For BlockSet::NewBlocks this won't reorganize to before the last kept state.
148146
pub fn new(block_set: BlockSet, start_hash: &H256, start_number: BlockNumber) -> Self {
149-
let (limit_reorg, sync_receipts) = match block_set {
150-
BlockSet::NewBlocks => (true, false),
151-
BlockSet::OldBlocks => (false, true)
147+
let sync_receipts = match block_set {
148+
BlockSet::NewBlocks => false,
149+
BlockSet::OldBlocks => true
152150
};
153151
BlockDownloader {
154-
block_set: block_set,
152+
block_set,
155153
state: State::Idle,
156154
highest_block: None,
157155
last_imported_block: start_number,
@@ -164,7 +162,6 @@ impl BlockDownloader {
164162
download_receipts: sync_receipts,
165163
target_hash: None,
166164
retract_step: 1,
167-
limit_reorg: limit_reorg,
168165
useless_headers_count: 0,
169166
}
170167
}
@@ -321,12 +318,20 @@ impl BlockDownloader {
321318
self.state = State::Blocks;
322319
return Ok(DownloadAction::Reset);
323320
} else {
321+
trace_sync!(self, "No useful subchain heads received, expected hash {:?}", expected_hash);
324322
let best = io.chain().chain_info().best_block_number;
325323
let oldest_reorg = io.chain().pruning_info().earliest_state;
326324
let last = self.last_imported_block;
327-
if self.limit_reorg && best > last && (last == 0 || last < oldest_reorg) {
328-
trace_sync!(self, "No common block, disabling peer");
329-
return Err(BlockDownloaderImportError::Invalid);
325+
match self.block_set {
326+
BlockSet::NewBlocks if best > last && (last == 0 || last < oldest_reorg) => {
327+
trace_sync!(self, "No common block, disabling peer");
328+
return Err(BlockDownloaderImportError::Invalid)
329+
},
330+
BlockSet::OldBlocks => {
331+
trace_sync!(self, "Expected some useful headers for downloading OldBlocks. Try a different peer");
332+
return Err(BlockDownloaderImportError::Useless)
333+
},
334+
_ => (),
330335
}
331336
}
332337
},
@@ -429,7 +434,7 @@ impl BlockDownloader {
429434
} else {
430435
let best = io.chain().chain_info().best_block_number;
431436
let oldest_reorg = io.chain().pruning_info().earliest_state;
432-
if self.limit_reorg && best > start && start < oldest_reorg {
437+
if self.block_set == BlockSet::NewBlocks && best > start && start < oldest_reorg {
433438
debug_sync!(self, "Could not revert to previous ancient block, last: {} ({})", start, start_hash);
434439
self.reset();
435440
} else {

ethcore/transaction/src/transaction.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ pub mod signature {
9090
match v {
9191
v if v == 27 => 0,
9292
v if v == 28 => 1,
93-
v if v > 36 => ((v - 1) % 2) as u8,
94-
_ => 4
93+
v if v >= 35 => ((v - 1) % 2) as u8,
94+
_ => 4
9595
}
9696
}
9797
}
@@ -364,7 +364,7 @@ impl UnverifiedTransaction {
364364
pub fn chain_id(&self) -> Option<u64> {
365365
match self.v {
366366
v if self.is_unsigned() => Some(v),
367-
v if v > 36 => Some((v - 35) / 2),
367+
v if v >= 35 => Some((v - 35) / 2),
368368
_ => None,
369369
}
370370
}
@@ -583,6 +583,27 @@ mod tests {
583583
assert_eq!(t.chain_id(), None);
584584
}
585585

586+
#[test]
587+
fn signing_eip155_zero_chainid() {
588+
use ethkey::{Random, Generator};
589+
590+
let key = Random.generate().unwrap();
591+
let t = Transaction {
592+
action: Action::Create,
593+
nonce: U256::from(42),
594+
gas_price: U256::from(3000),
595+
gas: U256::from(50_000),
596+
value: U256::from(1),
597+
data: b"Hello!".to_vec()
598+
};
599+
600+
let hash = t.hash(Some(0));
601+
let sig = ::ethkey::sign(&key.secret(), &hash).unwrap();
602+
let u = t.with_signature(sig, Some(0));
603+
604+
assert!(SignedTransaction::new(u).is_ok());
605+
}
606+
586607
#[test]
587608
fn signing() {
588609
use ethkey::{Random, Generator};

parity/run.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,11 @@ fn prepare_account_provider(spec: &SpecType, dirs: &Directories, data_dir: &str,
961961
account_settings,
962962
);
963963

964+
// Add development account if running dev chain:
965+
if let SpecType::Dev = *spec {
966+
insert_dev_account(&account_provider);
967+
}
968+
964969
for a in cfg.unlocked_accounts {
965970
// Check if the account exists
966971
if !account_provider.has_account(a) {
@@ -977,11 +982,6 @@ fn prepare_account_provider(spec: &SpecType, dirs: &Directories, data_dir: &str,
977982
}
978983
}
979984

980-
// Add development account if running dev chain:
981-
if let SpecType::Dev = *spec {
982-
insert_dev_account(&account_provider);
983-
}
984-
985985
Ok(account_provider)
986986
}
987987

scripts/gitlab/build-windows.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ set -u # treat unset variables as error
55
set INCLUDE="C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include;C:\vs2015\VC\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt"
66
set LIB="C:\vs2015\VC\lib;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\x64"
77

8-
rustup default stable-x86_64-pc-windows-msvc
9-
108
echo "__________Show ENVIROMENT__________"
119
echo "CI_SERVER_NAME: " $CI_SERVER_NAME
1210
echo "CARGO_HOME: " $CARGO_HOME

0 commit comments

Comments
 (0)