Skip to content

Commit

Permalink
fix(cannon): Force a valid network name (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm authored Oct 17, 2023
1 parent 81b4341 commit bfe0bcf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/cannon/ethereum/beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/attestantio/go-eth2-client/spec"
"github.com/ethpandaops/beacon/pkg/beacon"
"github.com/ethpandaops/xatu/pkg/cannon/ethereum/services"
"github.com/ethpandaops/xatu/pkg/networks"
"github.com/ethpandaops/xatu/pkg/observability"
"github.com/go-co-op/gocron"
"github.com/jellydator/ttlcache/v3"
Expand Down Expand Up @@ -113,6 +114,10 @@ func (b *BeaconNode) Start(ctx context.Context) error {
wg.Wait()
}

if b.Metadata().Network.Name == networks.NetworkNameUnknown {
errs <- errors.New("unknown network detected. Please override the network name via config if you are using a custom network")
}

b.log.Info("All services are ready")

for _, callback := range b.onReadyCallbacks {
Expand Down
6 changes: 6 additions & 0 deletions pkg/cannon/ethereum/services/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,18 @@ func (m *MetadataService) DeriveNetwork(_ context.Context) error {
return errors.New("genesis is not available")
}

if m.Spec == nil {
return errors.New("spec is not available")
}

network := networks.DeriveFromGenesisRoot(xatuethv1.RootAsString(m.Genesis.GenesisValidatorsRoot))

if m.overrideNetworkName != "" {
network.Name = networks.NetworkName(m.overrideNetworkName)
}

network.ID = m.Spec.DepositChainID

if network.Name != m.Network.Name {
m.log.WithFields(logrus.Fields{
"name": network.Name,
Expand Down

0 comments on commit bfe0bcf

Please sign in to comment.