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

core/consensus: integrate qbft #603

Merged
merged 2 commits into from
May 24, 2022
Merged

core/consensus: integrate qbft #603

merged 2 commits into from
May 24, 2022

Conversation

corverroos
Copy link
Contributor

Integrates consensus QBFT component into charon run.

Also adds unit test for consensus component.

category: feature
ticket: #602
feature_flag: qbft_consensus

return nil, nil, err
}

if featureset.Enabled(featureset.QBFTConsensus) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is how feature flags are used

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool :)

@@ -43,9 +43,7 @@ const (
)

// NewComponent returns a new consensus QBFT component.
func NewComponent(tcpNode host.Host, peers []p2p.Peer,
peerIdx int64, p2pKey *ecdsa.PrivateKey,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing peerIdx, rather inferring it from tcphost to avoid mistakes.

Comment on lines -115 to -117
if msg == nil {
return [32]byte{}, nil
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking if an interface is nil is bad, since nil pointer implementations of the interface isn't nil...

@codecov
Copy link

codecov bot commented May 24, 2022

Codecov Report

Merging #603 (68bfeba) into main (6e537c4) will increase coverage by 1.85%.
The diff coverage is 53.27%.

@@            Coverage Diff             @@
##             main     #603      +/-   ##
==========================================
+ Coverage   54.58%   56.44%   +1.85%     
==========================================
  Files          96       96              
  Lines        8975     9062      +87     
==========================================
+ Hits         4899     5115     +216     
+ Misses       3373     3208     -165     
- Partials      703      739      +36     
Impacted Files Coverage Δ
app/lifecycle/orderstart_string.go 40.00% <ø> (ø)
app/app.go 58.97% <43.58%> (-1.74%) ⬇️
core/consensus/msg.go 60.00% <46.66%> (+32.82%) ⬆️
core/consensus/transport.go 58.55% <58.62%> (+58.55%) ⬆️
core/consensus/component.go 63.44% <63.63%> (+63.44%) ⬆️
core/qbft/qbft.go 82.13% <100.00%> (ø)
testutil/compose/new.go 75.00% <0.00%> (-25.00%) ⬇️
testutil/compose/config.go 82.35% <0.00%> (ø)
testutil/compose/define.go 49.04% <0.00%> (+2.98%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6e537c4...68bfeba. Read the comment docs.

func NewComponent(tcpNode host.Host, peers []p2p.Peer,
peerIdx int64, p2pKey *ecdsa.PrivateKey,
) (*Component, error) {
func NewComponent(tcpNode host.Host, peers []p2p.Peer, p2pKey *ecdsa.PrivateKey) (*Component, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is the only component created in this package, the constructor should be named New . Also, the component should not be called "Component" but actually what it is Perhaps "QBFT".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That way it will read consensu.QBFT in other packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

Copy link
Contributor

@dB2510 dB2510 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

) (host.Host, *enode.LocalNode, error) {
p2pKey := conf.TestConfig.P2PKey
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this was moved from here to Run function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previously this was only used in p2p wiring, now it is used in p2p and qbft (need to sign messages). So moved it one level up.

return nil, nil, err
}

if featureset.Enabled(featureset.QBFTConsensus) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool :)

@@ -42,8 +42,8 @@ const (
protocolID = "/charon/consensus/qbft/1.0.0"
)

// NewComponent returns a new consensus QBFT component.
func NewComponent(tcpNode host.Host, peers []p2p.Peer, p2pKey *ecdsa.PrivateKey) (*Component, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NewComponent looks more relevant 🙃

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😉

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we name components "component", everything would be named component, that is why we should avoid those types of generics in naming

@corverroos corverroos added the merge when ready Indicates bulldozer bot may merge when all checks pass label May 24, 2022
@obol-bulldozer obol-bulldozer bot merged commit 5be0785 into main May 24, 2022
@obol-bulldozer obol-bulldozer bot deleted the corver/qbftint branch May 24, 2022 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge when ready Indicates bulldozer bot may merge when all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants