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/tracker: implement inclusion delay tracker #1468

Merged
merged 6 commits into from
Nov 22, 2022
Merged

Conversation

corverroos
Copy link
Contributor

@corverroos corverroos commented Nov 21, 2022

Implement a function that calculates the clusters inclusion delay for a specific block.

category: feature
ticket: #1254

@codecov
Copy link

codecov bot commented Nov 21, 2022

Codecov Report

Base: 54.01% // Head: 53.72% // Decreases project coverage by -0.29% ⚠️

Coverage data is based on head (5807a66) compared to base (e7cbb56).
Patch coverage: 44.89% of modified lines in pull request are covered.

❗ Current head 5807a66 differs from pull request most recent head 96fb576. Consider uploading reports for the commit 96fb576 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1468      +/-   ##
==========================================
- Coverage   54.01%   53.72%   -0.30%     
==========================================
  Files         147      148       +1     
  Lines       18683    18751      +68     
==========================================
- Hits        10092    10074      -18     
- Misses       7217     7297      +80     
- Partials     1374     1380       +6     
Impacted Files Coverage Δ
core/tracker/incldelay.go 44.89% <44.89%> (ø)
core/qbft/qbft.go 72.44% <0.00%> (-10.03%) ⬇️
testutil/compose/run.go 82.14% <0.00%> (-3.05%) ⬇️
core/priority/prioritiser.go 59.67% <0.00%> (-2.89%) ⬇️
testutil/compose/auto.go 0.00% <0.00%> (ø)
testutil/compose/alert.go 0.00% <0.00%> (ø)
core/consensus/component.go 59.30% <0.00%> (+0.12%) ⬆️
core/dutydb/memory.go 69.28% <0.00%> (+0.69%) ⬆️
app/app.go 62.69% <0.00%> (+0.76%) ⬆️
app/vmock.go 74.09% <0.00%> (+1.03%) ⬆️
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

"github.com/obolnetwork/charon/core"
)

// epochLag is the number of epochs to lag when calculating inclusion delay (to ensure finality).
Copy link
Contributor

Choose a reason for hiding this comment

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

finality is ensured in atleast 2 epochs, why is the lag equal to 1 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated the comment accordingly

core/tracker/incldelay.go Outdated Show resolved Hide resolved
}

blockSlot := current.Slot - (epochLag * current.SlotsPerEpoch)
if blockSlot < fromSlot {
Copy link
Contributor

Choose a reason for hiding this comment

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

add a comment for this condition

// is expected by the network and the slot the attestation is actually included on-chain.
// See https://rated.gitbook.io/rated-documentation/rating-methodologies/ethereum-beacon-chain/network-explorer-definitions/top-screener#inclusion-delay.
func NewInclDelayFunc(eth2Cl eth2wrap.Client, dutiesFunc dutiesFunc) func(context.Context, core.Slot) error {
return newInclDelayFunc(eth2Cl, dutiesFunc, func(delays []int64) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this callback function can be written outside as a separate function for better readability


// newInclDelayFunc extends NewInclDelayFunc with abstracted callback.
func newInclDelayFunc(eth2Cl eth2wrap.Client, dutiesFunc dutiesFunc, callback func([]int64)) func(context.Context, core.Slot) error {
var fromSlot int64
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest: add comment for this variable

core/tracker/incldelay.go Outdated Show resolved Hide resolved
corverroos and others added 2 commits November 22, 2022 17:57
Co-authored-by: Abhishek Kumar <43061995+xenowits@users.noreply.github.com>
@corverroos corverroos added the merge when ready Indicates bulldozer bot may merge when all checks pass label Nov 22, 2022
@obol-bulldozer obol-bulldozer bot merged commit 029c2b8 into main Nov 22, 2022
@obol-bulldozer obol-bulldozer bot deleted the corver/incldelay branch November 22, 2022 16:02
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.

3 participants