From 56f53e416f55811713fa3ab5685a7d7898625735 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Thu, 9 Jan 2025 08:54:09 -0800 Subject: [PATCH 1/3] Update blobs by range rpc topics to v1 --- CHANGELOG.md | 1 + beacon-chain/p2p/rpc_topic_mappings.go | 3 --- beacon-chain/sync/rate_limiter.go | 2 -- beacon-chain/sync/rpc.go | 4 ++-- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1329a57bdeff..3a53112a0a35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve - Re-organize the content of files to ease the creation of a new fork boilerplate. - Fixed Metadata errors for peers connected via QUIC. - Process light client finality updates only for new finalized epochs instead of doing it for every block. +- Update blobs by rpc topics from V2 to V1. ### Deprecated diff --git a/beacon-chain/p2p/rpc_topic_mappings.go b/beacon-chain/p2p/rpc_topic_mappings.go index a50555e82edc..7d9c5ebdff0a 100644 --- a/beacon-chain/p2p/rpc_topic_mappings.go +++ b/beacon-chain/p2p/rpc_topic_mappings.go @@ -73,9 +73,6 @@ const ( RPCBlocksByRootTopicV2 = protocolPrefix + BeaconBlocksByRootsMessageName + SchemaVersionV2 // RPCMetaDataTopicV2 defines the v2 topic for the metadata rpc method. RPCMetaDataTopicV2 = protocolPrefix + MetadataMessageName + SchemaVersionV2 - - RPCBlobSidecarsByRangeTopicV2 = protocolPrefix + BlobSidecarsByRangeName + SchemaVersionV2 - RPCBlobSidecarsByRootTopicV2 = protocolPrefix + BlobSidecarsByRootName + SchemaVersionV2 ) // RPC errors for topic parsing. diff --git a/beacon-chain/sync/rate_limiter.go b/beacon-chain/sync/rate_limiter.go index 4c1a824dc067..5d088f5002a1 100644 --- a/beacon-chain/sync/rate_limiter.go +++ b/beacon-chain/sync/rate_limiter.go @@ -79,8 +79,6 @@ func newRateLimiter(p2pProvider p2p.P2P) *limiter { topicMap[addEncoding(p2p.RPCBlobSidecarsByRootTopicV1)] = blobCollector // BlobSidecarsByRangeV1 topicMap[addEncoding(p2p.RPCBlobSidecarsByRangeTopicV1)] = blobCollector - topicMap[addEncoding(p2p.RPCBlobSidecarsByRootTopicV2)] = blobCollector - topicMap[addEncoding(p2p.RPCBlobSidecarsByRangeTopicV2)] = blobCollector // General topic for all rpc requests. topicMap[rpcLimiterTopic] = leakybucket.NewCollector(5, defaultBurstLimit*2, leakyBucketPeriod, false /* deleteEmptyBuckets */) diff --git a/beacon-chain/sync/rpc.go b/beacon-chain/sync/rpc.go index c04c8621ea03..1157976865c2 100644 --- a/beacon-chain/sync/rpc.go +++ b/beacon-chain/sync/rpc.go @@ -47,8 +47,8 @@ func (s *Service) rpcHandlerByTopicFromFork(forkIndex int) (map[string]rpcHandle p2p.RPCBlocksByRootTopicV2: s.beaconBlocksRootRPCHandler, p2p.RPCPingTopicV1: s.pingHandler, p2p.RPCMetaDataTopicV2: s.metaDataHandler, - p2p.RPCBlobSidecarsByRootTopicV2: s.blobSidecarByRootRPCHandler, // Modified in Electra - p2p.RPCBlobSidecarsByRangeTopicV2: s.blobSidecarsByRangeRPCHandler, // Modified in Electra + p2p.RPCBlobSidecarsByRootTopicV1: s.blobSidecarByRootRPCHandler, // Modified in Electra + p2p.RPCBlobSidecarsByRangeTopicV1: s.blobSidecarsByRangeRPCHandler, // Modified in Electra }, nil } From 01c12ef3aaf89139c5bca5163e5292c5c4efff13 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Thu, 9 Jan 2025 08:54:09 -0800 Subject: [PATCH 2/3] Update blobs by range rpc topics to v1 --- beacon-chain/sync/blobs_test.go | 4 ---- beacon-chain/sync/fork_watcher_test.go | 8 ++++---- beacon-chain/sync/rate_limiter_test.go | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/beacon-chain/sync/blobs_test.go b/beacon-chain/sync/blobs_test.go index 0bdabb957b7b..8415a8c4fec1 100644 --- a/beacon-chain/sync/blobs_test.go +++ b/beacon-chain/sync/blobs_test.go @@ -220,12 +220,8 @@ func (c *blobsTestCase) setup(t *testing.T) (*Service, []blocks.ROBlob, func()) byRootRate := params.BeaconConfig().MaxRequestBlobSidecars * uint64(params.BeaconConfig().MaxBlobsPerBlock(0)) byRangeRate := params.BeaconConfig().MaxRequestBlobSidecars * uint64(params.BeaconConfig().MaxBlobsPerBlock(0)) - byRootRateElectra := params.BeaconConfig().MaxRequestBlobSidecarsElectra * uint64(params.BeaconConfig().MaxBlobsPerBlock(0)) - byRangeRateElectra := params.BeaconConfig().MaxRequestBlobSidecarsElectra * uint64(params.BeaconConfig().MaxBlobsPerBlock(0)) s.setRateCollector(p2p.RPCBlobSidecarsByRootTopicV1, leakybucket.NewCollector(0.000001, int64(byRootRate), time.Second, false)) s.setRateCollector(p2p.RPCBlobSidecarsByRangeTopicV1, leakybucket.NewCollector(0.000001, int64(byRangeRate), time.Second, false)) - s.setRateCollector(p2p.RPCBlobSidecarsByRootTopicV2, leakybucket.NewCollector(0.000001, int64(byRootRateElectra), time.Second, false)) - s.setRateCollector(p2p.RPCBlobSidecarsByRangeTopicV2, leakybucket.NewCollector(0.000001, int64(byRangeRateElectra), time.Second, false)) return s, sidecars, cleanup } diff --git a/beacon-chain/sync/fork_watcher_test.go b/beacon-chain/sync/fork_watcher_test.go index bc256ec7bd9b..223117a6bc70 100644 --- a/beacon-chain/sync/fork_watcher_test.go +++ b/beacon-chain/sync/fork_watcher_test.go @@ -228,8 +228,8 @@ func TestService_CheckForNextEpochFork(t *testing.T) { for _, p := range s.cfg.p2p.Host().Mux().Protocols() { rpcMap[string(p)] = true } - assert.Equal(t, true, rpcMap[p2p.RPCBlobSidecarsByRangeTopicV2+s.cfg.p2p.Encoding().ProtocolSuffix()], "topic doesn't exist") - assert.Equal(t, true, rpcMap[p2p.RPCBlobSidecarsByRootTopicV2+s.cfg.p2p.Encoding().ProtocolSuffix()], "topic doesn't exist") + assert.Equal(t, true, rpcMap[p2p.RPCBlobSidecarsByRangeTopicV1+s.cfg.p2p.Encoding().ProtocolSuffix()], "topic doesn't exist") + assert.Equal(t, true, rpcMap[p2p.RPCBlobSidecarsByRootTopicV1+s.cfg.p2p.Encoding().ProtocolSuffix()], "topic doesn't exist") }, }, { @@ -272,8 +272,8 @@ func TestService_CheckForNextEpochFork(t *testing.T) { for _, p := range s.cfg.p2p.Host().Mux().Protocols() { rpcMap[string(p)] = true } - assert.Equal(t, true, rpcMap[p2p.RPCBlobSidecarsByRangeTopicV2+s.cfg.p2p.Encoding().ProtocolSuffix()], "topic doesn't exist") - assert.Equal(t, true, rpcMap[p2p.RPCBlobSidecarsByRootTopicV2+s.cfg.p2p.Encoding().ProtocolSuffix()], "topic doesn't exist") + assert.Equal(t, true, rpcMap[p2p.RPCBlobSidecarsByRangeTopicV1+s.cfg.p2p.Encoding().ProtocolSuffix()], "topic doesn't exist") + assert.Equal(t, true, rpcMap[p2p.RPCBlobSidecarsByRootTopicV1+s.cfg.p2p.Encoding().ProtocolSuffix()], "topic doesn't exist") }, }, } diff --git a/beacon-chain/sync/rate_limiter_test.go b/beacon-chain/sync/rate_limiter_test.go index f3f7b85729af..653581103147 100644 --- a/beacon-chain/sync/rate_limiter_test.go +++ b/beacon-chain/sync/rate_limiter_test.go @@ -18,7 +18,7 @@ import ( func TestNewRateLimiter(t *testing.T) { rlimiter := newRateLimiter(mockp2p.NewTestP2P(t)) - assert.Equal(t, len(rlimiter.limiterMap), 14, "correct number of topics not registered") + assert.Equal(t, len(rlimiter.limiterMap), 12, "correct number of topics not registered") } func TestNewRateLimiter_FreeCorrectly(t *testing.T) { From 9688b902146bc1cd0c2b428fc0617fb77d65d5e0 Mon Sep 17 00:00:00 2001 From: Manu NALEPA Date: Fri, 10 Jan 2025 10:14:24 +0100 Subject: [PATCH 3/3] RPC handler comments: Use "Added", "Modified" and "Upgraded". - Added: No message with this message name was previously existing. - Upgraded: A message with this message name was existing in the previous fork, but the schema version is upgraded in the current fork. - Modified: The couple message name, schema version is the same than in the previous fork, but the implementation of the handler is modified in the current fork. --- beacon-chain/sync/rpc.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/beacon-chain/sync/rpc.go b/beacon-chain/sync/rpc.go index 1157976865c2..f931db7f2ee5 100644 --- a/beacon-chain/sync/rpc.go +++ b/beacon-chain/sync/rpc.go @@ -57,8 +57,8 @@ func (s *Service) rpcHandlerByTopicFromFork(forkIndex int) (map[string]rpcHandle return map[string]rpcHandler{ p2p.RPCStatusTopicV1: s.statusRPCHandler, p2p.RPCGoodByeTopicV1: s.goodbyeRPCHandler, - p2p.RPCBlocksByRangeTopicV2: s.beaconBlocksByRangeRPCHandler, - p2p.RPCBlocksByRootTopicV2: s.beaconBlocksRootRPCHandler, + p2p.RPCBlocksByRangeTopicV2: s.beaconBlocksByRangeRPCHandler, // Modified in Deneb + p2p.RPCBlocksByRootTopicV2: s.beaconBlocksRootRPCHandler, // Modified in Deneb p2p.RPCPingTopicV1: s.pingHandler, p2p.RPCMetaDataTopicV2: s.metaDataHandler, p2p.RPCBlobSidecarsByRootTopicV1: s.blobSidecarByRootRPCHandler, // Added in Deneb @@ -73,10 +73,10 @@ func (s *Service) rpcHandlerByTopicFromFork(forkIndex int) (map[string]rpcHandle return map[string]rpcHandler{ p2p.RPCStatusTopicV1: s.statusRPCHandler, p2p.RPCGoodByeTopicV1: s.goodbyeRPCHandler, - p2p.RPCBlocksByRangeTopicV2: s.beaconBlocksByRangeRPCHandler, // Modified in Altair - p2p.RPCBlocksByRootTopicV2: s.beaconBlocksRootRPCHandler, // Modified in Altair + p2p.RPCBlocksByRangeTopicV2: s.beaconBlocksByRangeRPCHandler, // Updated in Altair and modified in Capella + p2p.RPCBlocksByRootTopicV2: s.beaconBlocksRootRPCHandler, // Updated in Altair and modified in Capella p2p.RPCPingTopicV1: s.pingHandler, - p2p.RPCMetaDataTopicV2: s.metaDataHandler, // Modified in Altair + p2p.RPCMetaDataTopicV2: s.metaDataHandler, // Updated in Altair }, nil }