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

*: add Hash/Address generic parameters to dBFT #94

Merged
merged 3 commits into from
Feb 13, 2024
Merged

Conversation

AnnaShaleva
Copy link
Member

@AnnaShaleva AnnaShaleva commented Feb 13, 2024

Spread the generic Hash/Adress disease, add custom Hash/Address implementation and get rid of NeoGo dependency.

Close #2. @roman-khimov, let's firstly agree and merge this PR, and after that I'll move all payloads/block/tx implementation to the testing code together with custom Hash/Address implementation (#91). Now I clearly see that we need this.

Copy link
Member

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

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

I'll be missing Option a bit, but it looks very nice otherwise.

crypto/crypto.go Outdated Show resolved Hide resolved
crypto/crypto.go Show resolved Hide resolved
dbft.go Show resolved Hide resolved
dbft.go Outdated Show resolved Hide resolved
dbft.go Outdated Show resolved Hide resolved
@@ -3,13 +3,14 @@ package dbft
import (
"testing"

"github.com/nspcc-dev/neo-go/pkg/util"
"github.com/stretchr/testify/require"

Copy link
Member

Choose a reason for hiding this comment

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

Surprising that we have this in code.

Copy link
Member Author

Choose a reason for hiding this comment

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

We have this due to the order of commits. First commit adds generics to dBFT, and thus, it should be properly instantiated in all places. Next commit adds custom hash/address implementation, so this dependency is removed in the latter commit anyway.

Copy link
Member

Choose a reason for hiding this comment

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

I mean the whitespace line, but it's not added, so can stay for a while.

@roman-khimov
Copy link
Member

BTW, likely README should be adjusted a bit as well.

Copy link

codecov bot commented Feb 13, 2024

Codecov Report

Attention: 47 lines in your changes are missing coverage. Please review.

Comparison is base (92d9aec) 73.18% compared to head (87f247c) 73.13%.

Files Patch % Lines
config.go 81.05% 17 Missing and 1 partial ⚠️
payload/recovery_message.go 53.33% 7 Missing ⚠️
payload/consensus_message.go 28.57% 5 Missing ⚠️
crypto/hash.go 50.00% 4 Missing ⚠️
payload/prepare_request.go 0.00% 4 Missing ⚠️
dbft.go 89.28% 3 Missing ⚠️
payload/constructors.go 50.00% 2 Missing ⚠️
payload/prepare_response.go 0.00% 2 Missing ⚠️
block/block.go 85.71% 1 Missing ⚠️
payload/message.go 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #94      +/-   ##
==========================================
- Coverage   73.18%   73.13%   -0.06%     
==========================================
  Files          24       24              
  Lines        1365     1381      +16     
==========================================
+ Hits          999     1010      +11     
- Misses        298      303       +5     
  Partials       68       68              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

A part of #2. Use generics instead of util.Uint160 and util.Uint256
types for DBFT and related components. Keep util.Uint160 and util.Uint256
only for specific DBFT implementation in testing code.

The following regressions/behaviour changes were made to properly
apply generics:
1. `dbft.Option` alias is removed since type parameters can't be defined
   on aliases (generic type aliases are prohibited). Ref.
   golang/go#46477.
2. Default dBFT configuration is reduced: all payload-specific defaults
   are removed, as described in #91.
   It is done because default dBFT configuration should not depend on any
   implementation-specific hash type.
3. DBFT configuration validation check is extended wrt point 2.
4. The check if generic `dbft.DBFT` type implements generic `dbft.Service`
   interface is removed since such check should be performed on particular
   (non-generic) DBFT implementation.

Signed-off-by: Anna Shaleva <[email protected]>
A part of #2. Use custom Hash/Address implementation, get rid of
util.Uint256/util.Uint160 NeoGo dependency.

Signed-off-by: Anna Shaleva <[email protected]>
A part of #2, not needed anymore.

Signed-off-by: Anna Shaleva <[email protected]>
@@ -3,13 +3,14 @@ package dbft
import (
"testing"

"github.com/nspcc-dev/neo-go/pkg/util"
"github.com/stretchr/testify/require"

Copy link
Member

Choose a reason for hiding this comment

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

I mean the whitespace line, but it's not added, so can stay for a while.

@roman-khimov roman-khimov merged commit 3c9c1c8 into master Feb 13, 2024
6 of 7 checks passed
@roman-khimov roman-khimov deleted the generic-dbft branch February 13, 2024 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Why dBFT requires NeoGO package
2 participants