Skip to content
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
3 changes: 1 addition & 2 deletions cmd/cortex/cvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import (

"github.com/CortexFoundation/CortexTheseus/cmd/utils"
"github.com/CortexFoundation/CortexTheseus/log"
"github.com/CortexFoundation/CortexTheseus/p2p"
)

func homeDir() string {
Expand Down Expand Up @@ -202,7 +201,7 @@ func cvmServer(ctx *cli.Context) error {
return errors.New("fs start failed")
}

err = storagefs.Start(&p2p.Server{})
err = storagefs.Start()
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/wnode/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ func run() {
return
}
defer server.Stop()
shh.Start(&p2p.Server{})
shh.Start()
defer shh.Stop()

if !*forwarderMode {
Expand Down
18 changes: 8 additions & 10 deletions ctxc/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ func New(stack *node.Node, config *Config) (*Cortex, error) {

ctxc.miner = miner.New(ctxc, &config.Miner, ctxc.chainConfig, ctxc.eventMux, ctxc.engine, ctxc.isLocalBlock)
ctxc.miner.SetExtra(makeExtraData(config.Miner.ExtraData))

ctxc.dropper = newDropper(ctxc.p2pServer.MaxDialedConns(), ctxc.p2pServer.MaxInboundConns())

ctxc.APIBackend = &CortexAPIBackend{stack.Config().AllowUnprotectedTxs, ctxc, nil}
Expand All @@ -287,9 +288,9 @@ func New(stack *node.Node, config *Config) (*Cortex, error) {
gpoParams.Default = config.Miner.GasPrice
}
ctxc.APIBackend.gpo = gasprice.NewOracle(ctxc.APIBackend, gpoParams)
if err != nil {
return nil, err
}

// Start the RPC service
ctxc.netRPCService = ctxcapi.NewPublicNetAPI(ctxc.p2pServer, networkID)

//stack.RegisterProtocols(ctxc.Protocols())

Expand Down Expand Up @@ -609,8 +610,7 @@ func (s *Cortex) Protocols() []p2p.Protocol {

// Start implements node.Service, starting all internal goroutines needed by the
// Cortex protocol implementation.
func (s *Cortex) Start(srvr *p2p.Server) error {
s.startCtxcEntryUpdate(srvr.LocalNode())
func (s *Cortex) Start() error {
if err := s.setupDiscovery(); err != nil {
return err
}
Expand All @@ -620,13 +620,9 @@ func (s *Cortex) Start(srvr *p2p.Server) error {
// Regularly update shutdown marker
s.shutdownTracker.Start()

// Start the RPC service
s.netRPCService = ctxcapi.NewPublicNetAPI(srvr, s.NetVersion())

// Figure out a max peers count based on the server limits
maxPeers := srvr.MaxPeers
// Start the networking layer and the light server if requested
s.protocolManager.Start(maxPeers)
s.protocolManager.Start(s.p2pServer.MaxPeers)

// Start the connection manager
s.dropper.Start(s.p2pServer, func() bool { return !s.Synced() })
Expand Down Expand Up @@ -697,6 +693,8 @@ func (s *Cortex) updateFilterMapsHeads() {
}

func (s *Cortex) setupDiscovery() error {
s.startENRUpdater(s.p2pServer.LocalNode())

dnsclient := dnsdisc.NewClient(dnsdisc.Config{})
if len(s.config.DiscoveryURLs) > 0 {
iter, err := dnsclient.NewIterator(s.config.DiscoveryURLs...)
Expand Down
2 changes: 1 addition & 1 deletion ctxc/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (e ctxcEntry) ENRKey() string {
}

// startCtxcEntryUpdate starts the ENR updater loop.
func (ctxc *Cortex) startCtxcEntryUpdate(ln *enode.LocalNode) {
func (ctxc *Cortex) startENRUpdater(ln *enode.LocalNode) {
var newHead = make(chan core.ChainHeadEvent, 10)
sub := ctxc.blockchain.SubscribeChainHeadEvent(newHead)

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.6.0
github.com/CortexFoundation/inference v1.0.2-0.20230307032835-9197d586a4e8
github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66
github.com/CortexFoundation/torrentfs v1.0.69-0.20250413152926-abb59313c23c
github.com/CortexFoundation/torrentfs v1.0.69-0.20250415112856-b1b452a24746
github.com/VictoriaMetrics/fastcache v1.12.2
github.com/arsham/figurine v1.3.0
github.com/aws/aws-sdk-go-v2 v1.36.3
Expand Down Expand Up @@ -206,7 +206,7 @@ require (
github.com/pion/transport/v2 v2.2.10 // indirect
github.com/pion/transport/v3 v3.0.7 // indirect
github.com/pion/turn/v4 v4.0.0 // indirect
github.com/pion/webrtc/v4 v4.0.14 // indirect
github.com/pion/webrtc/v4 v4.0.15 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.22.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66/go.mod h1:
github.com/CortexFoundation/torrentfs v1.0.13-0.20200623060705-ce027f43f2f8/go.mod h1:Ma+tGhPPvz4CEZHaqEJQMOEGOfHeQBiAoNd1zyc/w3Q=
github.com/CortexFoundation/torrentfs v1.0.14-0.20200703071639-3fcabcabf274/go.mod h1:qnb3YlIJmuetVBtC6Lsejr0Xru+1DNmDCdTqnwy7lhk=
github.com/CortexFoundation/torrentfs v1.0.20-0.20200810031954-d36d26f82fcc/go.mod h1:N5BsicP5ynjXIi/Npl/SRzlJ630n1PJV2sRj0Z0t2HA=
github.com/CortexFoundation/torrentfs v1.0.69-0.20250413152926-abb59313c23c h1:lpJ1OrrVq0fAz9299pdKPZPfmqopKFO+OHpCJQ9xHbo=
github.com/CortexFoundation/torrentfs v1.0.69-0.20250413152926-abb59313c23c/go.mod h1:Lf7iaFiGPvExQiyPufsbQ8hs0XkKUunTLcp0r77/IaY=
github.com/CortexFoundation/torrentfs v1.0.69-0.20250415112856-b1b452a24746 h1:VP6BvIxVY1jh4UmvpJQqIzpmnYva25xVRevXHoPP/2M=
github.com/CortexFoundation/torrentfs v1.0.69-0.20250415112856-b1b452a24746/go.mod h1:Lf7iaFiGPvExQiyPufsbQ8hs0XkKUunTLcp0r77/IaY=
github.com/CortexFoundation/wormhole v0.0.2-0.20241128010855-a23c88842cfa h1:46VAGWxOwpoLlPNcR9etAhK0NtT215skO9Wl4i14r4o=
github.com/CortexFoundation/wormhole v0.0.2-0.20241128010855-a23c88842cfa/go.mod h1:ipzmPabDgzYKUbXkGVe2gTkBEp+MsDx6pXGiuYzmP6s=
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
Expand Down Expand Up @@ -1037,8 +1037,8 @@ github.com/pion/turn/v4 v4.0.0 h1:qxplo3Rxa9Yg1xXDxxH8xaqcyGUtbHYw4QSCvmFWvhM=
github.com/pion/turn/v4 v4.0.0/go.mod h1:MuPDkm15nYSklKpN8vWJ9W2M0PlyQZqYt1McGuxG7mA=
github.com/pion/webrtc/v2 v2.2.7/go.mod h1:EfCuvKjzMgX4F/aSryRUC7L9o3u2N8WNUgnzd6wOO+8=
github.com/pion/webrtc/v2 v2.2.9/go.mod h1:TcArPDphZIBtZ+mh8J/qOREyY3ca7ihQrenulOIvfPQ=
github.com/pion/webrtc/v4 v4.0.14 h1:nyds/sFRR+HvmWoBa6wrL46sSfpArE0qR883MBW96lg=
github.com/pion/webrtc/v4 v4.0.14/go.mod h1:R3+qTnQTS03UzwDarYecgioNf7DYgTsldxnCXB821Kk=
github.com/pion/webrtc/v4 v4.0.15 h1:DWuBtTHBa9rQNqyhW+jptkq6r3zdGqr1OQ4pa2Q+Ey4=
github.com/pion/webrtc/v4 v4.0.15/go.mod h1:RXf6sJ8FUX+qwF4+AwB+A3c2Y6WpuATRTe4L/fTWNa4=
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
Expand Down
2 changes: 1 addition & 1 deletion node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func (n *Node) Start() error {
var started []reflect.Type
for kind, service := range services {
// Start the next service, stopping all previous upon failure
if err := service.Start(running); err != nil {
if err := service.Start(); err != nil {
for _, kind := range started {
services[kind].Stop()
}
Expand Down
2 changes: 1 addition & 1 deletion node/node_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type SampleService struct{}

func (s *SampleService) Protocols() []p2p.Protocol { return nil }
func (s *SampleService) APIs() []rpc.API { return nil }
func (s *SampleService) Start(*p2p.Server) error { fmt.Println("Service starting..."); return nil }
func (s *SampleService) Start() error { fmt.Println("Service starting..."); return nil }
func (s *SampleService) Stop() error { fmt.Println("Service stopping..."); return nil }

func ExampleService() {
Expand Down
10 changes: 5 additions & 5 deletions node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func TestServiceLifeCycle(t *testing.T) {
id := id // Closure for the constructor
constructor := func(*ServiceContext) (Service, error) {
return &InstrumentedService{
startHook: func(*p2p.Server) { started[id] = true },
startHook: func() { started[id] = true },
stopHook: func() { stopped[id] = true },
}, nil
}
Expand Down Expand Up @@ -214,7 +214,7 @@ func TestServiceRestarts(t *testing.T) {
running = false

return &InstrumentedService{
startHook: func(*p2p.Server) {
startHook: func() {
if running {
panic("already running")
}
Expand Down Expand Up @@ -266,7 +266,7 @@ func TestServiceConstructionAbortion(t *testing.T) {
id := id // Closure for the constructor
constructor := func(*ServiceContext) (Service, error) {
return &InstrumentedService{
startHook: func(*p2p.Server) { started[id] = true },
startHook: func() { started[id] = true },
}, nil
}
if err := stack.Register(maker(constructor)); err != nil {
Expand Down Expand Up @@ -317,7 +317,7 @@ func TestServiceStartupAbortion(t *testing.T) {
id := id // Closure for the constructor
constructor := func(*ServiceContext) (Service, error) {
return &InstrumentedService{
startHook: func(*p2p.Server) { started[id] = true },
startHook: func() { started[id] = true },
stopHook: func() { stopped[id] = true },
}, nil
}
Expand Down Expand Up @@ -372,7 +372,7 @@ func TestServiceTerminationGuarantee(t *testing.T) {
id := id // Closure for the constructor
constructor := func(*ServiceContext) (Service, error) {
return &InstrumentedService{
startHook: func(*p2p.Server) { started[id] = true },
startHook: func() { started[id] = true },
stopHook: func() { stopped[id] = true },
}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion node/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ type Service interface {

// Start is called after all services have been constructed and the networking
// layer was also initialized to spawn any goroutines required by the service.
Start(server *p2p.Server) error
Start() error

// Stop terminates all goroutines belonging to the service, blocking until they
// are all terminated.
Expand Down
8 changes: 4 additions & 4 deletions node/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type NoopService struct{}

func (s *NoopService) Protocols() []p2p.Protocol { return nil }
func (s *NoopService) APIs() []rpc.API { return nil }
func (s *NoopService) Start(*p2p.Server) error { return nil }
func (s *NoopService) Start() error { return nil }
func (s *NoopService) Stop() error { return nil }

func NewNoopService(*ServiceContext) (Service, error) { return new(NoopService), nil }
Expand All @@ -55,7 +55,7 @@ type InstrumentedService struct {
stop error

protocolsHook func()
startHook func(*p2p.Server)
startHook func()
stopHook func()
}

Expand All @@ -72,9 +72,9 @@ func (s *InstrumentedService) APIs() []rpc.API {
return s.apis
}

func (s *InstrumentedService) Start(server *p2p.Server) error {
func (s *InstrumentedService) Start() error {
if s.startHook != nil {
s.startHook(server)
s.startHook()
}
return s.start
}
Expand Down
8 changes: 1 addition & 7 deletions vendor/github.com/CortexFoundation/torrentfs/fs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion vendor/github.com/pion/webrtc/v4/.golangci.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions vendor/github.com/pion/webrtc/v4/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions vendor/github.com/pion/webrtc/v4/icecandidate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/github.com/pion/webrtc/v4/icetransport.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading