Skip to content
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

Fix/kusama grid size fixes #2180

Merged
merged 51 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
4db536c
fix recovery (validators <= discovery_keys)
turuslan Aug 6, 2024
cc3c7b5
Merge remote-tracking branch 'origin/fix/recovery'
iceseer Aug 7, 2024
8e599f2
backing init fixup
iceseer Aug 8, 2024
d85691f
kusama fixup
iceseer Aug 8, 2024
4b66108
update our view in topology
iceseer Aug 9, 2024
d738478
remove logs
iceseer Aug 9, 2024
d3075ec
remove logs
iceseer Aug 9, 2024
9ddbd74
kusama fixup
iceseer Aug 10, 2024
294e62a
kusama fixup
iceseer Aug 10, 2024
d24595b
not to doublicate sends
iceseer Aug 11, 2024
6ba5f3b
test fixup!
iceseer Aug 13, 2024
4409145
grid view from authorities
iceseer Aug 13, 2024
e636577
audi
iceseer Aug 13, 2024
312db03
audi
iceseer Aug 13, 2024
7063722
audi errors
iceseer Aug 14, 2024
59b80b6
force authority discovery for the given peer set
iceseer Aug 15, 2024
4e466f1
logs
iceseer Aug 15, 2024
8a81d70
fixup!
iceseer Aug 15, 2024
82b3ac6
remove logs
iceseer Sep 17, 2024
0361c16
Merge remote-tracking branch 'origin/1691-consider-pvf-executor-param…
iceseer Sep 17, 2024
69ee666
revert
iceseer Sep 17, 2024
3c2a372
revert
iceseer Sep 17, 2024
abf8c4f
Merge branch 'master' into fix/kusama_backed_candidates
iceseer Sep 17, 2024
5f990b7
fixup
iceseer Sep 17, 2024
1868eef
fixup fork wakeups
iceseer Sep 17, 2024
2a39991
Merge branch 'master' into fix/kusama_backed_candidates
iceseer Sep 17, 2024
5afb11a
fixup fork wakeups
iceseer Sep 17, 2024
1708944
feature: formatter for optional
xDimon Sep 19, 2024
44f1ec2
refactor: make log messages cleaner
xDimon Sep 19, 2024
9694e2c
feature: detailed log messages for recovery
xDimon Sep 19, 2024
1f23bae
draft
iceseer Sep 20, 2024
399eca8
Merge branch 'master' into fix/kusama_backed_candidates
iceseer Sep 23, 2024
0c479bd
unify_with_peer
iceseer Sep 23, 2024
66eda86
unify_with_peer
iceseer Sep 23, 2024
89769c4
draft
xDimon Sep 23, 2024
1b1ad04
toml
xDimon Sep 23, 2024
afd6364
PATCH FOR APPROVAL
iceseer Sep 20, 2024
544d616
Merge remote-tracking branch 'origin/fix/recovery_candidate' into fix…
iceseer Sep 23, 2024
796198d
Fix kusama parachain validator crash
igor-egorov Sep 24, 2024
1ed3b95
Fix minideb-release.Dockerfile + tini
igor-egorov Sep 24, 2024
69761e4
restore callback
iceseer Sep 25, 2024
6cc34d7
av store clear
iceseer Sep 25, 2024
b28abf6
t
iceseer Sep 25, 2024
e0b6a74
finalization fix
iceseer Sep 26, 2024
dc959da
formatted
iceseer Sep 28, 2024
0407c69
revert
iceseer Sep 28, 2024
cd60736
Merge remote-tracking branch 'origin/master' into fix/kusama_backed_c…
iceseer Sep 28, 2024
97ed05a
revert
iceseer Sep 28, 2024
7826cea
Merge branch 'master' into fix/kusama_backed_candidates
iceseer Sep 30, 2024
e7859cc
Merge branch 'master' into fix/kusama_backed_candidates
iceseer Oct 1, 2024
7095f4d
issues
iceseer Oct 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions core/network/impl/protocols/fetch_attested_candidate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ namespace kagome::network {
const blockchain::GenesisBlockHash &genesis_hash,
std::shared_ptr<parachain::ParachainProcessorImpl> pp)
: RequestResponseProtocolImpl<
vstaging::AttestedCandidateRequest,
vstaging::AttestedCandidateResponse,
ScaleMessageReadWriter>{kFetchAttestedCandidateProtocolName,
host,
make_protocols(
kFetchAttestedCandidateProtocol,
genesis_hash,
kProtocolPrefixPolkadot),
log::createLogger(
kFetchAttestedCandidateProtocolName,
"req_attested_candidate_protocol")},
vstaging::AttestedCandidateRequest,
vstaging::AttestedCandidateResponse,
ScaleMessageReadWriter>{kFetchAttestedCandidateProtocolName,
host,
make_protocols(
kFetchAttestedCandidateProtocol,
genesis_hash,
kProtocolPrefixPolkadot),
log::createLogger(
kFetchAttestedCandidateProtocolName,
"req_attested_candidate_protocol")},
pp_{std::move(pp)} {
BOOST_ASSERT(pp_);
}
Expand All @@ -64,7 +64,7 @@ namespace kagome::network {
"Fetching attested candidate response failed.(error={})",
res.error());
} else {
base().logger()->trace("Fetching attested candidate response.");
SL_TRACE(base().logger(), "Fetching attested candidate response.");
}
return res;
}
Expand Down
52 changes: 29 additions & 23 deletions core/network/impl/protocols/protocol_fetch_available_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,26 @@ namespace kagome::network {
const blockchain::GenesisBlockHash &genesis_hash,
std::shared_ptr<parachain::AvailabilityStore> av_store)
: RequestResponseProtocolImpl<
FetchAvailableDataRequest,
FetchAvailableDataResponse,
ScaleMessageReadWriter>{kName,
host,
make_protocols(kFetchAvailableDataProtocol,
genesis_hash,
kProtocolPrefixPolkadot),
log::createLogger(
kName, "req_available_data_protocol")},
FetchAvailableDataRequest,
FetchAvailableDataResponse,
ScaleMessageReadWriter>{kName,
host,
make_protocols(
kFetchAvailableDataProtocol,
genesis_hash,
kProtocolPrefixPolkadot),
log::createLogger(
kName,
"req_available_data_protocol")},
av_store_{std::move(av_store)} {}

private:
std::optional<outcome::result<ResponseType>> onRxRequest(
RequestType candidate_hash, std::shared_ptr<Stream>) override {
SL_TRACE(base().logger(),
"Fetch available data .(candidate hash={})",
candidate_hash);

if (auto r = av_store_->getPovAndData(candidate_hash)) {
return std::move(*r);
}
Expand All @@ -73,25 +79,25 @@ namespace kagome::network {
const blockchain::GenesisBlockHash &genesis_hash,
std::shared_ptr<parachain::BackingStore> backing_store)
: RequestResponseProtocolImpl<
FetchStatementRequest,
FetchStatementResponse,
ScaleMessageReadWriter>{kName,
host,
make_protocols(kFetchStatementProtocol,
genesis_hash,
kProtocolPrefixPolkadot),
log::createLogger(
kName, "req_statement_protocol")},
FetchStatementRequest,
FetchStatementResponse,
ScaleMessageReadWriter>{kName,
host,
make_protocols(kFetchStatementProtocol,
genesis_hash,
kProtocolPrefixPolkadot),
log::createLogger(
kName, "req_statement_protocol")},
backing_store_{std::move(backing_store)} {}

private:
std::optional<outcome::result<ResponseType>> onRxRequest(
RequestType req, std::shared_ptr<Stream>) override {
base().logger()->trace(
"Statement fetch request received.(relay parent={}, candidate "
"hash={})",
req.relay_parent,
req.candidate_hash);
SL_TRACE(base().logger(),
"Statement fetch request received.(relay parent={}, candidate "
"hash={})",
req.relay_parent,
req.candidate_hash);

if (auto res = backing_store_->getCadidateInfo(req.relay_parent,
req.candidate_hash)) {
Expand Down
24 changes: 12 additions & 12 deletions core/network/impl/protocols/protocol_req_pov.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ namespace kagome::network {
const blockchain::GenesisBlockHash &genesis_hash,
std::shared_ptr<ReqPovObserver> observer)
: RequestResponseProtocolImpl<
RequestPov,
ResponsePov,
ScaleMessageReadWriter>{kReqPovProtocolName,
host,
make_protocols(kReqPovProtocol,
genesis_hash,
kProtocolPrefixPolkadot),
log::createLogger(kReqPovProtocolName,
"req_pov_protocol")},
RequestPov,
ResponsePov,
ScaleMessageReadWriter>{kReqPovProtocolName,
host,
make_protocols(kReqPovProtocol,
genesis_hash,
kProtocolPrefixPolkadot),
log::createLogger(kReqPovProtocolName,
"req_pov_protocol")},
observer_{std::move(observer)} {}

protected:
Expand All @@ -57,8 +57,8 @@ namespace kagome::network {
}

void onTxRequest(const RequestPov &request) override {
base().logger()->trace("Transmit PoV request(candidate hash={})",
request);
SL_TRACE(
base().logger(), "Transmit PoV request(candidate hash={})", request);
}

private:
Expand All @@ -72,7 +72,7 @@ namespace kagome::network {
const blockchain::GenesisBlockHash &genesis_hash,
std::shared_ptr<ReqPovObserver> observer)
: impl_{std::make_shared<ReqPovProtocolImpl>(
host, chain_spec, genesis_hash, std::move(observer))} {}
host, chain_spec, genesis_hash, std::move(observer))} {}

const Protocol &ReqPovProtocol::protocolName() const {
BOOST_ASSERT(impl_ && !!"ReqPovProtocolImpl must be initialized!");
Expand Down
93 changes: 43 additions & 50 deletions core/parachain/approval/approval_distribution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ namespace kagome::parachain {
common::MainThreadPool &main_thread_pool,
LazySPtr<dispute::DisputeCoordinator> dispute_coordinator)
: approval_thread_handler_{poolHandlerReadyMake(
this, app_state_manager, approval_thread_pool, logger_)},
this, app_state_manager, approval_thread_pool, logger_)},
worker_pool_handler_{worker_thread_pool.handler(*app_state_manager)},
parachain_host_(std::move(parachain_host)),
slots_util_(slots_util),
Expand Down Expand Up @@ -1717,17 +1717,19 @@ namespace kagome::parachain {
auto cb = [weak_self{wself},
hashed_candidate,
session_index,
validator_index,
relay_block_hash](outcome::result<Pvf::Result> outcome) {
validator_index](outcome::result<Pvf::Result> outcome) {
auto self = weak_self.lock();
if (not self) {
return;
}
const auto &candidate_receipt = hashed_candidate.get();

std::vector<Hash> advence_hashes;
self->approvals_cache_.exclusiveAccess([&](auto &approvals_cache) {
if (auto it = approvals_cache.find(hashed_candidate.getHash());
it != approvals_cache.end()) {
ApprovalCache &ac = it->second;
advence_hashes.assign(ac.blocks_.begin(), ac.blocks_.end());
ac.approval_result = outcome.has_error()
? ApprovalOutcome::Failed
: ApprovalOutcome::Approved;
Expand All @@ -1746,9 +1748,10 @@ namespace kagome::parachain {
candidate_receipt,
false);
} else {
self->issue_approval(hashed_candidate.getHash(),
validator_index,
relay_block_hash);
for (const auto &b : advence_hashes) {
self->issue_approval(
hashed_candidate.getHash(), validator_index, b);
}
}
};
self->pvf_->pvfValidate(available_data.validation_data,
Expand Down Expand Up @@ -2084,12 +2087,12 @@ namespace kagome::parachain {
return;
}
} else {
SL_WARN(logger_,
"Assignment from a peer is out of view. (peer id={}, "
"block_hash={}, validator index={})",
peer_id,
std::get<0>(message_subject),
std::get<2>(message_subject));
SL_TRACE(logger_,
"Assignment from a peer is out of view. (peer id={}, "
"block_hash={}, validator index={})",
peer_id,
std::get<0>(message_subject),
std::get<2>(message_subject));
}

/// if the assignment is known to be valid, reward the peer
Expand Down Expand Up @@ -2586,24 +2589,17 @@ namespace kagome::parachain {
auto se = pm_->getStreamEngine();
BOOST_ASSERT(se);

auto msg = std::make_shared<
network::WireMessage<network::vstaging::ValidatorProtocolMessage>>(
network::vstaging::ApprovalDistributionMessage{
network::vstaging::Assignments{
.assignments = {network::vstaging::Assignment{
.indirect_assignment_cert = indirect_cert,
.candidate_bitfield = candidate_indices,
}}}});

for (const auto &peer : peers) {
parachain_processor_->tryOpenOutgoingValidationStream(
peer,
network::CollationVersion::VStaging,
[WEAK_SELF, peer{peer}, se, msg]() {
WEAK_LOCK(self);
se->send(peer, self->router_->getValidationProtocolVStaging(), msg);
});
}
se->broadcast(
router_->getValidationProtocolVStaging(),
std::make_shared<
network::WireMessage<network::vstaging::ValidatorProtocolMessage>>(
network::vstaging::ApprovalDistributionMessage{
network::vstaging::Assignments{
.assignments = {network::vstaging::Assignment{
.indirect_assignment_cert = indirect_cert,
.candidate_bitfield = candidate_indices,
}}}}),
[&](const libp2p::peer::PeerId &p) { return peers.contains(p); });
}

void ApprovalDistribution::send_assignments_batched(
Expand Down Expand Up @@ -2714,22 +2710,15 @@ namespace kagome::parachain {
auto se = pm_->getStreamEngine();
BOOST_ASSERT(se);

auto msg = std::make_shared<
network::WireMessage<network::vstaging::ValidatorProtocolMessage>>(
network::vstaging::ApprovalDistributionMessage{
network::vstaging::Approvals{
.approvals = {vote},
}});

for (const auto &peer : peers) {
parachain_processor_->tryOpenOutgoingValidationStream(
peer,
network::CollationVersion::VStaging,
[WEAK_SELF, peer{peer}, se, msg]() {
WEAK_LOCK(self);
se->send(peer, self->router_->getValidationProtocolVStaging(), msg);
});
}
se->broadcast(
router_->getValidationProtocolVStaging(),
std::make_shared<
network::WireMessage<network::vstaging::ValidatorProtocolMessage>>(
network::vstaging::ApprovalDistributionMessage{
network::vstaging::Approvals{
.approvals = {vote},
}}),
[&](const libp2p::peer::PeerId &p) { return peers.contains(p); });
}

void ApprovalDistribution::issue_approval(const CandidateHash &candidate_hash,
Expand Down Expand Up @@ -2879,7 +2868,10 @@ namespace kagome::parachain {
GroupIndex backing_group,
std::optional<CoreIndex> core,
bool distribute_assignment) {
/// TODO(iceseer): don't launch approval work if the node is syncing.
if (!parachain_processor_->canProcessParachains()) {
return;
}

const auto &block_hash = indirect_cert.block_hash;
const auto validator_index = indirect_cert.validator;

Expand Down Expand Up @@ -2940,9 +2932,10 @@ namespace kagome::parachain {
};
return approval::min_or_some(
e.next_no_show,
(e.last_assignment_tick ? filter(
*e.last_assignment_tick + kApprovalDelay, tick_now)
: std::optional<Tick>{}));
(e.last_assignment_tick
? filter(*e.last_assignment_tick + kApprovalDelay,
tick_now)
: std::optional<Tick>{}));
},
[&](const approval::PendingRequiredTranche &e) {
std::optional<DelayTranche> next_announced{};
Expand Down
14 changes: 0 additions & 14 deletions core/parachain/availability/bitfield/signer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,6 @@ namespace kagome::parachain {
for (auto &candidate : candidates) {
bitfield.bits.push_back(
candidate && store_->hasChunk(*candidate, signer.validatorIndex()));
if (candidate) {
SL_TRACE(logger_,
"Signing bitfields.(relay_parent={}, validator index={}, has "
"chunk={})",
relay_parent,
signer.validatorIndex(),
bitfield.bits.back() ? 1 : 0);
} else {
SL_TRACE(logger_,
"Signing bitfields.(relay_parent={}, validator index={}, NOT "
"OCCUPIED)",
relay_parent,
signer.validatorIndex());
}
}

OUTCOME_TRY(signed_bitfield, signer.sign(bitfield));
Expand Down
13 changes: 6 additions & 7 deletions core/parachain/backing/grid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ namespace kagome::parachain::grid {

/// View for one group
struct View {
std::unordered_set<ValidatorIndex> receiving, sending;
std::unordered_set<ValidatorIndex> sending, receiving;

bool operator==(const View &r) const {
return sending == r.sending && receiving == r.receiving;
}
iceseer marked this conversation as resolved.
Show resolved Hide resolved

bool canReceive(bool full, ValidatorIndex from) const {
return (full ? receiving : sending).contains(from);
Expand Down Expand Up @@ -237,12 +241,7 @@ namespace kagome::parachain::grid {
}

inline std::vector<ValidatorIndex> shuffle(
const std::vector<std::vector<ValidatorIndex>> &groups,
std::span<const uint8_t, 32> babe_randomness) {
size_t n = 0;
for (auto &group : groups) {
n += group.size();
}
size_t n, std::span<const uint8_t, 32> babe_randomness) {
std::vector<ValidatorIndex> validators;
validators.resize(n);
std::iota(validators.begin(), validators.end(), 0);
Expand Down
Loading