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/dutydb: implement in-memory dutyDB #178

Merged
merged 7 commits into from
Mar 5, 2022
Merged

core/dutydb: implement in-memory dutyDB #178

merged 7 commits into from
Mar 5, 2022

Conversation

corverroos
Copy link
Contributor

Implements a placeholder in-memory dutyDB.

Refactor the dutyDB interface types to explicit eth2 types since they are duty type specific.
Adds AttestestionDuty with AttestationData so DutyDB can map responses to pubkey via aggbits

category: feature
ticket: #165

@codecov
Copy link

codecov bot commented Mar 4, 2022

Codecov Report

❗ No coverage uploaded for pull request base (main@a06f808). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #178   +/-   ##
=======================================
  Coverage        ?   56.73%           
=======================================
  Files           ?       39           
  Lines           ?     2346           
  Branches        ?        0           
=======================================
  Hits            ?     1331           
  Misses          ?      882           
  Partials        ?      133           

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 a06f808...7b9214e. Read the comment docs.

@@ -66,6 +66,7 @@ issues:
- bodyclose
- noctx
- revive
- gosec
Copy link
Contributor Author

Choose a reason for hiding this comment

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

exclude gosec from tests

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 good!
Few comments

core/dutydb/memory.go Outdated Show resolved Hide resolved
}

// Store key and value for PubKeyByAttestation
pKey := pkKey{
Copy link
Contributor

@dB2510 dB2510 Mar 5, 2022

Choose a reason for hiding this comment

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

this data can be same for two DVs, if 2 validators are part of same committee for the same slot

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well, not the pkkey, since that is has aggbits which is unique per validator. It is the other key, attkey which can be match mutliple Dvs, but we ensure that data is consistent

core/encode.go Outdated Show resolved Hide resolved
core/encode.go Outdated
@@ -56,7 +55,7 @@ func DecodeAttesterUnsingedData(unsignedData UnsignedData) (*eth2p0.AttestationD
}

// EncodeAttesterUnsingedData returns the attestation data as an encoded UnsignedData.
func EncodeAttesterUnsingedData(attData *eth2p0.AttestationData) (UnsignedData, error) {
func EncodeAttesterUnsingedData(attData *AttestationData) (UnsignedData, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

**EncodeAttesterUnsignedData

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -85,33 +85,37 @@ func (f *Fetcher) Fetch(ctx context.Context, duty core.Duty, argSet core.FetchAr
// fetchAttesterData returns the fetched attestation data set for committees and validators in the arg set.
func (f *Fetcher) fetchAttesterData(ctx context.Context, slot int64, argSet core.FetchArgSet,
) (core.UnsignedDataSet, error) {
valsByComm := make(map[eth2p0.CommitteeIndex][]core.PubKey)
// We may have multiple validators in the same committee, use the same attestation data in that case.
Copy link
Contributor

Choose a reason for hiding this comment

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

Exactly!

for _, pubkey := range pubkeys {
resp[pubkey] = dutyData
}
resp[pubkey] = dutyData
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose this data is to be sent to our validators for partial signing after this with their key share

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup

corverroos and others added 2 commits March 5, 2022 11:01
Co-authored-by: Dhruv Bodani <dhruvbodani2510@gmail.com>
core/encode.go Outdated Show resolved Hide resolved
@corverroos corverroos merged commit 27bf239 into main Mar 5, 2022
@corverroos corverroos deleted the corver/dutydb branch March 5, 2022 09:13
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.

None yet

2 participants