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 chain router from node.Config #2683

Merged
merged 1 commit into from
Jan 31, 2024
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
1 change: 0 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,6 @@ func GetNodeConfig(v *viper.Viper) (node.Config, error) {
}

// Router
nodeConfig.ConsensusRouter = &router.ChainRouter{}
nodeConfig.RouterHealthConfig, err = getRouterHealthConfig(v, healthCheckAveragerHalflife)
if err != nil {
return node.Config{}, err
Expand Down
2 changes: 0 additions & 2 deletions node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ type Config struct {
// Metrics
MeterVMEnabled bool `json:"meterVMEnabled"`

// Router that is used to handle incoming consensus messages
ConsensusRouter router.Router `json:"-"`
RouterHealthConfig router.HealthConfig `json:"routerHealthConfig"`
ConsensusShutdownTimeout time.Duration `json:"consensusShutdownTimeout"`
// Poll for new frontiers every [FrontierPollFrequency]
Expand Down
22 changes: 13 additions & 9 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ func New(
return nil, fmt.Errorf("couldn't initialize tracer: %w", err)
}

if n.Config.TraceConfig.Enabled {
n.Config.ConsensusRouter = router.Trace(n.Config.ConsensusRouter, n.tracer)
}

n.initMetrics()
n.initNAT()
if err := n.initAPIServer(); err != nil { // Start the API Server
Expand Down Expand Up @@ -277,6 +273,8 @@ type Node struct {
portMapper *nat.Mapper
ipUpdater dynamicip.Updater

chainRouter router.Router

// Profiles the process. Nil if continuous profiling is disabled.
profiler profiler.ContinuousProfiler

Expand Down Expand Up @@ -514,14 +512,20 @@ func (n *Node) initNetworking() error {

tlsConfig := peer.TLSConfig(n.Config.StakingTLSCert, n.tlsKeyLogWriterCloser)

// Create chain router
n.chainRouter = &router.ChainRouter{}
if n.Config.TraceConfig.Enabled {
n.chainRouter = router.Trace(n.chainRouter, n.tracer)
}

// Configure benchlist
n.Config.BenchlistConfig.Validators = n.vdrs
n.Config.BenchlistConfig.Benchable = n.Config.ConsensusRouter
n.Config.BenchlistConfig.Benchable = n.chainRouter
n.benchlistManager = benchlist.NewManager(&n.Config.BenchlistConfig)

n.uptimeCalculator = uptime.NewLockedCalculator()

consensusRouter := n.Config.ConsensusRouter
consensusRouter := n.chainRouter
if !n.Config.SybilProtectionEnabled {
// Sybil protection is disabled so we don't have a txID that added us as
// a validator. Because each validator needs a txID associated with it,
Expand Down Expand Up @@ -1088,7 +1092,7 @@ func (n *Node) initChainManager(avaxAssetID ids.ID) error {
go n.Log.RecoverAndPanic(n.timeoutManager.Dispatch)

// Routes incoming messages from peers to the appropriate chain
err = n.Config.ConsensusRouter.Initialize(
err = n.chainRouter.Initialize(
n.ID,
n.Log,
n.timeoutManager,
Expand Down Expand Up @@ -1117,7 +1121,7 @@ func (n *Node) initChainManager(avaxAssetID ids.ID) error {
VertexAcceptorGroup: n.VertexAcceptorGroup,
DB: n.DB,
MsgCreator: n.msgCreator,
Router: n.Config.ConsensusRouter,
Router: n.chainRouter,
Net: n.Net,
Validators: n.vdrs,
PartialSyncPrimaryNetwork: n.Config.PartialSyncPrimaryNetwork,
Expand Down Expand Up @@ -1432,7 +1436,7 @@ func (n *Node) initHealthAPI() error {
return fmt.Errorf("couldn't register network health check: %w", err)
}

err = healthChecker.RegisterHealthCheck("router", n.Config.ConsensusRouter, health.ApplicationTag)
err = healthChecker.RegisterHealthCheck("router", n.chainRouter, health.ApplicationTag)
if err != nil {
return fmt.Errorf("couldn't register router health check: %w", err)
}
Expand Down
Loading