Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove propagation of lightclient updates #7192

Merged
merged 2 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cl/rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,15 @@ func (b *BeaconRpcP2P) SetStatus(finalizedRoot libcommon.Hash, finalizedEpoch ui
})
return err
}

func (b *BeaconRpcP2P) PropagateBlock(block *cltypes.SignedBeaconBlock) error {
encoded, err := block.EncodeSSZ(nil)
if err != nil {
return err
}
_, err = b.sentinel.PublishGossip(b.ctx, &sentinel.GossipData{
Data: encoded,
Type: sentinel.GossipType_BeaconBlockGossipType,
})
return err
}
8 changes: 4 additions & 4 deletions cmd/sentinel/sentinel/gossip.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"fmt"
"sync"

"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/log/v3"
pubsub "github.com/libp2p/go-libp2p-pubsub"
"github.com/libp2p/go-libp2p/core/peer"
Expand Down Expand Up @@ -102,9 +101,10 @@ func (s *GossipSubscription) do(ctx context.Context, sub *pubsub.Subscription, t
if msg.GetFrom() == s.host {
return
}
if err := s.topic.Publish(ctx, common.CopyBytes(msg.Data)); err != nil {
return
}
s.ch <- msg
}
}

func (g *GossipSubscription) Publish(data []byte) error {
return g.topic.Publish(g.ctx, data)
}
4 changes: 4 additions & 0 deletions cmd/sentinel/sentinel/sentinel.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,7 @@ func (s *Sentinel) Host() host.Host {
func (s *Sentinel) Peers() *peers.Peers {
return s.peers
}

func (s *Sentinel) GossipManager() *GossipManager {
return s.subManager
}
26 changes: 26 additions & 0 deletions cmd/sentinel/sentinel/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,32 @@ func (s *SentinelServer) BanPeer(_ context.Context, p *sentinelrpc.Peer) (*senti
return &sentinelrpc.EmptyMessage{}, nil
}

func (s *SentinelServer) PublishGossip(_ context.Context, msg *sentinelrpc.GossipData) (*sentinelrpc.EmptyMessage, error) {
manager := s.sentinel.GossipManager()
// Snappify payload before sending it to gossip
compressedData := utils.CompressSnappy(msg.Data)
var subscription *sentinel.GossipSubscription

switch msg.Type {
case sentinelrpc.GossipType_BeaconBlockGossipType:
subscription = manager.GetMatchingSubscription(string(sentinel.BeaconBlockTopic))
case sentinelrpc.GossipType_AggregateAndProofGossipType:
subscription = manager.GetMatchingSubscription(string(sentinel.BeaconAggregateAndProofTopic))
case sentinelrpc.GossipType_VoluntaryExitGossipType:
subscription = manager.GetMatchingSubscription(string(sentinel.VoluntaryExitTopic))
case sentinelrpc.GossipType_ProposerSlashingGossipType:
subscription = manager.GetMatchingSubscription(string(sentinel.ProposerSlashingTopic))
case sentinelrpc.GossipType_AttesterSlashingGossipType:
subscription = manager.GetMatchingSubscription(string(sentinel.AttesterSlashingTopic))
default:
return &sentinelrpc.EmptyMessage{}, nil
}
if subscription == nil {
return &sentinelrpc.EmptyMessage{}, nil
}
return &sentinelrpc.EmptyMessage{}, subscription.Publish(compressedData)
}

func (s *SentinelServer) SubscribeGossip(_ *sentinelrpc.EmptyMessage, stream sentinelrpc.Sentinel_SubscribeGossipServer) error {
// first of all subscribe
ch, subId, err := s.gossipNotifier.addSubscriber()
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/ledgerwatch/erigon
go 1.19

require (
github.com/ledgerwatch/erigon-lib v0.0.0-20230325072849-9f1fc3dd0d0c
github.com/ledgerwatch/erigon-lib v0.0.0-20230327103053-23fe5e817bfa
github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20230306083105-1391330d62a3
github.com/ledgerwatch/log/v3 v3.7.0
github.com/ledgerwatch/secp256k1 v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758 h1:0D5M2HQSGD3PYPwICLl+/9oulQauOuETfgFvhBDffs0=
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
github.com/ledgerwatch/erigon-lib v0.0.0-20230325072849-9f1fc3dd0d0c h1:Ba+HaeqlyMLlN/HzDsYw8IXyzkN+IJabAiP2jV3OvVE=
github.com/ledgerwatch/erigon-lib v0.0.0-20230325072849-9f1fc3dd0d0c/go.mod h1:CkP5qnLv68u1AAHHamS7TBgPmlPBn0aVcPrHi7njrIU=
github.com/ledgerwatch/erigon-lib v0.0.0-20230327103053-23fe5e817bfa h1:2d7REYLaoY5tqhdP4qH6P7QNl7SbNO7JjTEUMq5x7s4=
github.com/ledgerwatch/erigon-lib v0.0.0-20230327103053-23fe5e817bfa/go.mod h1:JCt4IGL5ZAS1XGTFgSs2RSOxiTw3XX5PrkKjwhiI8Mo=
github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20230306083105-1391330d62a3 h1:tfzawK1gIIgRjVZeANXOr0Ziu+kqCIBuKMe0TXfl5Aw=
github.com/ledgerwatch/erigon-snapshot v1.1.1-0.20230306083105-1391330d62a3/go.mod h1:3AuPxZc85jkehh/HA9h8gabv5MSi3kb/ddtzBsTVJFo=
github.com/ledgerwatch/log/v3 v3.7.0 h1:aFPEZdwZx4jzA3+/Pf8wNDN5tCI0cIolq/kfvgcM+og=
Expand Down