Compare commits

...

2 Commits

Author SHA1 Message Date
Manu NALEPA
3f2081b9ea WIP2 2024-11-28 11:25:46 +01:00
Manu NALEPA
9c3d336e3b WIP 2024-11-27 21:48:31 +01:00
21 changed files with 238 additions and 56 deletions

View File

@@ -108,7 +108,7 @@ func testBlindedBlockFixtures(t *testing.T) *blindedBlockFixtures {
}
func TestPayloadBodiesViaUnblinder(t *testing.T) {
defer util.HackElectraMaxuint(t)()
defer util.HackElectraEIP7549Maxuint(t)()
fx := testBlindedBlockFixtures(t)
t.Run("mix of non-empty and empty", func(t *testing.T) {
cli, srv := newMockEngine(t)
@@ -145,7 +145,7 @@ func TestPayloadBodiesViaUnblinder(t *testing.T) {
}
func TestFixtureEquivalence(t *testing.T) {
defer util.HackElectraMaxuint(t)()
defer util.HackElectraEIP7549Maxuint(t)()
fx := testBlindedBlockFixtures(t)
t.Run("full and blinded block equivalence", func(t *testing.T) {
testAssertReconstructedEquivalent(t, fx.denebBlock.blinded.block, fx.denebBlock.full)
@@ -248,7 +248,7 @@ func TestComputeRanges(t *testing.T) {
}
func TestReconstructBlindedBlockBatchFallbackToRange(t *testing.T) {
defer util.HackElectraMaxuint(t)()
defer util.HackElectraEIP7549Maxuint(t)()
ctx := context.Background()
t.Run("fallback fails", func(t *testing.T) {
cli, srv := newMockEngine(t)
@@ -334,7 +334,7 @@ func TestReconstructBlindedBlockBatchFallbackToRange(t *testing.T) {
}
func TestReconstructBlindedBlockBatchDenebAndElectra(t *testing.T) {
defer util.HackElectraMaxuint(t)()
defer util.HackElectraEIP7549Maxuint(t)()
t.Run("deneb and electra", func(t *testing.T) {
cli, srv := newMockEngine(t)
fx := testBlindedBlockFixtures(t)

View File

@@ -2,6 +2,7 @@ package p2p
import (
"github.com/prysmaticlabs/prysm/v5/config/params"
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v5/time/slots"
)
@@ -14,11 +15,17 @@ func (s *Service) forkWatcher() {
select {
case currSlot := <-slotTicker.C():
currEpoch := slots.ToEpoch(currSlot)
if currEpoch == params.BeaconConfig().AltairForkEpoch ||
currEpoch == params.BeaconConfig().BellatrixForkEpoch ||
currEpoch == params.BeaconConfig().CapellaForkEpoch ||
currEpoch == params.BeaconConfig().DenebForkEpoch ||
currEpoch == params.BeaconConfig().ElectraForkEpoch {
forkEpochs := map[primitives.Epoch]bool{
params.BeaconConfig().AltairForkEpoch: true,
params.BeaconConfig().BellatrixForkEpoch: true,
params.BeaconConfig().CapellaForkEpoch: true,
params.BeaconConfig().DenebForkEpoch: true,
params.BeaconConfig().ElectraForkEpoch: true,
params.BeaconConfig().Eip7594ForkEpoch: true,
}
if forkEpochs[currEpoch] {
// If we are in the fork epoch, we update our enr with
// the updated fork digest. These repeatedly does
// this over the epoch, which might be slightly wasteful

View File

@@ -30,17 +30,20 @@ func TestGossipTopicMappings_CorrectType(t *testing.T) {
capellaForkEpoch := primitives.Epoch(300)
denebForkEpoch := primitives.Epoch(400)
electraForkEpoch := primitives.Epoch(500)
eip7594ForkEpoch := primitives.Epoch(600)
bCfg.AltairForkEpoch = altairForkEpoch
bCfg.BellatrixForkEpoch = bellatrixForkEpoch
bCfg.CapellaForkEpoch = capellaForkEpoch
bCfg.DenebForkEpoch = denebForkEpoch
bCfg.ElectraForkEpoch = electraForkEpoch
bCfg.ForkVersionSchedule[bytesutil.ToBytes4(bCfg.AltairForkVersion)] = primitives.Epoch(100)
bCfg.ForkVersionSchedule[bytesutil.ToBytes4(bCfg.BellatrixForkVersion)] = primitives.Epoch(200)
bCfg.ForkVersionSchedule[bytesutil.ToBytes4(bCfg.CapellaForkVersion)] = primitives.Epoch(300)
bCfg.ForkVersionSchedule[bytesutil.ToBytes4(bCfg.DenebForkVersion)] = primitives.Epoch(400)
bCfg.ForkVersionSchedule[bytesutil.ToBytes4(bCfg.ElectraForkVersion)] = primitives.Epoch(500)
bCfg.Eip7594ForkEpoch = eip7594ForkEpoch
bCfg.ForkVersionSchedule[bytesutil.ToBytes4(bCfg.AltairForkVersion)] = altairForkEpoch
bCfg.ForkVersionSchedule[bytesutil.ToBytes4(bCfg.BellatrixForkVersion)] = bellatrixForkEpoch
bCfg.ForkVersionSchedule[bytesutil.ToBytes4(bCfg.CapellaForkVersion)] = capellaForkEpoch
bCfg.ForkVersionSchedule[bytesutil.ToBytes4(bCfg.DenebForkVersion)] = denebForkEpoch
bCfg.ForkVersionSchedule[bytesutil.ToBytes4(bCfg.ElectraForkVersion)] = electraForkEpoch
bCfg.ForkVersionSchedule[bytesutil.ToBytes4(bCfg.Eip7594ForkVersion)] = eip7594ForkEpoch
params.OverrideBeaconConfig(bCfg)
// Phase 0
@@ -53,9 +56,15 @@ func TestGossipTopicMappings_CorrectType(t *testing.T) {
pMessage = GossipTopicMappings(AttesterSlashingSubnetTopicFormat, 0)
_, ok = pMessage.(*ethpb.AttesterSlashing)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(ProposerSlashingSubnetTopicFormat, 0)
_, ok = pMessage.(*ethpb.ProposerSlashing)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(AggregateAndProofSubnetTopicFormat, 0)
_, ok = pMessage.(*ethpb.SignedAggregateAttestationAndProof)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(ExitSubnetTopicFormat, 0)
_, ok = pMessage.(*ethpb.SignedVoluntaryExit)
assert.Equal(t, true, ok)
// Altair Fork
pMessage = GossipTopicMappings(BlockSubnetTopicFormat, altairForkEpoch)
@@ -67,9 +76,21 @@ func TestGossipTopicMappings_CorrectType(t *testing.T) {
pMessage = GossipTopicMappings(AttesterSlashingSubnetTopicFormat, altairForkEpoch)
_, ok = pMessage.(*ethpb.AttesterSlashing)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(ProposerSlashingSubnetTopicFormat, altairForkEpoch)
_, ok = pMessage.(*ethpb.ProposerSlashing)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(AggregateAndProofSubnetTopicFormat, altairForkEpoch)
_, ok = pMessage.(*ethpb.SignedAggregateAttestationAndProof)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(ExitSubnetTopicFormat, altairForkEpoch)
_, ok = pMessage.(*ethpb.SignedVoluntaryExit)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(SyncCommitteeSubnetTopicFormat, altairForkEpoch)
_, ok = pMessage.(*ethpb.SyncCommitteeMessage)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(SyncContributionAndProofSubnetTopicFormat, altairForkEpoch)
_, ok = pMessage.(*ethpb.SignedContributionAndProof)
assert.Equal(t, true, ok)
// Bellatrix Fork
pMessage = GossipTopicMappings(BlockSubnetTopicFormat, bellatrixForkEpoch)
@@ -81,9 +102,21 @@ func TestGossipTopicMappings_CorrectType(t *testing.T) {
pMessage = GossipTopicMappings(AttesterSlashingSubnetTopicFormat, bellatrixForkEpoch)
_, ok = pMessage.(*ethpb.AttesterSlashing)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(ProposerSlashingSubnetTopicFormat, bellatrixForkEpoch)
_, ok = pMessage.(*ethpb.ProposerSlashing)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(AggregateAndProofSubnetTopicFormat, bellatrixForkEpoch)
_, ok = pMessage.(*ethpb.SignedAggregateAttestationAndProof)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(ExitSubnetTopicFormat, bellatrixForkEpoch)
_, ok = pMessage.(*ethpb.SignedVoluntaryExit)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(SyncCommitteeSubnetTopicFormat, bellatrixForkEpoch)
_, ok = pMessage.(*ethpb.SyncCommitteeMessage)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(SyncContributionAndProofSubnetTopicFormat, bellatrixForkEpoch)
_, ok = pMessage.(*ethpb.SignedContributionAndProof)
assert.Equal(t, true, ok)
// Capella Fork
pMessage = GossipTopicMappings(BlockSubnetTopicFormat, capellaForkEpoch)
@@ -95,9 +128,24 @@ func TestGossipTopicMappings_CorrectType(t *testing.T) {
pMessage = GossipTopicMappings(AttesterSlashingSubnetTopicFormat, capellaForkEpoch)
_, ok = pMessage.(*ethpb.AttesterSlashing)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(ProposerSlashingSubnetTopicFormat, capellaForkEpoch)
_, ok = pMessage.(*ethpb.ProposerSlashing)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(AggregateAndProofSubnetTopicFormat, capellaForkEpoch)
_, ok = pMessage.(*ethpb.SignedAggregateAttestationAndProof)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(ExitSubnetTopicFormat, capellaForkEpoch)
_, ok = pMessage.(*ethpb.SignedVoluntaryExit)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(SyncCommitteeSubnetTopicFormat, capellaForkEpoch)
_, ok = pMessage.(*ethpb.SyncCommitteeMessage)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(SyncContributionAndProofSubnetTopicFormat, capellaForkEpoch)
_, ok = pMessage.(*ethpb.SignedContributionAndProof)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(BlsToExecutionChangeSubnetTopicFormat, capellaForkEpoch)
_, ok = pMessage.(*ethpb.SignedBLSToExecutionChange)
assert.Equal(t, true, ok)
// Deneb Fork
pMessage = GossipTopicMappings(BlockSubnetTopicFormat, denebForkEpoch)
@@ -109,9 +157,27 @@ func TestGossipTopicMappings_CorrectType(t *testing.T) {
pMessage = GossipTopicMappings(AttesterSlashingSubnetTopicFormat, denebForkEpoch)
_, ok = pMessage.(*ethpb.AttesterSlashing)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(ProposerSlashingSubnetTopicFormat, denebForkEpoch)
_, ok = pMessage.(*ethpb.ProposerSlashing)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(AggregateAndProofSubnetTopicFormat, denebForkEpoch)
_, ok = pMessage.(*ethpb.SignedAggregateAttestationAndProof)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(ExitSubnetTopicFormat, denebForkEpoch)
_, ok = pMessage.(*ethpb.SignedVoluntaryExit)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(SyncCommitteeSubnetTopicFormat, denebForkEpoch)
_, ok = pMessage.(*ethpb.SyncCommitteeMessage)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(SyncContributionAndProofSubnetTopicFormat, denebForkEpoch)
_, ok = pMessage.(*ethpb.SignedContributionAndProof)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(BlsToExecutionChangeSubnetTopicFormat, denebForkEpoch)
_, ok = pMessage.(*ethpb.SignedBLSToExecutionChange)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(BlobSubnetTopicFormat, denebForkEpoch)
_, ok = pMessage.(*ethpb.BlobSidecar)
assert.Equal(t, true, ok)
// Electra Fork
pMessage = GossipTopicMappings(BlockSubnetTopicFormat, electraForkEpoch)
@@ -123,7 +189,58 @@ func TestGossipTopicMappings_CorrectType(t *testing.T) {
pMessage = GossipTopicMappings(AttesterSlashingSubnetTopicFormat, electraForkEpoch)
_, ok = pMessage.(*ethpb.AttesterSlashingElectra)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(ProposerSlashingSubnetTopicFormat, electraForkEpoch)
_, ok = pMessage.(*ethpb.ProposerSlashing)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(AggregateAndProofSubnetTopicFormat, electraForkEpoch)
_, ok = pMessage.(*ethpb.SignedAggregateAttestationAndProofElectra)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(ExitSubnetTopicFormat, electraForkEpoch)
_, ok = pMessage.(*ethpb.SignedVoluntaryExit)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(SyncCommitteeSubnetTopicFormat, electraForkEpoch)
_, ok = pMessage.(*ethpb.SyncCommitteeMessage)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(SyncContributionAndProofSubnetTopicFormat, electraForkEpoch)
_, ok = pMessage.(*ethpb.SignedContributionAndProof)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(BlsToExecutionChangeSubnetTopicFormat, electraForkEpoch)
_, ok = pMessage.(*ethpb.SignedBLSToExecutionChange)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(BlobSubnetTopicFormat, electraForkEpoch)
_, ok = pMessage.(*ethpb.BlobSidecar)
assert.Equal(t, true, ok)
// EIP-7594 Fork
pMessage = GossipTopicMappings(BlockSubnetTopicFormat, eip7594ForkEpoch)
_, ok = pMessage.(*ethpb.SignedBeaconBlockElectra)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(AttestationSubnetTopicFormat, eip7594ForkEpoch)
_, ok = pMessage.(*ethpb.AttestationElectra)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(AttesterSlashingSubnetTopicFormat, eip7594ForkEpoch)
_, ok = pMessage.(*ethpb.AttesterSlashingElectra)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(ProposerSlashingSubnetTopicFormat, eip7594ForkEpoch)
_, ok = pMessage.(*ethpb.ProposerSlashing)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(AggregateAndProofSubnetTopicFormat, eip7594ForkEpoch)
_, ok = pMessage.(*ethpb.SignedAggregateAttestationAndProofElectra)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(ExitSubnetTopicFormat, eip7594ForkEpoch)
_, ok = pMessage.(*ethpb.SignedVoluntaryExit)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(SyncCommitteeSubnetTopicFormat, eip7594ForkEpoch)
_, ok = pMessage.(*ethpb.SyncCommitteeMessage)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(SyncContributionAndProofSubnetTopicFormat, eip7594ForkEpoch)
_, ok = pMessage.(*ethpb.SignedContributionAndProof)
assert.Equal(t, true, ok)
pMessage = GossipTopicMappings(BlsToExecutionChangeSubnetTopicFormat, eip7594ForkEpoch)
_, ok = pMessage.(*ethpb.SignedBLSToExecutionChange)
assert.Equal(t, true, ok)
// Note: BlobSidecar removal from EIP-7594 fork.
pMessage = GossipTopicMappings(DataColumnSubnetTopicFormat, eip7594ForkEpoch)
_, ok = pMessage.(*ethpb.DataColumnSidecar)
assert.Equal(t, true, ok)
}

View File

@@ -79,6 +79,7 @@ func TestGetSpec(t *testing.T) {
config.DenebForkEpoch = 105
config.ElectraForkVersion = []byte("ElectraForkVersion")
config.ElectraForkEpoch = 107
config.Eip7594ForkVersion = []byte("Eip7594ForkVersion")
config.Eip7594ForkEpoch = 109
config.BLSWithdrawalPrefixByte = byte('b')
config.ETH1AddressWithdrawalPrefixByte = byte('c')
@@ -190,7 +191,7 @@ func TestGetSpec(t *testing.T) {
data, ok := resp.Data.(map[string]interface{})
require.Equal(t, true, ok)
assert.Equal(t, 156, len(data))
assert.Equal(t, 157, len(data))
for k, v := range data {
t.Run(k, func(t *testing.T) {
switch k {
@@ -268,6 +269,8 @@ func TestGetSpec(t *testing.T) {
assert.Equal(t, "0x"+hex.EncodeToString([]byte("ElectraForkVersion")), v)
case "ELECTRA_FORK_EPOCH":
assert.Equal(t, "107", v)
case "EIP7594_FORK_VERSION":
assert.Equal(t, "0x"+hex.EncodeToString([]byte("Eip7594ForkVersion")), v)
case "EIP7594_FORK_EPOCH":
assert.Equal(t, "109", v)
case "MIN_ANCHOR_POW_BLOCK_DIFFICULTY":

View File

@@ -1713,7 +1713,7 @@ func TestFetchDataColumnsFromPeers(t *testing.T) {
// Fork epochs.
denebForkEpoch primitives.Epoch
eip7954ForkEpoch primitives.Epoch
eip7594ForkEpoch primitives.Epoch
// Current slot.
currentSlot uint64
@@ -1753,29 +1753,29 @@ func TestFetchDataColumnsFromPeers(t *testing.T) {
isError: false,
},
{
name: "All blocks are before EIP-7954 fork epoch",
name: "All blocks are before EIP-7594 fork epoch",
denebForkEpoch: 0,
eip7954ForkEpoch: 1,
eip7594ForkEpoch: 1,
currentSlot: 40,
blocksParams: []blockParams{
{slot: 25, hasBlobs: false}, // Before EIP-7954 fork epoch
{slot: 26, hasBlobs: false}, // Before EIP-7954 fork epoch
{slot: 27, hasBlobs: false}, // Before EIP-7954 fork epoch
{slot: 28, hasBlobs: false}, // Before EIP-7954 fork epoch
{slot: 25, hasBlobs: false}, // Before EIP-7594 fork epoch
{slot: 26, hasBlobs: false}, // Before EIP-7594 fork epoch
{slot: 27, hasBlobs: false}, // Before EIP-7594 fork epoch
{slot: 28, hasBlobs: false}, // Before EIP-7594 fork epoch
},
batchSize: 32,
addedRODataColumns: [][]int{nil, nil, nil, nil},
isError: false,
},
{
name: "All blocks with commitments before are EIP-7954 fork epoch",
name: "All blocks with commitments before are EIP-7594 fork epoch",
denebForkEpoch: 0,
eip7954ForkEpoch: 1,
eip7594ForkEpoch: 1,
currentSlot: 40,
blocksParams: []blockParams{
{slot: 25, hasBlobs: false}, // Before EIP-7954 fork epoch
{slot: 26, hasBlobs: true}, // Before EIP-7954 fork epoch
{slot: 27, hasBlobs: true}, // Before EIP-7954 fork epoch
{slot: 25, hasBlobs: false}, // Before EIP-7594 fork epoch
{slot: 26, hasBlobs: true}, // Before EIP-7594 fork epoch
{slot: 27, hasBlobs: true}, // Before EIP-7594 fork epoch
{slot: 32, hasBlobs: false},
{slot: 33, hasBlobs: false},
},
@@ -1785,12 +1785,12 @@ func TestFetchDataColumnsFromPeers(t *testing.T) {
{
name: "Some blocks with blobs but without any missing data columns",
denebForkEpoch: 0,
eip7954ForkEpoch: 1,
eip7594ForkEpoch: 1,
currentSlot: 40,
blocksParams: []blockParams{
{slot: 25, hasBlobs: false}, // Before EIP-7954 fork epoch
{slot: 26, hasBlobs: true}, // Before EIP-7954 fork epoch
{slot: 27, hasBlobs: true}, // Before EIP-7954 fork epoch
{slot: 25, hasBlobs: false}, // Before EIP-7594 fork epoch
{slot: 26, hasBlobs: true}, // Before EIP-7594 fork epoch
{slot: 27, hasBlobs: true}, // Before EIP-7594 fork epoch
{slot: 32, hasBlobs: false},
{slot: 33, hasBlobs: true},
},
@@ -1808,11 +1808,11 @@ func TestFetchDataColumnsFromPeers(t *testing.T) {
{
name: "Some blocks with blobs with missing data columns - one round needed",
denebForkEpoch: 0,
eip7954ForkEpoch: 1,
eip7594ForkEpoch: 1,
currentSlot: 40,
blocksParams: []blockParams{
{slot: 25, hasBlobs: false}, // Before EIP-7954 fork epoch
{slot: 27, hasBlobs: true}, // Before EIP-7954 fork epoch
{slot: 25, hasBlobs: false}, // Before EIP-7594 fork epoch
{slot: 27, hasBlobs: true}, // Before EIP-7594 fork epoch
{slot: 32, hasBlobs: false},
{slot: 33, hasBlobs: true},
{slot: 34, hasBlobs: true},
@@ -1916,7 +1916,7 @@ func TestFetchDataColumnsFromPeers(t *testing.T) {
{
name: "Some blocks with blobs with missing data columns - partial responses",
denebForkEpoch: 0,
eip7954ForkEpoch: 1,
eip7594ForkEpoch: 1,
currentSlot: 40,
blocksParams: []blockParams{
{slot: 33, hasBlobs: true},
@@ -1970,7 +1970,7 @@ func TestFetchDataColumnsFromPeers(t *testing.T) {
{
name: "Some blocks with blobs with missing data columns - first response is invalid",
denebForkEpoch: 0,
eip7954ForkEpoch: 1,
eip7594ForkEpoch: 1,
currentSlot: 40,
blocksParams: []blockParams{
{slot: 38, hasBlobs: true},
@@ -2004,7 +2004,7 @@ func TestFetchDataColumnsFromPeers(t *testing.T) {
{
name: "Some blocks with blobs with missing data columns - first response is empty",
denebForkEpoch: 0,
eip7954ForkEpoch: 1,
eip7594ForkEpoch: 1,
currentSlot: 40,
blocksParams: []blockParams{{slot: 38, hasBlobs: true}},
storedDataColumns: []map[int]bool{{38: true, 102: true}},
@@ -2033,7 +2033,7 @@ func TestFetchDataColumnsFromPeers(t *testing.T) {
{
name: "Some blocks with blobs with missing data columns - no response at all",
denebForkEpoch: 0,
eip7954ForkEpoch: 1,
eip7594ForkEpoch: 1,
currentSlot: 40,
blocksParams: []blockParams{{slot: 38, hasBlobs: true}},
storedDataColumns: []map[int]bool{{38: true, 102: true}},
@@ -2056,7 +2056,7 @@ func TestFetchDataColumnsFromPeers(t *testing.T) {
{
name: "Some blocks with blobs with missing data columns - request has to be split",
denebForkEpoch: 0,
eip7954ForkEpoch: 1,
eip7594ForkEpoch: 1,
currentSlot: 40,
blocksParams: []blockParams{
{slot: 32, hasBlobs: true}, {slot: 33, hasBlobs: true}, {slot: 34, hasBlobs: true}, {slot: 35, hasBlobs: true}, // 4
@@ -2177,7 +2177,7 @@ func TestFetchDataColumnsFromPeers(t *testing.T) {
params.BeaconConfig().DenebForkEpoch = tc.denebForkEpoch
// Set the EIP-7594 fork epoch.
params.BeaconConfig().Eip7594ForkEpoch = tc.eip7954ForkEpoch
params.BeaconConfig().Eip7594ForkEpoch = tc.eip7594ForkEpoch
// Save the blocks in the store.
storage := make(map[[fieldparams.RootLength]byte][]int)

View File

@@ -166,7 +166,8 @@ type BeaconChainConfig struct {
DenebForkEpoch primitives.Epoch `yaml:"DENEB_FORK_EPOCH" spec:"true"` // DenebForkEpoch is used to represent the assigned fork epoch for deneb.
ElectraForkVersion []byte `yaml:"ELECTRA_FORK_VERSION" spec:"true"` // ElectraForkVersion is used to represent the fork version for electra.
ElectraForkEpoch primitives.Epoch `yaml:"ELECTRA_FORK_EPOCH" spec:"true"` // ElectraForkEpoch is used to represent the assigned fork epoch for electra.
Eip7594ForkEpoch primitives.Epoch `yaml:"EIP7594_FORK_EPOCH" spec:"true"` // EIP7594ForkEpoch is used to represent the assigned fork epoch for peer das.
Eip7594ForkVersion []byte `yaml:"EIP7594_FORK_VERSION" spec:"true"` // EIP7594ForkVersion is used to represent the assigned fork version for peer DAS.
Eip7594ForkEpoch primitives.Epoch `yaml:"EIP7594_FORK_EPOCH" spec:"true"` // EIP7594ForkEpoch is used to represent the assigned fork epoch for peer DAS.
ForkVersionSchedule map[[fieldparams.VersionLength]byte]primitives.Epoch // Schedule of fork epochs by version.
ForkVersionNames map[[fieldparams.VersionLength]byte]string // Human-readable names of fork versions.
@@ -297,6 +298,7 @@ func configForkSchedule(b *BeaconChainConfig) map[[fieldparams.VersionLength]byt
fvs[bytesutil.ToBytes4(b.CapellaForkVersion)] = b.CapellaForkEpoch
fvs[bytesutil.ToBytes4(b.DenebForkVersion)] = b.DenebForkEpoch
fvs[bytesutil.ToBytes4(b.ElectraForkVersion)] = b.ElectraForkEpoch
fvs[bytesutil.ToBytes4(b.Eip7594ForkVersion)] = b.Eip7594ForkEpoch
return fvs
}
@@ -319,6 +321,7 @@ func ConfigForkVersions(b *BeaconChainConfig) map[[fieldparams.VersionLength]byt
bytesutil.ToBytes4(b.CapellaForkVersion): version.Capella,
bytesutil.ToBytes4(b.DenebForkVersion): version.Deneb,
bytesutil.ToBytes4(b.ElectraForkVersion): version.Electra,
bytesutil.ToBytes4(b.Eip7594ForkVersion): version.EIP7594,
}
}

View File

@@ -12,6 +12,7 @@ func InteropConfig() *BeaconChainConfig {
c.CapellaForkVersion = []byte{3, 0, 0, 235}
c.DenebForkVersion = []byte{4, 0, 0, 235}
c.ElectraForkVersion = []byte{5, 0, 0, 235}
c.Eip7594ForkVersion = []byte{6, 0, 0, 235}
c.InitializeForkSchedule()
return c

View File

@@ -218,6 +218,7 @@ func ConfigToYaml(cfg *BeaconChainConfig) []byte {
fmt.Sprintf("ELECTRA_FORK_EPOCH: %d", cfg.ElectraForkEpoch),
fmt.Sprintf("ELECTRA_FORK_VERSION: %#x", cfg.ElectraForkVersion),
fmt.Sprintf("EIP7594_FORK_EPOCH: %d", cfg.Eip7594ForkEpoch),
fmt.Sprintf("EIP7594_FORK_VERSION: %#x", cfg.Eip7594ForkVersion),
fmt.Sprintf("EPOCHS_PER_SUBNET_SUBSCRIPTION: %d", cfg.EpochsPerSubnetSubscription),
fmt.Sprintf("ATTESTATION_SUBNET_EXTRA_BITS: %d", cfg.AttestationSubnetExtraBits),
fmt.Sprintf("ATTESTATION_SUBNET_PREFIX_BITS: %d", cfg.AttestationSubnetPrefixBits),

View File

@@ -29,7 +29,6 @@ var placeholderFields = []string{
"EIP6110_FORK_VERSION",
"EIP7002_FORK_EPOCH",
"EIP7002_FORK_VERSION",
"EIP7594_FORK_VERSION",
"EIP7732_FORK_EPOCH",
"EIP7732_FORK_VERSION",
"FIELD_ELEMENTS_PER_BLOB", // Compile time constant.
@@ -150,6 +149,7 @@ func assertEqualConfigs(t *testing.T, name string, fields []string, expected, ac
assert.Equal(t, expected.CapellaForkEpoch, actual.CapellaForkEpoch, "%s: CapellaForkEpoch", name)
assert.Equal(t, expected.DenebForkEpoch, actual.DenebForkEpoch, "%s: DenebForkEpoch", name)
assert.Equal(t, expected.ElectraForkEpoch, actual.ElectraForkEpoch, "%s: ElectraForkEpoch", name)
assert.Equal(t, expected.Eip7594ForkEpoch, actual.Eip7594ForkEpoch, "%s: EIP7594ForkEpoch", name)
assert.Equal(t, expected.SqrRootSlotsPerEpoch, actual.SqrRootSlotsPerEpoch, "%s: SqrRootSlotsPerEpoch", name)
assert.DeepEqual(t, expected.GenesisForkVersion, actual.GenesisForkVersion, "%s: GenesisForkVersion", name)
assert.DeepEqual(t, expected.AltairForkVersion, actual.AltairForkVersion, "%s: AltairForkVersion", name)
@@ -157,6 +157,7 @@ func assertEqualConfigs(t *testing.T, name string, fields []string, expected, ac
assert.DeepEqual(t, expected.CapellaForkVersion, actual.CapellaForkVersion, "%s: CapellaForkVersion", name)
assert.DeepEqual(t, expected.DenebForkVersion, actual.DenebForkVersion, "%s: DenebForkVersion", name)
assert.DeepEqual(t, expected.ElectraForkVersion, actual.ElectraForkVersion, "%s: ElectraForkVersion", name)
assert.DeepEqual(t, expected.Eip7594ForkVersion, actual.Eip7594ForkVersion, "%s: Eip7594ForkVersion", name)
assertYamlFieldsMatch(t, name, fields, expected, actual)
}

View File

@@ -29,6 +29,8 @@ const (
mainnetDenebForkEpoch = 269568 // March 13, 2024, 13:55:35 UTC
// Electra Fork Epoch for mainnet config
mainnetElectraForkEpoch = math.MaxUint64 // Far future / to be defined
// EIP-7594 Fork Epoch for mainnet config
mainnetEIP7594ForkEpoch = math.MaxUint64 // Far future / to be defined
)
var mainnetNetworkConfig = &NetworkConfig{
@@ -217,7 +219,8 @@ var mainnetBeaconConfig = &BeaconChainConfig{
DenebForkEpoch: mainnetDenebForkEpoch,
ElectraForkVersion: []byte{5, 0, 0, 0},
ElectraForkEpoch: mainnetElectraForkEpoch,
Eip7594ForkEpoch: math.MaxUint64,
Eip7594ForkVersion: []byte{6, 0, 0, 0},
Eip7594ForkEpoch: mainnetEIP7594ForkEpoch,
// New values introduced in Altair hard fork 1.
// Participation flag indices.
@@ -341,6 +344,7 @@ func FillTestVersions(c *BeaconChainConfig, b byte) {
c.CapellaForkVersion = make([]byte, fieldparams.VersionLength)
c.DenebForkVersion = make([]byte, fieldparams.VersionLength)
c.ElectraForkVersion = make([]byte, fieldparams.VersionLength)
c.Eip7594ForkVersion = make([]byte, fieldparams.VersionLength)
c.GenesisForkVersion[fieldparams.VersionLength-1] = b
c.AltairForkVersion[fieldparams.VersionLength-1] = b
@@ -348,6 +352,7 @@ func FillTestVersions(c *BeaconChainConfig, b byte) {
c.CapellaForkVersion[fieldparams.VersionLength-1] = b
c.DenebForkVersion[fieldparams.VersionLength-1] = b
c.ElectraForkVersion[fieldparams.VersionLength-1] = b
c.Eip7594ForkVersion[fieldparams.VersionLength-1] = b
c.GenesisForkVersion[0] = 0
c.AltairForkVersion[0] = 1
@@ -355,4 +360,5 @@ func FillTestVersions(c *BeaconChainConfig, b byte) {
c.CapellaForkVersion[0] = 3
c.DenebForkVersion[0] = 4
c.ElectraForkVersion[0] = 5
c.Eip7594ForkVersion[0] = 6
}

View File

@@ -96,6 +96,7 @@ func MinimalSpecConfig() *BeaconChainConfig {
minimalConfig.DenebForkEpoch = math.MaxUint64
minimalConfig.ElectraForkVersion = []byte{5, 0, 0, 1}
minimalConfig.ElectraForkEpoch = math.MaxUint64
minimalConfig.Eip7594ForkVersion = []byte{6, 0, 0, 1}
minimalConfig.Eip7594ForkEpoch = math.MaxUint64
minimalConfig.SyncCommitteeSize = 32

View File

@@ -57,6 +57,7 @@ func E2ETestConfig() *BeaconChainConfig {
e2eConfig.CapellaForkVersion = []byte{3, 0, 0, 253}
e2eConfig.DenebForkVersion = []byte{4, 0, 0, 253}
e2eConfig.ElectraForkVersion = []byte{5, 0, 0, 253}
e2eConfig.Eip7594ForkVersion = []byte{6, 0, 0, 253}
e2eConfig.InitializeForkSchedule()
return e2eConfig
@@ -102,6 +103,7 @@ func E2EMainnetTestConfig() *BeaconChainConfig {
e2eConfig.CapellaForkVersion = []byte{3, 0, 0, 254}
e2eConfig.DenebForkVersion = []byte{4, 0, 0, 254}
e2eConfig.ElectraForkVersion = []byte{5, 0, 0, 254}
e2eConfig.Eip7594ForkVersion = []byte{6, 0, 0, 254}
// Deneb changes.
e2eConfig.MinPerEpochChurnLimit = 2

View File

@@ -39,9 +39,10 @@ func HoleskyConfig() *BeaconChainConfig {
cfg.CapellaForkVersion = []byte{0x4, 0x1, 0x70, 0x0}
cfg.DenebForkEpoch = 29696
cfg.DenebForkVersion = []byte{0x05, 0x1, 0x70, 0x0}
cfg.ElectraForkEpoch = math.MaxUint64
cfg.Eip7594ForkEpoch = math.MaxUint64
cfg.ElectraForkEpoch = math.MaxUint64 // TODO: Define holesky fork epoch for electra. This is a placeholder value.
cfg.ElectraForkVersion = []byte{0x06, 0x1, 0x70, 0x0} // TODO: Define holesky fork version for electra. This is a placeholder value.
cfg.Eip7594ForkEpoch = math.MaxUint64 // TODO: Define EIP7594 fork epoch for electra. This is a placeholder value.
cfg.Eip7594ForkVersion = []byte{0x07, 0x1, 0x70, 0x0} // TODO: Define EIP7594 fork version for electra. This is a placeholder value.
cfg.TerminalTotalDifficulty = "0"
cfg.DepositContractAddress = "0x4242424242424242424242424242424242424242"
cfg.EjectionBalance = 28000000000

View File

@@ -44,9 +44,10 @@ func SepoliaConfig() *BeaconChainConfig {
cfg.CapellaForkVersion = []byte{0x90, 0x00, 0x00, 0x72}
cfg.DenebForkEpoch = 132608
cfg.DenebForkVersion = []byte{0x90, 0x00, 0x00, 0x73}
cfg.ElectraForkEpoch = math.MaxUint64
cfg.ElectraForkEpoch = math.MaxUint64 // TODO: Define sepolia fork epoch for electra. This is a placeholder value.
cfg.ElectraForkVersion = []byte{0x90, 0x00, 0x00, 0x74} // TODO: Define sepolia fork version for electra. This is a placeholder value.
cfg.Eip7594ForkEpoch = math.MaxUint64
cfg.Eip7594ForkEpoch = math.MaxUint64 // TODO: Define sepolia fork epoch for EIP7594. This is a placeholder value.
cfg.Eip7594ForkVersion = []byte{0x90, 0x00, 0x00, 0x75} // TODO: Define sepolia fork epoch for EIP7594. This is a placeholder value.
cfg.TerminalTotalDifficulty = "17000000000000000"
cfg.DepositContractAddress = "0x7f02C3E3c98b133055B8B348B2Ac625669Ed295D"
cfg.InitializeForkSchedule()

View File

@@ -88,6 +88,8 @@ func FromForkVersion(cv [fieldparams.VersionLength]byte) (*VersionedUnmarshaler,
fork = version.Deneb
case bytesutil.ToBytes4(cfg.ElectraForkVersion):
fork = version.Electra
case bytesutil.ToBytes4(cfg.Eip7594ForkVersion):
fork = version.EIP7594
default:
return nil, errors.Wrapf(ErrForkNotFound, "version=%#x", cv)
}
@@ -153,7 +155,7 @@ func (cf *VersionedUnmarshaler) UnmarshalBeaconState(marshaled []byte) (s state.
if err != nil {
return nil, errors.Wrapf(err, "failed to init state trie from state, detected fork=%s", forkName)
}
case version.Electra:
case version.Electra, version.EIP7594:
st := &ethpb.BeaconStateElectra{}
err = st.UnmarshalSSZ(marshaled)
if err != nil {

View File

@@ -46,7 +46,7 @@ func TestSlotFromBlock(t *testing.T) {
}
func TestByState(t *testing.T) {
undo := util.HackElectraMaxuint(t)
undo := util.HackElectraEIP7549Maxuint(t)
defer undo()
bc := params.BeaconConfig()
altairSlot, err := slots.EpochStart(bc.AltairForkEpoch)
@@ -59,6 +59,8 @@ func TestByState(t *testing.T) {
require.NoError(t, err)
electraSlot, err := slots.EpochStart(bc.ElectraForkEpoch)
require.NoError(t, err)
eip7594Slot, err := slots.EpochStart(bc.Eip7594ForkEpoch)
require.NoError(t, err)
cases := []struct {
name string
version int
@@ -101,6 +103,12 @@ func TestByState(t *testing.T) {
slot: electraSlot,
forkversion: bytesutil.ToBytes4(bc.ElectraForkVersion),
},
{
name: "eip7594",
version: version.EIP7594,
slot: eip7594Slot,
forkversion: bytesutil.ToBytes4(bc.Eip7594ForkVersion),
},
}
for _, c := range cases {
st, err := stateForVersion(c.version)
@@ -133,7 +141,7 @@ func stateForVersion(v int) (state.BeaconState, error) {
return util.NewBeaconStateCapella()
case version.Deneb:
return util.NewBeaconStateDeneb()
case version.Electra:
case version.Electra, version.EIP7594:
return util.NewBeaconStateElectra()
default:
return nil, fmt.Errorf("unrecognized version %d", v)
@@ -142,7 +150,7 @@ func stateForVersion(v int) (state.BeaconState, error) {
func TestUnmarshalState(t *testing.T) {
ctx := context.Background()
undo := util.HackElectraMaxuint(t)
undo := util.HackElectraEIP7549Maxuint(t)
defer undo()
bc := params.BeaconConfig()
altairSlot, err := slots.EpochStart(bc.AltairForkEpoch)
@@ -155,6 +163,8 @@ func TestUnmarshalState(t *testing.T) {
require.NoError(t, err)
electraSlot, err := slots.EpochStart(bc.ElectraForkEpoch)
require.NoError(t, err)
eip7594Slot, err := slots.EpochStart(bc.Eip7594ForkEpoch)
require.NoError(t, err)
cases := []struct {
name string
version int
@@ -197,6 +207,12 @@ func TestUnmarshalState(t *testing.T) {
slot: electraSlot,
forkversion: bytesutil.ToBytes4(bc.ElectraForkVersion),
},
{
name: "eip7594",
version: version.EIP7594,
slot: eip7594Slot,
forkversion: bytesutil.ToBytes4(bc.Eip7594ForkVersion),
},
}
for _, c := range cases {
st, err := stateForVersion(c.version)
@@ -222,7 +238,7 @@ func TestUnmarshalState(t *testing.T) {
}
func TestDetectAndUnmarshalBlock(t *testing.T) {
undo := util.HackElectraMaxuint(t)
undo := util.HackElectraEIP7549Maxuint(t)
defer undo()
altairS, err := slots.EpochStart(params.BeaconConfig().AltairForkEpoch)
require.NoError(t, err)
@@ -320,7 +336,7 @@ func TestDetectAndUnmarshalBlock(t *testing.T) {
}
func TestUnmarshalBlock(t *testing.T) {
undo := util.HackElectraMaxuint(t)
undo := util.HackElectraEIP7549Maxuint(t)
defer undo()
genv := bytesutil.ToBytes4(params.BeaconConfig().GenesisForkVersion)
altairv := bytesutil.ToBytes4(params.BeaconConfig().AltairForkVersion)
@@ -442,7 +458,7 @@ func TestUnmarshalBlock(t *testing.T) {
}
func TestUnmarshalBlindedBlock(t *testing.T) {
undo := util.HackElectraMaxuint(t)
undo := util.HackElectraEIP7549Maxuint(t)
defer undo()
genv := bytesutil.ToBytes4(params.BeaconConfig().GenesisForkVersion)
altairv := bytesutil.ToBytes4(params.BeaconConfig().AltairForkVersion)

View File

@@ -350,6 +350,8 @@ func (s *PremineGenesisConfig) setFork(g state.BeaconState) error {
pv, cv = params.BeaconConfig().CapellaForkVersion, params.BeaconConfig().DenebForkVersion
case version.Electra:
pv, cv = params.BeaconConfig().ElectraForkVersion, params.BeaconConfig().ElectraForkVersion
case version.EIP7594:
pv, cv = params.BeaconConfig().Eip7594ForkVersion, params.BeaconConfig().Eip7594ForkVersion
default:
return errUnsupportedVersion
}

View File

@@ -11,6 +11,7 @@ const (
Capella
Deneb
Electra
EIP7594
)
var versionToString = map[int]string{
@@ -20,6 +21,7 @@ var versionToString = map[int]string{
Capella: "capella",
Deneb: "deneb",
Electra: "electra",
EIP7594: "eip7594",
}
// stringToVersion and allVersions are populated in init()

View File

@@ -21,15 +21,17 @@ import (
"github.com/prysmaticlabs/prysm/v5/time/slots"
)
// HackElectraMaxuint is helpful for tests that need to set up cases where the electra fork has passed.
// HackElectraEIP7549Maxuint is helpful for tests that need to set up cases where the electra and EIP7549
// forks has passed.
// We have unit tests that assert our config matches the upstream config, where the next fork is always
// set to MaxUint64 until the fork epoch is formally set. This creates an issue for tests that want to
// work with slots that are defined to be after electra because converting the max epoch to a slot leads
// to multiplication overflow.
// Monkey patching tests with this function is the simplest workaround in these cases.
func HackElectraMaxuint(t *testing.T) func() {
func HackElectraEIP7549Maxuint(t *testing.T) func() {
bc := params.MainnetConfig().Copy()
bc.ElectraForkEpoch = math.MaxUint32
bc.Eip7594ForkEpoch = math.MaxUint32 + 1
undo, err := params.SetActiveWithUndo(bc)
require.NoError(t, err)
return func() {

View File

@@ -86,6 +86,8 @@ func ToEpoch(slot primitives.Slot) primitives.Epoch {
func ToForkVersion(slot primitives.Slot) int {
epoch := ToEpoch(slot)
switch {
case epoch >= params.BeaconConfig().Eip7594ForkEpoch:
return version.EIP7594
case epoch >= params.BeaconConfig().ElectraForkEpoch:
return version.Electra
case epoch >= params.BeaconConfig().DenebForkEpoch:

View File

@@ -635,6 +635,18 @@ func TestSecondsUntilNextEpochStart(t *testing.T) {
}
func TestToForkVersion(t *testing.T) {
t.Run("EIP7594 fork version", func(t *testing.T) {
params.SetupTestConfigCleanup(t)
config := params.BeaconConfig()
config.Eip7594ForkEpoch = 200
params.OverrideBeaconConfig(config)
slot, err := EpochStart(params.BeaconConfig().Eip7594ForkEpoch)
require.NoError(t, err)
result := ToForkVersion(slot)
require.Equal(t, version.EIP7594, result)
})
t.Run("Electra fork version", func(t *testing.T) {
params.SetupTestConfigCleanup(t)
config := params.BeaconConfig()