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: track blinded proposals #3149

Merged
merged 2 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions core/tracker/inclusion.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,37 @@
return errors.Wrap(err, "hash aggregate")
}
} else if duty.Type == core.DutyProposer {
proposal, ok := data.(core.VersionedSignedProposal)
var (
block core.VersionedSignedProposal
blindedBlock core.VersionedSignedBlindedProposal

blinded bool
ok bool
)

block, ok = data.(core.VersionedSignedProposal)
if !ok {
return errors.New("invalid block")
blindedBlock, blinded = data.(core.VersionedSignedBlindedProposal)
if !blinded {
return errors.New("invalid block")
}

Check warning on line 120 in core/tracker/inclusion.go

View check run for this annotation

Codecov / codecov/patch

core/tracker/inclusion.go#L119-L120

Added lines #L119 - L120 were not covered by tests
}
if eth2wrap.IsSyntheticProposal(&proposal.VersionedSignedProposal) {
// Report inclusion for synthetic blocks as it is already included on-chain.
i.trackerInclFunc(duty, pubkey, data, nil)

return nil
switch blinded {
case true:
if eth2wrap.IsSyntheticBlindedBlock(&blindedBlock.VersionedSignedBlindedProposal) {
// Report inclusion for synthetic blocks as it is already included on-chain.
i.trackerInclFunc(duty, pubkey, data, nil)

return nil
}

Check warning on line 130 in core/tracker/inclusion.go

View check run for this annotation

Codecov / codecov/patch

core/tracker/inclusion.go#L126-L130

Added lines #L126 - L130 were not covered by tests
default:
if eth2wrap.IsSyntheticProposal(&block.VersionedSignedProposal) {
// Report inclusion for synthetic blocks as it is already included on-chain.
i.trackerInclFunc(duty, pubkey, data, nil)

return nil
}

Check warning on line 137 in core/tracker/inclusion.go

View check run for this annotation

Codecov / codecov/patch

core/tracker/inclusion.go#L133-L137

Added lines #L133 - L137 were not covered by tests
}
} else if duty.Type == core.DutyBuilderProposer {
return core.ErrDeprecatedDutyBuilderProposer
Expand Down
36 changes: 33 additions & 3 deletions core/tracker/tracker_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"math/rand"
"net/http"
"reflect"
"sync"
"testing"
"time"

eth2api "github.com/attestantio/go-eth2-client/api"
eth2v1 "github.com/attestantio/go-eth2-client/api/v1"
Expand Down Expand Up @@ -1111,12 +1113,26 @@ func TestIsParSigEventExpected(t *testing.T) {
}

func TestAnalyseParSigs(t *testing.T) {
t.Run("full block", func(t *testing.T) {
analyseParSigs(t, func() core.SignedData {
return testutil.RandomDenebCoreVersionedSignedProposal()
})
})

t.Run("blinded block", func(t *testing.T) {
analyseParSigs(t, func() core.SignedData {
return testutil.RandomDenebVersionedSignedBlindedProposal()
})
})
}

func analyseParSigs(t *testing.T, dataGen func() core.SignedData) {
t.Helper()
require.Empty(t, extractParSigs(context.Background(), nil))

var events []event

makeEvents := func(n int, pubkey string) {
data := testutil.RandomBellatrixCoreVersionedSignedProposal()
makeEvents := func(n int, pubkey string, data core.SignedData) {
offset := len(events)
for i := 0; i < n; i++ {
data, err := data.SetSignature(testutil.RandomCoreSignature())
Expand All @@ -1137,7 +1153,8 @@ func TestAnalyseParSigs(t *testing.T) {
6: "b",
}
for n, pubkey := range expect {
makeEvents(n, pubkey)
data := dataGen()
makeEvents(n, pubkey, data)
}

allParSigMsgs := extractParSigs(context.Background(), events)
Expand Down Expand Up @@ -1304,3 +1321,16 @@ func TestIgnoreUnsupported(t *testing.T) {
func randomStep() step {
return step(rand.Intn(int(sentinel)))
}

func TestSubmittedProposals(t *testing.T) {
ic := inclusionCore{
mu: sync.Mutex{},
submissions: make(map[subkey]submission),
}

err := ic.Submitted(core.NewProposerDuty(42), testutil.RandomCorePubKey(t), testutil.RandomDenebCoreVersionedSignedProposal(), 1*time.Millisecond)
require.NoError(t, err)

err = ic.Submitted(core.NewProposerDuty(42), testutil.RandomCorePubKey(t), testutil.RandomDenebVersionedSignedBlindedProposal(), 1*time.Millisecond)
require.NoError(t, err)
}
Loading