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: add new SignedData interface and impls #699

Merged
merged 6 commits into from
Jun 13, 2022

Conversation

corverroos
Copy link
Contributor

Step 1 of N: Adds the new interface and implementations and helper functions. Nothing wired or integrated yet.

category: refactor
ticket: #698

Comment on lines +30 to +33
_ SignedData = VersionedSignedBeaconBlock{}
_ SignedData = Attestation{}
_ SignedData = Signature{}
_ SignedData = SignedVoluntaryExit{}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The 4 implementations of the new SignedData interface

@codecov
Copy link

codecov bot commented Jun 12, 2022

Codecov Report

Merging #699 (e7efb6c) into main (69a1893) will decrease coverage by 0.79%.
The diff coverage is 45.02%.

@@            Coverage Diff             @@
##             main     #699      +/-   ##
==========================================
- Coverage   55.12%   54.32%   -0.80%     
==========================================
  Files         102      103       +1     
  Lines        9896    10126     +230     
==========================================
+ Hits         5455     5501      +46     
- Misses       3653     3820     +167     
- Partials      788      805      +17     
Impacted Files Coverage Δ
core/types.go 34.37% <ø> (-8.87%) ⬇️
core/signeddata.go 41.48% <41.48%> (ø)
core/proto.go 66.66% <60.46%> (-5.34%) ⬇️
core/qbft/qbft.go 71.67% <0.00%> (-10.31%) ⬇️
core/aggsigdb/memory.go 86.17% <0.00%> (-2.13%) ⬇️
dkg/disk.go 39.62% <0.00%> (-1.12%) ⬇️
cmd/createcluster.go 51.11% <0.00%> (-0.40%) ⬇️
app/app.go 58.75% <0.00%> (ø)
cmd/bootnode.go 40.35% <0.00%> (+0.16%) ⬆️

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 69a1893...e7efb6c. Read the comment docs.

core/types.go Outdated
Comment on lines 249 to 266
// SignedData is a signed duty data.
type SignedData interface {
// Signature returns the partial signature.
Signature() Signature
// SetSignature returns a copy of signed duty data with the signature replaced.
SetSignature(Signature) (SignedData, error)
// Marshaler returns the json serialised signed duty data (including the signature).
json.Marshaler
}

// ParSignedData2 is a partially signed duty data only signed by a single threshold BLS share.
// TODO(corver): Rename and place ParSignedData.
type ParSignedData2 struct {
SignedData
// ShareIdx returns the threshold BLS share index.
ShareIdx int
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

these are the two new types (one interface and one struct)

@corverroos corverroos changed the title core: add new signeddata interface and implementations core: add new SignedData interface and implementations Jun 12, 2022
@corverroos corverroos changed the title core: add new SignedData interface and implementations core: add new SignedData interface and impls Jun 12, 2022

// Attestation is a signed attestation and implements SignedData.
type Attestation struct {
eth2p0.Attestation
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cannot subtype since eth2p0.Attestation's field Signature clashes with interface method Signature

Copy link
Contributor

Choose a reason for hiding this comment

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

can we make this attestation private since we already have getter and setter methods(Signature and SetSignature)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Although I don't have any strong opinion on this.

Copy link
Contributor Author

@corverroos corverroos Jun 13, 2022

Choose a reason for hiding this comment

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

it cannot be made private since some components will cast and use the embedded type like bcast and aggsigdb. Also it is a value, and value can be public.

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.

Looks Great!

core/types.go Outdated
}
}

// Signature is a BLS12-381 Signature. It implements SignedData.
type Signature []byte
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is an implementation of SignedData then why it is not present in signeddata.go?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it was already present here, but sure can move it.

var (
_ SignedData = VersionedSignedBeaconBlock{}
_ SignedData = Attestation{}
_ SignedData = Signature{}
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume Signature{} is to used by Randao and exchanger in dkg. Can we be more specific about those types and also accomodate those cases as well? Since in exchanger we require to share some data(like cluster-lock and deposit-data) not just signature.

Copy link
Contributor Author

@corverroos corverroos Jun 13, 2022

Choose a reason for hiding this comment

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

Yeah, it depends if if the data also needs to be shared with the signature, then we need another type, not just Signature which is ONLY a signature with the data being out-of-band / implicit. This is how Randao and DKG lockhash+depositdata is implemeneted, as signatures only.

For randao, the data is the epoch, it is implicit in the duty slot, so not shared in the data at this point.
For DKG, it is the lock hash and the depositdatahash, those datas are implicit in DKg instance so not shared at this point.

We can include that data if we want, but we do not do this at this point. So that would be another refactor I think.


// Attestation is a signed attestation and implements SignedData.
type Attestation struct {
eth2p0.Attestation
Copy link
Contributor

Choose a reason for hiding this comment

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

can we make this attestation private since we already have getter and setter methods(Signature and SetSignature)?


// Attestation is a signed attestation and implements SignedData.
type Attestation struct {
eth2p0.Attestation
Copy link
Contributor

Choose a reason for hiding this comment

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

Although I don't have any strong opinion on this.

@corverroos corverroos added the merge when ready Indicates bulldozer bot may merge when all checks pass label Jun 13, 2022
@obol-bulldozer obol-bulldozer bot merged commit 1e3a05f into main Jun 13, 2022
@obol-bulldozer obol-bulldozer bot deleted the corver/newinterfacetypes branch June 13, 2022 16:04
obol-bulldozer bot pushed a commit that referenced this pull request Jun 14, 2022
Integrates new `SignedData` interface and `ParSignedData` type.

category: refactor
ticket: #699
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

2 participants