-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add a optional json dump state to evm-bin #9706
Changes from 1 commit
b06a2ad
08f4d13
7dccffa
280e97b
fea5dd6
a6feb4e
8dcab6c
8e40d2e
c4e0ed6
a4f7c65
0f66e39
6a6e019
e9add15
f4d4700
78470ab
ab3c485
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,21 +31,29 @@ use state::Account; | |
use ethjson; | ||
use types::account_diff::*; | ||
use rlp::{self, RlpStream}; | ||
use serde::Serializer; | ||
use rustc_hex::ToHex; | ||
|
||
#[derive(Debug, Clone, PartialEq, Eq)] | ||
#[derive(Debug, Clone, PartialEq, Eq, Serialize)] | ||
/// 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 { | ||
/// The balance of the account. | ||
pub balance: U256, | ||
/// The nonce of the account. | ||
pub nonce: U256, | ||
#[serde(serialize_with="opt_bytes_to_hex")] | ||
/// The code of the account or `None` in the special case that it is unknown. | ||
pub code: Option<Bytes>, | ||
/// The storage of the account. | ||
pub storage: BTreeMap<H256, H256>, | ||
} | ||
|
||
fn opt_bytes_to_hex<S>(opt_bytes: &Option<Bytes>, serializer: S) -> Result<S::Ok, S::Error> | ||
where S: Serializer { | ||
serializer.collect_str(&format_args!("0x{}",opt_bytes.as_ref().map(|b|b.to_hex()).unwrap_or("".to_string()))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does not implement it, alas There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider to replace |
||
} | ||
|
||
impl PodAccount { | ||
/// Convert Account to a PodAccount. | ||
/// NOTE: This will silently fail unless the account is fully cached. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ use types::state_diff::StateDiff; | |
use ethjson; | ||
|
||
/// State of all accounts in the system expressed in Plain Old Data. | ||
#[derive(Debug, Clone, PartialEq, Eq, Default)] | ||
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize)] | ||
pub struct PodState (BTreeMap<Address, PodAccount>); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not related to this PR, but there's an extra space between |
||
|
||
impl PodState { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,7 +66,7 @@ impl Fail { | |
} | ||
|
||
impl fmt::Display for Fail { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo -- looks like incorrect indentation. |
||
use self::Fail::*; | ||
match *self { | ||
Return { ref expected, ref actual } => | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
odd whitespace here, should be