From 0468995031cb5fbe7297e02a1645221df075b66c Mon Sep 17 00:00:00 2001 From: nisdas Date: Thu, 4 Jul 2024 18:11:04 +0800 Subject: [PATCH 1/6] Save All the Current Changes --- beacon-chain/blockchain/process_block.go | 2 +- beacon-chain/core/time/slot_epoch.go | 5 +++ beacon-chain/p2p/discovery.go | 2 +- beacon-chain/p2p/utils.go | 4 +-- .../rpc/prysm/v1alpha1/validator/proposer.go | 4 +-- beacon-chain/sync/BUILD.bazel | 1 + beacon-chain/sync/fork_watcher.go | 9 +++++ beacon-chain/sync/initial-sync/BUILD.bazel | 2 +- .../sync/initial-sync/blocks_fetcher.go | 4 +-- .../sync/initial-sync/blocks_fetcher_utils.go | 6 ++-- beacon-chain/sync/initial-sync/round_robin.go | 6 ++-- beacon-chain/sync/initial-sync/service.go | 4 +-- beacon-chain/sync/pending_blocks_queue.go | 5 +-- beacon-chain/sync/rpc.go | 31 ++++++++++------- .../sync/rpc_beacon_blocks_by_root.go | 4 +-- .../sync/rpc_data_column_sidecars_by_root.go | 6 ++-- beacon-chain/sync/service.go | 3 +- beacon-chain/sync/subscriber.go | 3 +- config/features/config.go | 7 ---- config/features/flags.go | 6 ---- config/params/config.go | 34 +++++++++++-------- config/params/loader.go | 1 + config/params/loader_test.go | 1 - config/params/mainnet_config.go | 1 + config/params/minimal_config.go | 1 + config/params/testnet_e2e_config.go | 2 ++ config/params/testnet_holesky_config.go | 1 + config/params/testnet_sepolia_config.go | 1 + 28 files changed, 89 insertions(+), 67 deletions(-) diff --git a/beacon-chain/blockchain/process_block.go b/beacon-chain/blockchain/process_block.go index 4c0666e9e08..786a9779d9e 100644 --- a/beacon-chain/blockchain/process_block.go +++ b/beacon-chain/blockchain/process_block.go @@ -541,7 +541,7 @@ func missingDataColumns(bs *filesystem.BlobStorage, root [32]byte, expected map[ // sidecars are missing, it will then read from the blobNotifier channel for the given root until the channel is // closed, the context hits cancellation/timeout, or notifications have been received for all the missing sidecars. func (s *Service) isDataAvailable(ctx context.Context, root [32]byte, signed interfaces.ReadOnlySignedBeaconBlock) error { - if features.Get().EnablePeerDAS { + if coreTime.PeerDASIsActive(signed.Block().Slot()) { return s.isDataAvailableDataColumns(ctx, root, signed) } if signed.Version() < version.Deneb { diff --git a/beacon-chain/core/time/slot_epoch.go b/beacon-chain/core/time/slot_epoch.go index 9ffa1561a3b..9938c937427 100644 --- a/beacon-chain/core/time/slot_epoch.go +++ b/beacon-chain/core/time/slot_epoch.go @@ -53,6 +53,11 @@ func HigherEqualThanAltairVersionAndEpoch(s state.BeaconState, e primitives.Epoc return s.Version() >= version.Altair && e >= params.BeaconConfig().AltairForkEpoch } +// PeerDASIsActive checks whether peerDAS is active at the provided slot. +func PeerDASIsActive(slot primitives.Slot) bool { + return params.PeerDASEnabled() && slots.ToEpoch(slot) >= params.BeaconConfig().Eip7594ForkEpoch +} + // CanUpgradeToAltair returns true if the input `slot` can upgrade to Altair. // Spec code: // If state.slot % SLOTS_PER_EPOCH == 0 and compute_epoch_at_slot(state.slot) == ALTAIR_FORK_EPOCH diff --git a/beacon-chain/p2p/discovery.go b/beacon-chain/p2p/discovery.go index 4cb1416870b..d9e1b9fee7b 100644 --- a/beacon-chain/p2p/discovery.go +++ b/beacon-chain/p2p/discovery.go @@ -266,7 +266,7 @@ func (s *Service) createLocalNode( localNode.Set(quicEntry) } - if features.Get().EnablePeerDAS { + if params.PeerDASEnabled() { localNode.Set(peerdas.Csc(peerdas.CustodySubnetCount())) } diff --git a/beacon-chain/p2p/utils.go b/beacon-chain/p2p/utils.go index 87311394f64..dfae8de2163 100644 --- a/beacon-chain/p2p/utils.go +++ b/beacon-chain/p2p/utils.go @@ -20,7 +20,7 @@ import ( "github.com/libp2p/go-libp2p/core/peer" "github.com/pkg/errors" "github.com/prysmaticlabs/go-bitfield" - "github.com/prysmaticlabs/prysm/v5/config/features" + "github.com/prysmaticlabs/prysm/v5/config/params" "github.com/prysmaticlabs/prysm/v5/consensus-types/wrapper" ecdsaprysm "github.com/prysmaticlabs/prysm/v5/crypto/ecdsa" "github.com/prysmaticlabs/prysm/v5/io/file" @@ -78,7 +78,7 @@ func privKey(cfg *Config) (*ecdsa.PrivateKey, error) { } // If the StaticPeerID flag is not set and if peerDAS is not enabled, return the private key. - if !(cfg.StaticPeerID || features.Get().EnablePeerDAS) { + if !(cfg.StaticPeerID || params.PeerDASEnabled()) { return ecdsaprysm.ConvertFromInterfacePrivKey(priv) } diff --git a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go index d336c02d5f9..34e8ea734f5 100644 --- a/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go +++ b/beacon-chain/rpc/prysm/v1alpha1/validator/proposer.go @@ -21,6 +21,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/feed/operation" "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/peerdas" + coreTime "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/time" "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/transition" "github.com/prysmaticlabs/prysm/v5/beacon-chain/db/kv" "github.com/prysmaticlabs/prysm/v5/beacon-chain/state" @@ -272,8 +273,6 @@ func (vs *Server) ProposeBeaconBlock(ctx context.Context, req *ethpb.GenericSign dataColumnSideCars []*ethpb.DataColumnSidecar ) - isPeerDASEnabled := features.Get().EnablePeerDAS - ctx, span := trace.StartSpan(ctx, "ProposerServer.ProposeBeaconBlock") defer span.End() @@ -285,6 +284,7 @@ func (vs *Server) ProposeBeaconBlock(ctx context.Context, req *ethpb.GenericSign if err != nil { return nil, status.Errorf(codes.InvalidArgument, "%s: %v", "decode block failed", err) } + isPeerDASEnabled := coreTime.PeerDASIsActive(block.Block().Slot()) if block.IsBlinded() { block, blobSidecars, dataColumnSideCars, err = vs.handleBlindedBlock(ctx, block, isPeerDASEnabled) diff --git a/beacon-chain/sync/BUILD.bazel b/beacon-chain/sync/BUILD.bazel index 28f7a7ece7a..19ce64c91d9 100644 --- a/beacon-chain/sync/BUILD.bazel +++ b/beacon-chain/sync/BUILD.bazel @@ -80,6 +80,7 @@ go_library( "//beacon-chain/core/helpers:go_default_library", "//beacon-chain/core/peerdas:go_default_library", "//beacon-chain/core/signing:go_default_library", + "//beacon-chain/core/time:go_default_library", "//beacon-chain/core/transition:go_default_library", "//beacon-chain/core/transition/interop:go_default_library", "//beacon-chain/db:go_default_library", diff --git a/beacon-chain/sync/fork_watcher.go b/beacon-chain/sync/fork_watcher.go index cc3d50d76f7..c744f30d8b3 100644 --- a/beacon-chain/sync/fork_watcher.go +++ b/beacon-chain/sync/fork_watcher.go @@ -67,6 +67,11 @@ func (s *Service) registerForUpcomingFork(currEpoch primitives.Epoch) error { s.registerRPCHandlersDeneb() } } + // Specially handle peerDAS + if params.PeerDASEnabled() && currEpoch+1 == params.BeaconConfig().Eip7594ForkEpoch { + s.registerRPCHandlersPeerDAS() + } + return nil } @@ -121,5 +126,9 @@ func (s *Service) deregisterFromPastFork(currEpoch primitives.Epoch) error { } } } + // Handle PeerDAS as its a special case. + if params.PeerDASEnabled() && currEpoch > 0 && (currEpoch-1) == params.BeaconConfig().Eip7594ForkEpoch { + s.unregisterBlobHandlers() + } return nil } diff --git a/beacon-chain/sync/initial-sync/BUILD.bazel b/beacon-chain/sync/initial-sync/BUILD.bazel index 68fc892aadc..05a09ca04e1 100644 --- a/beacon-chain/sync/initial-sync/BUILD.bazel +++ b/beacon-chain/sync/initial-sync/BUILD.bazel @@ -21,6 +21,7 @@ go_library( "//beacon-chain/core/feed/block:go_default_library", "//beacon-chain/core/feed/state:go_default_library", "//beacon-chain/core/peerdas:go_default_library", + "//beacon-chain/core/time:go_default_library", "//beacon-chain/core/transition:go_default_library", "//beacon-chain/das:go_default_library", "//beacon-chain/db:go_default_library", @@ -33,7 +34,6 @@ go_library( "//beacon-chain/sync/verify:go_default_library", "//beacon-chain/verification:go_default_library", "//cmd/beacon-chain/flags:go_default_library", - "//config/features:go_default_library", "//config/params:go_default_library", "//consensus-types/blocks:go_default_library", "//consensus-types/interfaces:go_default_library", diff --git a/beacon-chain/sync/initial-sync/blocks_fetcher.go b/beacon-chain/sync/initial-sync/blocks_fetcher.go index 14aea928e1a..3a21de7f4a9 100644 --- a/beacon-chain/sync/initial-sync/blocks_fetcher.go +++ b/beacon-chain/sync/initial-sync/blocks_fetcher.go @@ -14,6 +14,7 @@ import ( "go.opencensus.io/trace" "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/peerdas" + coreTime "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/time" "github.com/prysmaticlabs/prysm/v5/beacon-chain/db" "github.com/prysmaticlabs/prysm/v5/beacon-chain/db/filesystem" "github.com/prysmaticlabs/prysm/v5/beacon-chain/p2p" @@ -22,7 +23,6 @@ import ( prysmsync "github.com/prysmaticlabs/prysm/v5/beacon-chain/sync" "github.com/prysmaticlabs/prysm/v5/beacon-chain/sync/verify" "github.com/prysmaticlabs/prysm/v5/cmd/beacon-chain/flags" - "github.com/prysmaticlabs/prysm/v5/config/features" "github.com/prysmaticlabs/prysm/v5/config/params" "github.com/prysmaticlabs/prysm/v5/consensus-types/blocks" blocks2 "github.com/prysmaticlabs/prysm/v5/consensus-types/blocks" @@ -319,7 +319,7 @@ func (f *blocksFetcher) handleRequest(ctx context.Context, start primitives.Slot response.bwb, response.pid, response.err = f.fetchBlocksFromPeer(ctx, start, count, peers) if response.err == nil { - if features.Get().EnablePeerDAS { + if coreTime.PeerDASIsActive(start) { bwb, err := f.fetchColumnsFromPeer(ctx, response.bwb, response.pid, peers) if err != nil { response.err = err diff --git a/beacon-chain/sync/initial-sync/blocks_fetcher_utils.go b/beacon-chain/sync/initial-sync/blocks_fetcher_utils.go index 8b4f8df101b..cb842ddc337 100644 --- a/beacon-chain/sync/initial-sync/blocks_fetcher_utils.go +++ b/beacon-chain/sync/initial-sync/blocks_fetcher_utils.go @@ -6,9 +6,9 @@ import ( "github.com/libp2p/go-libp2p/core/peer" "github.com/pkg/errors" + coreTime "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/time" p2pTypes "github.com/prysmaticlabs/prysm/v5/beacon-chain/p2p/types" "github.com/prysmaticlabs/prysm/v5/cmd/beacon-chain/flags" - "github.com/prysmaticlabs/prysm/v5/config/features" "github.com/prysmaticlabs/prysm/v5/config/params" "github.com/prysmaticlabs/prysm/v5/consensus-types/blocks" "github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces" @@ -280,7 +280,7 @@ func (f *blocksFetcher) findForkWithPeer(ctx context.Context, pid peer.ID, slot return nil, errors.Wrap(err, "invalid blocks received in findForkWithPeer") } var bwb []blocks.BlockWithROBlobs - if features.Get().EnablePeerDAS { + if coreTime.PeerDASIsActive(block.Block().Slot()) { bwb, err = f.fetchColumnsFromPeer(ctx, altBlocks, pid, []peer.ID{pid}) if err != nil { return nil, errors.Wrap(err, "unable to retrieve blobs for blocks found in findForkWithPeer") @@ -312,7 +312,7 @@ func (f *blocksFetcher) findAncestor(ctx context.Context, pid peer.ID, b interfa if err != nil { return nil, errors.Wrap(err, "received invalid blocks in findAncestor") } - if features.Get().EnablePeerDAS { + if coreTime.PeerDASIsActive(b.Block().Slot()) { bwb, err = f.fetchColumnsFromPeer(ctx, bwb, pid, []peer.ID{pid}) if err != nil { return nil, errors.Wrap(err, "unable to retrieve columns for blocks found in findAncestor") diff --git a/beacon-chain/sync/initial-sync/round_robin.go b/beacon-chain/sync/initial-sync/round_robin.go index 3abacd93fa5..496d2ee8b8e 100644 --- a/beacon-chain/sync/initial-sync/round_robin.go +++ b/beacon-chain/sync/initial-sync/round_robin.go @@ -9,12 +9,12 @@ import ( "github.com/libp2p/go-libp2p/core/peer" "github.com/paulbellamy/ratecounter" "github.com/pkg/errors" + coreTime "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/time" "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/transition" "github.com/prysmaticlabs/prysm/v5/beacon-chain/das" "github.com/prysmaticlabs/prysm/v5/beacon-chain/db/filesystem" "github.com/prysmaticlabs/prysm/v5/beacon-chain/sync" "github.com/prysmaticlabs/prysm/v5/beacon-chain/verification" - "github.com/prysmaticlabs/prysm/v5/config/features" "github.com/prysmaticlabs/prysm/v5/consensus-types/blocks" "github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" @@ -173,7 +173,7 @@ func (s *Service) processFetchedDataRegSync( if len(bwb) == 0 { return } - if features.Get().EnablePeerDAS { + if coreTime.PeerDASIsActive(startSlot) { avs := das.NewLazilyPersistentStoreColumn(s.cfg.BlobStorage, emptyVerifier{}, s.cfg.P2P.NodeID()) batchFields := logrus.Fields{ "firstSlot": data.bwb[0].Block.Block().Slot(), @@ -357,7 +357,7 @@ func (s *Service) processBatchedBlocks(ctx context.Context, genesis time.Time, errParentDoesNotExist, first.Block().ParentRoot(), first.Block().Slot()) } var aStore das.AvailabilityStore - if features.Get().EnablePeerDAS { + if coreTime.PeerDASIsActive(first.Block().Slot()) { avs := das.NewLazilyPersistentStoreColumn(s.cfg.BlobStorage, emptyVerifier{}, s.cfg.P2P.NodeID()) s.logBatchSyncStatus(genesis, first, len(bwb)) for _, bb := range bwb { diff --git a/beacon-chain/sync/initial-sync/service.go b/beacon-chain/sync/initial-sync/service.go index d6c34036185..e58211b801b 100644 --- a/beacon-chain/sync/initial-sync/service.go +++ b/beacon-chain/sync/initial-sync/service.go @@ -18,6 +18,7 @@ import ( blockfeed "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/feed/block" statefeed "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/feed/state" "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/peerdas" + coreTime "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/time" "github.com/prysmaticlabs/prysm/v5/beacon-chain/das" "github.com/prysmaticlabs/prysm/v5/beacon-chain/db" "github.com/prysmaticlabs/prysm/v5/beacon-chain/db/filesystem" @@ -27,7 +28,6 @@ import ( "github.com/prysmaticlabs/prysm/v5/beacon-chain/sync" "github.com/prysmaticlabs/prysm/v5/beacon-chain/verification" "github.com/prysmaticlabs/prysm/v5/cmd/beacon-chain/flags" - "github.com/prysmaticlabs/prysm/v5/config/features" "github.com/prysmaticlabs/prysm/v5/config/params" "github.com/prysmaticlabs/prysm/v5/consensus-types/blocks" "github.com/prysmaticlabs/prysm/v5/crypto/rand" @@ -187,7 +187,7 @@ func (s *Service) Start() { log.WithError(err).Error("Error waiting for minimum number of peers") return } - if features.Get().EnablePeerDAS { + if coreTime.PeerDASIsActive(s.cfg.Chain.HeadSlot()) { if err := s.fetchOriginColumns(peers); err != nil { log.WithError(err).Error("Failed to fetch missing columns for checkpoint origin") return diff --git a/beacon-chain/sync/pending_blocks_queue.go b/beacon-chain/sync/pending_blocks_queue.go index bd303480c4e..f311c2102ea 100644 --- a/beacon-chain/sync/pending_blocks_queue.go +++ b/beacon-chain/sync/pending_blocks_queue.go @@ -12,8 +12,8 @@ import ( "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v5/async" "github.com/prysmaticlabs/prysm/v5/beacon-chain/blockchain" + coreTime "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/time" p2ptypes "github.com/prysmaticlabs/prysm/v5/beacon-chain/p2p/types" - "github.com/prysmaticlabs/prysm/v5/config/features" "github.com/prysmaticlabs/prysm/v5/config/params" "github.com/prysmaticlabs/prysm/v5/consensus-types/blocks" "github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces" @@ -204,7 +204,8 @@ func (s *Service) processAndBroadcastBlock(ctx context.Context, b interfaces.Rea return err } } - if features.Get().EnablePeerDAS { + + if coreTime.PeerDASIsActive(b.Block().Slot()) { request, err := s.pendingDataColumnRequestForBlock(blkRoot, b) if err != nil { return err diff --git a/beacon-chain/sync/rpc.go b/beacon-chain/sync/rpc.go index b57c3d005b8..328dfe9b16f 100644 --- a/beacon-chain/sync/rpc.go +++ b/beacon-chain/sync/rpc.go @@ -13,7 +13,6 @@ import ( ssz "github.com/prysmaticlabs/fastssz" "github.com/prysmaticlabs/prysm/v5/beacon-chain/p2p" p2ptypes "github.com/prysmaticlabs/prysm/v5/beacon-chain/p2p/types" - "github.com/prysmaticlabs/prysm/v5/config/features" "github.com/prysmaticlabs/prysm/v5/config/params" "github.com/prysmaticlabs/prysm/v5/monitoring/tracing" "github.com/prysmaticlabs/prysm/v5/time/slots" @@ -99,17 +98,6 @@ func (s *Service) registerRPCHandlersAltair() { } func (s *Service) registerRPCHandlersDeneb() { - if features.Get().EnablePeerDAS { - s.registerRPC( - p2p.RPCDataColumnSidecarsByRootTopicV1, - s.dataColumnSidecarByRootRPCHandler, - ) - s.registerRPC( - p2p.RPCDataColumnSidecarsByRangeTopicV1, - s.dataColumnSidecarsByRangeRPCHandler, - ) - return - } s.registerRPC( p2p.RPCBlobSidecarsByRangeTopicV1, s.blobSidecarsByRangeRPCHandler, @@ -120,6 +108,17 @@ func (s *Service) registerRPCHandlersDeneb() { ) } +func (s *Service) registerRPCHandlersPeerDAS() { + s.registerRPC( + p2p.RPCDataColumnSidecarsByRootTopicV1, + s.dataColumnSidecarByRootRPCHandler, + ) + s.registerRPC( + p2p.RPCDataColumnSidecarsByRangeTopicV1, + s.dataColumnSidecarsByRangeRPCHandler, + ) +} + // Remove all v1 Stream handlers that are no longer supported // from altair onwards. func (s *Service) unregisterPhase0Handlers() { @@ -132,6 +131,14 @@ func (s *Service) unregisterPhase0Handlers() { s.cfg.p2p.Host().RemoveStreamHandler(protocol.ID(fullMetadataTopic)) } +func (s *Service) unregisterBlobHandlers() { + fullBlobRangeTopic := p2p.RPCBlobSidecarsByRangeTopicV1 + s.cfg.p2p.Encoding().ProtocolSuffix() + fullBlobRootTopic := p2p.RPCBlobSidecarsByRootTopicV1 + s.cfg.p2p.Encoding().ProtocolSuffix() + + s.cfg.p2p.Host().RemoveStreamHandler(protocol.ID(fullBlobRangeTopic)) + s.cfg.p2p.Host().RemoveStreamHandler(protocol.ID(fullBlobRootTopic)) +} + // registerRPC for a given topic with an expected protobuf message type. func (s *Service) registerRPC(baseTopic string, handle rpcHandler) { topic := baseTopic + s.cfg.p2p.Encoding().ProtocolSuffix() diff --git a/beacon-chain/sync/rpc_beacon_blocks_by_root.go b/beacon-chain/sync/rpc_beacon_blocks_by_root.go index 0d3486ee632..8dda5333a7c 100644 --- a/beacon-chain/sync/rpc_beacon_blocks_by_root.go +++ b/beacon-chain/sync/rpc_beacon_blocks_by_root.go @@ -9,11 +9,11 @@ import ( "github.com/pkg/errors" "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/peerdas" + coreTime "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/time" "github.com/prysmaticlabs/prysm/v5/beacon-chain/execution" "github.com/prysmaticlabs/prysm/v5/beacon-chain/p2p/types" "github.com/prysmaticlabs/prysm/v5/beacon-chain/sync/verify" "github.com/prysmaticlabs/prysm/v5/beacon-chain/verification" - "github.com/prysmaticlabs/prysm/v5/config/features" fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams" "github.com/prysmaticlabs/prysm/v5/config/params" "github.com/prysmaticlabs/prysm/v5/consensus-types/blocks" @@ -58,7 +58,7 @@ func (s *Service) sendRecentBeaconBlocksRequest(ctx context.Context, requests *t if err != nil { return err } - if features.Get().EnablePeerDAS { + if coreTime.PeerDASIsActive(blk.Block().Slot()) { request, err := s.pendingDataColumnRequestForBlock(blkRoot, blk) if err != nil { return errors.Wrap(err, "pending data column request for block") diff --git a/beacon-chain/sync/rpc_data_column_sidecars_by_root.go b/beacon-chain/sync/rpc_data_column_sidecars_by_root.go index 4dbd344f9cd..a1a9611da91 100644 --- a/beacon-chain/sync/rpc_data_column_sidecars_by_root.go +++ b/beacon-chain/sync/rpc_data_column_sidecars_by_root.go @@ -13,12 +13,12 @@ import ( "go.opencensus.io/trace" "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/peerdas" + coreTime "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/time" "github.com/prysmaticlabs/prysm/v5/beacon-chain/db" "github.com/prysmaticlabs/prysm/v5/beacon-chain/db/filesystem" "github.com/prysmaticlabs/prysm/v5/beacon-chain/p2p" "github.com/prysmaticlabs/prysm/v5/beacon-chain/p2p/types" "github.com/prysmaticlabs/prysm/v5/cmd/beacon-chain/flags" - "github.com/prysmaticlabs/prysm/v5/config/features" "github.com/prysmaticlabs/prysm/v5/config/params" "github.com/prysmaticlabs/prysm/v5/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v5/encoding/bytesutil" @@ -210,12 +210,12 @@ func validateDataColumnsByRootRequest(colIdents types.DataColumnSidecarsByRootRe func DataColumnsRPCMinValidSlot(current primitives.Slot) (primitives.Slot, error) { // Avoid overflow if we're running on a config where deneb is set to far future epoch. - if params.BeaconConfig().DenebForkEpoch == math.MaxUint64 || !features.Get().EnablePeerDAS { + if params.BeaconConfig().DenebForkEpoch == math.MaxUint64 || !coreTime.PeerDASIsActive(current) { return primitives.Slot(math.MaxUint64), nil } minReqEpochs := params.BeaconConfig().MinEpochsForDataColumnSidecarsRequest currEpoch := slots.ToEpoch(current) - minStart := params.BeaconConfig().DenebForkEpoch + minStart := params.BeaconConfig().Eip7594ForkEpoch if currEpoch > minReqEpochs && currEpoch-minReqEpochs > minStart { minStart = currEpoch - minReqEpochs } diff --git a/beacon-chain/sync/service.go b/beacon-chain/sync/service.go index 82cc534b7f0..760f47a0bc9 100644 --- a/beacon-chain/sync/service.go +++ b/beacon-chain/sync/service.go @@ -36,7 +36,6 @@ import ( "github.com/prysmaticlabs/prysm/v5/beacon-chain/sync/backfill/coverage" "github.com/prysmaticlabs/prysm/v5/beacon-chain/verification" lruwrpr "github.com/prysmaticlabs/prysm/v5/cache/lru" - "github.com/prysmaticlabs/prysm/v5/config/features" fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams" "github.com/prysmaticlabs/prysm/v5/config/params" "github.com/prysmaticlabs/prysm/v5/consensus-types/blocks" @@ -253,7 +252,7 @@ func (s *Service) Start() { async.RunEvery(s.ctx, syncMetricsInterval, s.updateMetrics) // Run data column sampling - if features.Get().EnablePeerDAS { + if params.PeerDASEnabled() { go s.DataColumnSamplingRoutine(s.ctx) } } diff --git a/beacon-chain/sync/subscriber.go b/beacon-chain/sync/subscriber.go index 59db95812ae..a7f3a9d54f9 100644 --- a/beacon-chain/sync/subscriber.go +++ b/beacon-chain/sync/subscriber.go @@ -16,6 +16,7 @@ import ( "github.com/prysmaticlabs/prysm/v5/beacon-chain/cache" "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/altair" "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/helpers" + coreTime "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/time" "github.com/prysmaticlabs/prysm/v5/beacon-chain/p2p" "github.com/prysmaticlabs/prysm/v5/beacon-chain/p2p/peers" "github.com/prysmaticlabs/prysm/v5/cmd/beacon-chain/flags" @@ -137,7 +138,7 @@ func (s *Service) registerSubscribers(epoch primitives.Epoch, digest [4]byte) { // New Gossip Topic in Deneb if epoch >= params.BeaconConfig().DenebForkEpoch { - if features.Get().EnablePeerDAS { + if coreTime.PeerDASIsActive(slots.UnsafeEpochStart(epoch)) { if flags.Get().SubscribeToAllSubnets { s.subscribeStaticWithSubnets( p2p.DataColumnSubnetTopicFormat, diff --git a/config/features/config.go b/config/features/config.go index d9f6ca7f5cc..b6d6079506c 100644 --- a/config/features/config.go +++ b/config/features/config.go @@ -72,8 +72,6 @@ type Flags struct { PrepareAllPayloads bool // PrepareAllPayloads informs the engine to prepare a block on every slot. // BlobSaveFsync requires blob saving to block on fsync to ensure blobs are durably persisted before passing DA. BlobSaveFsync bool - // EnablePeerDAS enables running the node with the experimental data availability sampling scheme. - EnablePeerDAS bool // DataColumnsWithholdCount specifies the likelihood of withholding a data column sidecar when proposing a block (percentage) DataColumnsWithholdCount int @@ -259,11 +257,6 @@ func ConfigureBeaconChain(ctx *cli.Context) error { logEnabled(EnableQUIC) cfg.EnableQUIC = true } - cfg.EnablePeerDAS = true - if ctx.IsSet(EnablePeerDAS.Name) { - logEnabled(EnablePeerDAS) - cfg.EnablePeerDAS = true - } if ctx.IsSet(DataColumnsWithholdCount.Name) { logEnabled(DataColumnsWithholdCount) diff --git a/config/features/flags.go b/config/features/flags.go index f275d8d880d..180405864b9 100644 --- a/config/features/flags.go +++ b/config/features/flags.go @@ -171,11 +171,6 @@ var ( Name: "eip6110-validator-cache", Usage: "Enables the EIP-6110 validator cache.", } - // EnablePeerDAS is a flag for enabling the peer data availability sampling. - EnablePeerDAS = &cli.BoolFlag{ - Name: "peer-das", - Usage: "Enables Prysm to run with the experimental peer data availability sampling scheme.", - } // DataColumnsWithholdCount is a flag for withholding data columns when proposing a block. DataColumnsWithholdCount = &cli.IntFlag{ Name: "data-columns-withhold-count", @@ -241,7 +236,6 @@ var BeaconChainFlags = append(deprecatedBeaconFlags, append(deprecatedFlags, []c BlobSaveFsync, EnableQUIC, eip6110ValidatorCache, - EnablePeerDAS, DataColumnsWithholdCount, }...)...) diff --git a/config/params/config.go b/config/params/config.go index 2fa97d04cab..2bbf70e068b 100644 --- a/config/params/config.go +++ b/config/params/config.go @@ -155,20 +155,20 @@ type BeaconChainConfig struct { SlashingProtectionPruningEpochs primitives.Epoch // SlashingProtectionPruningEpochs defines a period after which all prior epochs are pruned in the validator database. // Fork-related values. - GenesisForkVersion []byte `yaml:"GENESIS_FORK_VERSION" spec:"true"` // GenesisForkVersion is used to track fork version between state transitions. - AltairForkVersion []byte `yaml:"ALTAIR_FORK_VERSION" spec:"true"` // AltairForkVersion is used to represent the fork version for altair. - AltairForkEpoch primitives.Epoch `yaml:"ALTAIR_FORK_EPOCH" spec:"true"` // AltairForkEpoch is used to represent the assigned fork epoch for altair. - BellatrixForkVersion []byte `yaml:"BELLATRIX_FORK_VERSION" spec:"true"` // BellatrixForkVersion is used to represent the fork version for bellatrix. - BellatrixForkEpoch primitives.Epoch `yaml:"BELLATRIX_FORK_EPOCH" spec:"true"` // BellatrixForkEpoch is used to represent the assigned fork epoch for bellatrix. - CapellaForkVersion []byte `yaml:"CAPELLA_FORK_VERSION" spec:"true"` // CapellaForkVersion is used to represent the fork version for capella. - CapellaForkEpoch primitives.Epoch `yaml:"CAPELLA_FORK_EPOCH" spec:"true"` // CapellaForkEpoch is used to represent the assigned fork epoch for capella. - DenebForkVersion []byte `yaml:"DENEB_FORK_VERSION" spec:"true"` // DenebForkVersion is used to represent the fork version for deneb. - 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 deneb. - ElectraForkEpoch primitives.Epoch `yaml:"ELECTRA_FORK_EPOCH" spec:"true"` // ElectraForkEpoch is used to represent the assigned fork epoch for deneb. - - 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. + GenesisForkVersion []byte `yaml:"GENESIS_FORK_VERSION" spec:"true"` // GenesisForkVersion is used to track fork version between state transitions. + AltairForkVersion []byte `yaml:"ALTAIR_FORK_VERSION" spec:"true"` // AltairForkVersion is used to represent the fork version for altair. + AltairForkEpoch primitives.Epoch `yaml:"ALTAIR_FORK_EPOCH" spec:"true"` // AltairForkEpoch is used to represent the assigned fork epoch for altair. + BellatrixForkVersion []byte `yaml:"BELLATRIX_FORK_VERSION" spec:"true"` // BellatrixForkVersion is used to represent the fork version for bellatrix. + BellatrixForkEpoch primitives.Epoch `yaml:"BELLATRIX_FORK_EPOCH" spec:"true"` // BellatrixForkEpoch is used to represent the assigned fork epoch for bellatrix. + CapellaForkVersion []byte `yaml:"CAPELLA_FORK_VERSION" spec:"true"` // CapellaForkVersion is used to represent the fork version for capella. + CapellaForkEpoch primitives.Epoch `yaml:"CAPELLA_FORK_EPOCH" spec:"true"` // CapellaForkEpoch is used to represent the assigned fork epoch for capella. + DenebForkVersion []byte `yaml:"DENEB_FORK_VERSION" spec:"true"` // DenebForkVersion is used to represent the fork version for deneb. + 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 deneb. + ElectraForkEpoch primitives.Epoch `yaml:"ELECTRA_FORK_EPOCH" spec:"true"` // ElectraForkEpoch is used to represent the assigned fork epoch for deneb. + 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. // Weak subjectivity values. SafetyDecay uint64 // SafetyDecay is defined as the loss in the 1/3 consensus safety margin of the casper FFG mechanism. @@ -361,6 +361,12 @@ func DenebEnabled() bool { return BeaconConfig().DenebForkEpoch < math.MaxUint64 } +// PeerDASEnabled centralizes the check to determine if code paths +// that are specific to peerdas should be allowed to execute. +func PeerDASEnabled() bool { + return BeaconConfig().Eip7594ForkEpoch < math.MaxUint64 +} + // WithinDAPeriod checks if the block epoch is within MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS of the given current epoch. func WithinDAPeriod(block, current primitives.Epoch) bool { return block+BeaconConfig().MinEpochsForBlobsSidecarsRequest >= current diff --git a/config/params/loader.go b/config/params/loader.go index 6a435906412..471f2361f0e 100644 --- a/config/params/loader.go +++ b/config/params/loader.go @@ -216,6 +216,7 @@ func ConfigToYaml(cfg *BeaconChainConfig) []byte { fmt.Sprintf("DENEB_FORK_VERSION: %#x", cfg.DenebForkVersion), 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("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), diff --git a/config/params/loader_test.go b/config/params/loader_test.go index 09b9491f2b1..d779159fd48 100644 --- a/config/params/loader_test.go +++ b/config/params/loader_test.go @@ -29,7 +29,6 @@ var placeholderFields = []string{ "EIP6110_FORK_VERSION", "EIP7002_FORK_EPOCH", "EIP7002_FORK_VERSION", - "EIP7594_FORK_EPOCH", "EIP7594_FORK_VERSION", "FIELD_ELEMENTS_PER_BLOB", // Compile time constant. "KZG_COMMITMENT_INCLUSION_PROOF_DEPTH", // Compile time constant on BlobSidecar.commitment_inclusion_proof. diff --git a/config/params/mainnet_config.go b/config/params/mainnet_config.go index d942687733e..501713898ce 100644 --- a/config/params/mainnet_config.go +++ b/config/params/mainnet_config.go @@ -216,6 +216,7 @@ var mainnetBeaconConfig = &BeaconChainConfig{ DenebForkEpoch: mainnetDenebForkEpoch, ElectraForkVersion: []byte{5, 0, 0, 0}, ElectraForkEpoch: mainnetElectraForkEpoch, + Eip7594ForkEpoch: math.MaxUint64, // New values introduced in Altair hard fork 1. // Participation flag indices. diff --git a/config/params/minimal_config.go b/config/params/minimal_config.go index 0fd7d0fb378..34d8f5385d3 100644 --- a/config/params/minimal_config.go +++ b/config/params/minimal_config.go @@ -95,6 +95,7 @@ func MinimalSpecConfig() *BeaconChainConfig { minimalConfig.DenebForkEpoch = math.MaxUint64 minimalConfig.ElectraForkVersion = []byte{5, 0, 0, 1} minimalConfig.ElectraForkEpoch = math.MaxUint64 + minimalConfig.Eip7594ForkEpoch = math.MaxUint64 minimalConfig.SyncCommitteeSize = 32 minimalConfig.InactivityScoreBias = 4 diff --git a/config/params/testnet_e2e_config.go b/config/params/testnet_e2e_config.go index a82c02ec16b..31031b942f2 100644 --- a/config/params/testnet_e2e_config.go +++ b/config/params/testnet_e2e_config.go @@ -44,6 +44,7 @@ func E2ETestConfig() *BeaconChainConfig { e2eConfig.CapellaForkEpoch = CapellaE2EForkEpoch e2eConfig.DenebForkEpoch = DenebE2EForkEpoch e2eConfig.ElectraForkEpoch = ElectraE2EForkEpoch + e2eConfig.Eip7594ForkEpoch = ElectraE2EForkEpoch // Terminal Total Difficulty. e2eConfig.TerminalTotalDifficulty = "480" @@ -88,6 +89,7 @@ func E2EMainnetTestConfig() *BeaconChainConfig { e2eConfig.CapellaForkEpoch = CapellaE2EForkEpoch e2eConfig.DenebForkEpoch = DenebE2EForkEpoch e2eConfig.ElectraForkEpoch = ElectraE2EForkEpoch + e2eConfig.Eip7594ForkEpoch = ElectraE2EForkEpoch // Terminal Total Difficulty. e2eConfig.TerminalTotalDifficulty = "480" diff --git a/config/params/testnet_holesky_config.go b/config/params/testnet_holesky_config.go index 66bf9bd23fc..30e0af9b0c8 100644 --- a/config/params/testnet_holesky_config.go +++ b/config/params/testnet_holesky_config.go @@ -39,6 +39,7 @@ func HoleskyConfig() *BeaconChainConfig { cfg.DenebForkEpoch = 29696 cfg.DenebForkVersion = []byte{0x05, 0x1, 0x70, 0x0} cfg.ElectraForkEpoch = math.MaxUint64 + cfg.Eip7594ForkEpoch = math.MaxUint64 cfg.ElectraForkVersion = []byte{0x06, 0x1, 0x70, 0x0} // TODO: Define holesky fork version for electra. This is a placeholder value. cfg.TerminalTotalDifficulty = "0" cfg.DepositContractAddress = "0x4242424242424242424242424242424242424242" diff --git a/config/params/testnet_sepolia_config.go b/config/params/testnet_sepolia_config.go index 0df3e1e51d0..1e027e6cb77 100644 --- a/config/params/testnet_sepolia_config.go +++ b/config/params/testnet_sepolia_config.go @@ -41,6 +41,7 @@ func SepoliaConfig() *BeaconChainConfig { cfg.DenebForkVersion = []byte{0x90, 0x00, 0x00, 0x73} cfg.ElectraForkEpoch = math.MaxUint64 cfg.ElectraForkVersion = []byte{0x90, 0x00, 0x00, 0x74} // TODO: Define sepolia fork version for electra. This is a placeholder value. + cfg.Eip7594ForkEpoch = math.MaxUint64 cfg.TerminalTotalDifficulty = "17000000000000000" cfg.DepositContractAddress = "0x7f02C3E3c98b133055B8B348B2Ac625669Ed295D" cfg.InitializeForkSchedule() From 8d17cd33e09f34fe4a32b9f1f670ab7425d23242 Mon Sep 17 00:00:00 2001 From: nisdas Date: Thu, 4 Jul 2024 18:17:39 +0800 Subject: [PATCH 2/6] Add check for data sampling --- beacon-chain/sync/data_columns_sampling.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/beacon-chain/sync/data_columns_sampling.go b/beacon-chain/sync/data_columns_sampling.go index 156d608289d..7e246e89cd0 100644 --- a/beacon-chain/sync/data_columns_sampling.go +++ b/beacon-chain/sync/data_columns_sampling.go @@ -7,6 +7,7 @@ import ( "github.com/libp2p/go-libp2p/core/peer" "github.com/pkg/errors" + coreTime "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/time" "github.com/sirupsen/logrus" "github.com/prysmaticlabs/prysm/v5/beacon-chain/core/feed" @@ -356,6 +357,10 @@ func (s *Service) DataColumnSamplingRoutine(ctx context.Context) { log.Debug("Pre Deneb block, skipping data column sampling") continue } + if coreTime.PeerDASIsActive(data.Slot) { + // We do not trigger sampling if peerDAS is not active yet. + continue + } // Get the commitments for this block. commitments, err := data.SignedBlock.Block().Body().BlobKzgCommitments() From d2e4ffd5d4b4a135288a7de2be0fdffef5c01dec Mon Sep 17 00:00:00 2001 From: nisdas Date: Thu, 4 Jul 2024 18:24:08 +0800 Subject: [PATCH 3/6] Fix Test --- beacon-chain/p2p/discovery_test.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/beacon-chain/p2p/discovery_test.go b/beacon-chain/p2p/discovery_test.go index f187d53f99b..24281f7f40d 100644 --- a/beacon-chain/p2p/discovery_test.go +++ b/beacon-chain/p2p/discovery_test.go @@ -30,7 +30,6 @@ import ( "github.com/prysmaticlabs/prysm/v5/beacon-chain/p2p/peers/scorers" testp2p "github.com/prysmaticlabs/prysm/v5/beacon-chain/p2p/testing" "github.com/prysmaticlabs/prysm/v5/beacon-chain/startup" - "github.com/prysmaticlabs/prysm/v5/config/features" "github.com/prysmaticlabs/prysm/v5/config/params" "github.com/prysmaticlabs/prysm/v5/consensus-types/wrapper" leakybucket "github.com/prysmaticlabs/prysm/v5/container/leaky-bucket" @@ -134,11 +133,10 @@ func TestStartDiscV5_DiscoverAllPeers(t *testing.T) { } func TestCreateLocalNode(t *testing.T) { - resetFn := features.InitWithReset(&features.Flags{ - EnablePeerDAS: true, - }) - defer resetFn() - + params.SetupTestConfigCleanup(t) + cfg := params.BeaconConfig() + cfg.Eip7594ForkEpoch = 1 + params.OverrideBeaconConfig(cfg) testCases := []struct { name string cfg *Config From 401e2846148eb3948c7f63ecdd78c579f1561afb Mon Sep 17 00:00:00 2001 From: nisdas Date: Thu, 4 Jul 2024 19:07:31 +0800 Subject: [PATCH 4/6] Gazelle --- beacon-chain/p2p/BUILD.bazel | 1 - 1 file changed, 1 deletion(-) diff --git a/beacon-chain/p2p/BUILD.bazel b/beacon-chain/p2p/BUILD.bazel index bd0b49be5c3..a8de38a2a8a 100644 --- a/beacon-chain/p2p/BUILD.bazel +++ b/beacon-chain/p2p/BUILD.bazel @@ -157,7 +157,6 @@ go_test( "//beacon-chain/p2p/types:go_default_library", "//beacon-chain/startup:go_default_library", "//cmd/beacon-chain/flags:go_default_library", - "//config/features:go_default_library", "//config/fieldparams:go_default_library", "//config/params:go_default_library", "//consensus-types/blocks:go_default_library", From 047f9dfaf90c8333ad62407cffb8a6f868de118e Mon Sep 17 00:00:00 2001 From: nisdas Date: Mon, 8 Jul 2024 12:23:54 +0800 Subject: [PATCH 5/6] Manu's Review --- config/params/config.go | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/config/params/config.go b/config/params/config.go index 2bbf70e068b..d64656167b4 100644 --- a/config/params/config.go +++ b/config/params/config.go @@ -155,20 +155,21 @@ type BeaconChainConfig struct { SlashingProtectionPruningEpochs primitives.Epoch // SlashingProtectionPruningEpochs defines a period after which all prior epochs are pruned in the validator database. // Fork-related values. - GenesisForkVersion []byte `yaml:"GENESIS_FORK_VERSION" spec:"true"` // GenesisForkVersion is used to track fork version between state transitions. - AltairForkVersion []byte `yaml:"ALTAIR_FORK_VERSION" spec:"true"` // AltairForkVersion is used to represent the fork version for altair. - AltairForkEpoch primitives.Epoch `yaml:"ALTAIR_FORK_EPOCH" spec:"true"` // AltairForkEpoch is used to represent the assigned fork epoch for altair. - BellatrixForkVersion []byte `yaml:"BELLATRIX_FORK_VERSION" spec:"true"` // BellatrixForkVersion is used to represent the fork version for bellatrix. - BellatrixForkEpoch primitives.Epoch `yaml:"BELLATRIX_FORK_EPOCH" spec:"true"` // BellatrixForkEpoch is used to represent the assigned fork epoch for bellatrix. - CapellaForkVersion []byte `yaml:"CAPELLA_FORK_VERSION" spec:"true"` // CapellaForkVersion is used to represent the fork version for capella. - CapellaForkEpoch primitives.Epoch `yaml:"CAPELLA_FORK_EPOCH" spec:"true"` // CapellaForkEpoch is used to represent the assigned fork epoch for capella. - DenebForkVersion []byte `yaml:"DENEB_FORK_VERSION" spec:"true"` // DenebForkVersion is used to represent the fork version for deneb. - 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 deneb. - ElectraForkEpoch primitives.Epoch `yaml:"ELECTRA_FORK_EPOCH" spec:"true"` // ElectraForkEpoch is used to represent the assigned fork epoch for deneb. - 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. + GenesisForkVersion []byte `yaml:"GENESIS_FORK_VERSION" spec:"true"` // GenesisForkVersion is used to track fork version between state transitions. + AltairForkVersion []byte `yaml:"ALTAIR_FORK_VERSION" spec:"true"` // AltairForkVersion is used to represent the fork version for altair. + AltairForkEpoch primitives.Epoch `yaml:"ALTAIR_FORK_EPOCH" spec:"true"` // AltairForkEpoch is used to represent the assigned fork epoch for altair. + BellatrixForkVersion []byte `yaml:"BELLATRIX_FORK_VERSION" spec:"true"` // BellatrixForkVersion is used to represent the fork version for bellatrix. + BellatrixForkEpoch primitives.Epoch `yaml:"BELLATRIX_FORK_EPOCH" spec:"true"` // BellatrixForkEpoch is used to represent the assigned fork epoch for bellatrix. + CapellaForkVersion []byte `yaml:"CAPELLA_FORK_VERSION" spec:"true"` // CapellaForkVersion is used to represent the fork version for capella. + CapellaForkEpoch primitives.Epoch `yaml:"CAPELLA_FORK_EPOCH" spec:"true"` // CapellaForkEpoch is used to represent the assigned fork epoch for capella. + DenebForkVersion []byte `yaml:"DENEB_FORK_VERSION" spec:"true"` // DenebForkVersion is used to represent the fork version for deneb. + 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 deneb. + ElectraForkEpoch primitives.Epoch `yaml:"ELECTRA_FORK_EPOCH" spec:"true"` // ElectraForkEpoch is used to represent the assigned fork epoch for deneb. + 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. // Weak subjectivity values. SafetyDecay uint64 // SafetyDecay is defined as the loss in the 1/3 consensus safety margin of the casper FFG mechanism. From cf7419a62aef1255f138394ff49ed3f5db305585 Mon Sep 17 00:00:00 2001 From: nisdas Date: Mon, 8 Jul 2024 12:27:47 +0800 Subject: [PATCH 6/6] Fix Test --- beacon-chain/rpc/eth/config/handlers_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/beacon-chain/rpc/eth/config/handlers_test.go b/beacon-chain/rpc/eth/config/handlers_test.go index 18a5159da58..ee0c8f6aee8 100644 --- a/beacon-chain/rpc/eth/config/handlers_test.go +++ b/beacon-chain/rpc/eth/config/handlers_test.go @@ -80,6 +80,7 @@ func TestGetSpec(t *testing.T) { config.DenebForkEpoch = 105 config.ElectraForkVersion = []byte("ElectraForkVersion") config.ElectraForkEpoch = 107 + config.Eip7594ForkEpoch = 109 config.BLSWithdrawalPrefixByte = byte('b') config.ETH1AddressWithdrawalPrefixByte = byte('c') config.GenesisDelay = 24 @@ -193,7 +194,7 @@ func TestGetSpec(t *testing.T) { data, ok := resp.Data.(map[string]interface{}) require.Equal(t, true, ok) - assert.Equal(t, 155, len(data)) + assert.Equal(t, 156, len(data)) for k, v := range data { t.Run(k, func(t *testing.T) { switch k { @@ -271,6 +272,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_EPOCH": + assert.Equal(t, "109", v) case "MIN_ANCHOR_POW_BLOCK_DIFFICULTY": assert.Equal(t, "1000", v) case "BLS_WITHDRAWAL_PREFIX":