* parity-version: bump beta to 2.1.2
* docs(rpc): push the branch along with tags (#9578)
* docs(rpc): push the branch along with tags
* ci: remove old rpc docs script
* Remove snapcraft clean (#9585)
* Revert " add snapcraft package image (master) (#9584)"
This reverts commit ceaedbbd7f
.
* Update package-snap.sh
* Update .gitlab-ci.yml
* ci: fix regex 🙄 (#9597)
* docs(rpc): annotate tag with the provided message (#9601)
* Update ropsten.json (#9602)
* HF in POA Sokol (2018-09-19) (#9607)
https://github.com/poanetwork/poa-chain-spec/pull/86
* fix(network): don't disconnect reserved peers (#9608)
The priority of && and || was borked.
* fix failing node-table tests on mac os, closes #9632 (#9633)
* ethcore-io retries failed work steal (#9651)
* ethcore-io uses newer version of crossbeam && retries failed work steal
* ethcore-io non-mio service uses newer crossbeam
* remove master from releasable branches (#9655)
* remove master from releasable branches
need backporting in beta
fix https://gitlab.parity.io/parity/parity-ethereum/-/jobs/101065 etc
* add except for snap packages for master
* Test fix for windows cache name... (#9658)
* Test fix for windows cache name...
* Fix variable name.
* fix(light_fetch): avoid race with BlockNumber::Latest (#9665)
* Calculate sha3 instead of sha256 for push-release. (#9673)
* Calculate sha3 instead of sha256 for push-release.
* Add pushes to the script.
* Hardfork the testnets (#9562)
* ethcore: propose hardfork block number 4230000 for ropsten
* ethcore: propose hardfork block number 9000000 for kovan
* ethcore: enable kip-4 and kip-6 on kovan
* etcore: bump kovan hardfork to block 9.2M
* ethcore: fix ropsten constantinople block number to 4.2M
* ethcore: disable difficulty_test_ropsten until ethereum/tests are updated upstream
* ci: fix push script (#9679)
* ci: fix push script
* Fix copying & running on windows.
* CI: Remove unnecessary pipes (#9681)
* ci: reduce gitlab pipelines significantly
* ci: build pipeline for PR
* ci: remove dead weight
* ci: remove github release script
* ci: remove forever broken aura tests
* ci: add random stuff to the end of the pipes
* ci: add wind and mac to the end of the pipe
* ci: remove snap artifacts
* ci: (re)move dockerfiles
* ci: clarify job names
* ci: add cargo audit job
* ci: make audit script executable
* ci: ignore snap and docker files for rust check
* ci: simplify audit script
* ci: rename misc to optional
* ci: add publish script to releaseable branches
* ci: more verbose cp command for windows build
* ci: fix weird binary checksum logic in push script
* ci: fix regex in push script for windows
* ci: simplify gitlab caching
* docs: align README with ci changes
* ci: specify default cargo target dir
* ci: print verbose environment
* ci: proper naming of scripts
* ci: restore docker files
* ci: use docker hub file
* ci: use cargo home instead of cargo target dir
* ci: touch random rust file to trigger real builds
* ci: set cargo target dir for audit script
* ci: remove temp file
* ci: don't export the cargo target dir in the audit script
* ci: fix windows unbound variable
* docs: fix gitlab badge path
* rename deprecated gitlab ci variables
https://docs.gitlab.com/ee/ci/variables/#9-0-renaming
* ci: fix git compare for nightly builds
* test: skip c++ example for all platforms but linux
* ci: add random rust file to trigger tests
* ci: remove random rust file
* disable cpp lib test for mac, win and beta (#9686)
* cleanup ci merge
* ci: fix tests
* fix bad-block reporting no reason (#9638)
* ethcore: fix detection of major import (#9552)
* sync: set state to idle after sync is completed
* sync: refactor sync reset
* Don't hash the init_code of CREATE. (#9688)
* Docker: run as parity user (#9689)
* Implement CREATE2 gas changes and fix some potential overflowing (#9694)
* Implement CREATE2 gas changes and fix some potential overflowing
* Ignore create2 state tests
* Split CREATE and CREATE2 in gasometer
* Generalize rounding (x + 31) / 32 to to_word_size
* make instantSeal engine backwards compatible, closes #9696 (#9700)
* ethcore: delay ropsten hardfork (#9704)
* fix (light/provider) : Make `read_only executions` read-only (#9591)
* `ExecutionsRequest` from light-clients as read-only
This changes so all `ExecutionRequests` from light-clients are executed
as read-only which the `virtual``flag == true ensures.
This boost up the current transaction to always succeed
Note, this only affects `eth_estimateGas` and `eth_call` AFAIK.
* grumbles(revert renaming) : TransactionProof
* grumbles(trace) : remove incorrect trace
* grumbles(state/prove_tx) : explicit `virt`
Remove the boolean flag to determine that a `state::prove_transaction`
whether it should be executed in a virtual context or not.
Because of that also rename the function to
`state::prove_transction_virtual` to make more clear
* CI: Skip docs job for nightly (#9693)
* ci: force-tag wiki changes
* ci: force-tag wiki changes
* ci: skip docs job for master and nightly
* ci: revert docs job checking for nightly tag
* ci: exclude docs job from nightly builds in gitlab script
128 lines
3.9 KiB
Rust
128 lines
3.9 KiB
Rust
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
|
|
// This file is part of Parity.
|
|
|
|
// Parity is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
|
|
// Parity is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
use engines::{Engine, Seal};
|
|
use parity_machine::{Machine, Transactions, TotalScoredHeader};
|
|
|
|
/// `InstantSeal` params.
|
|
#[derive(Default, Debug, PartialEq)]
|
|
pub struct InstantSealParams {
|
|
/// Whether to use millisecond timestamp
|
|
pub millisecond_timestamp: bool,
|
|
}
|
|
|
|
impl From<::ethjson::spec::InstantSealParams> for InstantSealParams {
|
|
fn from(p: ::ethjson::spec::InstantSealParams) -> Self {
|
|
InstantSealParams {
|
|
millisecond_timestamp: p.millisecond_timestamp,
|
|
}
|
|
}
|
|
}
|
|
|
|
/// An engine which does not provide any consensus mechanism, just seals blocks internally.
|
|
/// Only seals blocks which have transactions.
|
|
pub struct InstantSeal<M> {
|
|
params: InstantSealParams,
|
|
machine: M,
|
|
}
|
|
|
|
impl<M> InstantSeal<M> {
|
|
/// Returns new instance of InstantSeal over the given state machine.
|
|
pub fn new(params: InstantSealParams, machine: M) -> Self {
|
|
InstantSeal {
|
|
params, machine,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl<M: Machine> Engine<M> for InstantSeal<M>
|
|
where M::LiveBlock: Transactions,
|
|
M::ExtendedHeader: TotalScoredHeader,
|
|
<M::ExtendedHeader as TotalScoredHeader>::Value: Ord
|
|
{
|
|
fn name(&self) -> &str {
|
|
"InstantSeal"
|
|
}
|
|
|
|
fn machine(&self) -> &M { &self.machine }
|
|
|
|
fn seals_internally(&self) -> Option<bool> { Some(true) }
|
|
|
|
fn generate_seal(&self, block: &M::LiveBlock, _parent: &M::Header) -> Seal {
|
|
if block.transactions().is_empty() { Seal::None } else { Seal::Regular(Vec::new()) }
|
|
}
|
|
|
|
fn verify_local_seal(&self, _header: &M::Header) -> Result<(), M::Error> {
|
|
Ok(())
|
|
}
|
|
|
|
fn open_block_header_timestamp(&self, parent_timestamp: u64) -> u64 {
|
|
use std::{time, cmp};
|
|
|
|
let dur = time::SystemTime::now().duration_since(time::UNIX_EPOCH).unwrap_or_default();
|
|
let mut now = dur.as_secs();
|
|
if self.params.millisecond_timestamp {
|
|
now = now * 1000 + dur.subsec_millis() as u64;
|
|
}
|
|
cmp::max(now, parent_timestamp)
|
|
}
|
|
|
|
fn is_timestamp_valid(&self, header_timestamp: u64, parent_timestamp: u64) -> bool {
|
|
header_timestamp >= parent_timestamp
|
|
}
|
|
|
|
fn fork_choice(&self, new: &M::ExtendedHeader, current: &M::ExtendedHeader) -> super::ForkChoice {
|
|
super::total_difficulty_fork_choice(new, current)
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use std::sync::Arc;
|
|
use ethereum_types::{H520, Address};
|
|
use test_helpers::get_temp_state_db;
|
|
use spec::Spec;
|
|
use header::Header;
|
|
use block::*;
|
|
use engines::Seal;
|
|
|
|
#[test]
|
|
fn instant_can_seal() {
|
|
let spec = Spec::new_instant();
|
|
let engine = &*spec.engine;
|
|
let db = spec.ensure_db_good(get_temp_state_db(), &Default::default()).unwrap();
|
|
let genesis_header = spec.genesis_header();
|
|
let last_hashes = Arc::new(vec![genesis_header.hash()]);
|
|
let b = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes, Address::default(), (3141562.into(), 31415620.into()), vec![], false, &mut Vec::new().into_iter()).unwrap();
|
|
let b = b.close_and_lock().unwrap();
|
|
if let Seal::Regular(seal) = engine.generate_seal(b.block(), &genesis_header) {
|
|
assert!(b.try_seal(engine, seal).is_ok());
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn instant_cant_verify() {
|
|
let engine = Spec::new_instant().engine;
|
|
let mut header: Header = Header::default();
|
|
|
|
assert!(engine.verify_block_basic(&header).is_ok());
|
|
|
|
header.set_seal(vec![::rlp::encode(&H520::default()).into_vec()]);
|
|
|
|
assert!(engine.verify_block_unordered(&header).is_ok());
|
|
}
|
|
}
|