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/bcast: broadcast either blinded or full block #3144

Merged
merged 9 commits into from
Jun 21, 2024
31 changes: 26 additions & 5 deletions core/bcast/bcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,39 @@
return err
}

block, ok := aggData.(core.VersionedSignedProposal)
var (
block core.VersionedSignedProposal
blindedBlock core.VersionedSignedBlindedProposal

blinded bool
ok bool
)

block, ok = aggData.(core.VersionedSignedProposal)
Copy link
Contributor

Choose a reason for hiding this comment

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

It's terrible that we have to do all these castings.. and sad that I overlooked this issue in bcast.

if !ok {
return errors.New("invalid proposal")
// check if it's a blinded proposal
blindedBlock, blinded = aggData.(core.VersionedSignedBlindedProposal)
if !blinded {
return errors.New("invalid proposal")
}

Check warning on line 90 in core/bcast/bcast.go

View check run for this annotation

Codecov / codecov/patch

core/bcast/bcast.go#L86-L90

Added lines #L86 - L90 were not covered by tests
}

switch blinded {
case true:
err = b.eth2Cl.SubmitBlindedProposal(ctx, &eth2api.SubmitBlindedProposalOpts{
Proposal: &blindedBlock.VersionedSignedBlindedProposal,
})

Check warning on line 97 in core/bcast/bcast.go

View check run for this annotation

Codecov / codecov/patch

core/bcast/bcast.go#L94-L97

Added lines #L94 - L97 were not covered by tests
default:
err = b.eth2Cl.SubmitProposal(ctx, &eth2api.SubmitProposalOpts{
Proposal: &block.VersionedSignedProposal,
})
}

err = b.eth2Cl.SubmitProposal(ctx, &eth2api.SubmitProposalOpts{
Proposal: &block.VersionedSignedProposal,
})
if err == nil {
log.Info(ctx, "Successfully submitted block proposal to beacon node",
z.Any("delay", b.delayFunc(duty.Slot)),
z.Any("pubkey", pubkey),
z.Bool("blinded", blinded),
)
}

Expand Down
Loading