Skip to content

Commit

Permalink
fix: change custom domain type to genesis custom domain type +1 on fo…
Browse files Browse the repository at this point in the history
…rk. (#1808)

* change custom domain type to genesis custom domain type +1 on fork.

* review: refactor

* increment with BigEndian instead

---------

Co-authored-by: moshe-blox <[email protected]>
  • Loading branch information
y0sher and moshe-blox authored Oct 22, 2024
1 parent 6645880 commit 030607a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
21 changes: 16 additions & 5 deletions cli/operator/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package operator
import (
"context"
"encoding/base64"
"encoding/binary"
"encoding/hex"
"fmt"
"log"
Expand Down Expand Up @@ -608,12 +609,18 @@ func setupSSVNetwork(logger *zap.Logger) (networkconfig.NetworkConfig, error) {
if len(byts) != 4 {
return networkconfig.NetworkConfig{}, errors.New("custom domain type must be 4 bytes")
}

// Assign domain type as-is for Genesis.
networkConfig.GenesisDomainType = spectypes.DomainType(byts)
if networkConfig.PastAlanFork() {
logger.Info("custom domain type is ineffective now after Alan fork", fields.Domain(networkConfig.GenesisDomainType))
} else {
logger.Info("running with custom domain type", fields.Domain(networkConfig.GenesisDomainType))
}

// Assign domain type incremented by 1 for Alan.
alanDomainType := binary.BigEndian.Uint32(byts) + 1
binary.BigEndian.PutUint32(networkConfig.AlanDomainType[:], alanDomainType)

logger.Info("running with custom domain type",
zap.Stringer("genesis", format.DomainType(networkConfig.GenesisDomainType)),
zap.Stringer("alan", format.DomainType(networkConfig.AlanDomainType)),
)
}

genesisssvtypes.SetDefaultDomain(genesisspectypes.DomainType(networkConfig.GenesisDomainType))
Expand All @@ -623,6 +630,10 @@ func setupSSVNetwork(logger *zap.Logger) (networkconfig.NetworkConfig, error) {
nodeType = "full"
}

if !networkConfig.PastAlanFork() {
logger = logger.With(zap.Stringer("alan_domain", format.DomainType(networkConfig.AlanDomainType)))
}

logger.Info("setting ssv network",
fields.Network(networkConfig.Name),
fields.Domain(networkConfig.DomainType()),
Expand Down
2 changes: 1 addition & 1 deletion operator/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type Node interface {
type Options struct {
// NetworkName is the network name of this node
NetworkName string `yaml:"Network" env:"NETWORK" env-default:"mainnet" env-description:"Network is the network of this node"`
CustomDomainType string `yaml:"CustomDomainType" env:"CUSTOM_DOMAIN_TYPE" env-default:"" env-description:"Override the SSV domain type. This is used to isolate the node from the rest of the network. Do not set unless you know what you are doing. Example: 0x01020304"`
CustomDomainType string `yaml:"CustomDomainType" env:"CUSTOM_DOMAIN_TYPE" env-default:"" env-description:"Override the SSV domain type. This is used to isolate the node from the rest of the network. Do not set unless you know what you are doing. This would be incremented by 1 for Alan, for example: 0x01020304 becomes 0x01020305 post-fork."`
Network networkconfig.NetworkConfig
BeaconNode beaconprotocol.BeaconNode // TODO: consider renaming to ConsensusClient
ExecutionClient *executionclient.ExecutionClient
Expand Down

0 comments on commit 030607a

Please sign in to comment.