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

Reset blockchain properly #10669

Merged
merged 4 commits into from
May 21, 2019
Merged

Reset blockchain properly #10669

merged 4 commits into from
May 21, 2019

Conversation

seunlanlege
Copy link
Member

@seunlanlege seunlanlege commented May 16, 2019

Previously the reset blockchain feature wrongly assumed that the block hashes were the keys for BlockDetails in COL_EXTRA that has been corrected.
Also, there was a known issue with the reset feature where deleted blocks wouldn't be imported again because they were a "known child" of an existing block
that has also been corrected.

Should fix #10665

@parity-cla-bot
Copy link

It looks like @seunlanlege signed our Contributor License Agreement. 👍

Many thanks,

Parity Technologies CLA Bot

@seunlanlege seunlanlege added A0-pleasereview 🤓 Pull request needs code review. M4-core ⛓ Core client code / Rust. M4-io 💾 Interaction with filesystem/databases. labels May 16, 2019
@jam10o-new jam10o-new added B0-patch-stable 🕷 Pull request should also be back-ported to the stable branch. B1-patch-beta 🕷🕷 labels May 16, 2019
Copy link
Collaborator

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

Looks sane, any chance we could get a test for it? We should really try to make something to prevent from breaking it in the future again.

ethcore/src/client/client.rs Outdated Show resolved Hide resolved
ethcore/src/client/client.rs Outdated Show resolved Hide resolved
@soc1c soc1c added this to the 2.6 milestone May 17, 2019
@seunlanlege
Copy link
Member Author

@tomusdrw

please could you look at this again?

ethcore/blockchain/src/blockchain.rs Show resolved Hide resolved
ethcore/src/client/client.rs Outdated Show resolved Hide resolved
ethcore/src/client/client.rs Outdated Show resolved Hide resolved
&**self.db.read().key_value(),
::db::COL_EXTRA,
&*best_block_hash
).ok_or("block was previously imported; best_block_details should exist; qed")?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

can this block be removed in the meantime?

Copy link
Member Author

Choose a reason for hiding this comment

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

don't understand the question.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We do schedule it for deletion in db_transaction above, but it''s not yet comitted, so the block indeed should be there.
However this is an Err not expect, so a proof is not even needed in that case.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry I meant if the block could be deleted from a separate thread/process. Looks like in this case we're using rocksdb, which doesn't allow read/write from multiple processes and this method is only used in cli, so this is the only thread doing mutation, right? But if change our db backend to lmdb, this is something to keep in mind.

Copy link
Collaborator

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

Looks good to me after @ordian's comments are addressed.

ethcore/src/client/client.rs Outdated Show resolved Hide resolved
ethcore/src/client/client.rs Outdated Show resolved Hide resolved
&**self.db.read().key_value(),
::db::COL_EXTRA,
&*best_block_hash
).ok_or("block was previously imported; best_block_details should exist; qed")?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

We do schedule it for deletion in db_transaction above, but it''s not yet comitted, so the block indeed should be there.
However this is an Err not expect, so a proof is not even needed in that case.

@ordian
Copy link
Collaborator

ordian commented May 21, 2019

to fix cargo audit, merge with master

@ordian ordian merged commit 21a27fe into master May 21, 2019
@ordian ordian deleted the reset-blockchain branch May 21, 2019 11:52
.ok_or("Attempted to reset past genesis block")?;
let mut blocks_to_delete = Vec::with_capacity(num as usize);
let mut best_block_hash = self.chain.read().best_block_hash();
let mut batch = DBTransaction::with_capacity(blocks_to_delete.len());
Copy link
Member Author

Choose a reason for hiding this comment

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

damn, this should've been DBTransaction::with_capacity(blocks_to_delete.capacity()), shouldn't be much of a problem. this code runs in cli so the cost of resizing the buffer is negligible.

dvdplm added a commit that referenced this pull request May 22, 2019
* master:
  Don't panic if extra_data is longer than VANITY_LENGTH (#10682)
  docs: evmbin - Update Rust docs (#10658)
  Remove annoying compiler warnings (#10679)
  Reset blockchain properly (#10669)
dvdplm added a commit that referenced this pull request May 23, 2019
* master:
  add_sync_notifier in EthPubSubClient holds on to a Client for too long (#10689)
  Don't panic if extra_data is longer than VANITY_LENGTH (#10682)
  docs: evmbin - Update Rust docs (#10658)
  Remove annoying compiler warnings (#10679)
  Reset blockchain properly (#10669)
ordian added a commit that referenced this pull request May 23, 2019
* master:
  add_sync_notifier in EthPubSubClient holds on to a Client for too long (#10689)
  Don't panic if extra_data is longer than VANITY_LENGTH (#10682)
  docs: evmbin - Update Rust docs (#10658)
  Remove annoying compiler warnings (#10679)
  Reset blockchain properly (#10669)
This was referenced Jun 1, 2019
@soc1c soc1c mentioned this pull request Jun 11, 2019
6 tasks
@soc1c soc1c mentioned this pull request Jun 11, 2019
7 tasks
soc1c pushed a commit that referenced this pull request Jun 11, 2019
* delete BlockDetails from COL_EXTRA

* better proofs

* added tests

* PR suggestions
@ghost ghost mentioned this pull request Jun 11, 2019
soc1c added a commit that referenced this pull request Jun 11, 2019
* version: bump beta to 2.5.2

* [CI] allow cargo audit to fail (#10676)

* [CI] allow cargo audit to fail

* [.gitlab-ci.yml] add a comment about cargo audit

* [Cargo.lock] cargo update -p protobuf

* Reset blockchain properly (#10669)

* delete BlockDetails from COL_EXTRA

* better proofs

* added tests

* PR suggestions

* new image (#10673)

* Update publishing (#10644)

* docker images are now built on k8s: test run

* copy check_sync.sh in build-linux job

* copy scripts/docker/hub/* in build-linux job

* removed cache var

* cleanup, no more nightly dockers

* cleanup in dockerfile

* some new tags

* removed sccsche debug log, cleanup

* no_gits, new artifacts dir, changed scripts. Test run.

* define version once

* one source for TRACK

* stop kovan onchain updates

* moved changes for two images to a new branch

* rename Dockerfile

* no need in libudev-dev

* enable lto for release builds (#10717)

* Use RUSTFLAGS to set the optimization level (#10719)

* Use RUSTFLAGS to set the optimization level

Cargo has a [quirk]() in how configuration settings are propagated when `cargo test` runs: local code respect the settings in `[profile.test]` but all dependencies use the `[profile.dev]` settings. Here we force `opt-level=3` for all dependencies.

* Remove unused profile settings

* Maybe like this?

* Turn off incremental compilation

* Remove colors; try again with overflow-checks on

* Use quiet CI machine

* Turn overflow checking back on

* Be explicit about what options we use

* Remove "quiet machine" override

* ethcore: enable ECIP-1054 for classic (#10731)

* config: enable atlantis on ethereum classic

* config: enable atlantis on morden classic

* config: enable atlantis on morden classic

* config: enable atlantis on kotti classic

* ethcore: move kotti fork block to 0xAEF49

* ethcore: move morden fork block to 0x4829BA

* ethcore: move classic fork block to 0x81B320

* remove trailing comma

* remove trailing comma

* fix chainspec

* ethcore: move classic fork block to 0x7fffffffffffffff
@CremaFR
Copy link

CremaFR commented Jun 14, 2019

@soc1c It seems v2.4.7-stable does not include the fix.
v2.5.2-beta has it and reset blocks properly

ordian pushed a commit that referenced this pull request Jun 24, 2019
* delete BlockDetails from COL_EXTRA

* better proofs

* added tests

* PR suggestions
@s3krit s3krit mentioned this pull request Jun 25, 2019
s3krit added a commit that referenced this pull request Jun 25, 2019
* ethcore/res: activate atlantis classic hf on block 8772000 (#10766)

* fix docker tags for publishing (#10741)

* merge-backports

* Update version

* remove clique engine from backports

* Reset blockchain properly (#10669)

* delete BlockDetails from COL_EXTRA

* better proofs

* added tests

* PR suggestions

* adds rpc error message for --no-ancient-blocks (#10608)

* adds error message for --no-ancient-blocks, closes #10261

* Apply suggestions from code review

Co-Authored-By: seunlanlege <seunlanlege@gmail.com>

* Treat empty account the same as non-exist accounts in EIP-1052 (#10775)

* fix: aura don't add `SystemTime::now()` (#10720)

This commit does the following:
- Prevent overflow in `verify_timestamp()` by not adding `now` to found faulty timestamp
- Use explicit `CheckedSystemTime::checked_add` to prevent potential consensus issues because SystemTime is platform
depedent
- remove `#[cfg(not(time_checked_add))]` conditional compilation

* DevP2p: Get node IP address and udp port from Socket, if not included in PING packet (#10705)

* get node IP address and udp port from Socket, if not included in PING packet

* prevent bootnodes from being added to host nodes

* code corrections

* code corrections

* code corrections

* code corrections

* docs

* code corrections

* code corrections

* Apply suggestions from code review

Co-Authored-By: David <dvdplm@gmail.com>

* Revert "fix: aura don't add `SystemTime::now()` (#10720)"

This reverts commit f104784.

* Add a way to signal shutdown to snapshotting threads (#10744)

* Add a way to signal shutdown to snapshotting threads

* Pass Progress to fat_rlps() so we can abort from there too.

* Checking for abort in a single spot

* Remove nightly-only weak/strong counts

* fix warning

* Fix tests

* Add dummy impl to abort snapshots

* Add another dummy impl for TestSnapshotService

* Remove debugging code

* Return error instead of the odd Ok(())
Switch to AtomicU64

* revert .as_bytes() change

* fix build

* fix build maybe
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-pleasereview 🤓 Pull request needs code review. B0-patch-stable 🕷 Pull request should also be back-ported to the stable branch. M4-core ⛓ Core client code / Rust. M4-io 💾 Interaction with filesystem/databases.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stage 4 block verification failed on startup
7 participants