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)
This commit is contained in:
@@ -28,8 +28,8 @@
|
||||
"maximumExtraDataSize": "0x20",
|
||||
"minGasLimit": "0x1388",
|
||||
"networkID" : "0x3",
|
||||
"forkBlock": 3383558,
|
||||
"forkCanonHash": "0x6b4b80d65951375a70bc1ecf9a270d152dd355454d57869abbae2e42c213e0f3",
|
||||
"forkBlock": "0x40E80F",
|
||||
"forkCanonHash": "0x3e12d5c0f8d63fbc5831cc7f7273bd824fa4d0a9a4102d65d99a7ea5604abc00",
|
||||
"maxCodeSize": 24576,
|
||||
"maxCodeSizeTransition": 10,
|
||||
"eip150Transition": 0,
|
||||
|
||||
@@ -1495,7 +1495,7 @@ impl Call for Client {
|
||||
let sender = t.sender();
|
||||
let options = || TransactOptions::with_tracing().dont_check_nonce();
|
||||
|
||||
let cond = |gas| {
|
||||
let exec = |gas| {
|
||||
let mut tx = t.as_unsigned().clone();
|
||||
tx.gas = gas;
|
||||
let tx = tx.fake_sign(sender);
|
||||
@@ -1503,22 +1503,28 @@ impl Call for Client {
|
||||
let mut clone = state.clone();
|
||||
let machine = self.engine.machine();
|
||||
let schedule = machine.schedule(env_info.number);
|
||||
Ok(Executive::new(&mut clone, &env_info, &machine, &schedule)
|
||||
Executive::new(&mut clone, &env_info, &machine, &schedule)
|
||||
.transact_virtual(&tx, options())
|
||||
.ok()
|
||||
.map(|r| r.exception.is_none())
|
||||
.unwrap_or(false))
|
||||
};
|
||||
|
||||
if !cond(upper)? {
|
||||
let cond = |gas| exec(gas).unwrap_or(false);
|
||||
|
||||
if !cond(upper) {
|
||||
upper = max_upper;
|
||||
if !cond(upper)? {
|
||||
trace!(target: "estimate_gas", "estimate_gas failed with {}", upper);
|
||||
let err = ExecutionError::Internal(format!("Requires higher than upper limit of {}", upper));
|
||||
return Err(err.into())
|
||||
match exec(upper) {
|
||||
Some(false) => return Err(CallError::Exceptional),
|
||||
None => {
|
||||
trace!(target: "estimate_gas", "estimate_gas failed with {}", upper);
|
||||
let err = ExecutionError::Internal(format!("Requires higher than upper limit of {}", upper));
|
||||
return Err(err.into())
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
let lower = t.gas_required(&self.engine.schedule(env_info.number)).into();
|
||||
if cond(lower)? {
|
||||
if cond(lower) {
|
||||
trace!(target: "estimate_gas", "estimate_gas succeeded with {}", lower);
|
||||
return Ok(lower)
|
||||
}
|
||||
@@ -1527,12 +1533,12 @@ impl Call for Client {
|
||||
/// Returns the lowest value between `lower` and `upper` for which `cond` returns true.
|
||||
/// We assert: `cond(lower) = false`, `cond(upper) = true`
|
||||
fn binary_chop<F, E>(mut lower: U256, mut upper: U256, mut cond: F) -> Result<U256, E>
|
||||
where F: FnMut(U256) -> Result<bool, E>
|
||||
where F: FnMut(U256) -> bool
|
||||
{
|
||||
while upper - lower > 1.into() {
|
||||
let mid = (lower + upper) / 2;
|
||||
trace!(target: "estimate_gas", "{} .. {} .. {}", lower, mid, upper);
|
||||
let c = cond(mid)?;
|
||||
let c = cond(mid);
|
||||
match c {
|
||||
true => upper = mid,
|
||||
false => lower = mid,
|
||||
|
||||
@@ -136,8 +136,6 @@ pub struct BlockDownloader {
|
||||
target_hash: Option<H256>,
|
||||
/// Probing range for seeking common best block.
|
||||
retract_step: u64,
|
||||
/// Whether reorg should be limited.
|
||||
limit_reorg: bool,
|
||||
/// consecutive useless headers this round
|
||||
useless_headers_count: usize,
|
||||
}
|
||||
@@ -146,12 +144,12 @@ impl BlockDownloader {
|
||||
/// Create a new instance of syncing strategy.
|
||||
/// For BlockSet::NewBlocks this won't reorganize to before the last kept state.
|
||||
pub fn new(block_set: BlockSet, start_hash: &H256, start_number: BlockNumber) -> Self {
|
||||
let (limit_reorg, sync_receipts) = match block_set {
|
||||
BlockSet::NewBlocks => (true, false),
|
||||
BlockSet::OldBlocks => (false, true)
|
||||
let sync_receipts = match block_set {
|
||||
BlockSet::NewBlocks => false,
|
||||
BlockSet::OldBlocks => true
|
||||
};
|
||||
BlockDownloader {
|
||||
block_set: block_set,
|
||||
block_set,
|
||||
state: State::Idle,
|
||||
highest_block: None,
|
||||
last_imported_block: start_number,
|
||||
@@ -164,7 +162,6 @@ impl BlockDownloader {
|
||||
download_receipts: sync_receipts,
|
||||
target_hash: None,
|
||||
retract_step: 1,
|
||||
limit_reorg: limit_reorg,
|
||||
useless_headers_count: 0,
|
||||
}
|
||||
}
|
||||
@@ -321,12 +318,20 @@ impl BlockDownloader {
|
||||
self.state = State::Blocks;
|
||||
return Ok(DownloadAction::Reset);
|
||||
} else {
|
||||
trace_sync!(self, "No useful subchain heads received, expected hash {:?}", expected_hash);
|
||||
let best = io.chain().chain_info().best_block_number;
|
||||
let oldest_reorg = io.chain().pruning_info().earliest_state;
|
||||
let last = self.last_imported_block;
|
||||
if self.limit_reorg && best > last && (last == 0 || last < oldest_reorg) {
|
||||
trace_sync!(self, "No common block, disabling peer");
|
||||
return Err(BlockDownloaderImportError::Invalid);
|
||||
match self.block_set {
|
||||
BlockSet::NewBlocks if best > last && (last == 0 || last < oldest_reorg) => {
|
||||
trace_sync!(self, "No common block, disabling peer");
|
||||
return Err(BlockDownloaderImportError::Invalid)
|
||||
},
|
||||
BlockSet::OldBlocks => {
|
||||
trace_sync!(self, "Expected some useful headers for downloading OldBlocks. Try a different peer");
|
||||
return Err(BlockDownloaderImportError::Useless)
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -429,7 +434,7 @@ impl BlockDownloader {
|
||||
} else {
|
||||
let best = io.chain().chain_info().best_block_number;
|
||||
let oldest_reorg = io.chain().pruning_info().earliest_state;
|
||||
if self.limit_reorg && best > start && start < oldest_reorg {
|
||||
if self.block_set == BlockSet::NewBlocks && best > start && start < oldest_reorg {
|
||||
debug_sync!(self, "Could not revert to previous ancient block, last: {} ({})", start, start_hash);
|
||||
self.reset();
|
||||
} else {
|
||||
|
||||
@@ -90,8 +90,8 @@ pub mod signature {
|
||||
match v {
|
||||
v if v == 27 => 0,
|
||||
v if v == 28 => 1,
|
||||
v if v > 36 => ((v - 1) % 2) as u8,
|
||||
_ => 4
|
||||
v if v >= 35 => ((v - 1) % 2) as u8,
|
||||
_ => 4
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -364,7 +364,7 @@ impl UnverifiedTransaction {
|
||||
pub fn chain_id(&self) -> Option<u64> {
|
||||
match self.v {
|
||||
v if self.is_unsigned() => Some(v),
|
||||
v if v > 36 => Some((v - 35) / 2),
|
||||
v if v >= 35 => Some((v - 35) / 2),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -583,6 +583,27 @@ mod tests {
|
||||
assert_eq!(t.chain_id(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn signing_eip155_zero_chainid() {
|
||||
use ethkey::{Random, Generator};
|
||||
|
||||
let key = Random.generate().unwrap();
|
||||
let t = Transaction {
|
||||
action: Action::Create,
|
||||
nonce: U256::from(42),
|
||||
gas_price: U256::from(3000),
|
||||
gas: U256::from(50_000),
|
||||
value: U256::from(1),
|
||||
data: b"Hello!".to_vec()
|
||||
};
|
||||
|
||||
let hash = t.hash(Some(0));
|
||||
let sig = ::ethkey::sign(&key.secret(), &hash).unwrap();
|
||||
let u = t.with_signature(sig, Some(0));
|
||||
|
||||
assert!(SignedTransaction::new(u).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn signing() {
|
||||
use ethkey::{Random, Generator};
|
||||
|
||||
Reference in New Issue
Block a user