Skip to content

Commit

Permalink
Merge pull request #99 from aionnetwork/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
lyj729047457 authored Dec 16, 2019
2 parents 7fd720c + 5f796c2 commit 0139382
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 12 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
description = "aion network rust implementation"
name = "aionr"
# NOTE Make sure to update util/version/Cargo.toml as well
version = "1.0.2"
version = "1.0.3"
license = "GPL-3.0"
authors = ["aion foundation <[email protected]>"]

Expand Down
8 changes: 8 additions & 0 deletions core/src/db/state_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,14 @@ impl state::Backend for StateDB {
.map(|a| a.as_ref().map(|a| a.clone_basic()))
}

fn force_update(&mut self, addr: &Address, account: &AionVMAccount) {
let mut cache = self.account_cache.lock();

if let Some(&mut Some(ref mut existing)) = cache.accounts.get_mut(addr) {
existing.overwrite_with(account.clone());
}
}

fn get_cached_code(&self, hash: &H256) -> Option<Arc<Vec<u8>>> {
let mut cache = self.code_cache.lock();

Expand Down
2 changes: 1 addition & 1 deletion core/src/engine/unity_engine/header_validators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl HeaderValidator for FutureTimestampValidator {
.unwrap()
.as_secs();
if timestamp > timestamp_now + FUTURE_TIME_TOLERANCE {
error!(target: "validator", "block timestamp ({}) > local system time ({}) + {}", timestamp, timestamp_now, FUTURE_TIME_TOLERANCE);
debug!(target: "validator", "block timestamp ({}) > local system time ({}) + {}", timestamp, timestamp_now, FUTURE_TIME_TOLERANCE);
return Err(BlockError::InvalidFutureTimestamp(OutOfBounds {
min: None,
max: Some(timestamp_now + FUTURE_TIME_TOLERANCE),
Expand Down
2 changes: 2 additions & 0 deletions core/src/state/account/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,8 @@ impl AionVMAccount {
None
}

pub fn is_removed(&self, key: &Bytes) -> bool { return self.storage_removable.contains(key); }

pub fn set_storage(&mut self, key: Bytes, value: Bytes) {
// update removable set
if self.storage_removable.contains(&key) {
Expand Down
5 changes: 5 additions & 0 deletions core/src/state/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ pub trait Backend: Send {
/// Check whether an account is known to be empty. Returns true if known to be
/// empty, false otherwise.
fn is_known_null(&self, address: &Address) -> bool;

fn force_update(&mut self, address: &Address, account: &AionVMAccount);
}

/// A raw backend used to check proofs of execution.
Expand Down Expand Up @@ -127,6 +129,7 @@ impl Backend for ProofCheck {
fn get_cached_code(&self, _hash: &H256) -> Option<Arc<Vec<u8>>> { None }
fn note_non_null_account(&self, _address: &Address) {}
fn is_known_null(&self, _address: &Address) -> bool { false }
fn force_update(&mut self, _addr: &Address, _account: &AionVMAccount) {}
}

/// Proving state backend.
Expand Down Expand Up @@ -190,6 +193,7 @@ impl<H: AsHashStore + Send + Sync> Backend for Proving<H> {
fn get_cached_code(&self, _: &H256) -> Option<Arc<Vec<u8>>> { None }
fn note_non_null_account(&self, _: &Address) {}
fn is_known_null(&self, _: &Address) -> bool { false }
fn force_update(&mut self, _addr: &Address, _account: &AionVMAccount) {}
}

impl<H: AsHashStore + Clone> Clone for Proving<H> {
Expand Down Expand Up @@ -225,4 +229,5 @@ impl<H: AsHashStore + Send + Sync> Backend for Basic<H> {
fn get_cached_code(&self, _: &H256) -> Option<Arc<Vec<u8>>> { None }
fn note_non_null_account(&self, _: &Address) {}
fn is_known_null(&self, _: &Address) -> bool { false }
fn force_update(&mut self, _addr: &Address, _account: &AionVMAccount) {}
}
10 changes: 10 additions & 0 deletions core/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ impl<B: Backend> State<B> {
if let Some(value) = account.cached_storage_at(key) {
// println!("TT: 1");
return Ok(Some(value));
} else if account.is_removed(key) {
return Ok(None);
} else {
// storage not cached, will try local search later
local_account = Some(maybe_acc);
Expand Down Expand Up @@ -907,10 +909,18 @@ impl<B: Backend> State<B> {
}
}
}

if !account.is_empty() {
self.db.note_non_null_account(address);
}
}

// TODO: I wonder whether we rely on this
// if let Some(ref mut account) = a.account {
// if account.acc_type() == AccType::AVM {
// self.db.force_update(address, account);
// }
// }
}

{
Expand Down
2 changes: 1 addition & 1 deletion core/src/sync/handler/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ pub fn handle_broadcast_block(
}
Err(e) => {
// ignore this batch if any invalidated header
error!(target: "sync", "Invalid header: {:?}, header: {}", e, to_hex(header_rlp.as_raw()));
debug!(target: "sync", "Invalid header: {:?}, header: {}", e, to_hex(header_rlp.as_raw()));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/sync/handler/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,12 @@ pub fn receive_res(p2p: Mgr, hash: u64, cb_in: ChannelBuffer, storage: Arc<SyncS
}
Err(e) => {
// ignore this batch if any invalidated header
error!(target: "sync", "Invalid header: {:?}, header: {}", e, to_hex(header_rlp.as_raw()));
debug!(target: "sync", "Invalid header: {:?}, header: {}", e, to_hex(header_rlp.as_raw()));
break;
}
}
} else {
error!(target: "sync", "Invalid header: {}", to_hex(header_rlp.as_raw()));
debug!(target: "sync", "Invalid header: {}", to_hex(header_rlp.as_raw()));
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.2
1.0.3
2 changes: 1 addition & 1 deletion util/version/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[package]
name = "aion-version"
# NOTE: this value is used for Aion version string (via env CARGO_PKG_VERSION)
version = "1.0.2"
version = "1.0.3"
authors = ["Aion Foundation <[email protected]>"]
build = "build.rs"

Expand Down

0 comments on commit 0139382

Please sign in to comment.