Skip to content

Commit ab3a1d2

Browse files
authored
Remove propagation of lightclient updates (#7192)
1 parent 70bc7f7 commit ab3a1d2

File tree

6 files changed

+49
-7
lines changed

6 files changed

+49
-7
lines changed

cl/rpc/rpc.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,15 @@ func (b *BeaconRpcP2P) SetStatus(finalizedRoot libcommon.Hash, finalizedEpoch ui
272272
})
273273
return err
274274
}
275+
276+
func (b *BeaconRpcP2P) PropagateBlock(block *cltypes.SignedBeaconBlock) error {
277+
encoded, err := block.EncodeSSZ(nil)
278+
if err != nil {
279+
return err
280+
}
281+
_, err = b.sentinel.PublishGossip(b.ctx, &sentinel.GossipData{
282+
Data: encoded,
283+
Type: sentinel.GossipType_BeaconBlockGossipType,
284+
})
285+
return err
286+
}

cmd/sentinel/sentinel/gossip.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"fmt"
2020
"sync"
2121

22-
"github.com/ledgerwatch/erigon/common"
2322
"github.com/ledgerwatch/log/v3"
2423
pubsub "github.com/libp2p/go-libp2p-pubsub"
2524
"github.com/libp2p/go-libp2p/core/peer"
@@ -102,9 +101,10 @@ func (s *GossipSubscription) do(ctx context.Context, sub *pubsub.Subscription, t
102101
if msg.GetFrom() == s.host {
103102
return
104103
}
105-
if err := s.topic.Publish(ctx, common.CopyBytes(msg.Data)); err != nil {
106-
return
107-
}
108104
s.ch <- msg
109105
}
110106
}
107+
108+
func (g *GossipSubscription) Publish(data []byte) error {
109+
return g.topic.Publish(g.ctx, data)
110+
}

cmd/sentinel/sentinel/sentinel.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,7 @@ func (s *Sentinel) Host() host.Host {
270270
func (s *Sentinel) Peers() *peers.Peers {
271271
return s.peers
272272
}
273+
274+
func (s *Sentinel) GossipManager() *GossipManager {
275+
return s.subManager
276+
}

cmd/sentinel/sentinel/service/service.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,32 @@ func (s *SentinelServer) BanPeer(_ context.Context, p *sentinelrpc.Peer) (*senti
4444
return &sentinelrpc.EmptyMessage{}, nil
4545
}
4646

47+
func (s *SentinelServer) PublishGossip(_ context.Context, msg *sentinelrpc.GossipData) (*sentinelrpc.EmptyMessage, error) {
48+
manager := s.sentinel.GossipManager()
49+
// Snappify payload before sending it to gossip
50+
compressedData := utils.CompressSnappy(msg.Data)
51+
var subscription *sentinel.GossipSubscription
52+
53+
switch msg.Type {
54+
case sentinelrpc.GossipType_BeaconBlockGossipType:
55+
subscription = manager.GetMatchingSubscription(string(sentinel.BeaconBlockTopic))
56+
case sentinelrpc.GossipType_AggregateAndProofGossipType:
57+
subscription = manager.GetMatchingSubscription(string(sentinel.BeaconAggregateAndProofTopic))
58+
case sentinelrpc.GossipType_VoluntaryExitGossipType:
59+
subscription = manager.GetMatchingSubscription(string(sentinel.VoluntaryExitTopic))
60+
case sentinelrpc.GossipType_ProposerSlashingGossipType:
61+
subscription = manager.GetMatchingSubscription(string(sentinel.ProposerSlashingTopic))
62+
case sentinelrpc.GossipType_AttesterSlashingGossipType:
63+
subscription = manager.GetMatchingSubscription(string(sentinel.AttesterSlashingTopic))
64+
default:
65+
return &sentinelrpc.EmptyMessage{}, nil
66+
}
67+
if subscription == nil {
68+
return &sentinelrpc.EmptyMessage{}, nil
69+
}
70+
return &sentinelrpc.EmptyMessage{}, subscription.Publish(compressedData)
71+
}
72+
4773
func (s *SentinelServer) SubscribeGossip(_ *sentinelrpc.EmptyMessage, stream sentinelrpc.Sentinel_SubscribeGossipServer) error {
4874
// first of all subscribe
4975
ch, subId, err := s.gossipNotifier.addSubscriber()

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/ledgerwatch/erigon
33
go 1.19
44

55
require (
6-
github.com/ledgerwatch/erigon-lib v0.0.0-20230325072849-9f1fc3dd0d0c
6+
github.com/ledgerwatch/erigon-lib v0.0.0-20230327103053-23fe5e817bfa
77
github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20230306083105-1391330d62a3
88
github.com/ledgerwatch/log/v3 v3.7.0
99
github.com/ledgerwatch/secp256k1 v1.0.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
519519
github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758 h1:0D5M2HQSGD3PYPwICLl+/9oulQauOuETfgFvhBDffs0=
520520
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
521521
github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
522-
github.com/ledgerwatch/erigon-lib v0.0.0-20230325072849-9f1fc3dd0d0c h1:Ba+HaeqlyMLlN/HzDsYw8IXyzkN+IJabAiP2jV3OvVE=
523-
github.com/ledgerwatch/erigon-lib v0.0.0-20230325072849-9f1fc3dd0d0c/go.mod h1:CkP5qnLv68u1AAHHamS7TBgPmlPBn0aVcPrHi7njrIU=
522+
github.com/ledgerwatch/erigon-lib v0.0.0-20230327103053-23fe5e817bfa h1:2d7REYLaoY5tqhdP4qH6P7QNl7SbNO7JjTEUMq5x7s4=
523+
github.com/ledgerwatch/erigon-lib v0.0.0-20230327103053-23fe5e817bfa/go.mod h1:JCt4IGL5ZAS1XGTFgSs2RSOxiTw3XX5PrkKjwhiI8Mo=
524524
github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20230306083105-1391330d62a3 h1:tfzawK1gIIgRjVZeANXOr0Ziu+kqCIBuKMe0TXfl5Aw=
525525
github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20230306083105-1391330d62a3/go.mod h1:3AuPxZc85jkehh/HA9h8gabv5MSi3kb/ddtzBsTVJFo=
526526
github.com/ledgerwatch/log/v3 v3.7.0 h1:aFPEZdwZx4jzA3+/Pf8wNDN5tCI0cIolq/kfvgcM+og=

0 commit comments

Comments
 (0)