Skip to content

Commit

Permalink
*: cherrypick for v1.0-rc7, round two (#3156)
Browse files Browse the repository at this point in the history
- #3146
- #3155

category: misc
ticket: none
  • Loading branch information
gsora authored Jun 25, 2024
1 parent 84fe2ab commit 45f830b
Show file tree
Hide file tree
Showing 19 changed files with 487 additions and 523 deletions.
1 change: 1 addition & 0 deletions cmd/exit_sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ func runSignPartialExit(ctx context.Context, config exitConfig) error {
valAPICallOpts.Indices = []eth2p0.ValidatorIndex{
eth2p0.ValidatorIndex(config.ValidatorIndex),
}
valIndex = eth2p0.ValidatorIndex(config.ValidatorIndex)
} else {
valAPICallOpts.PubKeys = []eth2p0.BLSPubKey{
valEth2,
Expand Down
26 changes: 13 additions & 13 deletions core/bcast/bcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,26 @@ func (b Broadcaster) Broadcast(ctx context.Context, duty core.Duty, set core.Sig
}

var (
block core.VersionedSignedProposal
blindedBlock core.VersionedSignedBlindedProposal

blinded bool
ok bool
block core.VersionedSignedProposal
ok bool
)

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

switch blinded {
switch block.Blinded {
case true:
var blinded eth2api.VersionedSignedBlindedProposal

blinded, err = block.ToBlinded()
if err != nil {
return errors.Wrap(err, "cannot broadcast, expected blinded proposal")
}

err = b.eth2Cl.SubmitBlindedProposal(ctx, &eth2api.SubmitBlindedProposalOpts{
Proposal: &blindedBlock.VersionedSignedBlindedProposal,
Proposal: &blinded,
})
default:
err = b.eth2Cl.SubmitProposal(ctx, &eth2api.SubmitProposalOpts{
Expand All @@ -105,7 +105,7 @@ func (b Broadcaster) Broadcast(ctx context.Context, duty core.Duty, set core.Sig
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),
z.Bool("blinded", block.Blinded),
)
}

Expand Down
16 changes: 0 additions & 16 deletions core/eth2signeddata.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ var (
_ Eth2SignedData = VersionedSignedProposal{}
_ Eth2SignedData = Attestation{}
_ Eth2SignedData = SignedVoluntaryExit{}
_ Eth2SignedData = VersionedSignedBlindedProposal{}
_ Eth2SignedData = VersionedSignedValidatorRegistration{}
_ Eth2SignedData = SignedRandao{}
_ Eth2SignedData = BeaconCommitteeSelection{}
Expand Down Expand Up @@ -57,21 +56,6 @@ func (p VersionedSignedProposal) Epoch(ctx context.Context, eth2Cl eth2wrap.Clie
return eth2util.EpochFromSlot(ctx, eth2Cl, slot)
}

// Implement Eth2SignedData for VersionedSignedBlindedProposal.

func (VersionedSignedBlindedProposal) DomainName() signing.DomainName {
return signing.DomainBeaconProposer
}

func (p VersionedSignedBlindedProposal) Epoch(ctx context.Context, eth2Cl eth2wrap.Client) (eth2p0.Epoch, error) {
slot, err := p.VersionedSignedBlindedProposal.Slot()
if err != nil {
return 0, err
}

return eth2util.EpochFromSlot(ctx, eth2Cl, slot)
}

// Implement Eth2SignedData for Attestation.

func (Attestation) DomainName() signing.DomainName {
Expand Down
12 changes: 0 additions & 12 deletions core/eth2signeddata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,6 @@ func TestVerifyEth2SignedData(t *testing.T) {
name: "verify beacon block",
data: testutil.RandomBellatrixCoreVersionedSignedProposal(),
},
{
name: "verify blinded beacon block bellatrix",
data: testutil.RandomBellatrixVersionedSignedBlindedProposal(),
},
{
name: "verify blinded beacon block capella",
data: testutil.RandomCapellaVersionedSignedBlindedProposal(),
},
{
name: "verify blinded beacon block deneb",
data: testutil.RandomDenebVersionedSignedBlindedProposal(),
},
{
name: "verify randao",
data: testutil.RandomCoreSignedRandao(),
Expand Down
10 changes: 6 additions & 4 deletions core/parsigex/parsigex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,17 @@ func TestParSigExVerifier(t *testing.T) {

t.Run("Verify blinded proposal", func(t *testing.T) {
blindedBlock := testutil.RandomDenebVersionedSignedBlindedProposal()
blindedBlock.Deneb.Message.Slot = slot
sigRoot, err := blindedBlock.Root()
blindedBlock.DenebBlinded.Message.Slot = slot
sigRoot, err := blindedBlock.DenebBlinded.Message.HashTreeRoot()
require.NoError(t, err)

sigData, err := signing.GetDataRoot(ctx, bmock, signing.DomainBeaconProposer, epoch, sigRoot)
require.NoError(t, err)

blindedBlock.Deneb.Signature = sign(sigData[:])
data, err := core.NewPartialVersionedSignedBlindedProposal(&blindedBlock.VersionedSignedBlindedProposal, shareIdx)
blindedBlock.DenebBlinded.Signature = sign(sigData[:])
eth2apiBlinded, err := blindedBlock.ToBlinded()
require.NoError(t, err)
data, err := core.NewPartialVersionedSignedBlindedProposal(&eth2apiBlinded, shareIdx)
require.NoError(t, err)

require.NoError(t, verifyFunc(ctx, core.NewProposerDuty(slot), pubkey, data))
Expand Down
8 changes: 6 additions & 2 deletions core/serialise_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ import (

var coreTypeFuncs = []func() any{
func() any { return new(core.VersionedSignedProposal) },
func() any {
ret := new(core.VersionedSignedProposal)
ret.Blinded = true

return ret
},
func() any { return new(core.Attestation) },
func() any { return new(core.Signature) },
func() any { return new(core.SignedVoluntaryExit) },
func() any { return new(core.VersionedSignedBlindedProposal) },

func() any { return new(core.SignedRandao) },
func() any { return new(core.BeaconCommitteeSelection) },
func() any { return new(core.SignedAggregateAndProof) },
Expand Down
4 changes: 2 additions & 2 deletions core/sigagg/sigagg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ func TestSigAgg_DutyBuilderProposer(t *testing.T) {

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
block, err := core.NewVersionedSignedBlindedProposal(test.block)
block, err := core.NewVersionedSignedProposalFromBlindedProposal(test.block)
require.NoError(t, err)

msgRoot, err := block.MessageRoot()
Expand All @@ -514,7 +514,7 @@ func TestSigAgg_DutyBuilderProposer(t *testing.T) {
sig, err := tbls.Sign(secret, msg[:])
require.NoError(t, err)

block, err := core.NewVersionedSignedBlindedProposal(test.block)
block, err := core.NewVersionedSignedProposalFromBlindedProposal(test.block)
require.NoError(t, err)

sigCore := tblsconv.SigToCore(sig)
Expand Down
Loading

0 comments on commit 45f830b

Please sign in to comment.