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

feature/Ellastic-scaling + priority nodes + cluster integr #2102

Merged
merged 83 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 74 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
2590fb1
cache
iceseer Apr 12, 2024
c046edf
1
iceseer Apr 12, 2024
06a44c3
2
iceseer Apr 15, 2024
3c16aaf
3
iceseer Apr 15, 2024
3906185
formatting
iceseer Apr 15, 2024
2daab4e
small fix
iceseer Apr 15, 2024
6700860
fixup!
iceseer Apr 15, 2024
f6c20fa
send my view and inc use count
iceseer May 2, 2024
277a2b8
undisconnectable peers
iceseer May 2, 2024
d9ac5a8
statements store test
iceseer Apr 17, 2024
195ddc4
logs
iceseer Apr 17, 2024
e81fdc1
logs
iceseer Apr 17, 2024
2771593
fixup!
iceseer Apr 17, 2024
51f97fa
easy fixup
iceseer Apr 18, 2024
bf6c1f9
fixup
iceseer Apr 18, 2024
26a9e8a
request statements from peer transmitted us a manifest
iceseer Apr 19, 2024
37992e2
fixup
iceseer Apr 22, 2024
95f8bc1
formatting
iceseer Apr 22, 2024
413260b
additional logs
iceseer Apr 23, 2024
4a7c28d
rename
iceseer Apr 26, 2024
fdd64a5
BackedCandidate fixes
iceseer Apr 26, 2024
990cbd3
- ParachainHost_node_features
iceseer Apr 27, 2024
629f136
- ParachainHost_node_features
iceseer Apr 28, 2024
0ea468b
formatting
iceseer Apr 28, 2024
bf9ae01
formatting
iceseer Apr 28, 2024
4235111
fixup
iceseer May 3, 2024
3624739
fix executor param enum (#2078)
turuslan May 2, 2024
0386877
fixes -> branch !
iceseer May 6, 2024
9a446ec
fixes -> branch !
iceseer May 6, 2024
320254a
fixes -> branch !
iceseer May 8, 2024
6bdd67b
fix: sending dispute request
xDimon Apr 22, 2024
60f4930
fix: incoming dispute requests batching
xDimon May 13, 2024
c257936
feature: add logs
xDimon May 13, 2024
c18e5c2
feature: clang-format rules
xDimon May 13, 2024
478df81
Fix macos
kamilsa May 14, 2024
624fa02
fixes -> branch !
iceseer May 14, 2024
f5685b3
Merge branch 'master' into fix/crash_in_disputes
xDimon May 14, 2024
c7d0677
fixes -> branch !
iceseer May 15, 2024
e8e20c0
fixes -> branch !
iceseer May 15, 2024
0b00941
Merge remote-tracking branch 'origin/fix/crash_in_disputes' into test…
iceseer May 15, 2024
071475a
Merge branch 'master' into fix/crash_in_disputes
xDimon May 16, 2024
382b080
fixes -> branch !
iceseer May 17, 2024
9745c07
Merge branch 'master' into fix/crash_in_disputes
xDimon May 20, 2024
0ea84b3
draft
xDimon Apr 22, 2024
eb3daf0
tmp: disable disputes sending
xDimon May 20, 2024
5d97a10
Merge remote-tracking branch 'origin/test/without_rolling_sessions_wi…
iceseer May 21, 2024
fb031f9
Merge remote-tracking branch 'origin/master' into test/all_branches
iceseer May 21, 2024
3983043
cluster integration
iceseer May 22, 2024
6609cb9
Merge branch 'master' into test/all_branches
iceseer May 22, 2024
0ae340b
fixup!
iceseer May 23, 2024
bfe27e5
remove `need_to_process` check based on active_leaf
iceseer May 23, 2024
d324f40
test!!!!
iceseer May 23, 2024
fd16fb2
Always return true in handle_import_statements
kamilsa May 23, 2024
ab6849a
no test
iceseer May 23, 2024
a5058bb
kick_off_seconding
iceseer May 23, 2024
0575d03
impls
iceseer May 27, 2024
4b0b268
dequeue_next_collation_and_fetch
iceseer May 28, 2024
7988a9b
dequeue_next_collation_and_fetch
iceseer May 28, 2024
b8d5446
dequeue_next_collation_and_fetch
iceseer May 28, 2024
6746e3f
1
iceseer May 28, 2024
21b1243
new validator code
iceseer May 29, 2024
8a012e7
ref
iceseer May 30, 2024
4ff3b29
smoke complete
iceseer May 30, 2024
32208b2
Merge remote-tracking branch 'origin/master' into test/all_branches
iceseer May 30, 2024
3c03ff0
DO NOT COMMIT
iceseer May 30, 2024
368bb98
Revert "DO NOT COMMIT"
iceseer Jun 5, 2024
026c42d
fixup reverted eq
iceseer Jun 5, 2024
041ed03
ref
iceseer Jun 5, 2024
4727962
ref
iceseer Jun 5, 2024
99f9147
Merge remote-tracking branch 'origin/master' into test/all_branches
iceseer Jun 5, 2024
292c385
hunter
iceseer Jun 5, 2024
ac01e20
Revert "Always return true in handle_import_statements"
kamilsa Jun 6, 2024
d7c508a
trace statistics
iceseer Jun 6, 2024
8073861
memory fix
iceseer Jun 7, 2024
97c9cd2
issues fixes
iceseer Jun 14, 2024
7e6595a
issues fixes
iceseer Jun 17, 2024
a835a00
Merge remote-tracking branch 'origin/master' into test/all_branches
iceseer Jun 17, 2024
6042718
issues fixes
iceseer Jun 17, 2024
d78de3b
test fixes
iceseer Jun 17, 2024
8f79055
Merge branch 'master' into test/all_branches
iceseer Jun 17, 2024
e01466a
Merge branch 'master' into test/all_branches
kamilsa Jun 19, 2024
3dd36ca
issues
iceseer Jun 20, 2024
01d7020
issues
iceseer Jun 20, 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
6 changes: 6 additions & 0 deletions cmake/Hunter/init.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,11 @@ set(HUNTER_CACHE_SERVERS
CACHE STRING "Binary cache server"
)

# https://hunter.readthedocs.io/en/latest/reference/user-variables.html#hunter-use-cache-servers
# set(
# HUNTER_USE_CACHE_SERVERS NO
# CACHE STRING "Disable binary cache"
# )

iceseer marked this conversation as resolved.
Show resolved Hide resolved
include(${CMAKE_CURRENT_LIST_DIR}/HunterGate.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/hunter-gate-url.cmake)
15 changes: 15 additions & 0 deletions core/api/jrpc/value_converter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ namespace kagome::api {
inline jsonrpc::Value makeValue(const primitives::Version &);
inline jsonrpc::Value makeValue(const primitives::Justification &);
inline jsonrpc::Value makeValue(const primitives::RpcMethods &);
inline jsonrpc::Value makeValue(
const primitives::events::RemoveAfterFinalizationParams &val);
inline jsonrpc::Value makeValue(
const primitives::events::RemoveAfterFinalizationParams::HeaderInfo &val);

inline jsonrpc::Value makeValue(const uint32_t &val) {
return static_cast<int64_t>(val);
Expand Down Expand Up @@ -150,6 +154,17 @@ namespace kagome::api {
return value;
}

inline jsonrpc::Value makeValue(
const primitives::events::RemoveAfterFinalizationParams &val) {
return makeValue(val.removed);
}

inline jsonrpc::Value makeValue(
const primitives::events::RemoveAfterFinalizationParams::HeaderInfo
&val) {
return makeValue(val.hash);
}

template <size_t N>
inline jsonrpc::Value makeValue(const common::Blob<N> &val) {
return makeValue(BufferView{val});
Expand Down
66 changes: 39 additions & 27 deletions core/blockchain/impl/block_tree_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -813,9 +813,13 @@ namespace kagome::blockchain {

OUTCOME_TRY(p.storage_->putJustification(justification, block_hash));

std::vector<primitives::BlockHash> retired_hashes;
std::vector<
primitives::events::RemoveAfterFinalizationParams::HeaderInfo>
retired_hashes;
for (auto parent = node->parent(); parent; parent = parent->parent()) {
retired_hashes.emplace_back(parent->info.hash);
retired_hashes.emplace_back(
primitives::events::RemoveAfterFinalizationParams::HeaderInfo{
parent->info.hash, parent->info.number});
}

auto changes = p.tree_->finalize(node);
Expand Down Expand Up @@ -846,12 +850,13 @@ namespace kagome::blockchain {

main_pool_handler_->execute(
[weak{weak_from_this()},
retired_hashes{std::move(retired_hashes)}] {
retired{primitives::events::RemoveAfterFinalizationParams{
std::move(retired_hashes), header.number}}] {
if (auto self = weak.lock()) {
self->chain_events_engine_->notify(
primitives::events::ChainEventType::
kDeactivateAfterFinalization,
retired_hashes);
retired);
}
});

Expand Down Expand Up @@ -1301,7 +1306,8 @@ namespace kagome::blockchain {
}

std::vector<primitives::Extrinsic> extrinsics;
std::vector<primitives::BlockHash> retired_hashes;
std::vector<primitives::events::RemoveAfterFinalizationParams::HeaderInfo>
retired_hashes;

// remove from storage
retired_hashes.reserve(changes.prune.size());
Expand Down Expand Up @@ -1329,33 +1335,39 @@ namespace kagome::blockchain {
BOOST_ASSERT(block_header_opt.has_value());
OUTCOME_TRY(p.state_pruner_->pruneDiscarded(block_header_opt.value()));
}
retired_hashes.emplace_back(block.hash);
retired_hashes.emplace_back(
primitives::events::RemoveAfterFinalizationParams::HeaderInfo{
block.hash, block.number});
OUTCOME_TRY(p.storage_->removeBlock(block.hash));
}

// trying to return extrinsics back to transaction pool
main_pool_handler_->execute([extrinsics{std::move(extrinsics)},
wself{weak_from_this()},
retired_hashes{
std::move(retired_hashes)}]() mutable {
if (auto self = wself.lock()) {
auto eo = self->block_tree_data_.sharedAccess(
[&](const BlockTreeData &p) { return p.extrinsic_observer_; });

for (auto &&extrinsic : extrinsics) {
auto result = eo->onTxMessage(extrinsic);
if (result) {
SL_DEBUG(self->log_, "Tx {} was reapplied", result.value().toHex());
} else {
SL_DEBUG(self->log_, "Tx was skipped: {}", result.error());
}
}
main_pool_handler_->execute(
[extrinsics{std::move(extrinsics)},
wself{weak_from_this()},
retired{primitives::events::RemoveAfterFinalizationParams{
std::move(retired_hashes),
getLastFinalizedNoLock(p).number}}]() mutable {
if (auto self = wself.lock()) {
auto eo = self->block_tree_data_.sharedAccess(
[&](const BlockTreeData &p) { return p.extrinsic_observer_; });

for (auto &&extrinsic : extrinsics) {
auto result = eo->onTxMessage(extrinsic);
if (result) {
SL_DEBUG(
self->log_, "Tx {} was reapplied", result.value().toHex());
} else {
SL_DEBUG(self->log_, "Tx was skipped: {}", result.error());
}
}

self->chain_events_engine_->notify(
primitives::events::ChainEventType::kDeactivateAfterFinalization,
retired_hashes);
}
});
self->chain_events_engine_->notify(
primitives::events::ChainEventType::
kDeactivateAfterFinalization,
retired);
}
});

return outcome::success();
}
Expand Down
124 changes: 79 additions & 45 deletions core/dispute_coordinator/impl/dispute_coordinator_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace kagome::dispute {
[&](const ValidDisputeStatement &kind) {
return visit_in_place(
kind,
[&](const Explicit &) {
[&](const Explicit &x) {
std::array<uint8_t, 4> magic{'D', 'I', 'S', 'P'};
bool validity = true;
return scale::encode(
Expand Down Expand Up @@ -91,6 +91,15 @@ namespace kagome::dispute {
std::array<uint8_t, 4> magic{'A', 'P', 'P', 'R'};
return scale::encode(
std::tie(magic, candidate_hash, session));
},
[&](const ApprovalCheckingMultipleCandidates &candidates) {
std::array<uint8_t, 4> magic{'A', 'P', 'P', 'R'};
if (candidates.size() == 1) {
return scale::encode(
std::tie(magic, candidates.front(), session));
} else {
return scale::encode(std::tie(magic, candidates, session));
}
});
},
[&](const InvalidDisputeStatement &kind) {
Expand Down Expand Up @@ -320,7 +329,7 @@ namespace kagome::dispute {
// https://github.com/paritytech/polkadot/blob/40974fb99c86f5c341105b7db53c7aa0df707d66/node/core/dispute-coordinator/src/lib.rs#L298
for (auto &[session, candidate_hash, status] : active_disputes) {
auto env_opt = makeCandidateEnvironment(
*session_keys_, *rolling_session_window_, session);
*session_keys_, *rolling_session_window_, session, first_leaf.hash);
if (not env_opt.has_value()) {
continue;
}
Expand Down Expand Up @@ -535,6 +544,7 @@ namespace kagome::dispute {
auto res = process_active_leaves_update(update);
if (res.has_error()) {
SL_ERROR(log_, "Can't handle active list update: {}", res.error());
std::ignore = process_active_leaves_update(update);
return;
}
}
Expand All @@ -550,18 +560,6 @@ namespace kagome::dispute {
return outcome::success();
}

// Obtain the session info, for sake of `ValidatorId`s either from the
// rolling session window. Must be called _after_ `fn
// cache_session_info_for_head` which guarantees that the session info is
// available for the current session.
auto session_info_opt = rolling_session_window_->session_info(session);
if (not session_info_opt.has_value()) {
SL_WARN(log_,
"Could not retrieve session info from rolling session window");
return outcome::success();
}
auto &session_info = session_info_opt.value().get();

// Scraped on-chain backing votes for the candidates with the new active
// leaf as if we received them via gossip.
for (auto &[candidate_receipt, backers] :
Expand All @@ -571,6 +569,11 @@ namespace kagome::dispute {

SL_TRACE(log_, "Importing backing votes from chain for candidate");

OUTCOME_TRY(session, api_->session_index_for_child(relay_parent));
OUTCOME_TRY(session_info_opt, api_->session_info(relay_parent, session));
BOOST_ASSERT(session_info_opt.has_value());
const auto &session_info = session_info_opt.value();

std::vector<Indexed<SignedDisputeStatement>> statements;
for (auto &[validator_index, attestation] : backers) {
if (validator_index >= session_info.validators.size()) {
Expand Down Expand Up @@ -978,12 +981,18 @@ namespace kagome::dispute {
DisputeCoordinatorImpl::makeCandidateEnvironment(
crypto::SessionKeys &session_keys,
RollingSessionWindow &rolling_session_window,
SessionIndex session) {
auto session_info_opt = rolling_session_window.session_info(session);
SessionIndex session,
primitives::BlockHash relay_parent) {
auto session_info_opt_res = api_->session_info(relay_parent, session);
if (session_info_opt_res.has_error()) {
// TODO log
iceseer marked this conversation as resolved.
Show resolved Hide resolved
return std::nullopt;
}
auto session_info_opt = session_info_opt_res.value();
if (not session_info_opt.has_value()) {
return std::nullopt;
}
auto &session_info = session_info_opt.value().get();
auto session_info = std::move(session_info_opt.value());

std::unordered_set<ValidatorIndex> controlled_indices;
auto keypair = session_keys.getParaKeyPair(session_info.validators);
Expand All @@ -992,7 +1001,7 @@ namespace kagome::dispute {
}

return CandidateEnvironment{.session_index = session,
.session = session_info,
.session = std::move(session_info),
.controlled_indices = controlled_indices};
}

Expand All @@ -1015,16 +1024,6 @@ namespace kagome::dispute {
.hash(*hasher_)
: boost::relaxed_get<CandidateHash>(candidate_receipt);

auto env_opt = makeCandidateEnvironment(
*session_keys_, *rolling_session_window_, session);
if (not env_opt.has_value()) {
SL_DEBUG(log_,
"We are lacking a `SessionInfo` for handling import of "
"statements.");
return outcome::success(false);
}
auto &env = env_opt.value();

// In case we are not provided with a candidate receipt we operate under
// the assumption, that a previous vote which included a
// `CandidateReceipt` was seen. This holds since every block is preceded
Expand Down Expand Up @@ -1062,6 +1061,16 @@ namespace kagome::dispute {
relay_parent = old_state_opt->candidate_receipt.descriptor.relay_parent;
}

auto env_opt = makeCandidateEnvironment(
*session_keys_, *rolling_session_window_, session, relay_parent);
if (not env_opt.has_value()) {
SL_DEBUG(log_,
"We are lacking a `SessionInfo` for handling import of "
"statements.");
return outcome::success(false);
}
auto &env = env_opt.value();

auto disabled_validators_res = api_->disabled_validators(relay_parent);
if (disabled_validators_res.has_error()) {
SL_WARN(log_,
Expand Down Expand Up @@ -1154,19 +1163,24 @@ namespace kagome::dispute {
statements.end());
}
++imported_valid_votes;
return true;
// return true;
}
auto &existing = std::get<0>(it->second);
return visit_in_place(
valid,
[&](const Explicit &) {
return not is_type<Explicit>(existing);
},
[&](const BackingSeconded &) { return false; },
[&](const BackingValid &) { return false; },
[&](const ApprovalChecking &) {
return not is_type<ApprovalChecking>(existing);
});
// auto &existing = std::get<0>(it->second);
iceseer marked this conversation as resolved.
Show resolved Hide resolved
// return visit_in_place(
// valid,
// [&](const Explicit &) {
// return not is_type<Explicit>(existing);
// },
// [&](const BackingSeconded &) { return false; },
// [&](const BackingValid &) { return false; },
// [&](const ApprovalChecking &) {
// return not is_type<ApprovalChecking>(existing);
// },
// [&](const ApprovalCheckingMultipleCandidates &) {
// return not
// is_type<ApprovalCheckingMultipleCandidates>(
// existing);
// });
},
[&](const InvalidDisputeStatement &invalid) {
auto [it, fresh] = votes.invalid.emplace(
Expand All @@ -1181,9 +1195,9 @@ namespace kagome::dispute {
statements.end());
}
++imported_invalid_votes;
return true;
// return true;
}
return false;
// return false;
});
}

Expand Down Expand Up @@ -1467,7 +1481,11 @@ namespace kagome::dispute {
sig,
session};

SL_TRACE(log_, "Sending out own approval vote");
SL_TRACE(
log_,
"Sending out own approval vote. session={}, candidate_hash={}",
session,
candidate_hash);

auto dispute_message_res = make_dispute_message(
env.session, new_state.votes, statement, validator_index);
Expand Down Expand Up @@ -1791,7 +1809,12 @@ namespace kagome::dispute {
bool valid) {
// https://github.com/paritytech/polkadot/blob/40974fb99c86f5c341105b7db53c7aa0df707d66/node/core/dispute-coordinator/src/initialized.rs#L1102

SL_TRACE(log_, "Issuing local statement for candidate!");
SL_TRACE(log_,
"Issuing local statement for candidate! "
"session={}, candidate_hash={}, relay_parent={}",
session,
candidate_hash,
candidate_receipt.descriptor.relay_parent);

// Load environment:

Expand Down Expand Up @@ -2058,7 +2081,12 @@ namespace kagome::dispute {
std::move(candidate_receipt),
valid);

SL_TRACE(log_, "DisputeCoordinatorMessage::IssueLocalStatement");
SL_TRACE(log_,
"DisputeCoordinatorMessage::IssueLocalStatement. "
"session={}, candidate_hash={}, relay_parent={}",
session,
candidate_hash,
candidate_receipt.descriptor.relay_parent);
auto res = issue_local_statement(
candidate_hash, candidate_receipt, session, valid);

Expand Down Expand Up @@ -2507,6 +2535,12 @@ namespace kagome::dispute {
}
}

SL_TRACE( // FIXME It's temporary code. Remove after tests
log_,
"Dispute (candidate={}) did not send. Disabled",
candidate_hash);
return;

auto protocol = router_->getSendDisputeProtocol();
BOOST_ASSERT_MSG(protocol,
"Router did not provide `send dispute` protocol");
Expand Down
5 changes: 3 additions & 2 deletions core/dispute_coordinator/impl/dispute_coordinator_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,11 @@ namespace kagome::dispute {
std::vector<Indexed<SignedDisputeStatement>> statements,
CbOutcome<void> &&cb);

static std::optional<CandidateEnvironment> makeCandidateEnvironment(
std::optional<CandidateEnvironment> makeCandidateEnvironment(
crypto::SessionKeys &session_keys,
RollingSessionWindow &rolling_session_window,
SessionIndex session);
SessionIndex session,
primitives::BlockHash relay_parent);

outcome::result<void> process_on_chain_votes(ScrapedOnChainVotes votes);

Expand Down
Loading
Loading