openethereum/ethcore/src/spec/spec.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

1169 lines
45 KiB
Rust
Raw Normal View History

2020-09-22 14:53:52 +02:00
// Copyright 2015-2020 Parity Technologies (UK) Ltd.
// This file is part of OpenEthereum.
2016-02-05 13:40:41 +01:00
2020-09-22 14:53:52 +02:00
// OpenEthereum is free software: you can redistribute it and/or modify
2016-02-05 13:40:41 +01:00
// 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.
2020-09-22 14:53:52 +02:00
// OpenEthereum is distributed in the hope that it will be useful,
2016-02-05 13:40:41 +01:00
// 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
2020-09-22 14:53:52 +02:00
// along with OpenEthereum. If not, see <http://www.gnu.org/licenses/>.
2016-02-05 13:40:41 +01:00
2016-02-02 15:29:53 +01:00
//! Parameters for a block chain.
use std::{
collections::{BTreeMap, BTreeSet},
convert::TryFrom,
io::Read,
path::Path,
sync::Arc,
};
use bytes::Bytes;
use ethereum_types::{Address, Bloom, H256, U256};
use ethjson;
use hash::{keccak, KECCAK_NULL_RLP};
use parking_lot::RwLock;
use rlp::{Rlp, RlpStream};
2020-08-13 18:25:19 +02:00
use rustc_hex::FromHex;
use types::{header::Header, BlockNumber};
2020-11-04 19:11:05 +01:00
use vm::{AccessList, ActionParams, ActionValue, CallType, EnvInfo, ParamsType};
use builtin::Builtin;
use engines::{
ethcore: add clique engine (#9981) * fix broken sync * correct seal fields * ethcore: fix comment * parity: remove duplicate params * clique: fix whitespaces * ethcore: fix goerli chain spec * refactor signer_snapshot into pending/finalized state * move close_block_extra_data after seal is applied * refactor most of the logic into the signer_snapshot * clique: refactor locking logic out of the consensus engine interface * Fix jsonspec and add an unittest * Replace space with tabs * Unbroke sync * Fix broken sync * 1/2 state tracking without votes * 2/2 implement vote tracking * ci: use travis for goerli * ci: setup a clique network * ci: sync a görli node * add clique deploy script * ci: fix paths in clique deploy script * ci: use docker compose * ci: fix travis job names * ci: fix build deps * ci: massively reduce tests * Revert "ci: massively reduce tests" This reverts commit 6369f0b069ed2607a7e9f2e1d85489bacdc43384. * ci: run cargo test directly * ci: separate build and test stages * ci: cache rust installation * ci: simplify ci stages * ci: make clique deploy script executable * ci: shutdown goerli sync after 20min * ci: remove slow sync stage * ci: use timeout to finish jobs * ci: fix build path * ci: use absolute paths to end this confusion * ci: add geth and parity to path * ci: be more verbose * ci: allow for more relaxed caching timeout * ci: update repositories for custom ppa * ci: fix typo in file name * ci: fix docker compose file * ci: add ethkey to docker * ci: make sure deploy script is up to date with upstream * ci: stop docker container after certain time * ci: force superuser to update permissions on docker files * ci: reduce run time of script to ~30 min * ci: remove duplicate caching in travis * remove trace statements * clique: add more validation involving the recent signer list * ethcore: enable constantinople for rinkeby * ethcore: fix whitespaces in rinkeby spec * ethcore: reformat goerli.json * Revert "ci: remove duplicate caching in travis" This reverts commit a562838d3d194d37f9871dcbe00b783637978f89. * tmp commit * another tmp commit * it builds! * add sealing capabilities * add seal_header hook to allow separation of block seal/importing code paths * clique: remove populate_from_parent. * add panic * make turn delay random * initialize OpenBlock properly in 'enact' * misc: remove duplicate lines * misc: fix license headers * misc: convert spaces to tabs * misc: fix tabs * Update Cargo.toml * Update Cargo.toml * Update Cargo.toml * clique: ensure validator restores state before trying to seal * clique: make 'state' return an Error. Make some error messages more clear * Fix compile error after rebase & toolchain upgrade * fix a bunch of import warnings * Refactor code * Fix permissions * Refactoring syncing * Implement full validator checks * Refactor util functions to seperate file * mining 1 * ethcore: add chainspec for kotti * ethcore: rename pre-goerli configs * ethcore: load kotti chain spec * cli: add kotti to params * Implement working local sealing * making sealing & syncing work together * Relax timestamp checking * ethcore: prepare for the real goerli to launch * Implement NOTURN wiggle properly & cleanupnup warnings * Implement vote casting * Update docs & skip signing if no signer * Optimize step-service interval * Record state on local sealed block * Fix script filemode * Cleaning up codebase * restore enact trace logging * Delete clique.sh and move sync.sh * remove travis.yml * Remove dead code * Cleanup compile warning * address review comments * adding more comments and removing unwrap() * ci: remove sync script * Address review comments * fix compile error * adding better debugging for timing * Implement an dedicated thread for sealing timing * fix(add helper for timestamp overflows) (#10330) * fix(add helper timestamp overflows) * fix(simplify code) * fix(make helper private) * snap: official image / test (#10168) * official image / test * fix / test * bit more necromancy * fix paths * add source bin/df /test * add source bin/df /test2 * something w paths /test * something w paths /test * add source-type /test * show paths /test * copy plugin /test * plugin -> nil * install rhash * no questions while installing rhash * publish snap only for release * fix(docker): fix not receives SIGINT (#10059) * fix(docker): fix not receives SIGINT * fix: update with reviews * update with review * update * update * Don't add discovery initiators to the node table (#10305) * Don't add discovery initiators to the node table * Use enums for tracking state of the nodes in discovery * Dont try to ping ourselves * Fix minor nits * Update timeouts when observing an outdated node * Extracted update_bucket_record from update_node * Fixed typo * Fix two final nits from @todr * change docker image based on debian instead of ubuntu due to the chan… (#10336) * change docker image based on debian instead of ubuntu due to the changes of the build container * role back docker build image and docker deploy image to ubuntu:xenial based (#10338) * Bundle protocol and packet_id together in chain sync (#10315) Define a new `enum` where devp2p subprotocol packet ids (currently eth and par) are defined. Additionally provide functionality to query id value and protocol of a given id object. * snap: prefix version and populate candidate channel (#10343) * snap: populate candidate releases with beta snaps to avoid stale channel * snap: prefix version with v* * addressing review comments * engine: fix copyright header * scripts: restore permissions on sign command * ethcore: enforce tabs * ethcore: enforce tabs * ethcore: enforce tabs * addressing comments * addressing comments * addressing more comments * addressing more comments * addressing more comments * addressing more comments * addressing more comments * json-spec: fix clique epoch to non-zero u64 * ci: enable travis for parity goerli * ci: don't separate build and test step * ci: don't run c++ tests on travis * ci: simplify cargo test to squeeze into travis timeout * ci: don't run tests on travis at all * style(fixes) * fix(add tests) * fix(recent_signer bug) * fix(complete all tests) * fix(nits) * fix(simplify asserts) * fix(cliqueState): simplify code * fix(nits) * docs(comments what's need to fixed) * fix(revert unintended changes) * fix(tests) * fix(logs): voting logs * fix(readability + more logs) * fix(sync) * docs(add missing licens header) * fix(log): info! -> trace! * docs(fix nits) + fix(remove assert) * perf(use counter instead of vec) * fix(remove needless block in match) * fix(faulty comment) * grumbles(docs for tests) * fix(nits) * fix(revert_vote): only remove vote when votes == 0 * fix(vote counter): checked arithmetics * fix(simplify tests) * fix(nits) * fix(clique): err types * fix(clique utils): make use of errors * fix(cleanup nits) * fix(clique sealing): don't read state no signer * fix(replace Vec<Signers> with BTreeSet<Signers>) * fix(tests): BTreeSet and more generic helpers * fix(nits) * fix(ethcore_block_seal): remove needless `Box` * fix(faulty log): info -> trace * fix(checked SystemTime): prevent SystemTime panics * style(chain cfg): space after `:` * style(fn enact): fix whitespace * docs(clique): StepService * docs(nit): fix faulty comment * docs(fix typo) * style(fix bad indentation) * fix(bad regex match) * grumble(on_seal_block): make `&mut` to avoid clone * docs(on_seal_block): fix faulty documentation * Delete .travis.yml * docs: remove eth hf references in spec * Update client.rs * fix(nits) * fix(clique step): `RwLock` -> `AtomicBool` * fix(clique): use `Duration::as_millis` * Clean up some Clique documentation Co-authored-by: soc1c <soc1c@users.noreply.github.com> Co-authored-by: HCastano <HCastano@users.noreply.github.com> Co-authored-by: niklasad1 <niklasad1@users.noreply.github.com> Co-authored-by: jwasinger <jwasinger@users.noreply.github.com> Co-authored-by: ChainSafe <ChainSafe@users.noreply.github.com> Co-authored-by: thefallentree <thefallentree@users.noreply.github.com> Co-authored-by: 5chdn <5chdn@users.noreply.github.com>
2019-03-26 23:31:52 +01:00
AuthorityRound, BasicAuthority, Clique, EthEngine, InstantSeal, InstantSealParams, NullEngine,
DEFAULT_BLOCKHASH_CONTRACT,
};
use error::Error;
use executive::Executive;
use factory::Factories;
use machine::EthereumMachine;
use maplit::btreeset;
use pod_state::PodState;
use spec::{seal::Generic as GenericSeal, Genesis};
use state::{backend::Basic as BasicBackend, Backend, State, Substate};
use trace::{NoopTracer, NoopVMTracer};
pub use ethash::OptimizeFor;
const MAX_TRANSACTION_SIZE: usize = 300 * 1024;
// helper for formatting errors.
fn fmt_err<F: ::std::fmt::Display>(f: F) -> String {
format!("Spec json is invalid: {}", f)
}
/// Parameters common to ethereum-like blockchains.
/// NOTE: when adding bugfix hard-fork parameters,
/// add to `nonzero_bugfix_hard_fork`
///
/// we define a "bugfix" hard fork as any hard fork which
/// you would put on-by-default in a new chain.
#[derive(Debug, PartialEq, Default)]
#[cfg_attr(any(test, feature = "test-helpers"), derive(Clone))]
pub struct CommonParams {
/// Account start nonce.
pub account_start_nonce: U256,
/// Maximum size of extra data.
pub maximum_extra_data_size: usize,
/// Network id.
2016-12-04 19:48:26 +01:00
pub network_id: u64,
/// Chain id.
pub chain_id: u64,
/// Main subprotocol name.
pub subprotocol_name: String,
/// Minimum gas limit.
pub min_gas_limit: U256,
2016-07-27 21:38:22 +02:00
/// Fork block to check.
pub fork_block: Option<(BlockNumber, H256)>,
/// EIP150 transition block number.
pub eip150_transition: BlockNumber,
/// Number of first block where EIP-160 rules begin.
pub eip160_transition: BlockNumber,
/// Number of first block where EIP-161.abc begin.
pub eip161abc_transition: BlockNumber,
/// Number of first block where EIP-161.d begins.
pub eip161d_transition: BlockNumber,
/// Number of first block where EIP-98 rules begin.
pub eip98_transition: BlockNumber,
/// Number of first block where EIP-658 rules begin.
pub eip658_transition: BlockNumber,
/// Number of first block where EIP-155 rules begin.
pub eip155_transition: BlockNumber,
2017-03-14 11:41:56 +01:00
/// Validate block receipts root.
pub validate_receipts_transition: BlockNumber,
/// Validate transaction chain id.
pub validate_chain_id_transition: BlockNumber,
ethcore: add clique engine (#9981) * fix broken sync * correct seal fields * ethcore: fix comment * parity: remove duplicate params * clique: fix whitespaces * ethcore: fix goerli chain spec * refactor signer_snapshot into pending/finalized state * move close_block_extra_data after seal is applied * refactor most of the logic into the signer_snapshot * clique: refactor locking logic out of the consensus engine interface * Fix jsonspec and add an unittest * Replace space with tabs * Unbroke sync * Fix broken sync * 1/2 state tracking without votes * 2/2 implement vote tracking * ci: use travis for goerli * ci: setup a clique network * ci: sync a görli node * add clique deploy script * ci: fix paths in clique deploy script * ci: use docker compose * ci: fix travis job names * ci: fix build deps * ci: massively reduce tests * Revert "ci: massively reduce tests" This reverts commit 6369f0b069ed2607a7e9f2e1d85489bacdc43384. * ci: run cargo test directly * ci: separate build and test stages * ci: cache rust installation * ci: simplify ci stages * ci: make clique deploy script executable * ci: shutdown goerli sync after 20min * ci: remove slow sync stage * ci: use timeout to finish jobs * ci: fix build path * ci: use absolute paths to end this confusion * ci: add geth and parity to path * ci: be more verbose * ci: allow for more relaxed caching timeout * ci: update repositories for custom ppa * ci: fix typo in file name * ci: fix docker compose file * ci: add ethkey to docker * ci: make sure deploy script is up to date with upstream * ci: stop docker container after certain time * ci: force superuser to update permissions on docker files * ci: reduce run time of script to ~30 min * ci: remove duplicate caching in travis * remove trace statements * clique: add more validation involving the recent signer list * ethcore: enable constantinople for rinkeby * ethcore: fix whitespaces in rinkeby spec * ethcore: reformat goerli.json * Revert "ci: remove duplicate caching in travis" This reverts commit a562838d3d194d37f9871dcbe00b783637978f89. * tmp commit * another tmp commit * it builds! * add sealing capabilities * add seal_header hook to allow separation of block seal/importing code paths * clique: remove populate_from_parent. * add panic * make turn delay random * initialize OpenBlock properly in 'enact' * misc: remove duplicate lines * misc: fix license headers * misc: convert spaces to tabs * misc: fix tabs * Update Cargo.toml * Update Cargo.toml * Update Cargo.toml * clique: ensure validator restores state before trying to seal * clique: make 'state' return an Error. Make some error messages more clear * Fix compile error after rebase & toolchain upgrade * fix a bunch of import warnings * Refactor code * Fix permissions * Refactoring syncing * Implement full validator checks * Refactor util functions to seperate file * mining 1 * ethcore: add chainspec for kotti * ethcore: rename pre-goerli configs * ethcore: load kotti chain spec * cli: add kotti to params * Implement working local sealing * making sealing & syncing work together * Relax timestamp checking * ethcore: prepare for the real goerli to launch * Implement NOTURN wiggle properly & cleanupnup warnings * Implement vote casting * Update docs & skip signing if no signer * Optimize step-service interval * Record state on local sealed block * Fix script filemode * Cleaning up codebase * restore enact trace logging * Delete clique.sh and move sync.sh * remove travis.yml * Remove dead code * Cleanup compile warning * address review comments * adding more comments and removing unwrap() * ci: remove sync script * Address review comments * fix compile error * adding better debugging for timing * Implement an dedicated thread for sealing timing * fix(add helper for timestamp overflows) (#10330) * fix(add helper timestamp overflows) * fix(simplify code) * fix(make helper private) * snap: official image / test (#10168) * official image / test * fix / test * bit more necromancy * fix paths * add source bin/df /test * add source bin/df /test2 * something w paths /test * something w paths /test * add source-type /test * show paths /test * copy plugin /test * plugin -> nil * install rhash * no questions while installing rhash * publish snap only for release * fix(docker): fix not receives SIGINT (#10059) * fix(docker): fix not receives SIGINT * fix: update with reviews * update with review * update * update * Don't add discovery initiators to the node table (#10305) * Don't add discovery initiators to the node table * Use enums for tracking state of the nodes in discovery * Dont try to ping ourselves * Fix minor nits * Update timeouts when observing an outdated node * Extracted update_bucket_record from update_node * Fixed typo * Fix two final nits from @todr * change docker image based on debian instead of ubuntu due to the chan… (#10336) * change docker image based on debian instead of ubuntu due to the changes of the build container * role back docker build image and docker deploy image to ubuntu:xenial based (#10338) * Bundle protocol and packet_id together in chain sync (#10315) Define a new `enum` where devp2p subprotocol packet ids (currently eth and par) are defined. Additionally provide functionality to query id value and protocol of a given id object. * snap: prefix version and populate candidate channel (#10343) * snap: populate candidate releases with beta snaps to avoid stale channel * snap: prefix version with v* * addressing review comments * engine: fix copyright header * scripts: restore permissions on sign command * ethcore: enforce tabs * ethcore: enforce tabs * ethcore: enforce tabs * addressing comments * addressing comments * addressing more comments * addressing more comments * addressing more comments * addressing more comments * addressing more comments * json-spec: fix clique epoch to non-zero u64 * ci: enable travis for parity goerli * ci: don't separate build and test step * ci: don't run c++ tests on travis * ci: simplify cargo test to squeeze into travis timeout * ci: don't run tests on travis at all * style(fixes) * fix(add tests) * fix(recent_signer bug) * fix(complete all tests) * fix(nits) * fix(simplify asserts) * fix(cliqueState): simplify code * fix(nits) * docs(comments what's need to fixed) * fix(revert unintended changes) * fix(tests) * fix(logs): voting logs * fix(readability + more logs) * fix(sync) * docs(add missing licens header) * fix(log): info! -> trace! * docs(fix nits) + fix(remove assert) * perf(use counter instead of vec) * fix(remove needless block in match) * fix(faulty comment) * grumbles(docs for tests) * fix(nits) * fix(revert_vote): only remove vote when votes == 0 * fix(vote counter): checked arithmetics * fix(simplify tests) * fix(nits) * fix(clique): err types * fix(clique utils): make use of errors * fix(cleanup nits) * fix(clique sealing): don't read state no signer * fix(replace Vec<Signers> with BTreeSet<Signers>) * fix(tests): BTreeSet and more generic helpers * fix(nits) * fix(ethcore_block_seal): remove needless `Box` * fix(faulty log): info -> trace * fix(checked SystemTime): prevent SystemTime panics * style(chain cfg): space after `:` * style(fn enact): fix whitespace * docs(clique): StepService * docs(nit): fix faulty comment * docs(fix typo) * style(fix bad indentation) * fix(bad regex match) * grumble(on_seal_block): make `&mut` to avoid clone * docs(on_seal_block): fix faulty documentation * Delete .travis.yml * docs: remove eth hf references in spec * Update client.rs * fix(nits) * fix(clique step): `RwLock` -> `AtomicBool` * fix(clique): use `Duration::as_millis` * Clean up some Clique documentation Co-authored-by: soc1c <soc1c@users.noreply.github.com> Co-authored-by: HCastano <HCastano@users.noreply.github.com> Co-authored-by: niklasad1 <niklasad1@users.noreply.github.com> Co-authored-by: jwasinger <jwasinger@users.noreply.github.com> Co-authored-by: ChainSafe <ChainSafe@users.noreply.github.com> Co-authored-by: thefallentree <thefallentree@users.noreply.github.com> Co-authored-by: 5chdn <5chdn@users.noreply.github.com>
2019-03-26 23:31:52 +01:00
/// Number of first block where EIP-140 rules begin.
2017-05-23 15:49:17 +02:00
pub eip140_transition: BlockNumber,
ethcore: add clique engine (#9981) * fix broken sync * correct seal fields * ethcore: fix comment * parity: remove duplicate params * clique: fix whitespaces * ethcore: fix goerli chain spec * refactor signer_snapshot into pending/finalized state * move close_block_extra_data after seal is applied * refactor most of the logic into the signer_snapshot * clique: refactor locking logic out of the consensus engine interface * Fix jsonspec and add an unittest * Replace space with tabs * Unbroke sync * Fix broken sync * 1/2 state tracking without votes * 2/2 implement vote tracking * ci: use travis for goerli * ci: setup a clique network * ci: sync a görli node * add clique deploy script * ci: fix paths in clique deploy script * ci: use docker compose * ci: fix travis job names * ci: fix build deps * ci: massively reduce tests * Revert "ci: massively reduce tests" This reverts commit 6369f0b069ed2607a7e9f2e1d85489bacdc43384. * ci: run cargo test directly * ci: separate build and test stages * ci: cache rust installation * ci: simplify ci stages * ci: make clique deploy script executable * ci: shutdown goerli sync after 20min * ci: remove slow sync stage * ci: use timeout to finish jobs * ci: fix build path * ci: use absolute paths to end this confusion * ci: add geth and parity to path * ci: be more verbose * ci: allow for more relaxed caching timeout * ci: update repositories for custom ppa * ci: fix typo in file name * ci: fix docker compose file * ci: add ethkey to docker * ci: make sure deploy script is up to date with upstream * ci: stop docker container after certain time * ci: force superuser to update permissions on docker files * ci: reduce run time of script to ~30 min * ci: remove duplicate caching in travis * remove trace statements * clique: add more validation involving the recent signer list * ethcore: enable constantinople for rinkeby * ethcore: fix whitespaces in rinkeby spec * ethcore: reformat goerli.json * Revert "ci: remove duplicate caching in travis" This reverts commit a562838d3d194d37f9871dcbe00b783637978f89. * tmp commit * another tmp commit * it builds! * add sealing capabilities * add seal_header hook to allow separation of block seal/importing code paths * clique: remove populate_from_parent. * add panic * make turn delay random * initialize OpenBlock properly in 'enact' * misc: remove duplicate lines * misc: fix license headers * misc: convert spaces to tabs * misc: fix tabs * Update Cargo.toml * Update Cargo.toml * Update Cargo.toml * clique: ensure validator restores state before trying to seal * clique: make 'state' return an Error. Make some error messages more clear * Fix compile error after rebase & toolchain upgrade * fix a bunch of import warnings * Refactor code * Fix permissions * Refactoring syncing * Implement full validator checks * Refactor util functions to seperate file * mining 1 * ethcore: add chainspec for kotti * ethcore: rename pre-goerli configs * ethcore: load kotti chain spec * cli: add kotti to params * Implement working local sealing * making sealing & syncing work together * Relax timestamp checking * ethcore: prepare for the real goerli to launch * Implement NOTURN wiggle properly & cleanupnup warnings * Implement vote casting * Update docs & skip signing if no signer * Optimize step-service interval * Record state on local sealed block * Fix script filemode * Cleaning up codebase * restore enact trace logging * Delete clique.sh and move sync.sh * remove travis.yml * Remove dead code * Cleanup compile warning * address review comments * adding more comments and removing unwrap() * ci: remove sync script * Address review comments * fix compile error * adding better debugging for timing * Implement an dedicated thread for sealing timing * fix(add helper for timestamp overflows) (#10330) * fix(add helper timestamp overflows) * fix(simplify code) * fix(make helper private) * snap: official image / test (#10168) * official image / test * fix / test * bit more necromancy * fix paths * add source bin/df /test * add source bin/df /test2 * something w paths /test * something w paths /test * add source-type /test * show paths /test * copy plugin /test * plugin -> nil * install rhash * no questions while installing rhash * publish snap only for release * fix(docker): fix not receives SIGINT (#10059) * fix(docker): fix not receives SIGINT * fix: update with reviews * update with review * update * update * Don't add discovery initiators to the node table (#10305) * Don't add discovery initiators to the node table * Use enums for tracking state of the nodes in discovery * Dont try to ping ourselves * Fix minor nits * Update timeouts when observing an outdated node * Extracted update_bucket_record from update_node * Fixed typo * Fix two final nits from @todr * change docker image based on debian instead of ubuntu due to the chan… (#10336) * change docker image based on debian instead of ubuntu due to the changes of the build container * role back docker build image and docker deploy image to ubuntu:xenial based (#10338) * Bundle protocol and packet_id together in chain sync (#10315) Define a new `enum` where devp2p subprotocol packet ids (currently eth and par) are defined. Additionally provide functionality to query id value and protocol of a given id object. * snap: prefix version and populate candidate channel (#10343) * snap: populate candidate releases with beta snaps to avoid stale channel * snap: prefix version with v* * addressing review comments * engine: fix copyright header * scripts: restore permissions on sign command * ethcore: enforce tabs * ethcore: enforce tabs * ethcore: enforce tabs * addressing comments * addressing comments * addressing more comments * addressing more comments * addressing more comments * addressing more comments * addressing more comments * json-spec: fix clique epoch to non-zero u64 * ci: enable travis for parity goerli * ci: don't separate build and test step * ci: don't run c++ tests on travis * ci: simplify cargo test to squeeze into travis timeout * ci: don't run tests on travis at all * style(fixes) * fix(add tests) * fix(recent_signer bug) * fix(complete all tests) * fix(nits) * fix(simplify asserts) * fix(cliqueState): simplify code * fix(nits) * docs(comments what's need to fixed) * fix(revert unintended changes) * fix(tests) * fix(logs): voting logs * fix(readability + more logs) * fix(sync) * docs(add missing licens header) * fix(log): info! -> trace! * docs(fix nits) + fix(remove assert) * perf(use counter instead of vec) * fix(remove needless block in match) * fix(faulty comment) * grumbles(docs for tests) * fix(nits) * fix(revert_vote): only remove vote when votes == 0 * fix(vote counter): checked arithmetics * fix(simplify tests) * fix(nits) * fix(clique): err types * fix(clique utils): make use of errors * fix(cleanup nits) * fix(clique sealing): don't read state no signer * fix(replace Vec<Signers> with BTreeSet<Signers>) * fix(tests): BTreeSet and more generic helpers * fix(nits) * fix(ethcore_block_seal): remove needless `Box` * fix(faulty log): info -> trace * fix(checked SystemTime): prevent SystemTime panics * style(chain cfg): space after `:` * style(fn enact): fix whitespace * docs(clique): StepService * docs(nit): fix faulty comment * docs(fix typo) * style(fix bad indentation) * fix(bad regex match) * grumble(on_seal_block): make `&mut` to avoid clone * docs(on_seal_block): fix faulty documentation * Delete .travis.yml * docs: remove eth hf references in spec * Update client.rs * fix(nits) * fix(clique step): `RwLock` -> `AtomicBool` * fix(clique): use `Duration::as_millis` * Clean up some Clique documentation Co-authored-by: soc1c <soc1c@users.noreply.github.com> Co-authored-by: HCastano <HCastano@users.noreply.github.com> Co-authored-by: niklasad1 <niklasad1@users.noreply.github.com> Co-authored-by: jwasinger <jwasinger@users.noreply.github.com> Co-authored-by: ChainSafe <ChainSafe@users.noreply.github.com> Co-authored-by: thefallentree <thefallentree@users.noreply.github.com> Co-authored-by: 5chdn <5chdn@users.noreply.github.com>
2019-03-26 23:31:52 +01:00
/// Number of first block where EIP-210 rules begin.
pub eip210_transition: BlockNumber,
/// EIP-210 Blockhash contract address.
pub eip210_contract_address: Address,
/// EIP-210 Blockhash contract code.
pub eip210_contract_code: Bytes,
/// Gas allocated for EIP-210 blockhash update.
pub eip210_contract_gas: U256,
ethcore: add clique engine (#9981) * fix broken sync * correct seal fields * ethcore: fix comment * parity: remove duplicate params * clique: fix whitespaces * ethcore: fix goerli chain spec * refactor signer_snapshot into pending/finalized state * move close_block_extra_data after seal is applied * refactor most of the logic into the signer_snapshot * clique: refactor locking logic out of the consensus engine interface * Fix jsonspec and add an unittest * Replace space with tabs * Unbroke sync * Fix broken sync * 1/2 state tracking without votes * 2/2 implement vote tracking * ci: use travis for goerli * ci: setup a clique network * ci: sync a görli node * add clique deploy script * ci: fix paths in clique deploy script * ci: use docker compose * ci: fix travis job names * ci: fix build deps * ci: massively reduce tests * Revert "ci: massively reduce tests" This reverts commit 6369f0b069ed2607a7e9f2e1d85489bacdc43384. * ci: run cargo test directly * ci: separate build and test stages * ci: cache rust installation * ci: simplify ci stages * ci: make clique deploy script executable * ci: shutdown goerli sync after 20min * ci: remove slow sync stage * ci: use timeout to finish jobs * ci: fix build path * ci: use absolute paths to end this confusion * ci: add geth and parity to path * ci: be more verbose * ci: allow for more relaxed caching timeout * ci: update repositories for custom ppa * ci: fix typo in file name * ci: fix docker compose file * ci: add ethkey to docker * ci: make sure deploy script is up to date with upstream * ci: stop docker container after certain time * ci: force superuser to update permissions on docker files * ci: reduce run time of script to ~30 min * ci: remove duplicate caching in travis * remove trace statements * clique: add more validation involving the recent signer list * ethcore: enable constantinople for rinkeby * ethcore: fix whitespaces in rinkeby spec * ethcore: reformat goerli.json * Revert "ci: remove duplicate caching in travis" This reverts commit a562838d3d194d37f9871dcbe00b783637978f89. * tmp commit * another tmp commit * it builds! * add sealing capabilities * add seal_header hook to allow separation of block seal/importing code paths * clique: remove populate_from_parent. * add panic * make turn delay random * initialize OpenBlock properly in 'enact' * misc: remove duplicate lines * misc: fix license headers * misc: convert spaces to tabs * misc: fix tabs * Update Cargo.toml * Update Cargo.toml * Update Cargo.toml * clique: ensure validator restores state before trying to seal * clique: make 'state' return an Error. Make some error messages more clear * Fix compile error after rebase & toolchain upgrade * fix a bunch of import warnings * Refactor code * Fix permissions * Refactoring syncing * Implement full validator checks * Refactor util functions to seperate file * mining 1 * ethcore: add chainspec for kotti * ethcore: rename pre-goerli configs * ethcore: load kotti chain spec * cli: add kotti to params * Implement working local sealing * making sealing & syncing work together * Relax timestamp checking * ethcore: prepare for the real goerli to launch * Implement NOTURN wiggle properly & cleanupnup warnings * Implement vote casting * Update docs & skip signing if no signer * Optimize step-service interval * Record state on local sealed block * Fix script filemode * Cleaning up codebase * restore enact trace logging * Delete clique.sh and move sync.sh * remove travis.yml * Remove dead code * Cleanup compile warning * address review comments * adding more comments and removing unwrap() * ci: remove sync script * Address review comments * fix compile error * adding better debugging for timing * Implement an dedicated thread for sealing timing * fix(add helper for timestamp overflows) (#10330) * fix(add helper timestamp overflows) * fix(simplify code) * fix(make helper private) * snap: official image / test (#10168) * official image / test * fix / test * bit more necromancy * fix paths * add source bin/df /test * add source bin/df /test2 * something w paths /test * something w paths /test * add source-type /test * show paths /test * copy plugin /test * plugin -> nil * install rhash * no questions while installing rhash * publish snap only for release * fix(docker): fix not receives SIGINT (#10059) * fix(docker): fix not receives SIGINT * fix: update with reviews * update with review * update * update * Don't add discovery initiators to the node table (#10305) * Don't add discovery initiators to the node table * Use enums for tracking state of the nodes in discovery * Dont try to ping ourselves * Fix minor nits * Update timeouts when observing an outdated node * Extracted update_bucket_record from update_node * Fixed typo * Fix two final nits from @todr * change docker image based on debian instead of ubuntu due to the chan… (#10336) * change docker image based on debian instead of ubuntu due to the changes of the build container * role back docker build image and docker deploy image to ubuntu:xenial based (#10338) * Bundle protocol and packet_id together in chain sync (#10315) Define a new `enum` where devp2p subprotocol packet ids (currently eth and par) are defined. Additionally provide functionality to query id value and protocol of a given id object. * snap: prefix version and populate candidate channel (#10343) * snap: populate candidate releases with beta snaps to avoid stale channel * snap: prefix version with v* * addressing review comments * engine: fix copyright header * scripts: restore permissions on sign command * ethcore: enforce tabs * ethcore: enforce tabs * ethcore: enforce tabs * addressing comments * addressing comments * addressing more comments * addressing more comments * addressing more comments * addressing more comments * addressing more comments * json-spec: fix clique epoch to non-zero u64 * ci: enable travis for parity goerli * ci: don't separate build and test step * ci: don't run c++ tests on travis * ci: simplify cargo test to squeeze into travis timeout * ci: don't run tests on travis at all * style(fixes) * fix(add tests) * fix(recent_signer bug) * fix(complete all tests) * fix(nits) * fix(simplify asserts) * fix(cliqueState): simplify code * fix(nits) * docs(comments what's need to fixed) * fix(revert unintended changes) * fix(tests) * fix(logs): voting logs * fix(readability + more logs) * fix(sync) * docs(add missing licens header) * fix(log): info! -> trace! * docs(fix nits) + fix(remove assert) * perf(use counter instead of vec) * fix(remove needless block in match) * fix(faulty comment) * grumbles(docs for tests) * fix(nits) * fix(revert_vote): only remove vote when votes == 0 * fix(vote counter): checked arithmetics * fix(simplify tests) * fix(nits) * fix(clique): err types * fix(clique utils): make use of errors * fix(cleanup nits) * fix(clique sealing): don't read state no signer * fix(replace Vec<Signers> with BTreeSet<Signers>) * fix(tests): BTreeSet and more generic helpers * fix(nits) * fix(ethcore_block_seal): remove needless `Box` * fix(faulty log): info -> trace * fix(checked SystemTime): prevent SystemTime panics * style(chain cfg): space after `:` * style(fn enact): fix whitespace * docs(clique): StepService * docs(nit): fix faulty comment * docs(fix typo) * style(fix bad indentation) * fix(bad regex match) * grumble(on_seal_block): make `&mut` to avoid clone * docs(on_seal_block): fix faulty documentation * Delete .travis.yml * docs: remove eth hf references in spec * Update client.rs * fix(nits) * fix(clique step): `RwLock` -> `AtomicBool` * fix(clique): use `Duration::as_millis` * Clean up some Clique documentation Co-authored-by: soc1c <soc1c@users.noreply.github.com> Co-authored-by: HCastano <HCastano@users.noreply.github.com> Co-authored-by: niklasad1 <niklasad1@users.noreply.github.com> Co-authored-by: jwasinger <jwasinger@users.noreply.github.com> Co-authored-by: ChainSafe <ChainSafe@users.noreply.github.com> Co-authored-by: thefallentree <thefallentree@users.noreply.github.com> Co-authored-by: 5chdn <5chdn@users.noreply.github.com>
2019-03-26 23:31:52 +01:00
/// Number of first block where EIP-211 rules begin.
pub eip211_transition: BlockNumber,
2017-06-19 11:41:46 +02:00
/// Number of first block where EIP-214 rules begin.
pub eip214_transition: BlockNumber,
/// Number of first block where EIP-145 rules begin.
pub eip145_transition: BlockNumber,
/// Number of first block where EIP-1052 rules begin.
pub eip1052_transition: BlockNumber,
/// Number of first block where EIP-1283 rules begin.
pub eip1283_transition: BlockNumber,
/// Number of first block where EIP-1283 rules end.
pub eip1283_disable_transition: BlockNumber,
/// Number of first block where EIP-1283 rules re-enabled.
pub eip1283_reenable_transition: BlockNumber,
/// Number of first block where EIP-1014 rules begin.
pub eip1014_transition: BlockNumber,
/// Number of first block where EIP-1706 rules begin.
pub eip1706_transition: BlockNumber,
/// Number of first block where EIP-1344 rules begin: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1344.md
pub eip1344_transition: BlockNumber,
/// Number of first block where EIP-1884 rules begin:https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1884.md
pub eip1884_transition: BlockNumber,
/// Number of first block where EIP-2028 rules begin.
pub eip2028_transition: BlockNumber,
/// Number of first block where EIP-2315 rules begin.
pub eip2315_transition: BlockNumber,
2020-11-04 19:11:05 +01:00
/// Number of first block where EIP-2929 rules begin.
pub eip2929_transition: BlockNumber,
/// Number of first block where EIP-2930 rules begin.
pub eip2930_transition: BlockNumber,
/// Number of first block where dust cleanup rules (EIP-168 and EIP169) begin.
pub dust_protection_transition: BlockNumber,
/// Nonce cap increase per block. Nonce cap is only checked if dust protection is enabled.
pub nonce_cap_increment: u64,
/// Enable dust cleanup for contracts.
pub remove_dust_contracts: bool,
/// Wasm activation blocknumber, if any disabled initially.
pub wasm_activation_transition: BlockNumber,
/// Wasm deactivation blocknumber, if enabled.
pub wasm_disable_transition: BlockNumber,
/// Number of first block where KIP-4 rules begin. Only has effect if Wasm is activated.
pub kip4_transition: BlockNumber,
/// Number of first block where KIP-6 rules begin. Only has effect if Wasm is activated.
pub kip6_transition: BlockNumber,
/// Gas limit bound divisor (how much gas limit can change per block)
pub gas_limit_bound_divisor: U256,
/// Registrar contract address.
pub registrar: Address,
2017-08-29 14:38:01 +02:00
/// Node permission managing contract address.
pub node_permission_contract: Option<Address>,
/// Maximum contract code size that can be deployed.
pub max_code_size: u64,
/// Number of first block where max code size limit is active.
pub max_code_size_transition: BlockNumber,
2017-09-05 11:39:50 +02:00
/// Transaction permission managing contract address.
pub transaction_permission_contract: Option<Address>,
/// Block at which the transaction permission contract should start being used.
pub transaction_permission_contract_transition: BlockNumber,
/// Maximum size of transaction's RLP payload
pub max_transaction_size: usize,
2015-12-23 12:53:34 +01:00
}
impl CommonParams {
/// Schedule for an EVM in the post-EIP-150-era of the Ethereum main net.
pub fn schedule(&self, block_number: u64) -> ::vm::Schedule {
if block_number < self.eip150_transition {
::vm::Schedule::new_homestead()
} else {
let max_code_size = self.max_code_size(block_number);
let mut schedule = ::vm::Schedule::new_post_eip150(
max_code_size as _,
block_number >= self.eip160_transition,
block_number >= self.eip161abc_transition,
block_number >= self.eip161d_transition,
);
2020-08-05 06:08:03 +02:00
self.update_schedule(block_number, &mut schedule);
schedule
}
}
2020-08-05 06:08:03 +02:00
/// Returns max code size at given block.
pub fn max_code_size(&self, block_number: u64) -> u64 {
if block_number >= self.max_code_size_transition {
self.max_code_size
} else {
u64::max_value()
}
}
2020-08-05 06:08:03 +02:00
/// Apply common spec config parameters to the schedule.
pub fn update_schedule(&self, block_number: u64, schedule: &mut ::vm::Schedule) {
schedule.have_create2 = block_number >= self.eip1014_transition;
schedule.have_revert = block_number >= self.eip140_transition;
schedule.have_static_call = block_number >= self.eip214_transition;
schedule.have_return_data = block_number >= self.eip211_transition;
schedule.have_bitwise_shifting = block_number >= self.eip145_transition;
schedule.have_extcodehash = block_number >= self.eip1052_transition;
schedule.have_chain_id = block_number >= self.eip1344_transition;
schedule.eip1283 = (block_number >= self.eip1283_transition
&& !(block_number >= self.eip1283_disable_transition))
|| block_number >= self.eip1283_reenable_transition;
schedule.eip1706 = block_number >= self.eip1706_transition;
schedule.have_subs = block_number >= self.eip2315_transition;
2020-11-04 19:11:05 +01:00
schedule.eip2929 = block_number >= self.eip2929_transition;
schedule.eip2930 = block_number >= self.eip2930_transition;
2020-08-05 06:08:03 +02:00
if block_number >= self.eip1884_transition {
schedule.have_selfbalance = true;
schedule.sload_gas = 800;
schedule.balance_gas = 700;
schedule.extcodehash_gas = 700;
}
if block_number >= self.eip2028_transition {
schedule.tx_data_non_zero_gas = 16;
}
if block_number >= self.eip210_transition {
schedule.blockhash_gas = 800;
}
2020-11-04 19:11:05 +01:00
if block_number >= self.eip2929_transition {
schedule.eip2929 = true;
schedule.eip1283 = true;
schedule.call_gas = ::vm::schedule::EIP2929_COLD_ACCOUNT_ACCESS_COST;
schedule.balance_gas = ::vm::schedule::EIP2929_COLD_ACCOUNT_ACCESS_COST;
schedule.extcodecopy_base_gas = ::vm::schedule::EIP2929_COLD_ACCOUNT_ACCESS_COST;
schedule.extcodehash_gas = ::vm::schedule::EIP2929_COLD_ACCOUNT_ACCESS_COST;
schedule.extcodesize_gas = ::vm::schedule::EIP2929_COLD_ACCOUNT_ACCESS_COST;
schedule.cold_sload_cost = ::vm::schedule::EIP2929_COLD_SLOAD_COST;
schedule.cold_account_access_cost = ::vm::schedule::EIP2929_COLD_ACCOUNT_ACCESS_COST;
schedule.warm_storage_read_cost = ::vm::schedule::EIP2929_WARM_STORAGE_READ_COST;
schedule.sload_gas = ::vm::schedule::EIP2929_WARM_STORAGE_READ_COST;
schedule.sstore_reset_gas = ::vm::schedule::EIP2929_SSTORE_RESET_GAS;
}
if block_number >= self.dust_protection_transition {
schedule.kill_dust = match self.remove_dust_contracts {
true => ::vm::CleanDustMode::WithCodeAndStorage,
false => ::vm::CleanDustMode::BasicOnly,
};
}
if block_number >= self.wasm_activation_transition
&& block_number < self.wasm_disable_transition
{
let mut wasm = ::vm::WasmCosts::default();
if block_number >= self.kip4_transition {
wasm.have_create2 = true;
}
if block_number >= self.kip6_transition {
wasm.have_gasleft = true;
}
schedule.wasm = Some(wasm);
}
}
2020-08-05 06:08:03 +02:00
/// Return Some if the current parameters contain a bugfix hard fork not on block 0.
pub fn nonzero_bugfix_hard_fork(&self) -> Option<&str> {
if self.eip155_transition != 0 {
return Some("eip155Transition");
}
2020-08-05 06:08:03 +02:00
if self.validate_receipts_transition != 0 {
return Some("validateReceiptsTransition");
}
2020-08-05 06:08:03 +02:00
if self.validate_chain_id_transition != 0 {
return Some("validateChainIdTransition");
}
2020-08-05 06:08:03 +02:00
None
}
}
impl From<ethjson::spec::Params> for CommonParams {
fn from(p: ethjson::spec::Params) -> Self {
CommonParams {
2016-12-22 07:06:40 +01:00
account_start_nonce: p.account_start_nonce.map_or_else(U256::zero, Into::into),
maximum_extra_data_size: p.maximum_extra_data_size.into(),
network_id: p.network_id.into(),
chain_id: if let Some(n) = p.chain_id {
n.into()
} else {
p.network_id.into()
},
subprotocol_name: p.subprotocol_name.unwrap_or_else(|| "eth".to_owned()),
min_gas_limit: p.min_gas_limit.into(),
fork_block: if let (Some(n), Some(h)) = (p.fork_block, p.fork_hash) {
Some((n.into(), h.into()))
} else {
None
},
eip150_transition: p.eip150_transition.map_or(0, Into::into),
eip160_transition: p.eip160_transition.map_or(0, Into::into),
eip161abc_transition: p.eip161abc_transition.map_or(0, Into::into),
eip161d_transition: p.eip161d_transition.map_or(0, Into::into),
eip98_transition: p
.eip98_transition
.map_or_else(BlockNumber::max_value, Into::into),
eip155_transition: p.eip155_transition.map_or(0, Into::into),
validate_receipts_transition: p.validate_receipts_transition.map_or(0, Into::into),
validate_chain_id_transition: p.validate_chain_id_transition.map_or(0, Into::into),
eip140_transition: p
.eip140_transition
.map_or_else(BlockNumber::max_value, Into::into),
eip210_transition: p
.eip210_transition
.map_or_else(BlockNumber::max_value, Into::into),
eip210_contract_address: p.eip210_contract_address.map_or(0xf0.into(), Into::into),
eip210_contract_code: p.eip210_contract_code.map_or_else(
|| {
DEFAULT_BLOCKHASH_CONTRACT
.from_hex()
.expect("Default BLOCKHASH contract is valid")
},
Into::into,
),
eip210_contract_gas: p.eip210_contract_gas.map_or(1000000.into(), Into::into),
eip211_transition: p
.eip211_transition
.map_or_else(BlockNumber::max_value, Into::into),
eip145_transition: p
.eip145_transition
.map_or_else(BlockNumber::max_value, Into::into),
eip214_transition: p
.eip214_transition
.map_or_else(BlockNumber::max_value, Into::into),
eip658_transition: p
.eip658_transition
.map_or_else(BlockNumber::max_value, Into::into),
eip1052_transition: p
.eip1052_transition
.map_or_else(BlockNumber::max_value, Into::into),
eip1283_transition: p
.eip1283_transition
.map_or_else(BlockNumber::max_value, Into::into),
eip1283_disable_transition: p
.eip1283_disable_transition
.map_or_else(BlockNumber::max_value, Into::into),
eip1283_reenable_transition: p
.eip1283_reenable_transition
.map_or_else(BlockNumber::max_value, Into::into),
eip1706_transition: p
.eip1706_transition
.map_or_else(BlockNumber::max_value, Into::into),
eip1014_transition: p
.eip1014_transition
.map_or_else(BlockNumber::max_value, Into::into),
eip1344_transition: p
.eip1344_transition
.map_or_else(BlockNumber::max_value, Into::into),
eip1884_transition: p
.eip1884_transition
.map_or_else(BlockNumber::max_value, Into::into),
eip2028_transition: p
.eip2028_transition
.map_or_else(BlockNumber::max_value, Into::into),
eip2315_transition: p
.eip2315_transition
.map_or_else(BlockNumber::max_value, Into::into),
2020-11-04 19:11:05 +01:00
eip2929_transition: p
.eip2929_transition
.map_or_else(BlockNumber::max_value, Into::into),
eip2930_transition: p
.eip2930_transition
.map_or_else(BlockNumber::max_value, Into::into),
dust_protection_transition: p
.dust_protection_transition
.map_or_else(BlockNumber::max_value, Into::into),
nonce_cap_increment: p.nonce_cap_increment.map_or(64, Into::into),
remove_dust_contracts: p.remove_dust_contracts.unwrap_or(false),
gas_limit_bound_divisor: p.gas_limit_bound_divisor.into(),
registrar: p.registrar.map_or_else(Address::new, Into::into),
2017-08-29 14:38:01 +02:00
node_permission_contract: p.node_permission_contract.map(Into::into),
max_code_size: p.max_code_size.map_or(u64::max_value(), Into::into),
max_transaction_size: p
.max_transaction_size
.map_or(MAX_TRANSACTION_SIZE, Into::into),
max_code_size_transition: p.max_code_size_transition.map_or(0, Into::into),
2017-09-05 11:39:50 +02:00
transaction_permission_contract: p.transaction_permission_contract.map(Into::into),
transaction_permission_contract_transition: p
.transaction_permission_contract_transition
.map_or(0, Into::into),
wasm_activation_transition: p
.wasm_activation_transition
.map_or_else(BlockNumber::max_value, Into::into),
wasm_disable_transition: p
.wasm_disable_transition
.map_or_else(BlockNumber::max_value, Into::into),
kip4_transition: p
.kip4_transition
.map_or_else(BlockNumber::max_value, Into::into),
kip6_transition: p
.kip6_transition
.map_or_else(BlockNumber::max_value, Into::into),
}
}
}
/// Runtime parameters for the spec that are related to how the software should run the chain,
/// rather than integral properties of the chain itself.
#[derive(Debug, Clone, Copy)]
pub struct SpecParams<'a> {
/// The path to the folder used to cache nodes. This is typically /tmp/ on Unix-like systems
pub cache_dir: &'a Path,
/// Whether to run slower at the expense of better memory usage, or run faster while using
/// more
/// memory. This may get more fine-grained in the future but for now is simply a binary
/// option.
pub optimization_setting: Option<OptimizeFor>,
}
impl<'a> SpecParams<'a> {
/// Create from a cache path, with null values for the other fields
pub fn from_path(path: &'a Path) -> Self {
SpecParams {
cache_dir: path,
optimization_setting: None,
}
}
2020-08-05 06:08:03 +02:00
/// Create from a cache path and an optimization setting
pub fn new(path: &'a Path, optimization: OptimizeFor) -> Self {
SpecParams {
cache_dir: path,
optimization_setting: Some(optimization),
}
}
}
impl<'a, T: AsRef<Path>> From<&'a T> for SpecParams<'a> {
fn from(path: &'a T) -> Self {
Self::from_path(path.as_ref())
}
}
/// Parameters for a block chain; includes both those intrinsic to the design of the
/// chain and those to be interpreted by the active chain engine.
pub struct Spec {
2016-02-03 13:20:32 +01:00
/// User friendly spec name
pub name: String,
2016-02-03 13:20:32 +01:00
/// What engine are we using for this?
2020-07-29 10:36:15 +02:00
pub engine: Arc<dyn EthEngine>,
2016-12-12 23:21:44 +01:00
/// Name of the subdir inside the main data dir to use for chain data and settings.
2016-12-12 16:51:07 +01:00
pub data_dir: String,
2020-08-05 06:08:03 +02:00
2016-01-23 23:53:20 +01:00
/// Known nodes on the network in enode format.
pub nodes: Vec<String>,
2020-08-05 06:08:03 +02:00
2016-02-03 13:20:32 +01:00
/// The genesis block's parent hash field.
pub parent_hash: H256,
2016-02-03 13:20:32 +01:00
/// The genesis block's author field.
pub author: Address,
2016-02-03 13:20:32 +01:00
/// The genesis block's difficulty field.
pub difficulty: U256,
2016-02-03 13:20:32 +01:00
/// The genesis block's gas limit field.
pub gas_limit: U256,
2016-02-03 13:20:32 +01:00
/// The genesis block's gas used field.
pub gas_used: U256,
2016-02-03 13:20:32 +01:00
/// The genesis block's timestamp field.
pub timestamp: u64,
/// Transactions root of the genesis block. Should be KECCAK_NULL_RLP.
pub transactions_root: H256,
/// Receipts root of the genesis block. Should be KECCAK_NULL_RLP.
pub receipts_root: H256,
2016-02-03 13:20:32 +01:00
/// The genesis block's extra data field.
pub extra_data: Bytes,
2016-02-03 13:20:32 +01:00
/// Each seal field, expressed as RLP, concatenated.
pub seal_rlp: Bytes,
2020-08-05 06:08:03 +02:00
/// List of hard forks in the network.
pub hard_forks: BTreeSet<BlockNumber>,
/// Contract constructors to be executed on genesis.
constructors: Vec<(Address, Bytes)>,
2020-08-05 06:08:03 +02:00
/// May be prepopulated if we know this in advance.
state_root_memo: RwLock<H256>,
2020-08-05 06:08:03 +02:00
/// Genesis state as plain old data.
2016-02-03 13:20:32 +01:00
genesis_state: PodState,
}
#[cfg(test)]
impl Clone for Spec {
fn clone(&self) -> Spec {
Spec {
name: self.name.clone(),
engine: self.engine.clone(),
data_dir: self.data_dir.clone(),
nodes: self.nodes.clone(),
parent_hash: self.parent_hash.clone(),
transactions_root: self.transactions_root.clone(),
receipts_root: self.receipts_root.clone(),
author: self.author.clone(),
difficulty: self.difficulty.clone(),
gas_limit: self.gas_limit.clone(),
gas_used: self.gas_used.clone(),
timestamp: self.timestamp.clone(),
extra_data: self.extra_data.clone(),
seal_rlp: self.seal_rlp.clone(),
hard_forks: self.hard_forks.clone(),
constructors: self.constructors.clone(),
state_root_memo: RwLock::new(*self.state_root_memo.read()),
genesis_state: self.genesis_state.clone(),
}
}
}
fn load_machine_from(s: ethjson::spec::Spec) -> EthereumMachine {
v2.5.10 stable (#11239) * ropsten #6631425 foundation #8798209 (#11201) * [stable] builtin, istanbul and mordor testnet backports (#11234) * ethcore-builtin (#10850) * [builtin]: support `multiple prices and activations` in chain spec (#11039) * [chain specs]: activate `Istanbul` on mainnet (#11228) * ethcore/res: add mordor testnet configuration (#11200) * Update list of bootnodes for xDai chain (#11236) * ethcore: remove `test-helper feat` from build (#11047) * Secret store: fix Instant::now() related race in net_keep_alive (#11155) (#11159) * [stable]: backport #10691 and #10683 (#11143) * Fix compiler warning (that will become an error) (#10683) * Refactor Clique stepping (#10691) * Add Constantinople eips to the dev (instant_seal) config (#10809) * Add cargo-remote dir to .gitignore (?) * Insert explicit warning into the panic hook (#11225) * Fix docker centos build (#11226) * Update MIX bootnodes. (#11203) * Use provided usd-per-eth value if an endpoint is specified (#11209) * Add new line after writing block to hex file. (#10984) * Type annotation for next_key() matching of json filter options (#11192) (but no `FilterOption` in 2.5 so…) * Upgrade jsonrpc to latest (#11206) * [CI] check evmbin build (#11096) * Correct EIP-712 encoding (#11092) * [client]: Fix for incorrectly dropped consensus messages (#11086) * Fix block detail updating (#11015) * Switching sccache from local to Redis (#10971) * Made ecrecover implementation trait public (#11188) * [dependencies]: jsonrpc `14.0.1` (#11183) * [receipt]: add `sender` & `receiver` to `RichReceipts` (#11179) * [ethcore/builtin]: do not panic in blake2pricer on short input (#11180) * util Host: fix a double Read Lock bug in fn Host::session_readable() (#11175) * ethcore client: fix a double Read Lock bug in fn Client::logs() (#11172) * Change how RPCs eth_call and eth_estimateGas handle "Pending" (#11127) * Cleanup stratum a bit (#11161) * Upgrade to jsonrpc v14 (#11151) * SecretStore: expose restore_key_public in HTTP API (#10241)
2019-11-11 21:57:38 +01:00
let builtins = s
.accounts
.builtins()
.into_iter()
.map(|p| {
(
p.0.into(),
Builtin::try_from(p.1).expect("chain spec is invalid"),
2020-08-05 06:08:03 +02:00
)
})
v2.5.10 stable (#11239) * ropsten #6631425 foundation #8798209 (#11201) * [stable] builtin, istanbul and mordor testnet backports (#11234) * ethcore-builtin (#10850) * [builtin]: support `multiple prices and activations` in chain spec (#11039) * [chain specs]: activate `Istanbul` on mainnet (#11228) * ethcore/res: add mordor testnet configuration (#11200) * Update list of bootnodes for xDai chain (#11236) * ethcore: remove `test-helper feat` from build (#11047) * Secret store: fix Instant::now() related race in net_keep_alive (#11155) (#11159) * [stable]: backport #10691 and #10683 (#11143) * Fix compiler warning (that will become an error) (#10683) * Refactor Clique stepping (#10691) * Add Constantinople eips to the dev (instant_seal) config (#10809) * Add cargo-remote dir to .gitignore (?) * Insert explicit warning into the panic hook (#11225) * Fix docker centos build (#11226) * Update MIX bootnodes. (#11203) * Use provided usd-per-eth value if an endpoint is specified (#11209) * Add new line after writing block to hex file. (#10984) * Type annotation for next_key() matching of json filter options (#11192) (but no `FilterOption` in 2.5 so…) * Upgrade jsonrpc to latest (#11206) * [CI] check evmbin build (#11096) * Correct EIP-712 encoding (#11092) * [client]: Fix for incorrectly dropped consensus messages (#11086) * Fix block detail updating (#11015) * Switching sccache from local to Redis (#10971) * Made ecrecover implementation trait public (#11188) * [dependencies]: jsonrpc `14.0.1` (#11183) * [receipt]: add `sender` & `receiver` to `RichReceipts` (#11179) * [ethcore/builtin]: do not panic in blake2pricer on short input (#11180) * util Host: fix a double Read Lock bug in fn Host::session_readable() (#11175) * ethcore client: fix a double Read Lock bug in fn Client::logs() (#11172) * Change how RPCs eth_call and eth_estimateGas handle "Pending" (#11127) * Cleanup stratum a bit (#11161) * Upgrade to jsonrpc v14 (#11151) * SecretStore: expose restore_key_public in HTTP API (#10241)
2019-11-11 21:57:38 +01:00
.collect();
let params = CommonParams::from(s.params);
2020-08-05 06:08:03 +02:00
Spec::machine(&s.engine, params, builtins)
}
v2.5.10 stable (#11239) * ropsten #6631425 foundation #8798209 (#11201) * [stable] builtin, istanbul and mordor testnet backports (#11234) * ethcore-builtin (#10850) * [builtin]: support `multiple prices and activations` in chain spec (#11039) * [chain specs]: activate `Istanbul` on mainnet (#11228) * ethcore/res: add mordor testnet configuration (#11200) * Update list of bootnodes for xDai chain (#11236) * ethcore: remove `test-helper feat` from build (#11047) * Secret store: fix Instant::now() related race in net_keep_alive (#11155) (#11159) * [stable]: backport #10691 and #10683 (#11143) * Fix compiler warning (that will become an error) (#10683) * Refactor Clique stepping (#10691) * Add Constantinople eips to the dev (instant_seal) config (#10809) * Add cargo-remote dir to .gitignore (?) * Insert explicit warning into the panic hook (#11225) * Fix docker centos build (#11226) * Update MIX bootnodes. (#11203) * Use provided usd-per-eth value if an endpoint is specified (#11209) * Add new line after writing block to hex file. (#10984) * Type annotation for next_key() matching of json filter options (#11192) (but no `FilterOption` in 2.5 so…) * Upgrade jsonrpc to latest (#11206) * [CI] check evmbin build (#11096) * Correct EIP-712 encoding (#11092) * [client]: Fix for incorrectly dropped consensus messages (#11086) * Fix block detail updating (#11015) * Switching sccache from local to Redis (#10971) * Made ecrecover implementation trait public (#11188) * [dependencies]: jsonrpc `14.0.1` (#11183) * [receipt]: add `sender` & `receiver` to `RichReceipts` (#11179) * [ethcore/builtin]: do not panic in blake2pricer on short input (#11180) * util Host: fix a double Read Lock bug in fn Host::session_readable() (#11175) * ethcore client: fix a double Read Lock bug in fn Client::logs() (#11172) * Change how RPCs eth_call and eth_estimateGas handle "Pending" (#11127) * Cleanup stratum a bit (#11161) * Upgrade to jsonrpc v14 (#11151) * SecretStore: expose restore_key_public in HTTP API (#10241)
2019-11-11 21:57:38 +01:00
fn convert_json_to_spec(
(address, builtin): (ethjson::hash::Address, ethjson::spec::builtin::Builtin),
) -> Result<(Address, Builtin), Error> {
let builtin = Builtin::try_from(builtin)?;
Ok((address.into(), builtin))
}
/// Load from JSON object.
fn load_from(spec_params: SpecParams, s: ethjson::spec::Spec) -> Result<Spec, Error> {
v2.5.10 stable (#11239) * ropsten #6631425 foundation #8798209 (#11201) * [stable] builtin, istanbul and mordor testnet backports (#11234) * ethcore-builtin (#10850) * [builtin]: support `multiple prices and activations` in chain spec (#11039) * [chain specs]: activate `Istanbul` on mainnet (#11228) * ethcore/res: add mordor testnet configuration (#11200) * Update list of bootnodes for xDai chain (#11236) * ethcore: remove `test-helper feat` from build (#11047) * Secret store: fix Instant::now() related race in net_keep_alive (#11155) (#11159) * [stable]: backport #10691 and #10683 (#11143) * Fix compiler warning (that will become an error) (#10683) * Refactor Clique stepping (#10691) * Add Constantinople eips to the dev (instant_seal) config (#10809) * Add cargo-remote dir to .gitignore (?) * Insert explicit warning into the panic hook (#11225) * Fix docker centos build (#11226) * Update MIX bootnodes. (#11203) * Use provided usd-per-eth value if an endpoint is specified (#11209) * Add new line after writing block to hex file. (#10984) * Type annotation for next_key() matching of json filter options (#11192) (but no `FilterOption` in 2.5 so…) * Upgrade jsonrpc to latest (#11206) * [CI] check evmbin build (#11096) * Correct EIP-712 encoding (#11092) * [client]: Fix for incorrectly dropped consensus messages (#11086) * Fix block detail updating (#11015) * Switching sccache from local to Redis (#10971) * Made ecrecover implementation trait public (#11188) * [dependencies]: jsonrpc `14.0.1` (#11183) * [receipt]: add `sender` & `receiver` to `RichReceipts` (#11179) * [ethcore/builtin]: do not panic in blake2pricer on short input (#11180) * util Host: fix a double Read Lock bug in fn Host::session_readable() (#11175) * ethcore client: fix a double Read Lock bug in fn Client::logs() (#11172) * Change how RPCs eth_call and eth_estimateGas handle "Pending" (#11127) * Cleanup stratum a bit (#11161) * Upgrade to jsonrpc v14 (#11151) * SecretStore: expose restore_key_public in HTTP API (#10241)
2019-11-11 21:57:38 +01:00
let builtins: Result<BTreeMap<Address, Builtin>, _> = s
.accounts
.builtins()
.into_iter()
v2.5.10 stable (#11239) * ropsten #6631425 foundation #8798209 (#11201) * [stable] builtin, istanbul and mordor testnet backports (#11234) * ethcore-builtin (#10850) * [builtin]: support `multiple prices and activations` in chain spec (#11039) * [chain specs]: activate `Istanbul` on mainnet (#11228) * ethcore/res: add mordor testnet configuration (#11200) * Update list of bootnodes for xDai chain (#11236) * ethcore: remove `test-helper feat` from build (#11047) * Secret store: fix Instant::now() related race in net_keep_alive (#11155) (#11159) * [stable]: backport #10691 and #10683 (#11143) * Fix compiler warning (that will become an error) (#10683) * Refactor Clique stepping (#10691) * Add Constantinople eips to the dev (instant_seal) config (#10809) * Add cargo-remote dir to .gitignore (?) * Insert explicit warning into the panic hook (#11225) * Fix docker centos build (#11226) * Update MIX bootnodes. (#11203) * Use provided usd-per-eth value if an endpoint is specified (#11209) * Add new line after writing block to hex file. (#10984) * Type annotation for next_key() matching of json filter options (#11192) (but no `FilterOption` in 2.5 so…) * Upgrade jsonrpc to latest (#11206) * [CI] check evmbin build (#11096) * Correct EIP-712 encoding (#11092) * [client]: Fix for incorrectly dropped consensus messages (#11086) * Fix block detail updating (#11015) * Switching sccache from local to Redis (#10971) * Made ecrecover implementation trait public (#11188) * [dependencies]: jsonrpc `14.0.1` (#11183) * [receipt]: add `sender` & `receiver` to `RichReceipts` (#11179) * [ethcore/builtin]: do not panic in blake2pricer on short input (#11180) * util Host: fix a double Read Lock bug in fn Host::session_readable() (#11175) * ethcore client: fix a double Read Lock bug in fn Client::logs() (#11172) * Change how RPCs eth_call and eth_estimateGas handle "Pending" (#11127) * Cleanup stratum a bit (#11161) * Upgrade to jsonrpc v14 (#11151) * SecretStore: expose restore_key_public in HTTP API (#10241)
2019-11-11 21:57:38 +01:00
.map(convert_json_to_spec)
.collect();
v2.5.10 stable (#11239) * ropsten #6631425 foundation #8798209 (#11201) * [stable] builtin, istanbul and mordor testnet backports (#11234) * ethcore-builtin (#10850) * [builtin]: support `multiple prices and activations` in chain spec (#11039) * [chain specs]: activate `Istanbul` on mainnet (#11228) * ethcore/res: add mordor testnet configuration (#11200) * Update list of bootnodes for xDai chain (#11236) * ethcore: remove `test-helper feat` from build (#11047) * Secret store: fix Instant::now() related race in net_keep_alive (#11155) (#11159) * [stable]: backport #10691 and #10683 (#11143) * Fix compiler warning (that will become an error) (#10683) * Refactor Clique stepping (#10691) * Add Constantinople eips to the dev (instant_seal) config (#10809) * Add cargo-remote dir to .gitignore (?) * Insert explicit warning into the panic hook (#11225) * Fix docker centos build (#11226) * Update MIX bootnodes. (#11203) * Use provided usd-per-eth value if an endpoint is specified (#11209) * Add new line after writing block to hex file. (#10984) * Type annotation for next_key() matching of json filter options (#11192) (but no `FilterOption` in 2.5 so…) * Upgrade jsonrpc to latest (#11206) * [CI] check evmbin build (#11096) * Correct EIP-712 encoding (#11092) * [client]: Fix for incorrectly dropped consensus messages (#11086) * Fix block detail updating (#11015) * Switching sccache from local to Redis (#10971) * Made ecrecover implementation trait public (#11188) * [dependencies]: jsonrpc `14.0.1` (#11183) * [receipt]: add `sender` & `receiver` to `RichReceipts` (#11179) * [ethcore/builtin]: do not panic in blake2pricer on short input (#11180) * util Host: fix a double Read Lock bug in fn Host::session_readable() (#11175) * ethcore client: fix a double Read Lock bug in fn Client::logs() (#11172) * Change how RPCs eth_call and eth_estimateGas handle "Pending" (#11127) * Cleanup stratum a bit (#11161) * Upgrade to jsonrpc v14 (#11151) * SecretStore: expose restore_key_public in HTTP API (#10241)
2019-11-11 21:57:38 +01:00
let builtins = builtins?;
let g = Genesis::from(s.genesis);
let GenericSeal(seal_rlp) = g.seal.into();
let params = CommonParams::from(s.params);
2020-08-05 06:08:03 +02:00
let (engine, hard_forks) = Spec::engine(spec_params, s.engine, params, builtins);
let mut s = Spec {
name: s.name.clone().into(),
engine,
data_dir: s.data_dir.unwrap_or(s.name).into(),
nodes: s.nodes.unwrap_or_else(Vec::new),
parent_hash: g.parent_hash,
transactions_root: g.transactions_root,
receipts_root: g.receipts_root,
author: g.author,
difficulty: g.difficulty,
gas_limit: g.gas_limit,
gas_used: g.gas_used,
timestamp: g.timestamp,
extra_data: g.extra_data,
seal_rlp: seal_rlp,
hard_forks,
constructors: s
.accounts
.constructors()
.into_iter()
.map(|(a, c)| (a.into(), c.into()))
.collect(),
state_root_memo: RwLock::new(Default::default()), // will be overwritten right after.
genesis_state: s.accounts.into(),
};
2020-08-05 06:08:03 +02:00
// use memoized state root if provided.
match g.state_root {
Some(root) => *s.state_root_memo.get_mut() = root,
None => {
let _ = s.run_constructors(
&Default::default(),
BasicBackend(journaldb::new_memory_db()),
)?;
}
}
2020-08-05 06:08:03 +02:00
Ok(s)
}
2016-11-11 17:37:44 +01:00
macro_rules! load_bundled {
($e:expr) => {
Spec::load(
&::std::env::temp_dir(),
include_bytes!(concat!("../../res/", $e, ".json")) as &[u8],
)
.expect(concat!("Chain spec ", $e, " is invalid."))
2016-11-11 17:37:44 +01:00
};
}
#[cfg(any(test, feature = "test-helpers"))]
macro_rules! load_machine_bundled {
($e:expr) => {
Spec::load_machine(include_bytes!(concat!("../../res/", $e, ".json")) as &[u8])
.expect(concat!("Chain spec ", $e, " is invalid."))
};
}
impl Spec {
// create an instance of an Ethereum state machine, minus consensus logic.
fn machine(
engine_spec: &ethjson::spec::Engine,
params: CommonParams,
builtins: BTreeMap<Address, Builtin>,
) -> EthereumMachine {
if let ethjson::spec::Engine::Ethash(ref ethash) = *engine_spec {
EthereumMachine::with_ethash_extensions(params, builtins, ethash.params.clone().into())
} else {
EthereumMachine::regular(params, builtins)
}
}
2020-08-05 06:08:03 +02:00
Snapshot creation and restoration (#1679) * to_rlp takes self by-reference * clean up some derefs * out-of-order insertion for blockchain * implement block rebuilder without verification * group block chunk header into struct * block rebuilder does verification * integrate snapshot service with client service; flesh out implementation more * initial implementation of snapshot service * remove snapshottaker trait * snapshot writer trait with packed and loose implementations * write chunks using "snapshotwriter" in service * have snapshot taking use snapshotwriter * implement snapshot readers * back up client dbs when replacing * use snapshot reader in snapshot service * describe offset format * use new get_db_path in parity, allow some errors in service * blockchain formatting * implement parity snapshot * implement snapshot restore * force blocks to be submitted in order * fix bug loading block hashes in packed reader * fix seal field loading * fix uncle hash computation * fix a few bugs * store genesis state in db. reverse block chunk order in packed writer * allow out-of-order import for blocks * bring restoration types together * only snapshot the last 30000 blocks * restore into overlaydb instead of journaldb * commit version to database * use memorydbs and commit directly * fix trie test compilation * fix failing tests * sha3_null_rlp, not H256::zero * move overlaydb to ref_overlaydb, add new overlaydb without on-disk rc * port archivedb to new overlaydb * add deletion mode tests for overlaydb * use new overlaydb, check state root at end * share chain info between state and block snapshotting * create blocks snapshot using blockchain directly * allow snapshot from arbitrary block, remove panickers from snapshot creation * begin test framework * blockchain chunking test * implement stateproducer::tick * state snapshot test * create block and state chunks concurrently, better restoration informant * fix tests * add deletion mode tests for overlaydb * address comments * more tests * Fix up tests. * remove a few printlns * add a little more documentation to `commit` * fix tests * fix ref_overlaydb test names * snapshot command skeleton * revert ref_overlaydb renaming * reimplement snapshot commands * fix many errors * everything but inject * get ethcore compiling * get snapshot tests passing again * instrument snapshot commands again * fix fallout from other changes, mark snapshots as experimental * optimize injection patterns * do two injections * fix up tests * take snapshots from 1000 blocks efore * address minor comments * fix a few io crate related errors * clarify names about total difficulty [ci skip]
2016-08-05 17:00:46 +02:00
/// Convert engine spec into a arc'd Engine of the right underlying type.
/// TODO avoid this hard-coded nastiness - use dynamic-linked plugin framework instead.
fn engine(
spec_params: SpecParams,
engine_spec: ethjson::spec::Engine,
params: CommonParams,
builtins: BTreeMap<Address, Builtin>,
) -> (Arc<dyn EthEngine>, BTreeSet<BlockNumber>) {
let mut hard_forks = btreeset![
params.eip150_transition,
params.eip160_transition,
params.eip161abc_transition,
params.eip161d_transition,
params.eip98_transition,
params.eip658_transition,
params.eip155_transition,
params.validate_receipts_transition,
params.validate_chain_id_transition,
params.eip140_transition,
params.eip210_transition,
params.eip211_transition,
params.eip214_transition,
params.eip145_transition,
params.eip1052_transition,
params.eip1283_transition,
params.eip1283_disable_transition,
params.eip1283_reenable_transition,
params.eip1014_transition,
params.eip1706_transition,
params.eip1344_transition,
params.eip1884_transition,
params.eip2028_transition,
params.eip2315_transition,
2021-01-11 14:03:53 +01:00
params.eip2929_transition,
params.eip2930_transition,
params.dust_protection_transition,
params.wasm_activation_transition,
params.wasm_disable_transition,
params.kip4_transition,
params.kip6_transition,
params.max_code_size_transition,
params.transaction_permission_contract_transition,
];
// BUG: Rinkeby has homestead transition at block 1 but we can't reflect that in specs for non-Ethash networks
if params.network_id == 0x4 {
hard_forks.insert(1);
}
let machine = Self::machine(&engine_spec, params, builtins);
2020-08-05 06:08:03 +02:00
let engine: Arc<dyn EthEngine> = match engine_spec {
ethjson::spec::Engine::Null(null) => {
Arc::new(NullEngine::new(null.params.into(), machine))
2020-08-05 06:08:03 +02:00
}
ethjson::spec::Engine::Ethash(ethash) => {
// Specific transitions for Ethash-based networks
for block in &[
ethash.params.homestead_transition,
ethash.params.dao_hardfork_transition,
] {
if let Some(block) = *block {
hard_forks.insert(block.into());
}
}
// Ethereum's difficulty bomb delay is a fork too
if let Some(delays) = &ethash.params.difficulty_bomb_delays {
for delay in delays.keys().copied() {
hard_forks.insert(delay.into());
}
}
Arc::new(::ethereum::Ethash::new(
spec_params.cache_dir,
ethash.params.into(),
machine,
spec_params.optimization_setting,
))
}
ethjson::spec::Engine::InstantSeal(Some(instant_seal)) => {
Arc::new(InstantSeal::new(instant_seal.params.into(), machine))
2020-08-05 06:08:03 +02:00
}
ethjson::spec::Engine::InstantSeal(None) => {
Arc::new(InstantSeal::new(InstantSealParams::default(), machine))
2020-08-05 06:08:03 +02:00
}
ethjson::spec::Engine::BasicAuthority(basic_authority) => {
Arc::new(BasicAuthority::new(basic_authority.params.into(), machine))
2020-08-05 06:08:03 +02:00
}
ethjson::spec::Engine::Clique(clique) => Clique::new(clique.params.into(), machine)
.expect("Failed to start Clique consensus engine."),
ethjson::spec::Engine::AuthorityRound(authority_round) => {
AuthorityRound::new(authority_round.params.into(), machine)
.expect("Failed to start AuthorityRound consensus engine.")
2020-08-05 06:08:03 +02:00
}
};
// Dummy value is a filler for non-existent transitions
hard_forks.remove(&BlockNumber::max_value());
(engine, hard_forks)
2020-08-05 06:08:03 +02:00
}
// given a pre-constructor state, run all the given constructors and produce a new state and
// state root.
fn run_constructors<T: Backend>(&self, factories: &Factories, mut db: T) -> Result<T, Error> {
let mut root = KECCAK_NULL_RLP;
2020-08-05 06:08:03 +02:00
// basic accounts in spec.
{
let mut t = factories.trie.create(db.as_hash_db_mut(), &mut root);
2020-08-05 06:08:03 +02:00
for (address, account) in self.genesis_state.get().iter() {
t.insert(&**address, &account.rlp())?;
2020-08-05 06:08:03 +02:00
}
}
for (address, account) in self.genesis_state.get().iter() {
account.insert_additional(
&mut *factories
2020-08-05 06:08:03 +02:00
.accountdb
.create(db.as_hash_db_mut(), keccak(address)),
&factories.trie,
2020-08-05 06:08:03 +02:00
);
}
let start_nonce = self.engine.account_start_nonce(0);
2020-08-05 06:08:03 +02:00
let (root, db) = {
let mut state = State::from_existing(db, root, start_nonce, factories.clone())?;
2020-08-05 06:08:03 +02:00
// Execute contract constructors.
let env_info = EnvInfo {
number: 0,
author: self.author,
timestamp: self.timestamp,
difficulty: self.difficulty,
last_hashes: Default::default(),
gas_used: U256::zero(),
gas_limit: U256::max_value(),
};
2020-08-05 06:08:03 +02:00
2020-09-10 08:04:14 +02:00
if !self.constructors.is_empty() {
let from = Address::default();
for &(ref address, ref constructor) in self.constructors.iter() {
trace!(target: "spec", "run_constructors: Creating a contract at {}.", address);
trace!(target: "spec", " .. root before = {}", state.root());
let params = ActionParams {
code_address: address.clone(),
code_hash: Some(keccak(constructor)),
address: address.clone(),
sender: from.clone(),
origin: from.clone(),
gas: U256::max_value(),
gas_price: Default::default(),
value: ActionValue::Transfer(Default::default()),
code: Some(Arc::new(constructor.clone())),
data: None,
call_type: CallType::None,
params_type: ParamsType::Embedded,
2020-11-04 19:11:05 +01:00
access_list: AccessList::default(),
2020-09-10 08:04:14 +02:00
};
let mut substate = Substate::new();
2020-08-05 06:08:03 +02:00
{
2020-09-10 08:04:14 +02:00
let machine = self.engine.machine();
let schedule = machine.schedule(env_info.number);
let mut exec = Executive::new(&mut state, &env_info, &machine, &schedule);
if let Err(e) =
exec.create(params, &mut substate, &mut NoopTracer, &mut NoopVMTracer)
{
warn!(target: "spec", "Genesis constructor execution at {} failed: {}.", address, e);
}
}
2020-08-05 06:08:03 +02:00
2020-09-10 08:04:14 +02:00
if let Err(e) = state.commit() {
warn!(target: "spec", "Genesis constructor trie commit at {} failed: {}.", address, e);
}
2020-08-05 06:08:03 +02:00
2020-09-10 08:04:14 +02:00
trace!(target: "spec", " .. root after = {}", state.root());
}
} else {
state.populate_from(self.genesis_state().to_owned());
state.commit()?;
}
state.drop()
};
2020-08-05 06:08:03 +02:00
*self.state_root_memo.write() = root;
Ok(db)
}
2020-08-05 06:08:03 +02:00
/// Return the state root for the genesis state, memoising accordingly.
2016-01-11 11:51:31 +01:00
pub fn state_root(&self) -> H256 {
self.state_root_memo.read().clone()
}
2020-08-05 06:08:03 +02:00
/// Get common blockchain parameters.
pub fn params(&self) -> &CommonParams {
&self.engine.params()
}
2020-08-05 06:08:03 +02:00
2016-01-23 23:53:20 +01:00
/// Get the known knodes of the network in enode format.
pub fn nodes(&self) -> &[String] {
&self.nodes
}
2020-08-05 06:08:03 +02:00
2016-02-24 21:23:58 +01:00
/// Get the configured Network ID.
pub fn network_id(&self) -> u64 {
self.params().network_id
}
2020-08-05 06:08:03 +02:00
/// Get the chain ID used for signing.
pub fn chain_id(&self) -> u64 {
self.params().chain_id
}
2020-08-05 06:08:03 +02:00
/// Get the configured subprotocol name.
pub fn subprotocol_name(&self) -> String {
self.params().subprotocol_name.clone()
}
2020-08-05 06:08:03 +02:00
2016-07-27 21:38:22 +02:00
/// Get the configured network fork block.
pub fn fork_block(&self) -> Option<(BlockNumber, H256)> {
self.params().fork_block
}
2020-08-05 06:08:03 +02:00
2016-02-03 13:20:32 +01:00
/// Get the header of the genesis block.
pub fn genesis_header(&self) -> Header {
let mut header: Header = Default::default();
header.set_parent_hash(self.parent_hash.clone());
header.set_timestamp(self.timestamp);
header.set_number(0);
header.set_author(self.author.clone());
header.set_transactions_root(self.transactions_root.clone());
header.set_uncles_hash(keccak(RlpStream::new_list(0).out()));
header.set_extra_data(self.extra_data.clone());
header.set_state_root(self.state_root());
header.set_receipts_root(self.receipts_root.clone());
header.set_log_bloom(Bloom::default());
header.set_gas_used(self.gas_used.clone());
header.set_gas_limit(self.gas_limit.clone());
header.set_difficulty(self.difficulty.clone());
header.set_seal({
2016-12-05 15:07:31 +01:00
let r = Rlp::new(&self.seal_rlp);
r.iter().map(|f| f.as_raw().to_vec()).collect()
});
trace!(target: "spec", "Header hash is {}", header.hash());
header
}
2020-08-05 06:08:03 +02:00
/// Compose the genesis block for this chain.
pub fn genesis_block(&self) -> Bytes {
let empty_list = RlpStream::new_list(0).out();
let header = self.genesis_header();
let mut ret = RlpStream::new_list(3);
ret.append(&header);
ret.append_raw(&empty_list, 1);
ret.append_raw(&empty_list, 1);
ret.out()
}
2020-08-05 06:08:03 +02:00
/// Overwrite the genesis components.
pub fn overwrite_genesis_params(&mut self, g: Genesis) {
2016-12-14 12:50:32 +01:00
let GenericSeal(seal_rlp) = g.seal.into();
self.parent_hash = g.parent_hash;
self.transactions_root = g.transactions_root;
self.receipts_root = g.receipts_root;
self.author = g.author;
self.difficulty = g.difficulty;
self.gas_limit = g.gas_limit;
self.gas_used = g.gas_used;
self.timestamp = g.timestamp;
self.extra_data = g.extra_data;
2016-12-14 12:50:32 +01:00
self.seal_rlp = seal_rlp;
}
2020-08-05 06:08:03 +02:00
2016-01-25 23:24:51 +01:00
/// Alter the value of the genesis state.
pub fn set_genesis_state(&mut self, s: PodState) -> Result<(), Error> {
2016-01-25 23:24:51 +01:00
self.genesis_state = s;
let _ = self.run_constructors(
&Default::default(),
BasicBackend(journaldb::new_memory_db()),
)?;
2020-08-05 06:08:03 +02:00
Ok(())
2016-01-25 23:24:51 +01:00
}
2020-08-05 06:08:03 +02:00
/// Return genesis state as Plain old data.
pub fn genesis_state(&self) -> &PodState {
&self.genesis_state
}
2020-08-05 06:08:03 +02:00
2016-01-25 23:24:51 +01:00
/// Returns `false` if the memoized state root is invalid. `true` otherwise.
pub fn is_state_root_valid(&self) -> bool {
// TODO: get rid of this function and ensure state root always is valid.
// we're mostly there, but `self.genesis_state.root()` doesn't encompass
// post-constructor state.
*self.state_root_memo.read() == self.genesis_state.root()
2016-01-25 23:24:51 +01:00
}
2020-08-05 06:08:03 +02:00
/// Ensure that the given state DB has the trie nodes in for the genesis state.
pub fn ensure_db_good<T: Backend>(&self, db: T, factories: &Factories) -> Result<T, Error> {
if db.as_hash_db().contains(&self.state_root()) {
return Ok(db);
}
2020-08-05 06:08:03 +02:00
// TODO: could optimize so we don't re-run, but `ensure_db_good` is barely ever
// called anyway.
let db = self.run_constructors(factories, db)?;
Ok(db)
}
2020-08-05 06:08:03 +02:00
/// Loads just the state machine from a json file.
pub fn load_machine<R: Read>(reader: R) -> Result<EthereumMachine, String> {
ethjson::spec::Spec::load(reader)
.map_err(fmt_err)
.map(load_machine_from)
}
2020-08-05 06:08:03 +02:00
/// Loads spec from json file. Provide factories for executing contracts and ensuring
/// storage goes to the right place.
pub fn load<'a, T: Into<SpecParams<'a>>, R>(params: T, reader: R) -> Result<Self, String>
where
R: Read,
{
ethjson::spec::Spec::load(reader)
.map_err(fmt_err)
.and_then(|x| load_from(params.into(), x).map_err(fmt_err))
2016-01-08 16:24:14 +01:00
}
2020-08-05 06:08:03 +02:00
/// initialize genesis epoch data, using in-memory database for
/// constructor.
pub fn genesis_epoch_data(&self) -> Result<Vec<u8>, String> {
use types::transaction::{Action, Transaction, TypedTransaction};
2020-08-05 06:08:03 +02:00
let genesis = self.genesis_header();
2020-08-05 06:08:03 +02:00
let factories = Default::default();
let mut db = journaldb::new(
Arc::new(kvdb_memorydb::create(0)),
journaldb::Algorithm::Archive,
None,
);
2020-08-05 06:08:03 +02:00
self.ensure_db_good(BasicBackend(db.as_hash_db_mut()), &factories)
.map_err(|e| format!("Unable to initialize genesis state: {}", e))?;
2020-08-05 06:08:03 +02:00
let call = |a, d| {
let mut db = db.boxed_clone();
let env_info = ::evm::EnvInfo {
number: 0,
author: *genesis.author(),
timestamp: genesis.timestamp(),
difficulty: *genesis.difficulty(),
gas_limit: U256::max_value(),
last_hashes: Arc::new(Vec::new()),
gas_used: 0.into(),
};
2020-08-05 06:08:03 +02:00
let from = Address::default();
let tx = TypedTransaction::Legacy(Transaction {
nonce: self.engine.account_start_nonce(0),
action: Action::Call(a),
gas: U256::max_value(),
gas_price: U256::default(),
value: U256::default(),
data: d,
})
.fake_sign(from);
2020-08-05 06:08:03 +02:00
let res = ::state::prove_transaction_virtual(
db.as_hash_db_mut(),
*genesis.state_root(),
&tx,
self.engine.machine(),
&env_info,
factories.clone(),
);
2020-08-05 06:08:03 +02:00
res.map(|(out, proof)| (out, proof.into_iter().map(|x| x.into_vec()).collect()))
.ok_or_else(|| "Failed to prove call: insufficient state".into())
};
2020-08-05 06:08:03 +02:00
self.engine.genesis_epoch_data(&genesis, &call)
}
2020-08-05 06:08:03 +02:00
/// Create a new Spec with InstantSeal consensus which does internal sealing (not requiring
/// work).
pub fn new_instant() -> Spec {
load_bundled!("instant_seal")
}
2020-08-05 06:08:03 +02:00
/// Create a new Spec which conforms to the Frontier-era Morden chain except that it's a
/// NullEngine consensus.
#[cfg(any(test, feature = "test-helpers"))]
pub fn new_test() -> Spec {
load_bundled!("null_morden")
}
2020-08-05 06:08:03 +02:00
/// Create the EthereumMachine corresponding to Spec::new_test.
#[cfg(any(test, feature = "test-helpers"))]
pub fn new_test_machine() -> EthereumMachine {
load_machine_bundled!("null_morden")
}
2020-08-05 06:08:03 +02:00
/// Create a new Spec which conforms to the Frontier-era Morden chain except that it's a NullEngine consensus with applying reward on block close.
#[cfg(any(test, feature = "test-helpers"))]
pub fn new_test_with_reward() -> Spec {
load_bundled!("null_morden_with_reward")
}
2020-08-05 06:08:03 +02:00
v2.5.10 stable (#11239) * ropsten #6631425 foundation #8798209 (#11201) * [stable] builtin, istanbul and mordor testnet backports (#11234) * ethcore-builtin (#10850) * [builtin]: support `multiple prices and activations` in chain spec (#11039) * [chain specs]: activate `Istanbul` on mainnet (#11228) * ethcore/res: add mordor testnet configuration (#11200) * Update list of bootnodes for xDai chain (#11236) * ethcore: remove `test-helper feat` from build (#11047) * Secret store: fix Instant::now() related race in net_keep_alive (#11155) (#11159) * [stable]: backport #10691 and #10683 (#11143) * Fix compiler warning (that will become an error) (#10683) * Refactor Clique stepping (#10691) * Add Constantinople eips to the dev (instant_seal) config (#10809) * Add cargo-remote dir to .gitignore (?) * Insert explicit warning into the panic hook (#11225) * Fix docker centos build (#11226) * Update MIX bootnodes. (#11203) * Use provided usd-per-eth value if an endpoint is specified (#11209) * Add new line after writing block to hex file. (#10984) * Type annotation for next_key() matching of json filter options (#11192) (but no `FilterOption` in 2.5 so…) * Upgrade jsonrpc to latest (#11206) * [CI] check evmbin build (#11096) * Correct EIP-712 encoding (#11092) * [client]: Fix for incorrectly dropped consensus messages (#11086) * Fix block detail updating (#11015) * Switching sccache from local to Redis (#10971) * Made ecrecover implementation trait public (#11188) * [dependencies]: jsonrpc `14.0.1` (#11183) * [receipt]: add `sender` & `receiver` to `RichReceipts` (#11179) * [ethcore/builtin]: do not panic in blake2pricer on short input (#11180) * util Host: fix a double Read Lock bug in fn Host::session_readable() (#11175) * ethcore client: fix a double Read Lock bug in fn Client::logs() (#11172) * Change how RPCs eth_call and eth_estimateGas handle "Pending" (#11127) * Cleanup stratum a bit (#11161) * Upgrade to jsonrpc v14 (#11151) * SecretStore: expose restore_key_public in HTTP API (#10241)
2019-11-11 21:57:38 +01:00
/// Create a new Spec which conforms to the Frontier-era Morden chain except that it's a NullEngine consensus with finality.
#[cfg(any(test, feature = "test-helpers"))]
pub fn new_test_with_finality() -> Spec {
load_bundled!("null_morden_with_finality")
}
2020-08-05 06:08:03 +02:00
/// Create a new Spec which is a NullEngine consensus with a premine of address whose
/// secret is keccak('').
#[cfg(any(test, feature = "test-helpers"))]
pub fn new_null() -> Spec {
load_bundled!("null")
}
2020-08-05 06:08:03 +02:00
/// Create a new Spec which constructs a contract at address 5 with storage at 0 equal to 1.
#[cfg(any(test, feature = "test-helpers"))]
pub fn new_test_constructor() -> Spec {
load_bundled!("constructor")
}
2020-08-05 06:08:03 +02:00
/// Create a new Spec with AuthorityRound consensus which does internal sealing (not
/// requiring work).
/// Accounts with secrets keccak("0") and keccak("1") are the validators.
#[cfg(any(test, feature = "test-helpers"))]
pub fn new_test_round() -> Self {
load_bundled!("authority_round")
}
2020-08-05 06:08:03 +02:00
Aura: Broadcast empty step messages instead of creating empty blocks (#7605) * aura: broadcast empty step message instead of sealing empty block * aura: add empty_step messages to seal * aura: include parent_hash in empty step message * aura: verify received empty step messages * aura: verify empty step messages in block * aura: fix dead lock on empty_steps * aura: fix EmptyStep Encodable * aura: take number of empty steps into account in chain score * aura: use empty step signers for finality * aura: add empty "empty step" messages to seal when reading from spec * aura: fix EmptyStep rlp encoding * aura: use Vec<u8> instead of Bytes * aura: fix block empty step verification * Update .gitlab-ci.yml fix lint * aura: fix accumulation of empty step signatures for finality * aura: include empty steps in seal signature * aura: configurable max number of empty steps * engine: pass block header to seal_fields method This is necessary to make the number of seal fields dynamic, e.g. activating a transition on a certain block number that changes the seal. * aura: add transition to enable empty step messages * aura: clear old empty step messages on verify_block_external * aura: ignore empty step messages from the future * aura: report skipped primaries when empty steps are not enabled * aura: fix tests * aura: report misbehavior * aura: add tests for rolling finality with multiple signatures * engine: fix validator set test In this test the block validation wasn't failing because the block was in the future (expected failure) but was instead failing because the author of the block isn't the expected authority. Since we added reporting of blocks produced by the wrong authority this test started failing. * aura: reward all the authors of empty step messages * aura: fix reward attribution for new blocks * aura: add tests for empty steps broadcasting and inclusion in blocks * aura: reduce size of empty step messages in seal * aura: add test for empty step inclusion in blocks * aura: add test for rewarding of empty steps * aura: add test for empty steps validation * aura: fix rlp encoding of sealed empty step * aura: fix grumbles
2018-02-15 01:39:29 +01:00
/// Create a new Spec with AuthorityRound consensus which does internal sealing (not
/// requiring work) with empty step messages enabled.
/// Accounts with secrets keccak("0") and keccak("1") are the validators.
#[cfg(any(test, feature = "test-helpers"))]
Aura: Broadcast empty step messages instead of creating empty blocks (#7605) * aura: broadcast empty step message instead of sealing empty block * aura: add empty_step messages to seal * aura: include parent_hash in empty step message * aura: verify received empty step messages * aura: verify empty step messages in block * aura: fix dead lock on empty_steps * aura: fix EmptyStep Encodable * aura: take number of empty steps into account in chain score * aura: use empty step signers for finality * aura: add empty "empty step" messages to seal when reading from spec * aura: fix EmptyStep rlp encoding * aura: use Vec<u8> instead of Bytes * aura: fix block empty step verification * Update .gitlab-ci.yml fix lint * aura: fix accumulation of empty step signatures for finality * aura: include empty steps in seal signature * aura: configurable max number of empty steps * engine: pass block header to seal_fields method This is necessary to make the number of seal fields dynamic, e.g. activating a transition on a certain block number that changes the seal. * aura: add transition to enable empty step messages * aura: clear old empty step messages on verify_block_external * aura: ignore empty step messages from the future * aura: report skipped primaries when empty steps are not enabled * aura: fix tests * aura: report misbehavior * aura: add tests for rolling finality with multiple signatures * engine: fix validator set test In this test the block validation wasn't failing because the block was in the future (expected failure) but was instead failing because the author of the block isn't the expected authority. Since we added reporting of blocks produced by the wrong authority this test started failing. * aura: reward all the authors of empty step messages * aura: fix reward attribution for new blocks * aura: add tests for empty steps broadcasting and inclusion in blocks * aura: reduce size of empty step messages in seal * aura: add test for empty step inclusion in blocks * aura: add test for rewarding of empty steps * aura: add test for empty steps validation * aura: fix rlp encoding of sealed empty step * aura: fix grumbles
2018-02-15 01:39:29 +01:00
pub fn new_test_round_empty_steps() -> Self {
load_bundled!("authority_round_empty_steps")
}
2020-08-05 06:08:03 +02:00
/// Create a new Spec with AuthorityRound consensus (with empty steps) using a block reward
/// contract. The contract source code can be found at:
2020-09-22 14:53:52 +02:00
/// https://github.com/openethereum/block-reward/blob/daf7d44383b6cdb11cb6b953b018648e2b027cfb/contracts/ExampleBlockReward.sol
#[cfg(any(test, feature = "test-helpers"))]
pub fn new_test_round_block_reward_contract() -> Self {
load_bundled!("authority_round_block_reward_contract")
}
2020-08-05 06:08:03 +02:00
2020-09-22 14:53:52 +02:00
/// TestList.sol used in both specs: https://github.com/paritytech/contracts/pull/30/files (link not valid)
/// Accounts with secrets keccak("0") and keccak("1") are initially the validators.
/// Create a new Spec with BasicAuthority which uses a contract at address 5 to determine
/// the current validators using `getValidators`.
/// Second validator can be removed with
/// "0xbfc708a000000000000000000000000082a978b3f5962a5b0957d9ee9eef472ee55b42f1" and added
/// back in using
/// "0x4d238c8e00000000000000000000000082a978b3f5962a5b0957d9ee9eef472ee55b42f1".
#[cfg(any(test, feature = "test-helpers"))]
pub fn new_validator_safe_contract() -> Self {
load_bundled!("validator_safe_contract")
}
2020-08-05 06:08:03 +02:00
/// The same as the `safeContract`, but allows reporting and uses AuthorityRound.
/// Account is marked with `reportBenign` it can be checked as disliked with "0xd8f2e0bf".
/// Validator can be removed with `reportMalicious`.
#[cfg(any(test, feature = "test-helpers"))]
pub fn new_validator_contract() -> Self {
load_bundled!("validator_contract")
}
2020-08-05 06:08:03 +02:00
/// Create a new Spec with BasicAuthority which uses multiple validator sets changing with
/// height.
/// Account with secrets keccak("0") is the validator for block 1 and with keccak("1")
/// onwards.
#[cfg(any(test, feature = "test-helpers"))]
pub fn new_validator_multi() -> Self {
load_bundled!("validator_multi")
}
}
2016-01-06 16:00:42 +01:00
#[cfg(test)]
mod tests {
use super::*;
use state::State;
use tempdir::TempDir;
Private transactions integration pr (#6422) * Private transaction message added * Empty line removed * Private transactions logic removed from client into the separate module * Fixed compilation after merge with head * Signed private transaction message added as well * Comments after the review fixed * Private tx execution * Test update * Renamed some methods * Fixed some tests * Reverted submodules * Fixed build * Private transaction message added * Empty line removed * Private transactions logic removed from client into the separate module * Fixed compilation after merge with head * Signed private transaction message added as well * Comments after the review fixed * Encrypted private transaction message and signed reply added * Private tx execution * Test update * Main scenario completed * Merged with the latest head * Private transactions API * Comments after review fixed * Parameters for private transactions added to parity arguments * New files added * New API methods added * Do not process packets from unconfirmed peers * Merge with ptm_ss branch * Encryption and permissioning with key server added * Fixed compilation after merge * Version of Parity protocol incremented in order to support private transactions * Doc strings for constants added * Proper format for doc string added * fixed some encryptor.rs grumbles * Private transactions functionality moved to the separate crate * Refactoring in order to remove late initialisation * Tests fixed after moving to the separate crate * Fetch method removed * Sync test helpers refactored * Interaction with encryptor refactored * Contract address retrieving via substate removed * Sensible gas limit for private transactions implemented * New private contract with nonces added * Parsing of the response from key server fixed * Build fixed after the merge, native contracts removed * Crate renamed * Tests moved to the separate directory * Handling of errors reworked in order to use error chain * Encodable macro added, new constructor replaced with default * Native ethabi usage removed * Couple conversions optimized * Interactions with client reworked * Errors omitting removed * Fix after merge * Fix after the merge * private transactions improvements in progress * private_transactions -> ethcore/private-tx * making private transactions more idiomatic * private-tx encryptor uses shared FetchClient and is more idiomatic * removed redundant tests, moved integration tests to tests/ dir * fixed failing service test * reenable add_notify on private tx provider * removed private_tx tests from sync module * removed commented out code * Use plain password instead of unlocking account manager * remove dead code * Link to the contract changed * Transaction signature chain replay protection module created * Redundant type conversion removed * Contract address returned by private provider * Test fixed * Addressing grumbles in PrivateTransactions (#8249) * Tiny fixes part 1. * A bunch of additional comments and todos. * Fix ethsync tests. * resolved merge conflicts * final private tx pr (#8318) * added cli option that enables private transactions * fixed failing test * fixed failing test * fixed failing test * fixed failing test
2018-04-09 16:14:33 +02:00
use test_helpers::get_temp_state_db;
use types::{view, views::BlockView};
2020-08-05 06:08:03 +02:00
#[test]
fn test_load_empty() {
let tempdir = TempDir::new("").unwrap();
assert!(Spec::load(&tempdir.path(), &[] as &[u8]).is_err());
}
2020-08-05 06:08:03 +02:00
2016-01-07 19:10:29 +01:00
#[test]
fn test_chain() {
let test_spec = Spec::new_test();
2020-08-05 06:08:03 +02:00
assert_eq!(
test_spec.state_root(),
"f3f4696bbf3b3b07775128eb7a3763279a394e382130f27c21e70233e04946a9".into()
);
let genesis = test_spec.genesis_block();
assert_eq!(
view!(BlockView, &genesis).header_view().hash(),
"0cd786a2425d16f152c658316c423e6ce1181e15c3295826d7c9904cba9ce303".into()
);
2016-01-07 19:10:29 +01:00
}
2020-08-05 06:08:03 +02:00
#[test]
fn genesis_constructor() {
let _ = ::env_logger::try_init();
let spec = Spec::new_test_constructor();
let db = spec
.ensure_db_good(get_temp_state_db(), &Default::default())
.unwrap();
let state = State::from_existing(
db.boxed_clone(),
spec.state_root(),
spec.engine.account_start_nonce(0),
Default::default(),
)
.unwrap();
let expected = "0000000000000000000000000000000000000000000000000000000000000001".into();
let address = "0000000000000000000000000000000000001337".into();
2020-08-05 06:08:03 +02:00
assert_eq!(state.storage_at(&address, &H256::zero()).unwrap(), expected);
assert_eq!(state.balance(&address).unwrap(), 1.into());
}
}