Skip to content

Commit

Permalink
Comment assert, add zombienet test
Browse files Browse the repository at this point in the history
This commit includes changes for dispute finality handling and experimentation on transaction pool implementation. The changes implemented in the core/dispute_coordinator/impl/dispute_coordinator_impl.cpp file remove all debugging statements to improve readability and ensure cleaner code. Some adjustments have also been made to improve efficiency and avoid unnecessary computations.

In the file core/transaction_pool/impl/transaction_pool_impl.cpp, a commented assertion has been added, signifying a pending fix on issue #1786. Furthermore, configuration files for the zombienet had been deployed focusing on dispute resilience within the parachain validators' network layer. These configurations will prompt validation nodes to report any discrepancies on the chain, ensuring the integrity of the block records.

These modifications are crucial for maintaining the stability, security, and efficiency of the blockchain system.
  • Loading branch information
kamilsa committed Sep 5, 2023
1 parent dcdea18 commit 5853988
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 42 deletions.
106 changes: 66 additions & 40 deletions core/consensus/grandpa/impl/voting_round_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,13 @@ namespace kagome::consensus::grandpa {

SL_DEBUG(logger_, "Round #{}: Start round", round_number_);

pending_timer_handle_ =
scheduler_->scheduleWithHandle([&] { pending(); }, pending_interval_);
pending_timer_handle_ = scheduler_->scheduleWithHandle(
[wp = weak_from_this()] {
if (auto self = wp.lock()) {
self->pending();
}
},
pending_interval_);

sendNeighborMessage();

Expand Down Expand Up @@ -281,20 +286,26 @@ namespace kagome::consensus::grandpa {
}

stage_timer_handle_ = scheduler_->scheduleWithHandle(
[&] {
if (stage_ == Stage::PREVOTE_RUNS) {
SL_DEBUG(logger_,
"Round #{}: Time of prevote stage is out",
round_number_);
endPrevoteStage();
[wp = weak_from_this()] {
if (auto self = wp.lock()) {
if (self->stage_ == Stage::PREVOTE_RUNS) {
SL_DEBUG(self->logger_,
"Round #{}: Time of prevote stage is out",
self->round_number_);
self->endPrevoteStage();
}
}
},
toMilliseconds(duration_ * 2 - (scheduler_->now() - start_time_)));

on_complete_handler_ = [this] {
if (stage_ == Stage::PREVOTE_RUNS) {
SL_DEBUG(logger_, "Round #{}: Became completable", round_number_);
endPrevoteStage();
on_complete_handler_ = [wp = weak_from_this()] {
if (auto self = wp.lock()) {
if (self->stage_ == Stage::PREVOTE_RUNS) {
SL_DEBUG(self->logger_,
"Round #{}: Became completable",
self->round_number_);
self->endPrevoteStage();
}
}
};

Expand Down Expand Up @@ -346,20 +357,26 @@ namespace kagome::consensus::grandpa {
}

stage_timer_handle_ = scheduler_->scheduleWithHandle(
[&] {
if (stage_ == Stage::PRECOMMIT_RUNS) {
SL_DEBUG(logger_,
"Round #{}: Time of precommit stage is out",
round_number_);
endPrecommitStage();
[wp = weak_from_this()] {
if (auto self = wp.lock()) {
if (self->stage_ == Stage::PRECOMMIT_RUNS) {
SL_DEBUG(self->logger_,
"Round #{}: Time of precommit stage is out",
self->round_number_);
self->endPrecommitStage();
}
}
},
toMilliseconds(duration_ * 4 - (scheduler_->now() - start_time_)));

on_complete_handler_ = [this] {
if (stage_ == Stage::PRECOMMIT_RUNS) {
SL_DEBUG(logger_, "Round #{}: Became completable", round_number_);
endPrecommitStage();
on_complete_handler_ = [wp = weak_from_this()] {
if (auto self = wp.lock()) {
if (self->stage_ == Stage::PRECOMMIT_RUNS) {
SL_DEBUG(self->logger_,
"Round #{}: Became completable",
self->round_number_);
self->endPrecommitStage();
}
}
};

Expand Down Expand Up @@ -430,19 +447,21 @@ namespace kagome::consensus::grandpa {

SL_DEBUG(logger_, "Round #{}: Start final stage", round_number_);

on_complete_handler_ = [&] {
const bool is_ready_to_end =
finalized_.has_value()
and finalized_->number
>= (previous_round_
? previous_round_->bestFinalCandidate().number
: last_finalized_block_.number);

if (is_ready_to_end) {
SL_DEBUG(logger_,
"Round #{}: Conditions for final stage are met",
round_number_);
endWaitingStage();
on_complete_handler_ = [wp = weak_from_this()] {
if (auto self = wp.lock()) {
const bool is_ready_to_end =
self->finalized_.has_value()
and self->finalized_->number
>= (self->previous_round_
? self->previous_round_->bestFinalCandidate().number
: self->last_finalized_block_.number);

if (is_ready_to_end) {
SL_DEBUG(self->logger_,
"Round #{}: Conditions for final stage are met",
self->round_number_);
self->endWaitingStage();
}
}
};

Expand Down Expand Up @@ -1086,9 +1105,11 @@ namespace kagome::consensus::grandpa {
need_to_update_estimate = true;
}
if (prevote_ghost_) {
scheduler_->schedule([&] {
if (stage_ == Stage::PRECOMMIT_WAITS_FOR_PREVOTES) {
endPrecommitStage();
scheduler_->schedule([wp = weak_from_this()] {
if (auto self = wp.lock()) {
if (self->stage_ == Stage::PRECOMMIT_WAITS_FOR_PREVOTES) {
self->endPrecommitStage();
}
}
});
}
Expand Down Expand Up @@ -1609,7 +1630,12 @@ namespace kagome::consensus::grandpa {
SL_DEBUG(logger_, "Resend votes of recent rounds");
resend(shared_from_this());

pending_timer_handle_ =
scheduler_->scheduleWithHandle([&] { pending(); }, pending_interval_);
pending_timer_handle_ = scheduler_->scheduleWithHandle(
[wp = weak_from_this()] {
if (auto self = wp.lock()) {
self->pending();
}
},
pending_interval_);
}
} // namespace kagome::consensus::grandpa
3 changes: 2 additions & 1 deletion core/consensus/grandpa/impl/voting_round_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ namespace kagome::consensus::grandpa {

namespace kagome::consensus::grandpa {

class VotingRoundImpl : public VotingRound {
class VotingRoundImpl : public VotingRound,
public std::enable_shared_from_this<VotingRoundImpl> {
private:
VotingRoundImpl(const std::shared_ptr<Grandpa> &grandpa,
const GrandpaConfig &config,
Expand Down
2 changes: 1 addition & 1 deletion core/consensus/grandpa/voting_round.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace kagome::consensus::grandpa {
/**
* Handles execution of one grandpa round. For details @see VotingRoundImpl
*/
class VotingRound : public std::enable_shared_from_this<VotingRound> {
class VotingRound {
public:
virtual ~VotingRound() = default;

Expand Down

0 comments on commit 5853988

Please sign in to comment.