-
Notifications
You must be signed in to change notification settings - Fork 182
[API] Fixed corrupt governance state after rewinding chain #1966
Conversation
functions to public
…and `InitLastGovStateBlkNum`
Co-authored-by: Yunjong Jeong (ollie) <jeongyoonjong@gmail.com>
As this change deletes memory cache and local database only, resync resolve it natrually. Not changed process and communication at consensus and governance layers, thus no hardfork seems required. |
@blukat29, Updated the description of how to test. PTAL. |
and blockchain (2) Remove snapshot and staking info DB
Given feedback, the updated version removes snapshot and staking info database and memory cache. Also, added an additional fix for the previously existing bug. The description updated. PTAL. Thank you very much. |
@yoomee1313, I added the scenario test you provided in the description. Also, during the scenario test, I found a bug, which is not related to the sethead implementation. Rather than fixing it together here, allow me to upload a dedicated one separately. Thanks. |
Thanks @hyunsooda. I didn't know there was another issue.. Apart from that, I have tested next scenario and it works well with this PR.
Result.
|
Proposed changes
Added additional clear logics after
debug.SetHead
.Problem Statement
The existing
setHead
implementation considered only for the block data such as receipts and transactions. This PR addresses governance (header and contract) and staking state.What PR Does
Compared to two related PRs (#1186, #1756), this PR does not bridge additional implementation to fix this problem. I just defined the post-task and these utilize the existing implementation.
Cases
Case 1: header governance (+ cache)
Case 2: contract governance
Case 3: staking info DB (+ cache)
Case 4: Other DBs (i.e., state DB, MiscDB, etc)
setHead
call.Bug fix
The original codebase contained a bug where a discrepancy arises between the blockchain state and the headerchain state when lost state data appears because blockchain goes further delete operation exceeding the origin target number which is the origin block number to be rewound. Fixed in this PR together.
Test
[Prepration]
[Execution]
governance.vote("reward.mintingamount","123")
klay.getHeader(5)
contains non-empty vote dataklay.getHeader(10)
contains non-empty governance dataex)
debug.setHead(7)
[Secanrio test]
(Preparation is the same with above)
klay.setHead(30)
.klay.setHead()
with10, 20, 30, 33, 35, 40, n
works.Types of changes
Please put an x in the boxes related to your change.
Checklist
Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.
$ make test
)Related issues
Further comments
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...