@@ -905,13 +905,14 @@ func newDefFromConfig(ctx context.Context, conf clusterConfig) (cluster.Definiti
905905 }
906906
907907 var forkVersion string
908- if conf .Network != "" {
908+ if conf .testnetConfig .IsNonZero () {
909+ // Custom testnet config takes precedence (already registered in validateCreateConfig via validateNetworkConfig).
910+ forkVersion = conf .testnetConfig .GenesisForkVersionHex
911+ } else if conf .Network != "" {
909912 forkVersion , err = eth2util .NetworkToForkVersion (conf .Network )
910913 if err != nil {
911914 return cluster.Definition {}, err
912915 }
913- } else if conf .testnetConfig .GenesisForkVersionHex != "" {
914- forkVersion = conf .testnetConfig .GenesisForkVersionHex
915916 } else {
916917 return cluster.Definition {}, errors .New ("network not specified, missing --network or --testnet-fork-version" )
917918 }
@@ -1224,6 +1225,14 @@ func builderRegistrationFromETH2(reg core.VersionedSignedValidatorRegistration)
12241225
12251226// validateNetworkConfig returns an error if the network configuration is invalid in the given cluster configuration.
12261227func validateNetworkConfig (network string , testnet eth2util.Network ) error {
1228+ // Check if custom testnet configuration is provided first (takes precedence over default network).
1229+ if testnet .IsNonZero () {
1230+ // Add testnet config to supported networks.
1231+ eth2util .AddTestNetwork (testnet )
1232+
1233+ return nil
1234+ }
1235+
12271236 if network != "" {
12281237 if eth2util .ValidNetwork (network ) {
12291238 return nil
@@ -1232,13 +1241,5 @@ func validateNetworkConfig(network string, testnet eth2util.Network) error {
12321241 return errors .New ("invalid network specified" , z .Str ("network" , network ))
12331242 }
12341243
1235- // Check if custom testnet configuration is provided.
1236- if testnet .IsNonZero () {
1237- // Add testnet config to supported networks.
1238- eth2util .AddTestNetwork (testnet )
1239-
1240- return nil
1241- }
1242-
12431244 return errors .New ("missing --network flag or testnet config flags" )
12441245}
0 commit comments