github.com/kotalco/kotal@v0.3.0/clients/ethereum2/lighthouse_beacon_node.go (about)

     1  package ethereum2
     2  
     3  import (
     4  	"fmt"
     5  	"strings"
     6  
     7  	ethereum2v1alpha1 "github.com/kotalco/kotal/apis/ethereum2/v1alpha1"
     8  	"github.com/kotalco/kotal/controllers/shared"
     9  	corev1 "k8s.io/api/core/v1"
    10  )
    11  
    12  // LighthouseBeaconNode is SigmaPrime Ethereum 2.0 client
    13  // https://github.com/sigp/lighthouse
    14  type LighthouseBeaconNode struct {
    15  	node *ethereum2v1alpha1.BeaconNode
    16  }
    17  
    18  // HomeDir returns container home directory
    19  func (t *LighthouseBeaconNode) HomeDir() string {
    20  	return LighthouseHomeDir
    21  }
    22  
    23  // Command returns environment variables for running the client
    24  func (t *LighthouseBeaconNode) Env() []corev1.EnvVar {
    25  	return nil
    26  }
    27  
    28  // Args returns command line arguments required for client
    29  func (t *LighthouseBeaconNode) Args() (args []string) {
    30  
    31  	node := t.node
    32  
    33  	args = append(args, LighthouseDataDir, shared.PathData(t.HomeDir()))
    34  
    35  	args = append(args, LighthouseDebugLevel, string(t.node.Spec.Logging))
    36  
    37  	args = append(args, LighthouseNetwork, node.Spec.Network)
    38  
    39  	args = append(args, LighthouseExecutionEngineEndpoint, node.Spec.ExecutionEngineEndpoint)
    40  
    41  	args = append(args, LighthouseFeeRecipient, string(node.Spec.FeeRecipient))
    42  
    43  	jwtSecretPath := fmt.Sprintf("%s/jwt.secret", shared.PathSecrets(t.HomeDir()))
    44  	args = append(args, LighthouseJwtSecretFile, jwtSecretPath)
    45  
    46  	if node.Spec.REST {
    47  		args = append(args, LighthouseHTTP)
    48  		args = append(args, LighthouseAllowOrigins, strings.Join(node.Spec.CORSDomains, ","))
    49  		args = append(args, LighthouseHTTPPort, fmt.Sprintf("%d", node.Spec.RESTPort))
    50  		args = append(args, LighthouseHTTPAddress, shared.Host(node.Spec.REST))
    51  	}
    52  
    53  	if node.Spec.CheckpointSyncURL != "" {
    54  		args = append(args, LighthouseCheckpointSyncUrl, node.Spec.CheckpointSyncURL)
    55  	}
    56  
    57  	args = append(args, LighthousePort, fmt.Sprintf("%d", node.Spec.P2PPort))
    58  	args = append(args, LighthouseDiscoveryPort, fmt.Sprintf("%d", node.Spec.P2PPort))
    59  
    60  	return
    61  }
    62  
    63  // Command returns command for running the client
    64  func (t *LighthouseBeaconNode) Command() (command []string) {
    65  	command = []string{"lighthouse", "bn"}
    66  	return
    67  }