-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract finalization state storage #634
Conversation
As I added |
@@ -1017,12 +990,6 @@ bool FinalizationState::ProcessNewCommits(const CBlockIndex &block_index, | |||
ProcessNewCommit(tx); | |||
} | |||
|
|||
if (!g_storage.Restoring() && (block_index.nHeight + 2) % m_settings.epoch_length == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reviewers: this piece is moved to cache.cpp.
@Gnappuraz we will completely clear finalization state from snapshot code in #525.
@@ -220,17 +234,6 @@ class FinalizationState : public FinalizationStateData { | |||
std::vector<Validator> GetValidators() const; | |||
const Validator *GetValidator(const uint160 &validatorAddress) const; | |||
|
|||
static void Init(const esperanza::FinalizationParams ¶ms, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reviewers: I'm clearing finalization state from global/static functions in favor of cache component, but we still have a number of them.
For compatibility with current code base:
FinalizationState::GetState
.
These functions depends on FinalizationState::GetState
and simplifies accees to esperanza::FinalizationParams.
FinalizationState::ValidateDepositAmount
;esperanza::GetEpochLength
;esperanza::GetEpoch
;
I find some of the tests fail, rebased with master and working on the fix. Until then, wip. |
f429faf
to
cce3a0d
Compare
Signed-off-by: Stanislav Frolov <[email protected]>
Signed-off-by: Stanislav Frolov <[email protected]>
Signed-off-by: Stanislav Frolov <[email protected]>
Signed-off-by: Stanislav Frolov <[email protected]>
Rewrite the functional test in a way to wait for snapshot events, because snapshots are processed on an independent thread. Commit fixes flakiness in the functional tests we've discovered during working on the #634. Signed-off-by: Stanislav Frolov <[email protected]>
Signed-off-by: Stanislav Frolov <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but I want to give it one last good review before giving an approval.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GenerateBlockIndex
in the tests leaks memory.
Signed-off-by: Stanislav Frolov <[email protected]>
@scravy @Gnappuraz, I split this component into two: StateRepository and StateProcessor. Added additional tests for the StateRepository. Please note, StateRepository doesn't provide get/set/remove interface. The main interface functions are |
Signed-off-by: Stanislav Frolov <[email protected]>
The leak was fixed by storing it in the vector, instead of just having an unmanaged ptr
@kostyantyn Since this pull-request changed considerably and your utACK is quite stale after a few days and a bunch of commits I re-requested a review from you. Please have another look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly have some reservations on how the whole repository/processor are structured, I think we can do better but for the sake of moving forward let's continue and tackle this in an other venue.
utACK c74b041
if (!ReadBlockFromDisk(block, index, chainparams.GetConsensus())) { | ||
assert(not("Failed to read block")); | ||
} | ||
const bool ok = proc->ProcessNewTip(*index, block); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me it does not make much sense that the repository is calling processing logic, it should be the other way around but let's move on and we'll restructure later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Just from the naming of things that makes more sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will disappear after we restore states from the disk properly. There’s a comment addressed to this issue in the header file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can elaborate on this a bit. You're commenting on a function that restores the repository from the disk. Unfortunately, we don't have a proper serialization of finalization states that leads us to restore the states by processing blocks data (ProcessNewTip
). Once we implement proper serialization of states, we will get rid of this dependency as well as ResetToTip
trick.
Signed-off-by: Stanislav Frolov <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 10f1441
I very much welcome our new component to the family :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 10f1441
This PR extracts finalization states storage in
finalization::StateRepository
andfinalization::StateProcessor
components.Also, adds commits-based finalization state processing (see
StateProcessor::ProcessNewTipCandidate
,StateProcessor::ProcessNewCommits
) and corresponding unit tests.Also, from now calling
FinalizationState::ProcessNewTip()
twice is prohibited. We process tip only once per state because we have state per every block. Generally, we shouldn't have direct calls to this function except for StateProcessor and tests.These changes were initially present in #525. This PR is part of splitting that PR on smaller pieces.
Signed-off-by: Stanislav Frolov [email protected]