Skip to content

Commit

Permalink
Caplin electra devnet-5 (#13472)
Browse files Browse the repository at this point in the history
info: 
`https://notes.ethereum.org/@ethpandaops/pectra-devnet-5`
spec: 

`https://github.com/ethereum/consensus-specs/tree/v1.5.0-beta.0/specs/electra`
network config: 

`https://github.com/ethpandaops/pectra-devnets/tree/master/network-configs/devnet-5/metadata`
devnet5-scan:
`https://dora.pectra-devnet-5.ethpandaops.io/`

run:
```
wget https://github.com/ethpandaops/pectra-devnets/raw/refs/heads/master/network-configs/devnet-5/metadata/genesis.ssz
wget https://raw.githubusercontent.com/ethpandaops/pectra-devnets/refs/heads/master/network-configs/devnet-5/metadata/genesis.json
wget https://raw.githubusercontent.com/ethpandaops/pectra-devnets/refs/heads/master/network-configs/devnet-5/metadata/config.yaml
```

```
./build/bin/erigon --prune.mode=archive --datadir=/erigon-data/devnet-5 --http --http.api=engine,net,eth --bootnodes="enode://3308a61ede37d5f70218a592fb7f107a8af4172f24929989d65c71638b5ba81483092425db98d4be0ef273ea3703b1a0592a579926dd6d2ea82282bf62e0c700@104.248.20.215:30303?discport=30303,enode://a4959299a00be2caad41cf0f89f31aaf8f4a742c9532eaf8f0da15d8c14838dd0880ab2c8d7018c0ff8cabf8ca95d0ee96888c34873ec80a6681eb78bd6bc9ca@46.101.170.74:30303?discport=30303,enode://5c2b9e2b3d4f0780d7594ee71f5a29affc77edd3ad0c599cf3876e02ec5874ae36603a90c529263462c99f4058f1aaf855d3a686c244d13179d0ef86a3b659d8@164.92.66.90:30303?discport=30303,enode://43ecd4b33cff69aee89e075c330f2c819306b85ed100777db64142a42015796b10bf840625e9d527617ed3fb3791c11db1cee5c87627eaa2d347534941510d8d@167.99.133.31:30303?discport=30303" --log.console.verbosity=4 --caplin.custom-config=devnet-5/config.yaml --caplin.custom-genesis=devnet-5/genesis.ssz --sentinel.bootnodes="enr:-Iq4QAbOTKfv9ApSdZET7mTp6PQSxgsWeQSkYfc8qrHGjJAKZVIX092F0T97I1snRk8YYmo_5YRupZBEk7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AAAAAAACEZXRoMpBSs7OTYHECQAQAAAAAAAAAgmlkgnY0gmlwhJ9BdfiJc2VjcDI1NmsxoQLPB64Y9PyTvY-RACiH5RVokJDPcJk5TLYy_UkdUMLOHIhzeW5jbmV0c4gAAAAAAAAAAIN0Y3CCIyiDdWRwgiMo,
enr:-MS4QO7y1bqz_efNFDTVvk549Qswcfxr7yjSmDNsEKUfdJgLCiy0kFktRnvUFTN5gV-vkQXzPdAhYaL9wJIbArKcOmYEh2F0dG5ldHOIAAAAAAAAAGCEZXRoMpBSs7OTYHECQAQAAAAAAAAAgmlkgnY0gmlwhC5lrEeJc2VjcDI1NmsxoQKj6xQEduvyGSBzVLvL7AmKdv7F1pXywRO1FRlMzkIAWohzeW5jbmV0c4gAAAAAAAAAAIN0Y3CCIyiDdWRwgiMo,
enr:-MS4QBt0xNdVL-gFB9oXrQbh68lkJeRpsf38w95QavX2tCciGPxLmt4s_LzOYxqQ39ZLEF3Le0thEg8_JpjArl6I0tEEh2F0dG5ldHOIAAAAAAAADACEZXRoMpBSs7OTYHECQAQAAAAAAAAAgmlkgnY0gmlwhKdjhR-Jc2VjcDI1NmsxoQNlCfzBjJn9hpv9moXBMFReC14qR6goVe6rEEZl_tslRohzeW5jbmV0c4gAAAAAAAAAAIN0Y3CCIyiDdWRwgiMo,
enr:-MS4QIHCuLUKJ_BBurAamWWQG0qJKOc4iejUroxAPDW2C8B-fEFGh5XZ-JxggNLR0-OjCqwQQux-u1aueb6yeA_9GSgEh2F0dG5ldHOIAAAAAMAAAACEZXRoMpBSs7OTYHECQAQAAAAAAAAAgmlkgnY0gmlwhKRciXeJc2VjcDI1NmsxoQOg1wwF3rgnwm8hUunLKHCPa0-M6xc1QaPbii_pIaa0pIhzeW5jbmV0c4gAAAAAAAAAAIN0Y3CCIyiDdWRwgiMo" 2>&1 | tee devnet5.log
```
  • Loading branch information
domiwei authored Jan 27, 2025
1 parent f4fc23f commit e92fa09
Show file tree
Hide file tree
Showing 23 changed files with 129 additions and 59 deletions.
Binary file modified cl/antiquary/tests/test_data/electra/blocks_0.ssz_snappy
Binary file not shown.
Binary file modified cl/antiquary/tests/test_data/electra/blocks_1.ssz_snappy
Binary file not shown.
4 changes: 1 addition & 3 deletions cl/antiquary/tests/test_data/electra/meta.yaml
Git LFS file not shown
Binary file modified cl/antiquary/tests/test_data/electra/post.ssz_snappy
Binary file not shown.
Binary file modified cl/antiquary/tests/test_data/electra/pre.ssz_snappy
Binary file not shown.
29 changes: 20 additions & 9 deletions cl/clparams/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -573,17 +573,17 @@ type BeaconChainConfig struct {
WhistleBlowerRewardQuotientElectra uint64 `yaml:"WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA" spec:"true" json:"WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA,string"` // WhistleBlowerRewardQuotientElectra is used to calculate whistle blower reward post Electra hard fork.
MaxPendingPartialsPerWithdrawalsSweep uint64 `yaml:"MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP" spec:"true" json:"MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP,string"` // MaxPendingPartialsPerWithdrawalsSweep bounds the size of the sweep searching for pending partials per slot.
MaxPendingDepositsPerEpoch uint64 `yaml:"MAX_PENDING_DEPOSITS_PER_EPOCH" spec:"true" json:"MAX_PENDING_DEPOSITS_PER_EPOCH,string"` // MaxPendingDepositsPerEpoch defines the maximum number of pending deposits per epoch.
PendingDepositLimit uint64 `yaml:"PENDING_DEPOSIT_LIMIT" spec:"true" json:"PENDING_DEPOSIT_LIMIT,string"` // PendingDepositLimit defines the maximum number of pending deposits.
PendingDepositLimits uint64 `yaml:"PENDING_DEPOSITS_LIMIT" spec:"true" json:"PENDING_DEPOSIT_LIMIT,string"` // PendingDepositLimit defines the maximum number of pending deposits.
PendingPartialWithdrawalsLimit uint64 `yaml:"PENDING_PARTIAL_WITHDRAWALS_LIMIT" spec:"true" json:"PENDING_PARTIAL_WITHDRAWALS_LIMIT,string"` // PendingPartialWithdrawalsLimit defines the maximum number of pending partial withdrawals.
PendingConsolidationsLimit uint64 `yaml:"PENDING_CONSOLIDATIONS_LIMIT" spec:"true" json:"PENDING_CONSOLIDATIONS_LIMIT,string"` // PendingConsolidationsLimit defines the maximum number of pending consolidations.
MaxBlobsPerBlockElectra uint64 `yaml:"MAX_BLOBS_PER_BLOCK_ELECTRA" spec:"true" json:"MAX_BLOBS_PER_BLOCK_ELECTRA,string"` // MaxBlobsPerBlockElectra defines the maximum number of blobs per block for Electra.
// Constants for the Electra fork.
UnsetDepositRequestsStartIndex uint64 `yaml:"UNSET_DEPOSIT_REQUESTS_START_INDEX" spec:"true" json:"UNSET_DEPOSIT_REQUESTS_START_INDEX,string"` // UnsetDepositRequestsStartIndex defines the start index for unset deposit requests.
FullExitRequestAmount uint64 `yaml:"FULL_EXIT_REQUEST_AMOUNT" spec:"true" json:"FULL_EXIT_REQUEST_AMOUNT,string"` // FullExitRequestAmount defines the amount for a full exit request.
CompoundingWithdrawalPrefix byte `yaml:"COMPOUNDING_WITHDRAWAL_PREFIX" spec:"true" json:"COMPOUNDING_WITHDRAWAL_PREFIX,string"` // CompoundingWithdrawalPrefix is the prefix for compounding withdrawals.
DepositRequestType byte `yaml:"DEPOSIT_REQUEST_TYPE" spec:"true" json:"DEPOSIT_REQUEST_TYPE,string"` // DepositRequestType is the type for deposit requests.
WithdrawalRequestType byte `yaml:"WITHDRAWAL_REQUEST_TYPE" spec:"true" json:"WITHDRAWAL_REQUEST_TYPE,string"` // WithdrawalRequestType is the type for withdrawal requests.
ConsolidationRequestType byte `yaml:"CONSOLIDATION_REQUEST_TYPE" spec:"true" json:"CONSOLIDATION_REQUEST_TYPE,string"` // ConsolidationRequestType is the type for consolidation requests.

CompoundingWithdrawalPrefix byte `yaml:"COMPOUNDING_WITHDRAWAL_PREFIX" spec:"true" json:"COMPOUNDING_WITHDRAWAL_PREFIX"` // CompoundingWithdrawalPrefix is the prefix for compounding withdrawals.
DepositRequestType byte `yaml:"DEPOSIT_REQUEST_TYPE" spec:"true" json:"DEPOSIT_REQUEST_TYPE"` // DepositRequestType is the type for deposit requests.
WithdrawalRequestType byte `yaml:"WITHDRAWAL_REQUEST_TYPE" spec:"true" json:"WITHDRAWAL_REQUEST_TYPE"` // WithdrawalRequestType is the type for withdrawal requests.
ConsolidationRequestType byte `yaml:"CONSOLIDATION_REQUEST_TYPE" spec:"true" json:"CONSOLIDATION_REQUEST_TYPE"` // ConsolidationRequestType is the type for consolidation requests.
}

func (b *BeaconChainConfig) RoundSlotToEpoch(slot uint64) uint64 {
Expand Down Expand Up @@ -844,14 +844,15 @@ var MainnetBeaconConfig BeaconChainConfig = BeaconChainConfig{
MaxPerEpochActivationExitChurnLimit: 256_000_000_000,
MaxDepositRequestsPerPayload: 8192,
MaxWithdrawalRequestsPerPayload: 16,
MaxConsolidationRequestsPerPayload: 1,
MaxConsolidationRequestsPerPayload: 2,
MinSlashingPenaltyQuotientElectra: 4096,
WhistleBlowerRewardQuotientElectra: 4096,
MaxPendingPartialsPerWithdrawalsSweep: 8,
MaxPendingDepositsPerEpoch: 16,
PendingDepositLimit: 1 << 27,
PendingDepositLimits: 1 << 27,
PendingPartialWithdrawalsLimit: 1 << 27,
PendingConsolidationsLimit: 1 << 18,
MaxBlobsPerBlockElectra: 9,
// Electra constants.
UnsetDepositRequestsStartIndex: ^uint64(0), // 2**64 - 1
FullExitRequestAmount: 0,
Expand Down Expand Up @@ -1036,7 +1037,7 @@ func (b *BeaconChainConfig) GetMinSlashingPenaltyQuotient(version StateVersion)
}

func (b *BeaconChainConfig) GetWhistleBlowerRewardQuotient(version StateVersion) uint64 {
if version == ElectraVersion {
if version >= ElectraVersion {
return b.WhistleBlowerRewardQuotientElectra
}
return b.WhistleBlowerRewardQuotient
Expand Down Expand Up @@ -1114,6 +1115,16 @@ func (b *BeaconChainConfig) MaxEffectiveBalanceForVersion(version StateVersion)
}
}

func (b *BeaconChainConfig) MaxBlobsPerBlockByVersion(v StateVersion) uint64 {
switch v {
case Phase0Version, AltairVersion, BellatrixVersion, CapellaVersion, DenebVersion:
return b.MaxBlobsPerBlock
case ElectraVersion:
return b.MaxBlobsPerBlockElectra
}
panic("invalid version")
}

func (b *BeaconChainConfig) GetForkVersionByVersion(v StateVersion) uint32 {
switch v {
case Phase0Version:
Expand Down
10 changes: 5 additions & 5 deletions cl/cltypes/beacon_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,9 +555,9 @@ func (b *BeaconBody) GetExecutionRequestsList() []hexutility.Bytes {
return nil
}
// type + ssz
// ret = append(ret, append(hexutility.Bytes{requestType}, ssz...))
// in Mekong devnet-4, we don't need to add type
ret = append(ret, ssz)
if len(ssz) > 0 {
ret = append(ret, append(hexutility.Bytes{r.typ}, ssz...))
}
}
return ret
}
Expand All @@ -569,7 +569,7 @@ type DenebBeaconBlock struct {
}

func NewDenebBeaconBlock(beaconCfg *clparams.BeaconChainConfig, version clparams.StateVersion) *DenebBeaconBlock {
maxBlobsPerBlock := int(beaconCfg.MaxBlobsPerBlock)
maxBlobsPerBlock := int(beaconCfg.MaxBlobsPerBlockByVersion(version))
b := &DenebBeaconBlock{
Block: NewBeaconBlock(beaconCfg, version),
KZGProofs: solid.NewStaticListSSZ[*KZGProof](maxBlobsPerBlock, BYTES_KZG_PROOF),
Expand Down Expand Up @@ -630,7 +630,7 @@ func NewDenebSignedBeaconBlock(beaconCfg *clparams.BeaconChainConfig, version cl
log.Warn("DenebSignedBeaconBlock: version is not after DenebVersion")
return nil
}
maxBlobsPerBlock := int(beaconCfg.MaxBlobsPerBlock)
maxBlobsPerBlock := int(beaconCfg.MaxBlobsPerBlockByVersion(version))
b := &DenebSignedBeaconBlock{
SignedBlock: NewSignedBeaconBlock(beaconCfg, version),
KZGProofs: solid.NewStaticListSSZ[*KZGProof](maxBlobsPerBlock, BYTES_KZG_PROOF),
Expand Down
13 changes: 7 additions & 6 deletions cl/cltypes/execution_requests.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cltypes

import (
"crypto/sha256"
"encoding/json"

"github.com/erigontech/erigon-lib/common"
Expand All @@ -10,7 +11,6 @@ import (
"github.com/erigontech/erigon/cl/cltypes/solid"
"github.com/erigontech/erigon/cl/merkle_tree"
ssz2 "github.com/erigontech/erigon/cl/ssz"
"github.com/erigontech/erigon/core/types"
)

var (
Expand Down Expand Up @@ -85,10 +85,11 @@ func (e *ExecutionRequests) UnmarshalJSON(b []byte) error {
}

func ComputeExecutionRequestHash(executionRequests []hexutility.Bytes) common.Hash {
requests := make(types.FlatRequests, len(types.KnownRequestTypes))
for i, r := range types.KnownRequestTypes {
requests[i] = types.FlatRequest{Type: r, RequestData: executionRequests[i]}
sha := sha256.New()
for _, r := range executionRequests {
hi := sha256.Sum256(r)
sha.Write(hi[:])
}
rh := requests.Hash()
return *rh
h := common.BytesToHash(sha.Sum(nil))
return h
}
2 changes: 1 addition & 1 deletion cl/cltypes/solid/deposits.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@ func (p *PendingDeposit) Static() bool {
}

func NewPendingDepositList(cfg *clparams.BeaconChainConfig) *ListSSZ[*PendingDeposit] {
return NewStaticListSSZ[*PendingDeposit](int(cfg.PendingDepositLimit), SizePendingDeposit)
return NewStaticListSSZ[*PendingDeposit](int(cfg.PendingDepositLimits), SizePendingDeposit)
}
30 changes: 23 additions & 7 deletions cl/phase1/core/state/cache_accessors.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,18 +312,34 @@ func (b *CachingBeaconState) ComputeNextSyncCommittee() (*solid.SyncCommittee, e
return nil, err
}
candidateIndex := activeValidatorIndicies[shuffledIndex]
// Compute random byte.
buf := make([]byte, 8)
binary.LittleEndian.PutUint64(buf, i/32)
input := append(seed[:], buf...)
randomByte := uint64(utils.Sha256(input)[i%32])
// retrieve validator.
validator, err := b.ValidatorForValidatorIndex(int(candidateIndex))
if err != nil {
return nil, err
}
if validator.EffectiveBalance()*math.MaxUint8 >= beaconConfig.MaxEffectiveBalanceForVersion(b.Version())*randomByte {
syncCommitteePubKeys = append(syncCommitteePubKeys, validator.PublicKey())
if b.Version() >= clparams.ElectraVersion {
// electra and after
// random_bytes = hash(seed + uint_to_bytes(i // 16))
// offset = i % 16 * 2
// random_value = bytes_to_uint64(random_bytes[offset:offset + 2])
buf := make([]byte, 8)
binary.LittleEndian.PutUint64(buf, i/16)
input := append(seed[:], buf...)
randomBytes := utils.Sha256(input)
offset := (i % 16) * 2
randomValue := binary.LittleEndian.Uint16(randomBytes[offset : offset+2])
if validator.EffectiveBalance()*math.MaxUint16 >= beaconConfig.MaxEffectiveBalanceForVersion(b.Version())*uint64(randomValue) {
syncCommitteePubKeys = append(syncCommitteePubKeys, validator.PublicKey())
}
} else {
// Compute random byte.
buf := make([]byte, 8)
binary.LittleEndian.PutUint64(buf, i/32)
input := append(seed[:], buf...)
randomByte := uint64(utils.Sha256(input)[i%32])
if validator.EffectiveBalance()*math.MaxUint8 >= beaconConfig.MaxEffectiveBalanceForVersion(b.Version())*randomByte {
syncCommitteePubKeys = append(syncCommitteePubKeys, validator.PublicKey())
}
}
i++
}
Expand Down
39 changes: 39 additions & 0 deletions cl/phase1/core/state/shuffling/shuffling.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"encoding/binary"
"fmt"

"github.com/erigontech/erigon/cl/clparams"
"github.com/erigontech/erigon/cl/phase1/core/state/raw"

"github.com/erigontech/erigon/cl/utils"
Expand All @@ -29,6 +30,11 @@ func ComputeProposerIndex(b *raw.BeaconState, indices []uint64, seed [32]byte) (
if len(indices) == 0 {
return 0, nil
}
if b.Version() >= clparams.ElectraVersion {
return computeProposerIndexElectra(b, indices, seed)
}

// before electra case
maxRandomByte := uint64(1<<8 - 1)
i := uint64(0)
total := uint64(len(indices))
Expand Down Expand Up @@ -56,3 +62,36 @@ func ComputeProposerIndex(b *raw.BeaconState, indices []uint64, seed [32]byte) (
i += 1
}
}

func computeProposerIndexElectra(b *raw.BeaconState, indices []uint64, seed [32]byte) (uint64, error) {
maxRandomValue := uint64(1<<16 - 1)
i := uint64(0)
total := uint64(len(indices))
input := make([]byte, 40)
preInputs := ComputeShuffledIndexPreInputs(b.BeaconConfig(), seed)
for {
shuffled, err := ComputeShuffledIndex(b.BeaconConfig(), i%total, total, seed, preInputs, utils.Sha256)
if err != nil {
return 0, err
}
candidateIndex := indices[shuffled]
// [Modified in Electra]
// random_bytes = hash(seed + uint_to_bytes(i // 16))
// offset = i % 16 * 2
// random_value = bytes_to_uint64(random_bytes[offset:offset + 2])
copy(input, seed[:])
binary.LittleEndian.PutUint64(input[32:], i/16)
randomBytes := utils.Sha256(input)
offset := (i % 16) * 2
randomValue := binary.LittleEndian.Uint16(randomBytes[offset : offset+2])

validator, err := b.ValidatorForValidatorIndex(int(candidateIndex))
if err != nil {
return 0, err
}
if validator.EffectiveBalance()*maxRandomValue >= b.BeaconConfig().MaxEffectiveBalanceForVersion(b.Version())*uint64(randomValue) {
return candidateIndex, nil
}
i += 1
}
}
3 changes: 1 addition & 2 deletions cl/phase1/core/state/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ func (b *CachingBeaconState) UpgradeToElectra() error {
// Update the state root cache
b.SetVersion(clparams.ElectraVersion)

//earliestExitEpoch := ComputeActivationExitEpoch(b.BeaconConfig(), epoch)
earliestExitEpoch := epoch // for Mekong testnet
earliestExitEpoch := ComputeActivationExitEpoch(b.BeaconConfig(), epoch)
b.ValidatorSet().Range(func(i int, v solid.Validator, _ int) bool {
if v.ExitEpoch() != b.BeaconConfig().FarFutureEpoch {
if v.ExitEpoch() > earliestExitEpoch {
Expand Down
3 changes: 2 additions & 1 deletion cl/phase1/forkchoice/on_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ func verifyKzgCommitmentsAgainstTransactions(cfg *clparams.BeaconChainConfig, bl
return err
}

return ethutils.ValidateBlobs(block.BlobGasUsed, cfg.MaxBlobGasPerBlock, cfg.MaxBlobsPerBlock, expectedBlobHashes, &transactions)
maxBlobsPerBlock := cfg.MaxBlobsPerBlockByVersion(block.Version())
return ethutils.ValidateBlobs(block.BlobGasUsed, cfg.MaxBlobGasPerBlock, maxBlobsPerBlock, expectedBlobHashes, &transactions)
}

func collectOnBlockLatencyToUnixTime(ethClock eth_clock.EthereumClock, slot uint64) {
Expand Down
8 changes: 4 additions & 4 deletions cl/phase1/network/beacon_downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ type peerAndBlocks struct {
}

func (f *ForwardBeaconDownloader) RequestMore(ctx context.Context) {
count := uint64(16)
count := uint64(32)
var atomicResp atomic.Value
atomicResp.Store(peerAndBlocks{})
reqInterval := time.NewTicker(300 * time.Millisecond)
Expand All @@ -94,11 +94,11 @@ Loop:
if f.highestSlotProcessed > 2 {
reqSlot = f.highestSlotProcessed - 2
}
// double the request count every 30 seconds. This is inspired by the mekong network, which has many consecutive missing blocks.
// double the request count every 10 seconds. This is inspired by the mekong network, which has many consecutive missing blocks.
reqCount := count
if !f.highestSlotUpdateTime.IsZero() {
multiplier := int(time.Since(f.highestSlotUpdateTime).Seconds()) / 30
multiplier = min(multiplier, 4)
multiplier := int(time.Since(f.highestSlotUpdateTime).Seconds()) / 10
multiplier = min(multiplier, 6)
reqCount *= uint64(1 << uint(multiplier))
}
// leave a warning if we are stuck for more than 90 seconds
Expand Down
6 changes: 4 additions & 2 deletions cl/phase1/network/services/blob_sidecar_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ func (b *blobSidecarService) ProcessMessage(ctx context.Context, subnetId *uint6
}

// [REJECT] The sidecar's index is consistent with MAX_BLOBS_PER_BLOCK -- i.e. blob_sidecar.index < MAX_BLOBS_PER_BLOCK.
if msg.Index >= b.beaconCfg.MaxBlobsPerBlock {
blockVersion := b.beaconCfg.GetCurrentStateVersion(msg.SignedBlockHeader.Header.Slot / b.beaconCfg.SlotsPerEpoch)
maxBlobsPerBlock := b.beaconCfg.MaxBlobsPerBlockByVersion(blockVersion)
if msg.Index >= maxBlobsPerBlock {
return errors.New("blob index out of range")
}
sidecarSubnetIndex := msg.Index % b.beaconCfg.MaxBlobsPerBlock
sidecarSubnetIndex := msg.Index % maxBlobsPerBlock
if sidecarSubnetIndex != *subnetId {
return ErrBlobIndexOutOfRange
}
Expand Down
3 changes: 2 additions & 1 deletion cl/phase1/network/services/block_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ func (b *blockService) ProcessMessage(ctx context.Context, _ *uint64, msg *cltyp
}

// [REJECT] The length of KZG commitments is less than or equal to the limitation defined in Consensus Layer -- i.e. validate that len(body.signed_beacon_block.message.blob_kzg_commitments) <= MAX_BLOBS_PER_BLOCK
if msg.Block.Body.BlobKzgCommitments.Len() > int(b.beaconCfg.MaxBlobsPerBlock) {
blockVersion := b.beaconCfg.GetCurrentStateVersion(msg.Block.Slot / b.beaconCfg.SlotsPerEpoch)
if msg.Block.Body.BlobKzgCommitments.Len() > int(b.beaconCfg.MaxBlobsPerBlockByVersion(blockVersion)) {
return ErrInvalidCommitmentsCount
}
b.publishBlockGossipEvent(msg)
Expand Down
2 changes: 1 addition & 1 deletion cl/rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func (b *BeaconRpcP2P) SendBlobsSidecarByRangerReq(ctx context.Context, start, c
}

data := libcommon.CopyBytes(buffer.Bytes())
return b.sendBlobsSidecar(ctx, communication.BlobSidecarByRangeProtocolV2, data, count*b.beaconConfig.MaxBlobsPerBlock)
return b.sendBlobsSidecar(ctx, communication.BlobSidecarByRangeProtocolV1, data, count*b.beaconConfig.MaxBlobsPerBlock)
}

// SendBeaconBlocksByRangeReq retrieves blocks range from beacon chain.
Expand Down
5 changes: 4 additions & 1 deletion cl/sentinel/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,13 @@ func (s *SentinelServer) requestPeer(ctx context.Context, pid peer.ID, req *sent
if resp.StatusCode < 200 || resp.StatusCode > 399 {
errBody, _ := io.ReadAll(resp.Body)
errorMessage := fmt.Errorf("SentinelHttp: %s", string(errBody))
if strings.Contains(errorMessage.Error(), "Read Code: EOF") {
// don't ban the peer.
return nil, errorMessage
}
s.sentinel.Peers().RemovePeer(pid)
s.sentinel.Host().Peerstore().RemovePeer(pid)
s.sentinel.Host().Network().ClosePeer(pid)

return nil, errorMessage
}
// we should never get an invalid response to this. our responder should always set it on non-error response
Expand Down
3 changes: 2 additions & 1 deletion cl/sentinel/service/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,12 @@ func createSentinel(
sentinel.SyncCommitteeContributionAndProofSsz,
sentinel.BeaconAggregateAndProofSsz,
}

gossipTopics = append(
gossipTopics,
generateSubnetsTopics(
gossip.TopicNamePrefixBlobSidecar,
int(cfg.BeaconConfig.MaxBlobsPerBlock),
int(cfg.BeaconConfig.MaxBlobsPerBlockElectra),
)...)

attestationSubnetTopics := generateSubnetsTopics(
Expand Down
4 changes: 3 additions & 1 deletion cl/spectest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@


tests:
wget https://github.com/ethereum/consensus-spec-tests/releases/download/v1.5.0-alpha.8/mainnet.tar.gz
wget https://github.com/ethereum/consensus-spec-tests/releases/download/v1.5.0-beta.0/mainnet.tar.gz
tar xf mainnet.tar.gz
rm mainnet.tar.gz
# not needed for now
rm -rf tests/mainnet/eip6110
rm -rf tests/mainnet/whisk
rm -rf tests/mainnet/fulu

clean:
rm -rf tests
Expand Down
Loading

0 comments on commit e92fa09

Please sign in to comment.