Backport fixes to stable (#1855)

* Fix up the VM trace.

* Fix test.

* Fix state not using "account_starting_nonce" (#1830)

* failng test

* use account_starting_nonce instead of zero

* simplier test

* jsons are getting closer

* incorrect test client and incorrect tests fix

* null_morden is using 0x0 starting nonce

* replaced json with the correct one

* superwhatever line

* Bump json-ipc-server again (#1839)

* bump ipc version

* bumping once more

* v1.2.4

* Fixed reported max height and transaction propagation (#1852)

* Fixed max height and transaction propagation

* Fixed tests
This commit is contained in:
Arkadiy Paronyan
2016-08-05 23:34:06 +02:00
committed by Gav Wood
parent a9a41a03c5
commit aa9b152f76
13 changed files with 118 additions and 28 deletions

View File

@@ -4,7 +4,7 @@
"Null": null
},
"params": {
"accountStartNonce": "0x0100000",
"accountStartNonce": "0x0",
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x1388",
"networkID" : "0x2"

View File

@@ -66,6 +66,8 @@ pub struct TestBlockChainClient {
pub queue_size: AtomicUsize,
/// Miner
pub miner: Arc<Miner>,
/// Test spec
spec: Spec,
}
#[derive(Clone)]
@@ -105,6 +107,7 @@ impl TestBlockChainClient {
receipts: RwLock::new(HashMap::new()),
queue_size: AtomicUsize::new(0),
miner: Arc::new(Miner::with_spec(Spec::new_test())),
spec: Spec::new_test(),
};
client.add_blocks(1, EachBlockWith::Nothing); // add genesis block
client.genesis_hash = client.last_hash.read().unwrap().clone();
@@ -267,7 +270,7 @@ impl BlockChainClient for TestBlockChainClient {
fn nonce(&self, address: &Address, id: BlockID) -> Option<U256> {
match id {
BlockID::Latest => Some(self.nonces.read().unwrap().get(address).cloned().unwrap_or_else(U256::zero)),
BlockID::Latest => Some(self.nonces.read().unwrap().get(address).cloned().unwrap_or(self.spec.params.account_start_nonce)),
_ => None,
}
}

View File

@@ -98,11 +98,11 @@ impl<'a> Executive<'a> {
let check = options.check_nonce;
match options.tracing {
true => match options.vm_tracing {
true => self.transact_with_tracer(t, check, ExecutiveTracer::default(), ExecutiveVMTracer::default()),
true => self.transact_with_tracer(t, check, ExecutiveTracer::default(), ExecutiveVMTracer::toplevel()),
false => self.transact_with_tracer(t, check, ExecutiveTracer::default(), NoopVMTracer),
},
false => match options.vm_tracing {
true => self.transact_with_tracer(t, check, NoopTracer, ExecutiveVMTracer::default()),
true => self.transact_with_tracer(t, check, NoopTracer, ExecutiveVMTracer::toplevel()),
false => self.transact_with_tracer(t, check, NoopTracer, NoopVMTracer),
},
}
@@ -633,7 +633,7 @@ mod tests {
let engine = TestEngine::new(5);
let mut substate = Substate::new();
let mut tracer = ExecutiveTracer::default();
let mut vm_tracer = ExecutiveVMTracer::default();
let mut vm_tracer = ExecutiveVMTracer::toplevel();
let gas_left = {
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
@@ -692,7 +692,7 @@ mod tests {
],
subs: vec![
VMTrace {
parent_step: 7,
parent_step: 6,
code: vec![96, 16, 128, 96, 12, 96, 0, 57, 96, 0, 243, 0, 96, 0, 53, 84, 21, 96, 9, 87, 0, 91, 96, 32, 53, 96, 0, 53, 85],
operations: vec![
VMOperation { pc: 0, instruction: 96, gas_cost: 3.into(), executed: Some(VMExecutedOperation { gas_used: 67976.into(), stack_push: vec_into![16], mem_diff: None, store_diff: None }) },
@@ -742,7 +742,7 @@ mod tests {
let engine = TestEngine::new(5);
let mut substate = Substate::new();
let mut tracer = ExecutiveTracer::default();
let mut vm_tracer = ExecutiveVMTracer::default();
let mut vm_tracer = ExecutiveVMTracer::toplevel();
let gas_left = {
let mut ex = Executive::new(&mut state, &info, &engine, &factory);

View File

@@ -167,7 +167,7 @@ impl State {
/// Get the nonce of account `a`.
pub fn nonce(&self, a: &Address) -> U256 {
self.get(a, false).as_ref().map_or(U256::zero(), |account| *account.nonce())
self.get(a, false).as_ref().map_or(self.account_start_nonce, |account| *account.nonce())
}
/// Mutate storage of account `address` so that it is `value` for `key`.

View File

@@ -155,11 +155,24 @@ impl Tracer for ExecutiveTracer {
}
/// Simple VM tracer. Traces all operations.
#[derive(Default)]
pub struct ExecutiveVMTracer {
data: VMTrace,
}
impl ExecutiveVMTracer {
/// Create a new top-level instance.
pub fn toplevel() -> Self {
ExecutiveVMTracer {
data: VMTrace {
parent_step: 0,
code: vec![],
operations: vec![Default::default()], // prefill with a single entry so that prepare_subtrace can get the parent_step
subs: vec![],
}
}
}
}
impl VMTracer for ExecutiveVMTracer {
fn trace_prepare_execute(&mut self, pc: usize, instruction: u8, gas_cost: &U256) -> bool {
self.data.operations.push(VMOperation {
@@ -183,7 +196,7 @@ impl VMTracer for ExecutiveVMTracer {
fn prepare_subtrace(&self, code: &[u8]) -> Self {
ExecutiveVMTracer { data: VMTrace {
parent_step: self.data.operations.len(),
parent_step: self.data.operations.len() - 1, // won't overflow since we must already have pushed an operation in trace_prepare_execute.
code: code.to_vec(),
operations: vec![],
subs: vec![],

View File

@@ -473,7 +473,7 @@ impl Decodable for VMExecutedOperation {
}
}
#[derive(Debug, Clone, PartialEq, Binary)]
#[derive(Debug, Clone, PartialEq, Binary, Default)]
/// A record of the execution of a single VM operation.
pub struct VMOperation {
/// The program counter.