Merge branch 'master' into Fix-4858
This commit is contained in:
commit
88200a1193
@ -521,7 +521,9 @@ impl Engine for AuthorityRound {
|
||||
let parent_hash = block.fields().header.parent_hash().clone();
|
||||
::engines::common::push_last_hash(block, last_hashes.clone(), self, &parent_hash)?;
|
||||
|
||||
if !epoch_begin { return Ok(()) }
|
||||
// with immediate transitions, we don't use the epoch mechanism anyway.
|
||||
// the genesis is always considered an epoch, but we ignore it intentionally.
|
||||
if self.immediate_transitions || !epoch_begin { return Ok(()) }
|
||||
|
||||
// genesis is never a new block, but might as well check.
|
||||
let header = block.fields().header.clone();
|
||||
|
@ -346,7 +346,6 @@ impl Spec {
|
||||
};
|
||||
|
||||
let mut substate = Substate::new();
|
||||
state.kill_account(&address);
|
||||
|
||||
{
|
||||
let mut exec = Executive::new(&mut state, &env_info, self.engine.as_ref());
|
||||
@ -554,6 +553,9 @@ mod tests {
|
||||
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 = H256::from_str("0000000000000000000000000000000000000000000000000000000000000001").unwrap();
|
||||
assert_eq!(state.storage_at(&Address::from_str("0000000000000000000000000000000000000005").unwrap(), &H256::zero()).unwrap(), expected);
|
||||
let address = Address::from_str("0000000000000000000000000000000000000005").unwrap();
|
||||
|
||||
assert_eq!(state.storage_at(&address, &H256::zero()).unwrap(), expected);
|
||||
assert_eq!(state.balance(&address).unwrap(), 1.into());
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: parity
|
||||
version: master
|
||||
version: git
|
||||
summary: Fast, light, robust Ethereum implementation
|
||||
description: |
|
||||
Parity's goal is to be the fastest, lightest, and most secure Ethereum
|
||||
|
@ -367,44 +367,50 @@ impl<'a> TrieDBMut<'a> {
|
||||
}
|
||||
|
||||
// walk the trie, attempting to find the key's node.
|
||||
fn lookup<'x, 'key>(&'x self, partial: NibbleSlice<'key>, handle: &NodeHandle) -> super::Result<Option<DBValue>>
|
||||
fn lookup<'x, 'key>(&'x self, mut partial: NibbleSlice<'key>, handle: &NodeHandle) -> super::Result<Option<DBValue>>
|
||||
where 'x: 'key
|
||||
{
|
||||
match *handle {
|
||||
NodeHandle::Hash(ref hash) => Lookup {
|
||||
db: &*self.db,
|
||||
query: DBValue::from_slice,
|
||||
hash: hash.clone(),
|
||||
}.look_up(partial),
|
||||
NodeHandle::InMemory(ref handle) => match self.storage[handle] {
|
||||
Node::Empty => Ok(None),
|
||||
Node::Leaf(ref key, ref value) => {
|
||||
if NibbleSlice::from_encoded(key).0 == partial {
|
||||
Ok(Some(DBValue::from_slice(value)))
|
||||
} else {
|
||||
Ok(None)
|
||||
let mut handle = handle;
|
||||
loop {
|
||||
let (mid, child) = match *handle {
|
||||
NodeHandle::Hash(ref hash) => return Lookup {
|
||||
db: &*self.db,
|
||||
query: DBValue::from_slice,
|
||||
hash: hash.clone(),
|
||||
}.look_up(partial),
|
||||
NodeHandle::InMemory(ref handle) => match self.storage[handle] {
|
||||
Node::Empty => return Ok(None),
|
||||
Node::Leaf(ref key, ref value) => {
|
||||
if NibbleSlice::from_encoded(key).0 == partial {
|
||||
return Ok(Some(DBValue::from_slice(value)));
|
||||
} else {
|
||||
return Ok(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
Node::Extension(ref slice, ref child) => {
|
||||
let slice = NibbleSlice::from_encoded(slice).0;
|
||||
if partial.starts_with(&slice) {
|
||||
self.lookup(partial.mid(slice.len()), child)
|
||||
} else {
|
||||
Ok(None)
|
||||
Node::Extension(ref slice, ref child) => {
|
||||
let slice = NibbleSlice::from_encoded(slice).0;
|
||||
if partial.starts_with(&slice) {
|
||||
(slice.len(), child)
|
||||
} else {
|
||||
return Ok(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
Node::Branch(ref children, ref value) => {
|
||||
if partial.is_empty() {
|
||||
Ok(value.as_ref().map(|v| DBValue::from_slice(v)))
|
||||
} else {
|
||||
let idx = partial.at(0);
|
||||
match children[idx as usize].as_ref() {
|
||||
Some(child) => self.lookup(partial.mid(1), child),
|
||||
None => Ok(None),
|
||||
Node::Branch(ref children, ref value) => {
|
||||
if partial.is_empty() {
|
||||
return Ok(value.as_ref().map(|v| DBValue::from_slice(v)));
|
||||
} else {
|
||||
let idx = partial.at(0);
|
||||
match children[idx as usize].as_ref() {
|
||||
Some(child) => (1, child),
|
||||
None => return Ok(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
partial = partial.mid(mid);
|
||||
handle = child;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user