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: add deneb as default #2734

Merged
merged 21 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
58 changes: 57 additions & 1 deletion app/eth2wrap/synthproposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
eth2v1 "github.com/attestantio/go-eth2-client/api/v1"
eth2bellatrix "github.com/attestantio/go-eth2-client/api/v1/bellatrix"
eth2capella "github.com/attestantio/go-eth2-client/api/v1/capella"
eth2deneb "github.com/attestantio/go-eth2-client/api/v1/deneb"
eth2spec "github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/bellatrix"
"github.com/attestantio/go-eth2-client/spec/capella"
"github.com/attestantio/go-eth2-client/spec/deneb"
eth2p0 "github.com/attestantio/go-eth2-client/spec/phase0"
shuffle "github.com/protolambda/eth2-shuffle"
"go.uber.org/zap"
Expand Down Expand Up @@ -197,6 +199,14 @@
proposal.Capella.ProposerIndex = vIdx
proposal.Capella.Body.ExecutionPayload.FeeRecipient = feeRecipient
proposal.Capella.Body.ExecutionPayload.Transactions = fraction(proposal.Capella.Body.ExecutionPayload.Transactions)
case eth2spec.DataVersionDeneb:
proposal.Deneb = &eth2deneb.BlockContents{}
proposal.Deneb.Block = signedBlock.Deneb.Message
proposal.Deneb.Block.Body.Graffiti = GetSyntheticGraffiti()
proposal.Deneb.Block.Slot = slot
proposal.Deneb.Block.ProposerIndex = vIdx
proposal.Deneb.Block.Body.ExecutionPayload.FeeRecipient = feeRecipient
proposal.Deneb.Block.Body.ExecutionPayload.Transactions = fraction(proposal.Deneb.Block.Body.ExecutionPayload.Transactions)
default:
return nil, errors.New("unsupported proposal version")
}
Expand Down Expand Up @@ -274,6 +284,8 @@
graffiti = block.Bellatrix.Message.Body.Graffiti
case eth2spec.DataVersionCapella:
graffiti = block.Capella.Message.Body.Graffiti
case eth2spec.DataVersionDeneb:
graffiti = block.Deneb.SignedBlindedBlock.Message.Body.Graffiti
default:
return false
}
Expand All @@ -293,6 +305,8 @@
graffiti = block.Bellatrix.Message.Body.Graffiti
case eth2spec.DataVersionCapella:
graffiti = block.Capella.Message.Body.Graffiti
case eth2spec.DataVersionDeneb:
graffiti = block.Deneb.SignedBlock.Message.Body.Graffiti
default:
return false
}
Expand Down Expand Up @@ -543,7 +557,49 @@
},
},
}
default: // TODO(xenowits): Add a case for deneb blinded block
case eth2spec.DataVersionDeneb:
resp = &eth2api.VersionedBlindedProposal{
Version: proposal.Version,
Deneb: &eth2deneb.BlindedBeaconBlock{
Slot: proposal.Deneb.Block.Slot,
ProposerIndex: proposal.Deneb.Block.ProposerIndex,
ParentRoot: proposal.Deneb.Block.ParentRoot,
StateRoot: proposal.Deneb.Block.StateRoot,
Body: &eth2deneb.BlindedBeaconBlockBody{
RANDAOReveal: proposal.Deneb.Block.Body.RANDAOReveal,
ETH1Data: proposal.Deneb.Block.Body.ETH1Data,
Graffiti: proposal.Deneb.Block.Body.Graffiti,
ProposerSlashings: proposal.Deneb.Block.Body.ProposerSlashings,
AttesterSlashings: proposal.Deneb.Block.Body.AttesterSlashings,
Attestations: proposal.Deneb.Block.Body.Attestations,
Deposits: proposal.Deneb.Block.Body.Deposits,
VoluntaryExits: proposal.Deneb.Block.Body.VoluntaryExits,
SyncAggregate: proposal.Deneb.Block.Body.SyncAggregate,
ExecutionPayloadHeader: &deneb.ExecutionPayloadHeader{
ParentHash: proposal.Deneb.Block.Body.ExecutionPayload.ParentHash,
FeeRecipient: proposal.Deneb.Block.Body.ExecutionPayload.FeeRecipient,
StateRoot: proposal.Deneb.Block.Body.ExecutionPayload.StateRoot,
ReceiptsRoot: proposal.Deneb.Block.Body.ExecutionPayload.ReceiptsRoot,
LogsBloom: proposal.Deneb.Block.Body.ExecutionPayload.LogsBloom,
PrevRandao: proposal.Deneb.Block.Body.ExecutionPayload.PrevRandao,
BlockNumber: proposal.Deneb.Block.Body.ExecutionPayload.BlockNumber,
GasLimit: proposal.Deneb.Block.Body.ExecutionPayload.GasLimit,
GasUsed: proposal.Deneb.Block.Body.ExecutionPayload.GasUsed,
Timestamp: proposal.Deneb.Block.Body.ExecutionPayload.Timestamp,
ExtraData: proposal.Deneb.Block.Body.ExecutionPayload.ExtraData,
BaseFeePerGas: proposal.Deneb.Block.Body.ExecutionPayload.BaseFeePerGas,
BlockHash: proposal.Deneb.Block.Body.ExecutionPayload.BlockHash,
TransactionsRoot: eth2p0.Root{},
WithdrawalsRoot: eth2p0.Root{},
BlobGasUsed: proposal.Deneb.Block.Body.ExecutionPayload.BlobGasUsed,
ExcessBlobGas: proposal.Deneb.Block.Body.ExecutionPayload.ExcessBlobGas,
},
BLSToExecutionChanges: proposal.Deneb.Block.Body.BLSToExecutionChanges,
BlobKZGCommitments: proposal.Deneb.Block.Body.BlobKZGCommitments,
},
},
}
default:

Check warning on line 602 in app/eth2wrap/synthproposer.go

View check run for this annotation

Codecov / codecov/patch

app/eth2wrap/synthproposer.go#L602

Added line #L602 was not covered by tests
return nil, errors.New("unsupported blinded proposal version")
}

Expand Down
37 changes: 20 additions & 17 deletions app/eth2wrap/synthproposer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

eth2api "github.com/attestantio/go-eth2-client/api"
eth2v1 "github.com/attestantio/go-eth2-client/api/v1"
eth2capella "github.com/attestantio/go-eth2-client/api/v1/capella"
"github.com/attestantio/go-eth2-client/api/v1/deneb"
eth2spec "github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/bellatrix"
eth2p0 "github.com/attestantio/go-eth2-client/spec/phase0"
Expand Down Expand Up @@ -38,7 +38,7 @@ func TestSynthProposer(t *testing.T) {
require.NoError(t, err)

bmock.SubmitProposalFunc = func(ctx context.Context, proposal *eth2api.VersionedSignedProposal) error {
require.Equal(t, realBlockSlot, proposal.Capella.Message.Slot)
require.Equal(t, realBlockSlot, proposal.Deneb.SignedBlock.Message.Slot)
close(done)

return nil
Expand Down Expand Up @@ -114,18 +114,18 @@ func TestSynthProposer(t *testing.T) {
block := resp.Data

if duty.Slot == realBlockSlot {
require.NotContains(t, string(block.Capella.Body.Graffiti[:]), "DO NOT SUBMIT")
require.NotEqual(t, feeRecipient, block.Capella.Body.ExecutionPayload.FeeRecipient)
require.NotContains(t, string(block.Deneb.Block.Body.Graffiti[:]), "DO NOT SUBMIT")
require.NotEqual(t, feeRecipient, block.Deneb.Block.Body.ExecutionPayload.FeeRecipient)
} else {
require.Contains(t, string(block.Capella.Body.Graffiti[:]), "DO NOT SUBMIT")
require.Equal(t, feeRecipient, block.Capella.Body.ExecutionPayload.FeeRecipient)
require.Contains(t, string(block.Deneb.Block.Body.Graffiti[:]), "DO NOT SUBMIT")
require.Equal(t, feeRecipient, block.Deneb.Block.Body.ExecutionPayload.FeeRecipient)

continue
}
require.Equal(t, eth2spec.DataVersionCapella, block.Version)

require.Equal(t, eth2spec.DataVersionDeneb, block.Version)
signed := testutil.RandomVersionedSignedProposal()
signed.Capella.Message = block.Capella
signed.Deneb.SignedBlock.Message = block.Deneb.Block

err = eth2Cl.SubmitProposal(ctx, signed)
require.NoError(t, err)
}
Expand All @@ -143,18 +143,21 @@ func TestSynthProposer(t *testing.T) {
require.NoError(t, err)
block := resp.Data
if duty.Slot == realBlockSlot {
require.NotContains(t, string(block.Capella.Body.Graffiti[:]), "DO NOT SUBMIT")
require.NotEqual(t, feeRecipient, block.Capella.Body.ExecutionPayloadHeader.FeeRecipient)
require.NotContains(t, string(block.Deneb.Body.Graffiti[:]), "DO NOT SUBMIT")
require.NotEqual(t, feeRecipient, block.Deneb.Body.ExecutionPayloadHeader.FeeRecipient)
} else {
require.Equal(t, feeRecipient, block.Capella.Body.ExecutionPayloadHeader.FeeRecipient)
require.Equal(t, feeRecipient, block.Deneb.Body.ExecutionPayloadHeader.FeeRecipient)
}
require.Equal(t, eth2spec.DataVersionCapella, block.Version)
require.Equal(t, eth2spec.DataVersionDeneb, block.Version)

signed := &eth2api.VersionedSignedBlindedProposal{
Version: eth2spec.DataVersionCapella,
Capella: &eth2capella.SignedBlindedBeaconBlock{
Message: block.Capella,
Signature: testutil.RandomEth2Signature(),
Version: eth2spec.DataVersionDeneb,
Deneb: &deneb.SignedBlindedBlockContents{
SignedBlindedBlock: &deneb.SignedBlindedBeaconBlock{
Message: block.Deneb,
Signature: testutil.RandomEth2Signature(),
},
SignedBlindedBlobSidecars: nil,
},
}
err = eth2Cl.SubmitBlindedProposal(ctx, signed)
Expand Down
4 changes: 4 additions & 0 deletions core/eth2signeddata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ func TestVerifyEth2SignedData(t *testing.T) {
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
4 changes: 4 additions & 0 deletions core/fetcher/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ func verifyFeeRecipient(ctx context.Context, proposal *eth2api.VersionedProposal
actualAddr = fmt.Sprintf("%#x", proposal.Bellatrix.Body.ExecutionPayload.FeeRecipient)
case eth2spec.DataVersionCapella:
actualAddr = fmt.Sprintf("%#x", proposal.Capella.Body.ExecutionPayload.FeeRecipient)
case eth2spec.DataVersionDeneb:
actualAddr = fmt.Sprintf("%#x", proposal.Deneb.Block.Body.ExecutionPayload.FeeRecipient)
default:
return
}
Expand All @@ -416,6 +418,8 @@ func verifyFeeRecipientBlinded(ctx context.Context, proposal *eth2api.VersionedB
actualAddr = fmt.Sprintf("%#x", proposal.Bellatrix.Body.ExecutionPayloadHeader.FeeRecipient)
case eth2spec.DataVersionCapella:
actualAddr = fmt.Sprintf("%#x", proposal.Capella.Body.ExecutionPayloadHeader.FeeRecipient)
case eth2spec.DataVersionDeneb:
actualAddr = fmt.Sprintf("%#x", proposal.Deneb.Body.ExecutionPayloadHeader.FeeRecipient)
default:
return
}
Expand Down
12 changes: 8 additions & 4 deletions core/fetcher/fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,14 @@ func TestFetchBlocks(t *testing.T) {
slotA, err := dutyDataA.Slot()
require.NoError(t, err)
require.EqualValues(t, slot, slotA)
require.Equal(t, feeRecipientAddr, fmt.Sprintf("%#x", dutyDataA.Capella.Body.ExecutionPayload.FeeRecipient))
require.Equal(t, feeRecipientAddr, fmt.Sprintf("%#x", dutyDataA.Deneb.Block.Body.ExecutionPayload.FeeRecipient))
assertRandao(t, randaoByPubKey[pubkeysByIdx[vIdxA]].Signature().ToETH2(), dutyDataA)

dutyDataB := resDataSet[pubkeysByIdx[vIdxB]].(core.VersionedProposal)
slotB, err := dutyDataB.Slot()
require.NoError(t, err)
require.EqualValues(t, slot, slotB)
require.Equal(t, feeRecipientAddr, fmt.Sprintf("%#x", dutyDataB.Capella.Body.ExecutionPayload.FeeRecipient))
require.Equal(t, feeRecipientAddr, fmt.Sprintf("%#x", dutyDataB.Deneb.Block.Body.ExecutionPayload.FeeRecipient))
assertRandao(t, randaoByPubKey[pubkeysByIdx[vIdxB]].Signature().ToETH2(), dutyDataB)

return nil
Expand Down Expand Up @@ -329,14 +329,14 @@ func TestFetchBlocks(t *testing.T) {
slotA, err := dutyDataA.Slot()
require.NoError(t, err)
require.EqualValues(t, slot, slotA)
require.Equal(t, feeRecipientAddr, fmt.Sprintf("%#x", dutyDataA.Capella.Body.ExecutionPayloadHeader.FeeRecipient))
require.Equal(t, feeRecipientAddr, fmt.Sprintf("%#x", dutyDataA.Deneb.Body.ExecutionPayloadHeader.FeeRecipient))
assertRandaoBlindedBlock(t, randaoByPubKey[pubkeysByIdx[vIdxA]].Signature().ToETH2(), dutyDataA)

dutyDataB := resDataSet[pubkeysByIdx[vIdxB]].(core.VersionedBlindedProposal)
slotB, err := dutyDataB.Slot()
require.NoError(t, err)
require.EqualValues(t, slot, slotB)
require.Equal(t, feeRecipientAddr, fmt.Sprintf("%#x", dutyDataB.Capella.Body.ExecutionPayloadHeader.FeeRecipient))
require.Equal(t, feeRecipientAddr, fmt.Sprintf("%#x", dutyDataB.Deneb.Body.ExecutionPayloadHeader.FeeRecipient))
assertRandaoBlindedBlock(t, randaoByPubKey[pubkeysByIdx[vIdxB]].Signature().ToETH2(), dutyDataB)

return nil
Expand Down Expand Up @@ -566,6 +566,8 @@ func assertRandao(t *testing.T, randao eth2p0.BLSSignature, block core.Versioned
require.EqualValues(t, randao, block.Bellatrix.Body.RANDAOReveal)
case eth2spec.DataVersionCapella:
require.EqualValues(t, randao, block.Capella.Body.RANDAOReveal)
case eth2spec.DataVersionDeneb:
require.EqualValues(t, randao, block.Deneb.Block.Body.RANDAOReveal)
default:
require.Fail(t, "invalid block")
}
Expand All @@ -579,6 +581,8 @@ func assertRandaoBlindedBlock(t *testing.T, randao eth2p0.BLSSignature, block co
require.EqualValues(t, randao, block.Bellatrix.Body.RANDAOReveal)
case eth2spec.DataVersionCapella:
require.EqualValues(t, randao, block.Capella.Body.RANDAOReveal)
case eth2spec.DataVersionDeneb:
require.EqualValues(t, randao, block.Deneb.Body.RANDAOReveal)
default:
require.Fail(t, "invalid block")
}
Expand Down
12 changes: 7 additions & 5 deletions core/parsigex/parsigex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,26 +160,28 @@ func TestParSigExVerifier(t *testing.T) {

t.Run("Verify proposal", func(t *testing.T) {
proposal := testutil.RandomVersionedSignedProposal()
proposal.Capella.Message.Slot = slot
proposal.Deneb.SignedBlock.Message.Slot = slot
sigRoot, err := versionedSignedProposalRoot(t, proposal)
require.NoError(t, err)
sigData, err := signing.GetDataRoot(ctx, bmock, signing.DomainBeaconProposer, epoch, sigRoot)
require.NoError(t, err)
proposal.Capella.Signature = sign(sigData[:])
proposal.Deneb.SignedBlock.Signature = sign(sigData[:])
data, err := core.NewPartialVersionedSignedProposal(proposal, shareIdx)
require.NoError(t, err)

require.NoError(t, verifyFunc(ctx, core.NewProposerDuty(slot), pubkey, data))
})

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

sigData, err := signing.GetDataRoot(ctx, bmock, signing.DomainBeaconProposer, epoch, sigRoot)
require.NoError(t, err)
blindedBlock.Capella.Signature = sign(sigData[:])

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

Expand Down
8 changes: 8 additions & 0 deletions core/proto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ func TestParSignedDataSetProto(t *testing.T) {
Type: core.DutyProposer,
Data: testutil.RandomCapellaCoreVersionedSignedProposal(),
},
{
Type: core.DutyProposer,
Data: testutil.RandomDenebCoreVersionedSignedProposal(),
},
{
Type: core.DutyBuilderProposer,
Data: testutil.RandomBellatrixVersionedSignedBlindedProposal(),
Expand All @@ -55,6 +59,10 @@ func TestParSignedDataSetProto(t *testing.T) {
Type: core.DutyBuilderProposer,
Data: testutil.RandomCapellaVersionedSignedBlindedProposal(),
},
{
Type: core.DutyBuilderProposer,
Data: testutil.RandomDenebVersionedSignedBlindedProposal(),
},
{
Type: core.DutyBuilderRegistration,
Data: testutil.RandomCoreVersionedSignedValidatorRegistration(t),
Expand Down
16 changes: 16 additions & 0 deletions core/sigagg/sigagg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import (
eth2v1 "github.com/attestantio/go-eth2-client/api/v1"
eth2bellatrix "github.com/attestantio/go-eth2-client/api/v1/bellatrix"
eth2capella "github.com/attestantio/go-eth2-client/api/v1/capella"
eth2deneb "github.com/attestantio/go-eth2-client/api/v1/deneb"
eth2spec "github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/altair"
"github.com/attestantio/go-eth2-client/spec/bellatrix"
"github.com/attestantio/go-eth2-client/spec/capella"
"github.com/attestantio/go-eth2-client/spec/deneb"
eth2p0 "github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -368,6 +370,20 @@ func TestSigAgg_DutyProposer(t *testing.T) {
},
},
},
{
name: "deneb proposal",
proposal: &eth2api.VersionedSignedProposal{
Version: eth2spec.DataVersionDeneb,
Deneb: &eth2deneb.SignedBlockContents{
SignedBlock: &deneb.SignedBeaconBlock{
Message: testutil.RandomDenebBeaconBlock(),
Signature: testutil.RandomEth2Signature(),
},
KZGProofs: []deneb.KZGProof{},
Blobs: []deneb.Blob{},
},
},
},
}

for _, test := range tests {
Expand Down
16 changes: 16 additions & 0 deletions core/signeddata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
eth2api "github.com/attestantio/go-eth2-client/api"
eth2bellatrix "github.com/attestantio/go-eth2-client/api/v1/bellatrix"
eth2capella "github.com/attestantio/go-eth2-client/api/v1/capella"
eth2deneb "github.com/attestantio/go-eth2-client/api/v1/deneb"
eth2spec "github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/altair"
"github.com/attestantio/go-eth2-client/spec/bellatrix"
Expand Down Expand Up @@ -60,6 +61,21 @@ func TestSignedDataSetSignature(t *testing.T) {
},
},
},
{
name: "versioned signed blinded proposal deneb",
data: core.VersionedSignedBlindedProposal{
VersionedSignedBlindedProposal: eth2api.VersionedSignedBlindedProposal{
Version: eth2spec.DataVersionDeneb,
Deneb: &eth2deneb.SignedBlindedBlockContents{
SignedBlindedBlock: &eth2deneb.SignedBlindedBeaconBlock{
Message: testutil.RandomDenebBlindedBeaconBlock(),
Signature: testutil.RandomEth2Signature(),
},
SignedBlindedBlobSidecars: []*eth2deneb.SignedBlindedBlobSidecar{},
},
},
},
},
{
name: "signed beacon committee selection",
data: testutil.RandomCoreBeaconCommitteeSelection(),
Expand Down
8 changes: 4 additions & 4 deletions core/tracker/inclusion_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ func TestInclusion(t *testing.T) {
att3Duty := core.NewAttesterDuty(uint64(att3.Data.Slot))

block4 := testutil.RandomVersionedSignedProposal()
block4Duty := core.NewProposerDuty(uint64(block4.Capella.Message.Slot))
block4Duty := core.NewProposerDuty(uint64(block4.Deneb.SignedBlock.Message.Slot))

block5 := testutil.RandomCapellaVersionedSignedBlindedProposal()
block5.Capella.Message.Body.Graffiti = eth2wrap.GetSyntheticGraffiti() // Ignored, not included or missed.
block5Duty := core.NewBuilderProposerDuty(uint64(block5.Capella.Message.Slot))
block5 := testutil.RandomDenebVersionedSignedBlindedProposal()
block5.Deneb.SignedBlindedBlock.Message.Body.Graffiti = eth2wrap.GetSyntheticGraffiti() // Ignored, not included or missed.
block5Duty := core.NewBuilderProposerDuty(uint64(block5.Deneb.SignedBlindedBlock.Message.Slot))

// Submit all duties
err := incl.Submitted(att1Duty, "", core.NewAttestation(att1), 0)
Expand Down
Loading
Loading