Basic Authority (#991)
* Firt commit. * First non-functional but correct implementation of BasicAuthority. Still needs: - Sealing infrastructure. * Punch a hole to give miner access to key store. * Fix test built. * Basic version of synchronous mining. This will seal a block whenever a new transaction comes through. To be made better we need a timer which will wait for one second after the last block before sealing a new one - better still would be to cooperatively interleave blocks with other sealing nodes. * Add tests. * Fix minor issues from repotting. * Address grumbles.
This commit is contained in:
59
json/src/spec/basic_authority.rs
Normal file
59
json/src/spec/basic_authority.rs
Normal file
@@ -0,0 +1,59 @@
|
||||
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||
// This file is part of Parity.
|
||||
|
||||
// Parity is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Ethash params deserialization.
|
||||
|
||||
use uint::Uint;
|
||||
use hash::Address;
|
||||
|
||||
/// Ethash params deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
pub struct BasicAuthorityParams {
|
||||
/// Gas limit divisor.
|
||||
#[serde(rename="gasLimitBoundDivisor")]
|
||||
pub gas_limit_bound_divisor: Uint,
|
||||
/// Block duration.
|
||||
#[serde(rename="durationLimit")]
|
||||
pub duration_limit: Uint,
|
||||
/// Valid authorities
|
||||
pub authorities: Vec<Address>,
|
||||
}
|
||||
|
||||
/// Ethash engine deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
pub struct BasicAuthority {
|
||||
/// Ethash params.
|
||||
pub params: BasicAuthorityParams,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json;
|
||||
use spec::basic_authority::BasicAuthority;
|
||||
|
||||
#[test]
|
||||
fn basic_authority_deserialization() {
|
||||
let s = r#"{
|
||||
"params": {
|
||||
"gasLimitBoundDivisor": "0x0400",
|
||||
"durationLimit": "0x0d",
|
||||
"authorities" : ["0xc6d9d2cd449a754c494264e1809c50e34d64562b"]
|
||||
}
|
||||
}"#;
|
||||
|
||||
let _deserialized: BasicAuthority = serde_json::from_str(s).unwrap();
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
use serde::Deserializer;
|
||||
use serde::de::Visitor;
|
||||
use spec::Ethash;
|
||||
use spec::BasicAuthority;
|
||||
|
||||
/// Engine deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
@@ -27,6 +28,8 @@ pub enum Engine {
|
||||
Null,
|
||||
/// Ethash engine.
|
||||
Ethash(Ethash),
|
||||
/// BasicAuthority engine.
|
||||
BasicAuthority(BasicAuthority),
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -46,13 +49,13 @@ mod tests {
|
||||
let s = r#"{
|
||||
"Ethash": {
|
||||
"params": {
|
||||
"tieBreakingGas": false,
|
||||
"gasLimitBoundDivisor": "0x0400",
|
||||
"minimumDifficulty": "0x020000",
|
||||
"difficultyBoundDivisor": "0x0800",
|
||||
"durationLimit": "0x0d",
|
||||
"blockReward": "0x4563918244F40000",
|
||||
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b"
|
||||
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
|
||||
"frontierCompatibilityModeLimit" : "0x"
|
||||
}
|
||||
}
|
||||
}"#;
|
||||
|
||||
@@ -22,9 +22,6 @@ use hash::Address;
|
||||
/// Ethash params deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
pub struct EthashParams {
|
||||
/// Tie breaking gas.
|
||||
#[serde(rename="tieBreakingGas")]
|
||||
pub tie_breaking_gas: bool,
|
||||
/// Gas limit divisor.
|
||||
#[serde(rename="gasLimitBoundDivisor")]
|
||||
pub gas_limit_bound_divisor: Uint,
|
||||
@@ -42,6 +39,9 @@ pub struct EthashParams {
|
||||
pub block_reward: Uint,
|
||||
/// Namereg contract address.
|
||||
pub registrar: Address,
|
||||
/// Homestead transition block number.
|
||||
#[serde(rename="frontierCompatibilityModeLimit")]
|
||||
pub frontier_compatibility_mode_limit: Uint,
|
||||
}
|
||||
|
||||
/// Ethash engine deserialization.
|
||||
@@ -60,13 +60,13 @@ mod tests {
|
||||
fn ethash_deserialization() {
|
||||
let s = r#"{
|
||||
"params": {
|
||||
"tieBreakingGas": false,
|
||||
"gasLimitBoundDivisor": "0x0400",
|
||||
"minimumDifficulty": "0x020000",
|
||||
"difficultyBoundDivisor": "0x0800",
|
||||
"durationLimit": "0x0d",
|
||||
"blockReward": "0x4563918244F40000",
|
||||
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b"
|
||||
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
|
||||
"frontierCompatibilityModeLimit" : "0x42"
|
||||
}
|
||||
}"#;
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ pub mod seal;
|
||||
pub mod engine;
|
||||
pub mod state;
|
||||
pub mod ethash;
|
||||
pub mod basic_authority;
|
||||
|
||||
pub use self::account::Account;
|
||||
pub use self::builtin::{Builtin, Pricing, Linear};
|
||||
@@ -35,3 +36,4 @@ pub use self::seal::{Seal, Ethereum, Generic};
|
||||
pub use self::engine::Engine;
|
||||
pub use self::state::State;
|
||||
pub use self::ethash::{Ethash, EthashParams};
|
||||
pub use self::basic_authority::{BasicAuthority, BasicAuthorityParams};
|
||||
|
||||
@@ -24,9 +24,6 @@ pub struct Params {
|
||||
/// Account start nonce.
|
||||
#[serde(rename="accountStartNonce")]
|
||||
pub account_start_nonce: Uint,
|
||||
/// Homestead transition block number.
|
||||
#[serde(rename="frontierCompatibilityModeLimit")]
|
||||
pub frontier_compatibility_mode_limit: Uint,
|
||||
/// Maximum size of extra data.
|
||||
#[serde(rename="maximumExtraDataSize")]
|
||||
pub maximum_extra_data_size: Uint,
|
||||
|
||||
@@ -57,13 +57,13 @@ mod tests {
|
||||
"engine": {
|
||||
"Ethash": {
|
||||
"params": {
|
||||
"tieBreakingGas": false,
|
||||
"gasLimitBoundDivisor": "0x0400",
|
||||
"minimumDifficulty": "0x020000",
|
||||
"difficultyBoundDivisor": "0x0800",
|
||||
"durationLimit": "0x0d",
|
||||
"blockReward": "0x4563918244F40000",
|
||||
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b"
|
||||
"registrar" : "0xc6d9d2cd449a754c494264e1809c50e34d64562b",
|
||||
"frontierCompatibilityModeLimit" : "0x"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user