Merge branch 'master' into install-deps

This commit is contained in:
debris 2016-02-03 14:32:11 +01:00
commit b786be5c7c
20 changed files with 150 additions and 144 deletions

View File

@ -5,22 +5,22 @@ use header::BlockNumber;
use basic_types::LogBloom; use basic_types::LogBloom;
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
/// TODO [Gav Wood] Please document me /// Error indicating an expected value was not found.
pub struct Mismatch<T: fmt::Debug> { pub struct Mismatch<T: fmt::Debug> {
/// TODO [Gav Wood] Please document me /// Value expected.
pub expected: T, pub expected: T,
/// TODO [Gav Wood] Please document me /// Value found.
pub found: T, pub found: T,
} }
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
/// TODO [Gav Wood] Please document me /// Error indicating value found is outside of a valid range.
pub struct OutOfBounds<T: fmt::Debug> { pub struct OutOfBounds<T: fmt::Debug> {
/// TODO [Gav Wood] Please document me /// Minimum allowed value.
pub min: Option<T>, pub min: Option<T>,
/// TODO [Gav Wood] Please document me /// Maximum allowed value.
pub max: Option<T>, pub max: Option<T>,
/// TODO [Gav Wood] Please document me /// Value found.
pub found: T, pub found: T,
} }
@ -29,11 +29,10 @@ pub struct OutOfBounds<T: fmt::Debug> {
pub enum ExecutionError { pub enum ExecutionError {
/// Returned when there gas paid for transaction execution is /// Returned when there gas paid for transaction execution is
/// lower than base gas required. /// lower than base gas required.
/// TODO [Gav Wood] Please document me
NotEnoughBaseGas { NotEnoughBaseGas {
/// TODO [Gav Wood] Please document me /// Absolute minimum gas required.
required: U256, required: U256,
/// TODO [Gav Wood] Please document me /// Gas provided.
got: U256 got: U256
}, },
/// Returned when block (gas_used + gas) > gas_limit. /// Returned when block (gas_used + gas) > gas_limit.
@ -41,26 +40,26 @@ pub enum ExecutionError {
/// If gas =< gas_limit, upstream may try to execute the transaction /// If gas =< gas_limit, upstream may try to execute the transaction
/// in next block. /// in next block.
BlockGasLimitReached { BlockGasLimitReached {
/// TODO [Gav Wood] Please document me /// Gas limit of block for transaction.
gas_limit: U256, gas_limit: U256,
/// TODO [Gav Wood] Please document me /// Gas used in block prior to transaction.
gas_used: U256, gas_used: U256,
/// TODO [Gav Wood] Please document me /// Amount of gas in block.
gas: U256 gas: U256
}, },
/// Returned when transaction nonce does not match state nonce. /// Returned when transaction nonce does not match state nonce.
InvalidNonce { InvalidNonce {
/// TODO [Gav Wood] Please document me /// Nonce expected.
expected: U256, expected: U256,
/// TODO [Gav Wood] Please document me /// Nonce found.
got: U256 got: U256
}, },
/// Returned when cost of transaction (value + gas_price * gas) exceeds /// Returned when cost of transaction (value + gas_price * gas) exceeds
/// current sender balance. /// current sender balance.
NotEnoughCash { NotEnoughCash {
/// TODO [Gav Wood] Please document me /// Minimum required balance.
required: U512, required: U512,
/// TODO [Gav Wood] Please document me /// Actual balance.
got: U512 got: U512
}, },
/// Returned when internal evm error occurs. /// Returned when internal evm error occurs.
@ -68,64 +67,68 @@ pub enum ExecutionError {
} }
#[derive(Debug)] #[derive(Debug)]
/// TODO [Gav Wood] Please document me /// Errors concerning transaction proessing.
pub enum TransactionError { pub enum TransactionError {
/// TODO [Gav Wood] Please document me /// Transaction's gas limit (aka gas) is invalid.
InvalidGasLimit(OutOfBounds<U256>), InvalidGasLimit(OutOfBounds<U256>),
} }
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
/// TODO [arkpar] Please document me /// Errors concerning block processing.
pub enum BlockError { pub enum BlockError {
/// TODO [Gav Wood] Please document me /// Block has too many uncles.
TooManyUncles(OutOfBounds<usize>), TooManyUncles(OutOfBounds<usize>),
/// TODO [Gav Wood] Please document me /// Extra data is of an invalid length.
UncleWrongGeneration,
/// TODO [Gav Wood] Please document me
ExtraDataOutOfBounds(OutOfBounds<usize>), ExtraDataOutOfBounds(OutOfBounds<usize>),
/// TODO [arkpar] Please document me /// Seal is incorrect format.
InvalidSealArity(Mismatch<usize>), InvalidSealArity(Mismatch<usize>),
/// TODO [arkpar] Please document me /// Block has too much gas used.
TooMuchGasUsed(OutOfBounds<U256>), TooMuchGasUsed(OutOfBounds<U256>),
/// TODO [arkpar] Please document me /// Uncles hash in header is invalid.
InvalidUnclesHash(Mismatch<H256>), InvalidUnclesHash(Mismatch<H256>),
/// TODO [arkpar] Please document me /// An uncle is from a generation too old.
UncleTooOld(OutOfBounds<BlockNumber>), UncleTooOld(OutOfBounds<BlockNumber>),
/// TODO [arkpar] Please document me /// An uncle is from the same generation as the block.
UncleIsBrother(OutOfBounds<BlockNumber>), UncleIsBrother(OutOfBounds<BlockNumber>),
/// TODO [arkpar] Please document me /// An uncle is already in the chain.
UncleInChain(H256), UncleInChain(H256),
/// TODO [arkpar] Please document me /// An uncle has a parent not in the chain.
UncleParentNotInChain(H256), UncleParentNotInChain(H256),
/// TODO [arkpar] Please document me /// State root header field is invalid.
InvalidStateRoot(Mismatch<H256>), InvalidStateRoot(Mismatch<H256>),
/// TODO [arkpar] Please document me /// Gas used header field is invalid.
InvalidGasUsed(Mismatch<U256>), InvalidGasUsed(Mismatch<U256>),
/// TODO [arkpar] Please document me /// Transactions root header field is invalid.
InvalidTransactionsRoot(Mismatch<H256>), InvalidTransactionsRoot(Mismatch<H256>),
/// TODO [arkpar] Please document me /// Difficulty is out of range; this can be used as an looser error prior to getting a definitive
/// value for difficulty. This error needs only provide bounds of which it is out.
DifficultyOutOfBounds(OutOfBounds<U256>),
/// Difficulty header field is invalid; this is a strong error used after getting a definitive
/// value for difficulty (which is provided).
InvalidDifficulty(Mismatch<U256>), InvalidDifficulty(Mismatch<U256>),
/// TODO [arkpar] Please document me /// Seal element of type H256 (max_hash for Ethash, but could be something else for
/// other seal engines) is out of bounds.
MismatchedH256SealElement(Mismatch<H256>),
/// Proof-of-work aspect of seal, which we assume is a 256-bit value, is invalid.
InvalidProofOfWork(OutOfBounds<U256>),
/// Gas limit header field is invalid.
InvalidGasLimit(OutOfBounds<U256>), InvalidGasLimit(OutOfBounds<U256>),
/// TODO [arkpar] Please document me /// Receipts trie root header field is invalid.
InvalidReceiptsStateRoot(Mismatch<H256>), InvalidReceiptsRoot(Mismatch<H256>),
/// TODO [arkpar] Please document me /// Timestamp header field is invalid.
InvalidTimestamp(OutOfBounds<u64>), InvalidTimestamp(OutOfBounds<u64>),
/// TODO [arkpar] Please document me /// Log bloom header field is invalid.
InvalidLogBloom(Mismatch<LogBloom>), InvalidLogBloom(Mismatch<LogBloom>),
/// TODO [arkpar] Please document me /// Parent hash field of header is invalid; this is an invalid error indicating a logic flaw in the codebase.
InvalidEthashDifficulty(Mismatch<U256>), /// TODO: remove and favour an assert!/panic!.
/// TODO [arkpar] Please document me
InvalidBlockNonce(Mismatch<H256>),
/// TODO [arkpar] Please document me
InvalidParentHash(Mismatch<H256>), InvalidParentHash(Mismatch<H256>),
/// TODO [arkpar] Please document me /// Number field of header is invalid.
InvalidNumber(Mismatch<BlockNumber>), InvalidNumber(Mismatch<BlockNumber>),
/// Block number isn't sensible. /// Block number isn't sensible.
RidiculousNumber(OutOfBounds<BlockNumber>), RidiculousNumber(OutOfBounds<BlockNumber>),
/// TODO [arkpar] Please document me /// Parent given is unknown.
UnknownParent(H256), UnknownParent(H256),
/// TODO [Gav Wood] Please document me /// Uncle parent given is unknown.
UnknownUncleParent(H256), UnknownUncleParent(H256),
} }
@ -154,15 +157,15 @@ pub type ImportResult = Result<H256, ImportError>;
#[derive(Debug)] #[derive(Debug)]
/// General error type which should be capable of representing all errors in ethcore. /// General error type which should be capable of representing all errors in ethcore.
pub enum Error { pub enum Error {
/// TODO [Gav Wood] Please document me /// Error concerning a utility.
Util(UtilError), Util(UtilError),
/// TODO [Gav Wood] Please document me /// Error concerning block processing.
Block(BlockError), Block(BlockError),
/// TODO [Gav Wood] Please document me /// Unknown engine given.
UnknownEngineName(String), UnknownEngineName(String),
/// TODO [Gav Wood] Please document me /// Error concerning EVM code execution.
Execution(ExecutionError), Execution(ExecutionError),
/// TODO [Gav Wood] Please document me /// Error concerning transaction processing.
Transaction(TransactionError), Transaction(TransactionError),
} }

View File

@ -110,16 +110,18 @@ impl Engine for Ethash {
try!(UntrustedRlp::new(&header.seal[0]).as_val::<H256>()); try!(UntrustedRlp::new(&header.seal[0]).as_val::<H256>());
try!(UntrustedRlp::new(&header.seal[1]).as_val::<H64>()); try!(UntrustedRlp::new(&header.seal[1]).as_val::<H64>());
// TODO: consider removing these lines.
let min_difficulty = decode(self.spec().engine_params.get("minimumDifficulty").unwrap()); let min_difficulty = decode(self.spec().engine_params.get("minimumDifficulty").unwrap());
if header.difficulty < min_difficulty { if header.difficulty < min_difficulty {
return Err(From::from(BlockError::InvalidDifficulty(Mismatch { expected: min_difficulty, found: header.difficulty }))) return Err(From::from(BlockError::DifficultyOutOfBounds(OutOfBounds { min: Some(min_difficulty), max: None, found: header.difficulty })))
} }
let difficulty = Ethash::boundary_to_difficulty(&Ethash::from_ethash(quick_get_difficulty( let difficulty = Ethash::boundary_to_difficulty(&Ethash::from_ethash(quick_get_difficulty(
&Ethash::to_ethash(header.bare_hash()), &Ethash::to_ethash(header.bare_hash()),
header.nonce().low_u64(), header.nonce().low_u64(),
&Ethash::to_ethash(header.mix_hash())))); &Ethash::to_ethash(header.mix_hash()))));
if difficulty < header.difficulty { if difficulty < header.difficulty {
return Err(From::from(BlockError::InvalidEthashDifficulty(Mismatch { expected: header.difficulty, found: difficulty }))); return Err(From::from(BlockError::InvalidProofOfWork(OutOfBounds { min: Some(header.difficulty), max: None, found: difficulty })));
} }
Ok(()) Ok(())
} }
@ -129,10 +131,10 @@ impl Engine for Ethash {
let mix = Ethash::from_ethash(result.mix_hash); let mix = Ethash::from_ethash(result.mix_hash);
let difficulty = Ethash::boundary_to_difficulty(&Ethash::from_ethash(result.value)); let difficulty = Ethash::boundary_to_difficulty(&Ethash::from_ethash(result.value));
if mix != header.mix_hash() { if mix != header.mix_hash() {
return Err(From::from(BlockError::InvalidBlockNonce(Mismatch { expected: mix, found: header.mix_hash() }))); return Err(From::from(BlockError::MismatchedH256SealElement(Mismatch { expected: mix, found: header.mix_hash() })));
} }
if difficulty < header.difficulty { if difficulty < header.difficulty {
return Err(From::from(BlockError::InvalidEthashDifficulty(Mismatch { expected: header.difficulty, found: difficulty }))); return Err(From::from(BlockError::InvalidProofOfWork(OutOfBounds { min: Some(header.difficulty), max: None, found: difficulty })));
} }
Ok(()) Ok(())
} }

View File

@ -3,9 +3,9 @@
//! Contains all Ethereum network specific stuff, such as denominations and //! Contains all Ethereum network specific stuff, such as denominations and
//! consensus specifications. //! consensus specifications.
/// TODO [Gav Wood] Please document me /// Export the ethash module.
pub mod ethash; pub mod ethash;
/// TODO [Gav Wood] Please document me /// Export the denominations module.
pub mod denominations; pub mod denominations;
pub use self::ethash::*; pub use self::ethash::*;

View File

@ -68,9 +68,9 @@ impl ExtrasReadable for DB {
/// Implementations should convert arbitrary type to database key slice /// Implementations should convert arbitrary type to database key slice
pub trait ExtrasSliceConvertable { pub trait ExtrasSliceConvertable {
/// TODO [Gav Wood] Please document me /// Convert self, with `i` (the index), to a 264-bit extras DB key.
fn to_extras_slice(&self, i: ExtrasIndex) -> H264; fn to_extras_slice(&self, i: ExtrasIndex) -> H264;
/// TODO [debris] Please document me /// Interpret self as a 256-bit hash, if natively `H256`.
fn as_h256(&self) -> Option<&H256> { None } fn as_h256(&self) -> Option<&H256> { None }
} }

View File

@ -48,9 +48,9 @@ pub struct Header {
/// Block seal. /// Block seal.
pub seal: Vec<Bytes>, pub seal: Vec<Bytes>,
/// TODO [arkpar] Please document me /// The memoized hash of the RLP representation *including* the seal fields.
pub hash: RefCell<Option<H256>>, pub hash: RefCell<Option<H256>>,
/// TODO [Gav Wood] Please document me /// The memoized hash of the RLP representation *without* the seal fields.
pub bare_hash: RefCell<Option<H256>>, pub bare_hash: RefCell<Option<H256>>,
} }
@ -86,50 +86,50 @@ impl Header {
Self::default() Self::default()
} }
/// TODO [Gav Wood] Please document me /// Get the number field of the header.
pub fn number(&self) -> BlockNumber { self.number } pub fn number(&self) -> BlockNumber { self.number }
/// TODO [Gav Wood] Please document me /// Get the timestamp field of the header.
pub fn timestamp(&self) -> u64 { self.timestamp } pub fn timestamp(&self) -> u64 { self.timestamp }
/// TODO [Gav Wood] Please document me /// Get the author field of the header.
pub fn author(&self) -> &Address { &self.author } pub fn author(&self) -> &Address { &self.author }
/// TODO [Gav Wood] Please document me /// Get the extra data field of the header.
pub fn extra_data(&self) -> &Bytes { &self.extra_data } pub fn extra_data(&self) -> &Bytes { &self.extra_data }
/// TODO [Gav Wood] Please document me /// Get the state root field of the header.
pub fn state_root(&self) -> &H256 { &self.state_root } pub fn state_root(&self) -> &H256 { &self.state_root }
/// TODO [Gav Wood] Please document me /// Get the receipts root field of the header.
pub fn receipts_root(&self) -> &H256 { &self.receipts_root } pub fn receipts_root(&self) -> &H256 { &self.receipts_root }
/// TODO [Gav Wood] Please document me /// Get the gas limit field of the header.
pub fn gas_limit(&self) -> &U256 { &self.gas_limit } pub fn gas_limit(&self) -> &U256 { &self.gas_limit }
/// TODO [Gav Wood] Please document me /// Get the difficulty field of the header.
pub fn difficulty(&self) -> &U256 { &self.difficulty } pub fn difficulty(&self) -> &U256 { &self.difficulty }
/// TODO [Gav Wood] Please document me /// Get the seal field of the header.
pub fn seal(&self) -> &Vec<Bytes> { &self.seal } pub fn seal(&self) -> &Vec<Bytes> { &self.seal }
// TODO: seal_at, set_seal_at &c. // TODO: seal_at, set_seal_at &c.
/// TODO [Gav Wood] Please document me /// Set the number field of the header.
pub fn set_number(&mut self, a: BlockNumber) { self.number = a; self.note_dirty(); } pub fn set_number(&mut self, a: BlockNumber) { self.number = a; self.note_dirty(); }
/// TODO [Gav Wood] Please document me /// Set the timestamp field of the header.
pub fn set_timestamp(&mut self, a: u64) { self.timestamp = a; self.note_dirty(); } pub fn set_timestamp(&mut self, a: u64) { self.timestamp = a; self.note_dirty(); }
/// TODO [Gav Wood] Please document me /// Set the timestamp field of the header to the current time.
pub fn set_timestamp_now(&mut self) { self.timestamp = now_utc().to_timespec().sec as u64; self.note_dirty(); } pub fn set_timestamp_now(&mut self) { self.timestamp = now_utc().to_timespec().sec as u64; self.note_dirty(); }
/// TODO [Gav Wood] Please document me /// Set the author field of the header.
pub fn set_author(&mut self, a: Address) { if a != self.author { self.author = a; self.note_dirty(); } } pub fn set_author(&mut self, a: Address) { if a != self.author { self.author = a; self.note_dirty(); } }
/// TODO [Gav Wood] Please document me /// Set the extra data field of the header.
pub fn set_extra_data(&mut self, a: Bytes) { if a != self.extra_data { self.extra_data = a; self.note_dirty(); } } pub fn set_extra_data(&mut self, a: Bytes) { if a != self.extra_data { self.extra_data = a; self.note_dirty(); } }
/// TODO [Gav Wood] Please document me /// Set the gas used field of the header.
pub fn set_gas_used(&mut self, a: U256) { self.gas_used = a; self.note_dirty(); } pub fn set_gas_used(&mut self, a: U256) { self.gas_used = a; self.note_dirty(); }
/// TODO [Gav Wood] Please document me /// Set the gas limit field of the header.
pub fn set_gas_limit(&mut self, a: U256) { self.gas_limit = a; self.note_dirty(); } pub fn set_gas_limit(&mut self, a: U256) { self.gas_limit = a; self.note_dirty(); }
/// TODO [Gav Wood] Please document me /// Set the difficulty field of the header.
pub fn set_difficulty(&mut self, a: U256) { self.difficulty = a; self.note_dirty(); } pub fn set_difficulty(&mut self, a: U256) { self.difficulty = a; self.note_dirty(); }
/// TODO [Gav Wood] Please document me /// Set the seal field of the header.
pub fn set_seal(&mut self, a: Vec<Bytes>) { self.seal = a; self.note_dirty(); } pub fn set_seal(&mut self, a: Vec<Bytes>) { self.seal = a; self.note_dirty(); }
/// Get the hash of this header (sha3 of the RLP). /// Get the hash of this header (sha3 of the RLP).
@ -163,7 +163,7 @@ impl Header {
} }
// TODO: make these functions traity // TODO: make these functions traity
/// TODO [Gav Wood] Please document me /// Place this header into an RLP stream `s`, optionally `with_seal`.
pub fn stream_rlp(&self, s: &mut RlpStream, with_seal: Seal) { pub fn stream_rlp(&self, s: &mut RlpStream, with_seal: Seal) {
s.begin_list(13 + match with_seal { Seal::With => self.seal.len(), _ => 0 }); s.begin_list(13 + match with_seal { Seal::With => self.seal.len(), _ => 0 });
s.append(&self.parent_hash); s.append(&self.parent_hash);
@ -186,14 +186,14 @@ impl Header {
} }
} }
/// TODO [Gav Wood] Please document me /// Get the RLP of this header, optionally `with_seal`.
pub fn rlp(&self, with_seal: Seal) -> Bytes { pub fn rlp(&self, with_seal: Seal) -> Bytes {
let mut s = RlpStream::new(); let mut s = RlpStream::new();
self.stream_rlp(&mut s, with_seal); self.stream_rlp(&mut s, with_seal);
s.out() s.out()
} }
/// TODO [debris] Please document me /// Get the SHA3 (Keccak) of this header, optionally `with_seal`.
pub fn rlp_sha3(&self, with_seal: Seal) -> H256 { self.rlp(with_seal).sha3() } pub fn rlp_sha3(&self, with_seal: Seal) -> H256 { self.rlp(with_seal).sha3() }
} }

View File

@ -15,12 +15,12 @@ pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec<String> {
{ {
let mut fail_unless = |cond: bool| if !cond && !fail { let mut fail_unless = |cond: bool| if !cond && !fail {
failed.push(name.clone()); failed.push(name.clone());
flush(format!("FAIL\n")); flushln!("FAIL");
fail = true; fail = true;
true true
} else {false}; } else {false};
flush(format!(" - {}...", name)); flush!(" - {}...", name);
let blocks: Vec<(Bytes, bool)> = test["blocks"].as_array().unwrap().iter().map(|e| (xjson!(&e["rlp"]), e.find("blockHeader").is_some())).collect(); let blocks: Vec<(Bytes, bool)> = test["blocks"].as_array().unwrap().iter().map(|e| (xjson!(&e["rlp"]), e.find("blockHeader").is_some())).collect();
let mut spec = match era { let mut spec = match era {
@ -50,7 +50,7 @@ pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec<String> {
} }
} }
if !fail { if !fail {
flush(format!("ok\n")); flushln!("ok");
} }
} }
println!("!!! {:?} tests from failed.", failed.len()); println!("!!! {:?} tests from failed.", failed.len());

View File

@ -19,19 +19,19 @@ pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec<String> {
ChainEra::Homestead => ethereum::new_homestead_test(), ChainEra::Homestead => ethereum::new_homestead_test(),
}.to_engine().unwrap(); }.to_engine().unwrap();
flush(format!("\n")); flushln!("");
for (name, test) in json.as_object().unwrap() { for (name, test) in json.as_object().unwrap() {
let mut fail = false; let mut fail = false;
{ {
let mut fail_unless = |cond: bool| if !cond && !fail { let mut fail_unless = |cond: bool| if !cond && !fail {
failed.push(name.clone()); failed.push(name.clone());
flush(format!("FAIL\n")); flushln!("FAIL");
fail = true; fail = true;
true true
} else {false}; } else {false};
flush(format!(" - {}...", name)); flush!(" - {}...", name);
let t = Transaction::from_json(&test["transaction"]); let t = Transaction::from_json(&test["transaction"]);
let env = EnvInfo::from_json(&test["env"]); let env = EnvInfo::from_json(&test["env"]);
@ -73,7 +73,7 @@ pub fn json_chain_test(json_data: &[u8], era: ChainEra) -> Vec<String> {
} }
} }
if !fail { if !fail {
flush(format!("ok\n")); flushln!("ok");
} }
// TODO: Add extra APIs for output // TODO: Add extra APIs for output
//if fail_unless(out == r.) //if fail_unless(out == r.)

View File

@ -1,14 +1,14 @@
use util::*; use util::*;
use basic_types::LogBloom; use basic_types::LogBloom;
/// A single log's entry. /// A record of execution for a `LOG` operation.
#[derive(Default, Debug, Clone, PartialEq, Eq)] #[derive(Default, Debug, Clone, PartialEq, Eq)]
pub struct LogEntry { pub struct LogEntry {
/// TODO [Gav Wood] Please document me /// The address of the contract executing at the point of the `LOG` operation.
pub address: Address, pub address: Address,
/// TODO [Gav Wood] Please document me /// The topics associated with the `LOG` operation.
pub topics: Vec<H256>, pub topics: Vec<H256>,
/// TODO [Gav Wood] Please document me /// The data associated with the `LOG` operation.
pub data: Bytes, pub data: Bytes,
} }

View File

@ -2,15 +2,16 @@ use util::*;
use account::*; use account::*;
#[derive(Debug,Clone,PartialEq,Eq)] #[derive(Debug,Clone,PartialEq,Eq)]
/// Genesis account data. Does not have a DB overlay cache. /// An account, expressed as Plain-Old-Data (hence the name).
/// Does not have a DB overlay cache, code hash or anything like that.
pub struct PodAccount { pub struct PodAccount {
/// TODO [Gav Wood] Please document me /// The balance of the account.
pub balance: U256, pub balance: U256,
/// TODO [Gav Wood] Please document me /// The nonce of the account.
pub nonce: U256, pub nonce: U256,
/// TODO [Gav Wood] Please document me /// The code of the account.
pub code: Bytes, pub code: Bytes,
/// TODO [Gav Wood] Please document me /// The storage of the account.
pub storage: BTreeMap<H256, H256>, pub storage: BTreeMap<H256, H256>,
} }

View File

@ -2,7 +2,7 @@ use util::*;
use pod_account::*; use pod_account::*;
#[derive(Debug,Clone,PartialEq,Eq,Default)] #[derive(Debug,Clone,PartialEq,Eq,Default)]
/// TODO [Gav Wood] Please document me /// State of all accounts in the system expressed in Plain Old Data.
pub struct PodState (BTreeMap<Address, PodAccount>); pub struct PodState (BTreeMap<Address, PodAccount>);
impl PodState { impl PodState {

View File

@ -5,18 +5,18 @@ use log_entry::LogEntry;
/// Information describing execution of a transaction. /// Information describing execution of a transaction.
#[derive(Default, Debug, Clone)] #[derive(Default, Debug, Clone)]
pub struct Receipt { pub struct Receipt {
/// TODO [Gav Wood] Please document me /// The state root after executing the transaction.
pub state_root: H256, pub state_root: H256,
/// TODO [Gav Wood] Please document me /// The total gas used in the block following execution of the transaction.
pub gas_used: U256, pub gas_used: U256,
/// TODO [Gav Wood] Please document me /// The OR-wide combination of all logs' blooms for this transaction.
pub log_bloom: LogBloom, pub log_bloom: LogBloom,
/// TODO [Gav Wood] Please document me /// The logs stemming from this transaction.
pub logs: Vec<LogEntry>, pub logs: Vec<LogEntry>,
} }
impl Receipt { impl Receipt {
/// TODO [Gav Wood] Please document me /// Create a new receipt.
pub fn new(state_root: H256, gas_used: U256, logs: Vec<LogEntry>) -> Receipt { pub fn new(state_root: H256, gas_used: U256, logs: Vec<LogEntry>) -> Receipt {
Receipt { Receipt {
state_root: state_root, state_root: state_root,

View File

@ -34,53 +34,50 @@ fn json_to_rlp_map(json: &Json) -> HashMap<String, Bytes> {
/// chain and those to be interpreted by the active chain engine. /// chain and those to be interpreted by the active chain engine.
#[derive(Debug)] #[derive(Debug)]
pub struct Spec { pub struct Spec {
// User friendly spec name /// User friendly spec name
/// TODO [Gav Wood] Please document me
pub name: String, pub name: String,
// What engine are we using for this? /// What engine are we using for this?
/// TODO [Gav Wood] Please document me
pub engine_name: String, pub engine_name: String,
/// Known nodes on the network in enode format. /// Known nodes on the network in enode format.
pub nodes: Vec<String>, pub nodes: Vec<String>,
// Parameters concerning operation of the specific engine we're using. /// Parameters concerning operation of the specific engine we're using.
// Name -> RLP-encoded value /// Maps the parameter name to an RLP-encoded value.
/// TODO [Gav Wood] Please document me
pub engine_params: HashMap<String, Bytes>, pub engine_params: HashMap<String, Bytes>,
// Builtin-contracts are here for now but would like to abstract into Engine API eventually. /// Builtin-contracts we would like to see in the chain.
/// TODO [Gav Wood] Please document me /// (In principle these are just hints for the engine since that has the last word on them.)
pub builtins: BTreeMap<Address, Builtin>, pub builtins: BTreeMap<Address, Builtin>,
// Genesis params. /// The genesis block's parent hash field.
/// TODO [Gav Wood] Please document me
pub parent_hash: H256, pub parent_hash: H256,
/// TODO [Gav Wood] Please document me /// The genesis block's author field.
pub author: Address, pub author: Address,
/// TODO [Gav Wood] Please document me /// The genesis block's difficulty field.
pub difficulty: U256, pub difficulty: U256,
/// TODO [Gav Wood] Please document me /// The genesis block's gas limit field.
pub gas_limit: U256, pub gas_limit: U256,
/// TODO [Gav Wood] Please document me /// The genesis block's gas used field.
pub gas_used: U256, pub gas_used: U256,
/// TODO [Gav Wood] Please document me /// The genesis block's timestamp field.
pub timestamp: u64, pub timestamp: u64,
/// Transactions root of the genesis block. Should be SHA3_NULL_RLP. /// Transactions root of the genesis block. Should be SHA3_NULL_RLP.
pub transactions_root: H256, pub transactions_root: H256,
/// Receipts root of the genesis block. Should be SHA3_NULL_RLP. /// Receipts root of the genesis block. Should be SHA3_NULL_RLP.
pub receipts_root: H256, pub receipts_root: H256,
/// TODO [arkpar] Please document me /// The genesis block's extra data field.
pub extra_data: Bytes, pub extra_data: Bytes,
/// TODO [Gav Wood] Please document me /// The number of seal fields in the genesis block.
genesis_state: PodState,
/// TODO [Gav Wood] Please document me
pub seal_fields: usize, pub seal_fields: usize,
/// TODO [Gav Wood] Please document me /// Each seal field, expressed as RLP, concatenated.
pub seal_rlp: Bytes, pub seal_rlp: Bytes,
// May be prepopulated if we know this in advance. // May be prepopulated if we know this in advance.
state_root_memo: RwLock<Option<H256>>, state_root_memo: RwLock<Option<H256>>,
// Genesis state as plain old data.
genesis_state: PodState,
} }
#[allow(wrong_self_convention)] // because to_engine(self) should be to_engine(&self) #[allow(wrong_self_convention)] // because to_engine(self) should be to_engine(&self)
@ -106,7 +103,7 @@ impl Spec {
/// Get the known knodes of the network in enode format. /// Get the known knodes of the network in enode format.
pub fn nodes(&self) -> &Vec<String> { &self.nodes } pub fn nodes(&self) -> &Vec<String> { &self.nodes }
/// TODO [Gav Wood] Please document me /// Get the header of the genesis block.
pub fn genesis_header(&self) -> Header { pub fn genesis_header(&self) -> Header {
Header { Header {
parent_hash: self.parent_hash.clone(), parent_hash: self.parent_hash.clone(),

View File

@ -5,7 +5,7 @@ use pod_account::*;
use pod_state::PodState; use pod_state::PodState;
//use state_diff::*; // TODO: uncomment once to_pod() works correctly. //use state_diff::*; // TODO: uncomment once to_pod() works correctly.
/// TODO [Gav Wood] Please document me /// Result type for the execution ("application") of a transaction.
pub type ApplyResult = Result<Receipt, Error>; pub type ApplyResult = Result<Receipt, Error>;
/// Representation of the entire state of all accounts in the system. /// Representation of the entire state of all accounts in the system.

View File

@ -3,7 +3,8 @@ use pod_state::*;
use account_diff::*; use account_diff::*;
#[derive(Debug,Clone,PartialEq,Eq)] #[derive(Debug,Clone,PartialEq,Eq)]
/// TODO [Gav Wood] Please document me /// Expression for the delta between two system states. Encoded the
/// delta of every altered account.
pub struct StateDiff (BTreeMap<Address, AccountDiff>); pub struct StateDiff (BTreeMap<Address, AccountDiff>);
impl StateDiff { impl StateDiff {

View File

@ -26,7 +26,7 @@ impl Substate {
} }
} }
/// TODO [Gav Wood] Please document me /// Merge secondary substate `s` into self, accruing each element correspondingly.
pub fn accrue(&mut self, s: Substate) { pub fn accrue(&mut self, s: Substate) {
self.suicides.extend(s.suicides.into_iter()); self.suicides.extend(s.suicides.into_iter());
self.logs.extend(s.logs.into_iter()); self.logs.extend(s.logs.into_iter());

View File

@ -36,11 +36,11 @@ pub struct Transaction {
pub data: Bytes, pub data: Bytes,
// signature // signature
/// TODO [Gav Wood] Please document me /// The V field of the signature, either 27 or 28; helps describe the point on the curve.
pub v: u8, pub v: u8,
/// TODO [Gav Wood] Please document me /// The R field of the signature; helps describe the point on the curve.
pub r: U256, pub r: U256,
/// TODO [debris] Please document me /// The S field of the signature; helps describe the point on the curve.
pub s: U256, pub s: U256,
hash: RefCell<Option<H256>>, hash: RefCell<Option<H256>>,
@ -48,7 +48,7 @@ pub struct Transaction {
} }
impl Transaction { impl Transaction {
/// TODO [Gav Wood] Please document me /// Create a new transaction.
#[cfg(test)] #[cfg(test)]
pub fn new() -> Self { pub fn new() -> Self {
Transaction { Transaction {

View File

@ -154,7 +154,7 @@ pub fn verify_block_final(expected: &Header, got: &Header) -> Result<(), Error>
return Err(From::from(BlockError::InvalidStateRoot(Mismatch { expected: expected.state_root.clone(), found: got.state_root.clone() }))) return Err(From::from(BlockError::InvalidStateRoot(Mismatch { expected: expected.state_root.clone(), found: got.state_root.clone() })))
} }
if expected.receipts_root != got.receipts_root { if expected.receipts_root != got.receipts_root {
return Err(From::from(BlockError::InvalidReceiptsStateRoot(Mismatch { expected: expected.receipts_root.clone(), found: got.receipts_root.clone() }))) return Err(From::from(BlockError::InvalidReceiptsRoot(Mismatch { expected: expected.receipts_root.clone(), found: got.receipts_root.clone() })))
} }
Ok(()) Ok(())
} }

View File

@ -83,11 +83,12 @@ impl<'a> fmt::Display for PrettySlice<'a> {
} }
} }
/// TODO [Gav Wood] Please document me /// Trait to allow a type to be pretty-printed in `format!`, where unoverridable
/// defaults cannot otherwise be avoided.
pub trait ToPretty { pub trait ToPretty {
/// TODO [Gav Wood] Please document me /// Convert a type into a derivative form in order to make `format!` print it prettily.
fn pretty(&self) -> PrettySlice; fn pretty(&self) -> PrettySlice;
/// TODO [Gav Wood] Please document me /// Express the object as a hex string.
fn to_hex(&self) -> String { fn to_hex(&self) -> String {
format!("{}", self.pretty()) format!("{}", self.pretty())
} }
@ -144,11 +145,12 @@ pub type Bytes = Vec<u8>;
/// Slice of bytes to underlying memory /// Slice of bytes to underlying memory
pub trait BytesConvertable { pub trait BytesConvertable {
// TODO: rename to as_slice // TODO: rename to as_slice
/// TODO [Gav Wood] Please document me /// Get the underlying byte-wise representation of the value.
/// Deprecated - use `as_slice` instead.
fn bytes(&self) -> &[u8]; fn bytes(&self) -> &[u8];
/// TODO [Gav Wood] Please document me /// Get the underlying byte-wise representation of the value.
fn as_slice(&self) -> &[u8] { self.bytes() } fn as_slice(&self) -> &[u8] { self.bytes() }
/// TODO [Gav Wood] Please document me /// Get a copy of the underlying byte-wise representation.
fn to_bytes(&self) -> Bytes { self.as_slice().to_vec() } fn to_bytes(&self) -> Bytes { self.as_slice().to_vec() }
} }

View File

@ -48,7 +48,7 @@ macro_rules! flushln {
($fmt:expr, $($arg:tt)*) => (flush!(concat!($fmt, "\n"), $($arg)*)); ($fmt:expr, $($arg:tt)*) => (flush!(concat!($fmt, "\n"), $($arg)*));
} }
/// TODO [Gav Wood] Please document me #[doc(hidden)]
pub fn flush(s: String) { pub fn flush(s: String) {
::std::io::stdout().write(s.as_bytes()).unwrap(); ::std::io::stdout().write(s.as_bytes()).unwrap();
::std::io::stdout().flush().unwrap(); ::std::io::stdout().flush().unwrap();

View File

@ -72,7 +72,7 @@ impl<'db> TrieDBMut<'db> {
// TODO: return Result<Self, TrieError> // TODO: return Result<Self, TrieError>
pub fn from_existing(db: &'db mut HashDB, root: &'db mut H256) -> Self { pub fn from_existing(db: &'db mut HashDB, root: &'db mut H256) -> Self {
if !db.exists(root) { if !db.exists(root) {
flush(format!("Trie root not found {}", root)); flushln!("Trie root not found {}", root);
panic!("Trie root not found!"); panic!("Trie root not found!");
} }
TrieDBMut { TrieDBMut {