-
Notifications
You must be signed in to change notification settings - Fork 90
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
*: convert to uint64 #2668
*: convert to uint64 #2668
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #2668 +/- ##
==========================================
- Coverage 53.00% 52.94% -0.06%
==========================================
Files 202 202
Lines 28006 28011 +5
==========================================
- Hits 14844 14830 -14
- Misses 11301 11321 +20
+ Partials 1861 1860 -1
☔ View full report in Codecov by Sentry. |
@@ -743,7 +743,7 @@ func fmtStepPeers(step roundStep) string { | |||
|
|||
// leader return the deterministic leader index. | |||
func leader(duty core.Duty, round int64, nodes int) int64 { |
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.
why can't this function return uint64?
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.
it can, but uint64 is not really required by the code that uses this leader
helper function
I have tried to use uint64s only where's necessary (most for spec compliance)
@@ -319,11 +319,11 @@ func (s *Scheduler) resolveAttDuties(ctx context.Context, slot core.Slot, vals v | |||
continue | |||
} | |||
|
|||
duty := core.NewAttesterDuty(int64(attDuty.Slot)) | |||
duty := core.NewAttesterDuty(uint64(attDuty.Slot)) |
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.
Can attDuty.Slot
be moved to uint64 as well?
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.
attDuty.Slot
is of eth2p0.Slot
type. Since, NewAttesterDuty(slot uint64)
, we need to typecast the eth2p0.Slot to uint64 type
@@ -29,7 +30,7 @@ func StartDutyTrace(ctx context.Context, duty Duty, spanName string, opts ...tra | |||
ctx, outerSpan = tracer.Start(tracer.RootedCtx(ctx, traceID), fmt.Sprintf("core/duty.%s", strings.Title(duty.Type.String()))) | |||
ctx, innerSpan = tracer.Start(ctx, spanName, opts...) | |||
|
|||
outerSpan.SetAttributes(attribute.Int64("slot", duty.Slot)) | |||
outerSpan.SetAttributes(attribute.Int64("slot", safeInt64(duty.Slot))) |
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.
Same here, i wonder if we can have Slot as uint64 and eventually do the safeint64 checks when creating the struct.
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.
attribute has only 3 methods: attribute.Int()
, attribute.Int64()
& attribute.String()
q: why would we need to perform safeint checks if we define slots are uint64, won't the compiler already catch this?
@@ -131,7 +131,7 @@ func newExchanger(tcpNode host.Host, peerIdx int, peers []peer.ID, vals int, sig | |||
// signatures of the group according to public key of each DV. | |||
func (e *exchanger) exchange(ctx context.Context, sigType sigType, set core.ParSignedDataSet) (map[core.PubKey][]core.ParSignedData, error) { | |||
// Start the process by storing current peer's ParSignedDataSet | |||
duty := core.NewSignatureDuty(int64(sigType)) | |||
duty := core.NewSignatureDuty(uint64(sigType)) |
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.
Would change sigType to uint64 instead.
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.
I don't think that's required, what'd be the reason to change type for sigType
which is currently an int
to uint64
?
slots, committee indices etc should be uint64 because the spec mandates that.
733732d
to
09a368c
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Convert
Duty.Slot
from int64 to uint64.This is recommended according to ethereum consensus specs: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#custom-types
category: feature
ticket: #2658