-
Notifications
You must be signed in to change notification settings - Fork 39
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/candidate baking #1307
Feature/candidate baking #1307
Conversation
b093311
to
9d22ae2
Compare
35b21b3
to
50ed8d0
Compare
Signed-off-by: iceseer <iceseer@gmail.com>
50ed8d0
to
2169b6c
Compare
Signed-off-by: iceseer <iceseer@gmail.com>
06137e7
to
2cdaa39
Compare
Codecov Report
@@ Coverage Diff @@
## master #1307 +/- ##
==========================================
- Coverage 24.94% 24.50% -0.44%
==========================================
Files 612 612
Lines 22589 22984 +395
Branches 11794 11998 +204
==========================================
- Hits 5635 5633 -2
- Misses 11751 12149 +398
+ Partials 5203 5202 -1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
std::shared_ptr<WorkersContext> context_; | ||
std::shared_ptr<WorkGuard> work_guard_; | ||
std::unique_ptr<std::thread> workers_[kBackgroundWorkers]; |
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.
Better to wrap as (?)ThreadPool for reuse.
Signed-off-by: iceseer <iceseer@gmail.com>
func{std::forward<F>(func)}, | ||
stream](auto &&result) mutable { | ||
auto self = wptr.lock(); | ||
if (!result || !self) return std::forward<F>(func)(std::move(result)); |
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.
if (!result || !self) return std::forward<F>(func)(std::move(result)); | |
if (!result || !self) { | |
return std::forward<F>(func)(std::move(result)); |
}); | ||
template <bool DirectionIncoming, typename F> | ||
void doCollatorHandshake( | ||
std::shared_ptr<kagome::network::Stream> const &stream, F &&func) { |
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.
std::shared_ptr<kagome::network::Stream> const &stream, F &&func) { | |
const std::shared_ptr<kagome::network::Stream> &stream, F &&func) { |
if (!stream) | ||
cb(ProtocolError::HANDSHAKE_ERROR); | ||
else | ||
cb(stream); |
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.
if (!stream) | |
cb(ProtocolError::HANDSHAKE_ERROR); | |
else | |
cb(stream); | |
if (!stream) { | |
cb(ProtocolError::HANDSHAKE_ERROR); | |
} else { | |
cb(stream); | |
} |
doCollatorHandshake<true>( | ||
stream, | ||
[wptr{weak_from_this()}]( | ||
std::shared_ptr<Stream> const &stream) mutable { |
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.
std::shared_ptr<Stream> const &stream) mutable { | |
const std::shared_ptr<Stream> &stream) mutable { |
@@ -305,6 +304,7 @@ namespace kagome::network { | |||
} | |||
|
|||
ProtocolBaseImpl base_; | |||
Protocol const protocol_; |
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.
Protocol const protocol_; | |
const Protocol protocol_; |
auto const &[it, inserted] = peer_map.insert( | ||
std::make_pair(peer_id, | ||
std::make_shared<FetchedCollationState>( | ||
std::move(response), | ||
CollationState::kFetched, | ||
PoVDataState::kComplete))); |
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.
auto const &[it, inserted] = peer_map.insert( | |
std::make_pair(peer_id, | |
std::make_shared<FetchedCollationState>( | |
std::move(response), | |
CollationState::kFetched, | |
PoVDataState::kComplete))); | |
auto inserted = peer_map.emplace( | |
peer_id, | |
std::make_shared<FetchedCollationState>( | |
std::move(response), | |
CollationState::kFetched, | |
PoVDataState::kComplete)).second; |
outcome::result<network::Signature> ParachainProcessorImpl::sign( | ||
T const &t) const { | ||
if (!keypair_) return Error::KEY_NOT_PRESENT; | ||
|
||
auto payload = scale::encode(t).value(); | ||
return crypto_provider_->sign(*keypair_, payload).value(); | ||
} | ||
|
||
std::optional<network::ValidatorIndex> ParachainProcessorImpl::getOurIndex() { | ||
logger_->error("Not implemented. Return my validator index."); | ||
return std::nullopt; | ||
} |
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.
May use ValidatorSigner
from #1336 (TODO: signable trait or conversion function, e.g. bitfield is encoded as is, but statement has prefix and conversion to other type)
candidateDescriptorFrom(*validation_result.fetched_collation), | ||
.commitments = std::move(*validation_result.commitments)}; | ||
|
||
auto sign_result = sign(receipt); |
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.
Must sign ("BKNG": [u8; 4], 1: u8, candidate_hash: [u8; 32])
CompactStatementInner
} else if constexpr (kStatementType == StatementType::kValid) { | ||
auto const candidate_hash = | ||
candidateHashFrom(*validation_result.fetched_collation); | ||
auto sign_result = sign(candidate_hash); |
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.
Must sign ("BKNG": [u8; 4], 2: u8, candidate_hash: [u8; 32])
Signed-off-by: iceseer <iceseer@gmail.com>
b7a7f26
to
9552195
Compare
Referenced issues
Resolves #1289
Description of the Change
Candidate baking implementation for parachains.