Conversation
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.
There should also be a mechanism for detecting a reorganization which is too large and rebuilding old states in the journal so it's not a fatal error which ruins the database forever. (now that tx verification happens after block import, we could just check if route.retracted > self.history
). Maybe not for a hotfix release, but this is important for the future.
while era <= latest - config.history { | ||
trace!("Removing era {}", era); | ||
let batch = DBTransaction::new(&db); | ||
try!(state_db.journal_db_mut().commit_old(&batch, era, &chain.block_hash(era).expect("Old block not found in the database"))); |
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.
This is exactly why I made https://github.com/ethcore/parity/pull/2329. There is no need for commit
, commit_old
since they work the same way.
It should just mark_canonical
in a loop.
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.
I understand this is beta
, but I would strongly suggest using that mechanism for the version that lands on master
.
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.
agreed
if let (Some(earliest), Some(latest)) = (state_db.journal_db().earliest_era(), state_db.journal_db().latest_era()) { | ||
if latest > earliest && latest - earliest > config.history { | ||
let mut era = earliest; | ||
while era <= latest - config.history { |
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.
for era in earliest..(latest - config.history + 1) {
is a bit less error-prone.
@@ -219,6 +219,8 @@ Footprint Options: | |||
fast - maintain journal overlay. Fast but 50MB used. | |||
auto - use the method most recently synced or | |||
default to fast if none synced [default: auto]. | |||
--pruning-history NUM Set a number of recent states to keep when pruning | |||
is active. [default: 64]. |
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.
Isn't ~128 a bit safer? Although the mainnet isn't often susceptible to reorgs beyond 5 or so, the testnet, ETC, expanse, or private chains don't have quite the same level of stability.
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.
They are more stable than ETH currently. ETH has higher uncle rate because of the attack.
@@ -73,6 +73,7 @@ impl Configuration { | |||
pub fn into_command(self) -> Result<Cmd, String> { | |||
let dirs = self.directories(); | |||
let pruning = try!(self.args.flag_pruning.parse()); | |||
let pruning_history = self.args.flag_pruning_history; |
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.
History below a certain amount shouldn't be allowed until we have a way to recover from a prehistoric reorganization.
@@ -187,6 +188,19 @@ impl Client { | |||
try!(db.write(batch).map_err(ClientError::Database)); | |||
} | |||
|
|||
trace!("Cleanup journal: DB Earliest = {:?}, Latest = {:?}", state_db.journal_db().earliest_era(), state_db.journal_db().latest_era()); | |||
let history = cmp::max(MIN_HISTORY_SIZE, config.history); |
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.
an issue with this approach is that the user has no idea that their pruning argument is ignored.
if let (Some(earliest), Some(latest)) = (state_db.journal_db().earliest_era(), state_db.journal_db().latest_era()) { | ||
if latest > earliest && latest - earliest > history { | ||
for era in earliest..(latest - history + 1) { | ||
trace!("Removing era {}", era); |
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.
The new traces here have no target
.
4b04d6b
to
3784c6c
Compare
@@ -73,6 +74,7 @@ pub use blockchain::CacheSize as BlockChainCacheSize; | |||
|
|||
const MAX_TX_QUEUE_SIZE: usize = 4096; | |||
const MAX_QUEUE_SIZE_TO_SLEEP_ON: usize = 2; | |||
const MIN_HISTORY_SIZE: u64 = 64; |
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.
why so high for the limit? seems a bit odd when default == min limit
would have liked to see at least one test. |
@@ -395,6 +395,10 @@ impl<'x> OpenBlock<'x> { | |||
uncle_bytes: uncle_bytes, | |||
} | |||
} | |||
|
|||
#[cfg(test)] | |||
/// Return mutable block reference. To be used in tests only. |
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.
attributes under doc
No description provided.