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

Don't prune ancient state when instantiating a Client #11270

Merged
merged 1 commit into from
Nov 22, 2019

Conversation

dvdplm
Copy link
Collaborator

@dvdplm dvdplm commented Nov 20, 2019

This is possibly a controversial PR.
Before this PR, a call to Client::new() will delete all state below the --pruning-history threshold. This is side-effectey and surprising and I don't think it is necessary; I think it is better if Client::new() avoids touching the database.
For commands like e.g. parity snapshot, kicking off a pruning run before starting the snapshot can be problematic as state might be deleted before we even start; for other commands like import, export, or reset, pruning the state before executing the command seems unneccesary and slow.

After this the client will prune ancient state as a side effect of importing new blocks (in commit_block()), which I think is fine.

@dvdplm dvdplm self-assigned this Nov 20, 2019
@dvdplm dvdplm added A0-pleasereview 🤓 Pull request needs code review. M4-core ⛓ Core client code / Rust. labels Nov 20, 2019
@dvdplm dvdplm requested review from 0x7CFE and debris November 20, 2019 07:34
Copy link
Collaborator

@debris debris left a comment

Choose a reason for hiding this comment

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

it seems reasonable

@debris debris added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Nov 21, 2019
@0x7CFE
Copy link
Contributor

0x7CFE commented Nov 21, 2019

How it was tested?

@dvdplm
Copy link
Collaborator Author

dvdplm commented Nov 21, 2019

How it was tested?

Not 100% sure I understand what you mean by "testing" here, but you are right that I am uncertain about what consequences of skipping pruning-on-start are. I am not sure why we prune at startup in the first place, possibly to reduce memory usage for the case the user has changed the pruning history settings between restarts?
Do you, or anyone, have any suggestion on how to test this change?

@0x7CFE
Copy link
Contributor

0x7CFE commented Nov 22, 2019

Do you, or anyone, have any suggestion on how to test this change?

Not at the moment. Have you tried syncing the node on a clean or populated db? If that works OK, then I would probably agree that this change worth it.

Do you have any estimations on how much will PR save in time on a real world scenario?

@dvdplm
Copy link
Collaborator Author

dvdplm commented Nov 22, 2019

The pruning only runs at startup so I don’t expect any performance impact at all on nodes that are already running tbh. For nodes running with a big pruning history (1000 or above), startup is noticeably faster which impacts short lived commands such as import/export etc.

@0x7CFE
Copy link
Contributor

0x7CFE commented Nov 22, 2019

Fair enough.

@ordian ordian added this to the 2.7 milestone Nov 22, 2019
@ordian ordian merged commit 6e34ee6 into master Nov 22, 2019
@ordian ordian deleted the dp/fix/dont-prune-state-on-client-construction branch November 22, 2019 11:18
ordian added a commit that referenced this pull request Nov 25, 2019
* master:
  [ethcore]: apply filter when `PendingSet::AlwaysQueue` in `ready_transactions_filtered` (#11227)
  Update lib.rs (#11286)
  Don't prune ancient state when instantiating a Client (#11270)
  fixed verify_uncles error type (#11276)
  ethcore: fix rlp deprecation warnings (#11280)
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.

4 participants