Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Configurable history size in beta #2587

Merged
merged 5 commits into from Oct 12, 2016
Merged

Configurable history size in beta #2587

merged 5 commits into from Oct 12, 2016

Conversation

arkpar
Copy link
Collaborator

@arkpar arkpar commented Oct 12, 2016

No description provided.

@arkpar arkpar added A0-pleasereview 🤓 Pull request needs code review. M4-core ⛓ Core client code / Rust. labels Oct 12, 2016
Copy link
Contributor

@rphmeier rphmeier left a 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")));
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Collaborator Author

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 {
Copy link
Contributor

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].
Copy link
Contributor

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.

Copy link
Collaborator Author

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;
Copy link
Contributor

@rphmeier rphmeier Oct 12, 2016

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.

@rphmeier rphmeier added A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. and removed A0-pleasereview 🤓 Pull request needs code review. labels Oct 12, 2016
@@ -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);
Copy link
Contributor

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);
Copy link
Contributor

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.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 87.213% when pulling 4b04d6b on history-config into 66f6845 on beta.

@arkpar arkpar added A0-pleasereview 🤓 Pull request needs code review. and removed A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. labels Oct 12, 2016
@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 87.267% when pulling 3784c6c on history-config into 8fba01a on beta.

@rphmeier rphmeier added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Oct 12, 2016
@@ -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;
Copy link
Contributor

@gavofyork gavofyork Oct 12, 2016

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

@gavofyork
Copy link
Contributor

would have liked to see at least one test.

@gavofyork gavofyork added A6-mustntgrumble 💦 Pull request has areas for improvement. The author need not address them before merging. and removed A8-looksgood 🦄 Pull request is reviewed well. labels Oct 12, 2016
@arkpar arkpar added A0-pleasereview 🤓 Pull request needs code review. and removed A6-mustntgrumble 💦 Pull request has areas for improvement. The author need not address them before merging. labels Oct 12, 2016
@gavofyork gavofyork added A7-looksgoodtestsfail 🤖 Pull request is reviewed well, but cannot be merged due to tests failing. and removed A0-pleasereview 🤓 Pull request needs code review. labels Oct 12, 2016
@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 87.342% when pulling 03f9a32 on history-config into 8fba01a on beta.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 87.354% when pulling 03f9a32 on history-config into 8fba01a on beta.

@@ -395,6 +395,10 @@ impl<'x> OpenBlock<'x> {
uncle_bytes: uncle_bytes,
}
}

#[cfg(test)]
/// Return mutable block reference. To be used in tests only.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attributes under doc

@arkpar arkpar added A8-looksgood 🦄 Pull request is reviewed well. and removed A7-looksgoodtestsfail 🤖 Pull request is reviewed well, but cannot be merged due to tests failing. labels Oct 12, 2016
@arkpar arkpar merged commit 6b4d0ce into beta Oct 12, 2016
@gavofyork gavofyork deleted the history-config branch October 13, 2016 08:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well. M4-core ⛓ Core client code / Rust.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants