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

Allow to reset the chain to a particular block #8259

Closed
tomusdrw opened this issue Mar 29, 2018 · 2 comments · Fixed by #9782
Closed

Allow to reset the chain to a particular block #8259

tomusdrw opened this issue Mar 29, 2018 · 2 comments · Fixed by #9782
Assignees
Labels
F8-enhancement 🎊 An additional feature request. M4-core ⛓ Core client code / Rust. Q2-easy 💃 Can be fixed by copy and pasting from StackOverflow.
Milestone

Comments

@tomusdrw
Copy link
Collaborator

tomusdrw commented Mar 29, 2018

Re-syncing archive nodes is not always feasible nowadays. And sometimes due to bugs your DB might be missing or have incorrect values for Parity-generated data (think traces, fatdb, logs).
It should be possible (and easy) to re-sync the chain from some particular block to re-produce those values.
If I'm not mistaken, for archive nodes it's just a matter of reseting best block hash if "best" key of EXTRA column in DB.

EDIT:
Seems that sync/src/block_sync.rs will never attempt to import blocks that are already known, so reset requires to remove hashes of all previously imported blocks as well.

@tomusdrw tomusdrw added F8-enhancement 🎊 An additional feature request. Q2-easy 💃 Can be fixed by copy and pasting from StackOverflow. M4-core ⛓ Core client code / Rust. labels Mar 29, 2018
@5chdn 5chdn added this to the 1.12 milestone Mar 29, 2018
@mg6maciej
Copy link

Hey,
I've tried to do this on my own, connecting to RocksDB and changing the data.
Here are the steps I followed:

  • sudo docker run -v /Users/mg6maciej/parityroot9:/storage parity/parity:v1.10.0 --base-path /storage --pruning archive --tracing 'on'
  • wait a bit to synchronize a few blocks
...
2018-04-12 12:48:17 UTC Syncing  #463680 b5c4…fd25   593 blk/s  928 tx/s  31 Mgas/s  13660+    5 Qed   #477353   19/25 peers      9 MiB chain    6 MiB db   27 MiB queue   11 MiB sync  RPC:  0 conn,  0 req/s,   0 µs
2018-04-12 12:48:27 UTC Syncing  #469406 8a5f…614c   572 blk/s  804 tx/s  29 Mgas/s  16071+  116 Qed   #485604   20/25 peers      8 MiB chain    6 MiB db   33 MiB queue    9 MiB sync  RPC:  0 conn,  0 req/s,   0 µs
  • Stop parity
^C2018-04-12 12:48:30 UTC Finishing work, please wait...
  • Read the newest block from RocksDB best key in HEADERS (col3)
    c9919ded297babe7c21d4dd64ab76916a00b2e596657ad09411fea8cce032343, which corresponds to block number 470_558
  • Set best to has corresponding to 450_000 (a1601b0a9b2e062ea358f09653c0b366380207bf544b5946b03ca2d4387ca17b)
  • Delete all keys in HEADERS, BODIES and EXTRA (col1, col2 and col3) equal to hashes corresponding to blocks from 450_001 to 470_558. Note: in EXTRA these keys are prefixed with byte 0.
  • Start parity with the same params as in step 1
  • Be sad about the error "Parent not found"
2018-04-12 13:03:27 UTC Block import failed for #450002 (3716…00d5): Parent not found (a9f3…8123)
2018-04-12 13:03:30 UTC Public node URL: enode://3f50779cf8797326338ec05f6f455664ce71747e01de0a3f56e12c127d229f015b1985487dd1ad7fdf970da7d92f346810024fe85b65870a9bc1264592137940@172.17.0.2:30303
2018-04-12 13:03:36 UTC Syncing  #450000 a160…a17b     0 blk/s    0 tx/s   0 Mgas/s      0+    0 Qed   #449937    9/25 peers     74 KiB chain  0 bytes db  0 bytes queue  584 KiB sync  RPC:  0 conn,  0 req/s,   0 µs
2018-04-12 13:03:46 UTC Syncing  #450000 a160…a17b     0 blk/s    0 tx/s   0 Mgas/s      0+    0 Qed   #449873    2/25 peers     74 KiB chain  0 bytes db  0 bytes queue    2 MiB sync  RPC:  0 conn,  0 req/s,   0 µs
2018-04-12 13:03:55 UTC Syncing  #450000 a160…a17b     0 blk/s    0 tx/s   0 Mgas/s      0+    0 Qed   #449745    2/25 peers     74 KiB chain  0 bytes db  0 bytes queue    2 MiB sync  RPC:  0 conn,  0 req/s,   0 µs
2018-04-12 13:04:00 UTC Syncing  #450000 a160…a17b     0 blk/s    0 tx/s   0 Mgas/s      0+    0 Qed   #449745    2/25 peers     74 KiB chain  0 bytes db  0 bytes queue    2 MiB sync  RPC:  0 conn,  0 req/s,   0 µs
2018-04-12 13:04:05 UTC Syncing  #450000 a160…a17b     0 blk/s    0 tx/s   0 Mgas/s      0+    0 Qed   #449872    2/25 peers     74 KiB chain  0 bytes db  0 bytes queue    2 MiB sync  RPC:  0 conn,  0 req/s,   0 µs
2018-04-12 13:04:10 UTC Syncing  #450000 a160…a17b     0 blk/s    0 tx/s   0 Mgas/s      0+    0 Qed   #449999    2/25 peers     74 KiB chain  0 bytes db  0 bytes queue    2 MiB sync  RPC:  0 conn,  0 req/s,   0 µs

Is there anything else I need to delete for this to work? We want to reset Parity to block 5_200_000 as we noticed no logs returned for a couple of days in blocks from a month ago.

@5chdn 5chdn modified the milestones: 1.12, 1.13 Apr 24, 2018
@5chdn 5chdn modified the milestones: 2.1, 2.2 Jul 17, 2018
@5chdn 5chdn added this to the 2.3 milestone Sep 27, 2018
@seunlanlege seunlanlege self-assigned this Oct 18, 2018
@5chdn 5chdn modified the milestones: 2.3, 2.4 Oct 29, 2018
@5chdn 5chdn modified the milestones: 2.4, 2.5 Jan 10, 2019
@richardpringle
Copy link

docs?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
F8-enhancement 🎊 An additional feature request. M4-core ⛓ Core client code / Rust. Q2-easy 💃 Can be fixed by copy and pasting from StackOverflow.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants