From 9a1696bc6ef830ed096d60b3ad108463a1d4da45 Mon Sep 17 00:00:00 2001 From: Nicholas Pettas Date: Mon, 8 Apr 2024 16:36:39 -0700 Subject: [PATCH] add enr filtering --- go.mod | 6 +++++- go.sum | 7 +++++-- gossip/discover.go | 10 ++++++++++ gossip/service.go | 1 + 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 15f07868c..e97e630bf 100644 --- a/go.mod +++ b/go.mod @@ -109,7 +109,11 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/ethereum/go-ethereum => github.com/faircrypto/go-ethereum v1.1.4-rc1-6 +require github.com/panjf2000/ants/v2 v2.4.5 // indirect + +replace github.com/ethereum/go-ethereum => github.com/faircrypto/go-ethereum v1.10.8-ftm-rc9.0.20240408233151-381ed183bc52 + +//replace github.com/ethereum/go-ethereum => ./go-ethereum replace github.com/Fantom-foundation/lachesis-base => github.com/faircrypto/lachesis-base v0.0.0-20230817040848-1326ba9aa59b diff --git a/go.sum b/go.sum index 720612975..9d4e8b5a0 100644 --- a/go.sum +++ b/go.sum @@ -190,8 +190,8 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= github.com/evalphobia/logrus_sentry v0.8.2 h1:dotxHq+YLZsT1Bb45bB5UQbfCh3gM/nFFetyN46VoDQ= github.com/evalphobia/logrus_sentry v0.8.2/go.mod h1:pKcp+vriitUqu9KiWj/VRFbRfFNUwz95/UkgG8a6MNc= -github.com/faircrypto/go-ethereum v1.1.4-rc1-6 h1:74OcB2uM0q7sCyW2k52vvP4ALdJjSYWvEVpE+poCOGs= -github.com/faircrypto/go-ethereum v1.1.4-rc1-6/go.mod h1:ah5rnRobPJSTUKXIETbrkyrrEhWPTUPfmF1gPPNr0Tg= +github.com/faircrypto/go-ethereum v1.10.8-ftm-rc9.0.20240408233151-381ed183bc52 h1:tDi9ifPQRjBAhnMPei0N4GGd3yS/6mB+2n6HrWLhVEU= +github.com/faircrypto/go-ethereum v1.10.8-ftm-rc9.0.20240408233151-381ed183bc52/go.mod h1:738t3sZkf8FVTNT/34/PppH8Bn60QinNrWrzh9tJQqE= github.com/faircrypto/lachesis-base v0.0.0-20230817040848-1326ba9aa59b h1:mEofwrV6bMlbuneVS8tnZmNZut7WY2YH++2GI7DxzHg= github.com/faircrypto/lachesis-base v0.0.0-20230817040848-1326ba9aa59b/go.mod h1:Ogv5etzSmM2rQ4eN3OfmyitwWaaPjd4EIDiW/NAbYGk= github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8= @@ -514,6 +514,8 @@ github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFSt github.com/opentracing/opentracing-go v1.0.3-0.20180606204148-bd9c31933947/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/panjf2000/ants/v2 v2.4.5 h1:kcGvjXB7ea0MrzzszpnlVFthhYKoFxLi75nRbsq01HY= +github.com/panjf2000/ants/v2 v2.4.5/go.mod h1:f6F0NZVFsGCp5A7QW/Zj/m92atWwOkY0OIhFxRNFr4A= github.com/paulbellamy/ratecounter v0.2.0/go.mod h1:Hfx1hDpSGoqxkVVpBi/IlYD7kChlfo5C6hzIHwPqfFE= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/peterh/liner v1.0.1-0.20180619022028-8c1271fcf47f/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc= @@ -1068,6 +1070,7 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/gossip/discover.go b/gossip/discover.go index a9a2773db..2e9f615ea 100644 --- a/gossip/discover.go +++ b/gossip/discover.go @@ -19,6 +19,7 @@ package gossip import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/forkid" + "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p/enode" "github.com/ethereum/go-ethereum/rlp" @@ -59,6 +60,15 @@ func StartENRUpdater(svc *Service, ln *enode.LocalNode) { }() } +func StartENRFilter(svc *Service, p2p *p2p.Server) { + chainConfig := svc.store.GetEvmChainConfig() + gh := common.Hash(*svc.store.GetGenesisID()) + forkFilter := forkid.NewOperaFilter(chainConfig, gh, func() uint64 { + return uint64(svc.store.GetLatestBlockIndex()) + }) + p2p.SetFilter(forkFilter) +} + // currentENREntry constructs an `eth` ENR entry based on the current state of the chain. func currentENREntry(svc *Service) *enrEntry { genesisHash := *svc.store.GetGenesisID() diff --git a/gossip/service.go b/gossip/service.go index d9f7dafb8..1a7e1b191 100644 --- a/gossip/service.go +++ b/gossip/service.go @@ -459,6 +459,7 @@ func (s *Service) Start() error { // start p2p StartENRUpdater(s, s.p2pServer.LocalNode()) + StartENRFilter(s, s.p2pServer) s.handler.Start(s.p2pServer.MaxPeers) // start emitters