From 7118cf11a39894f3284065f2650da4369f8ef85f Mon Sep 17 00:00:00 2001 From: Master Engineer <104206186+mastereng12@users.noreply.github.com> Date: Mon, 23 Sep 2024 13:39:16 -0400 Subject: [PATCH 1/2] fix: the signer config (#138) * fix the signer config * update README * minor fix (cherry picked from commit 04479374e5427f0af1a8c2f833307133ba9d33ef) # Conflicts: # cmd/main.go --- README.md | 3 +++ cmd/main.go | 6 ++++- config/config.go | 14 ++++++++++++ config/default.go | 9 ++++---- templates/docker-compose_signer.yml | 34 +++++++++++++++++++++++++++++ templates/signer_config.toml | 22 +++++++++++++++++++ utils/docker.go | 10 +++++---- 7 files changed, 89 insertions(+), 9 deletions(-) create mode 100644 templates/docker-compose_signer.yml create mode 100644 templates/signer_config.toml diff --git a/README.md b/README.md index 8e5846f..7f4e875 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ Please refer to the detailed [documentation](https://docs.lagrange.dev/state-com - [Using CLI](https://docs.lagrange.dev/state-committees/run-node/register-operator) - [Using Script](https://docs.lagrange.dev/state-committees/run-node/scripts) - Deploy attestation node + - [Deploy Remote Signer](https://docs.lagrange.dev/state-committees/run-node/deploy#signer) - [Deploy using CLI](https://docs.lagrange.dev/state-committees/run-node/deploy#deploy-using-cli) - [Deploy using templates](https://docs.lagrange.dev/state-committees/run-node/deploy#deploy-using-template) - [Post deployment](#post-deployment) @@ -82,7 +83,9 @@ The below commands will allow a developer to run a node and attest to the state - [generate-config](https://docs.lagrange.dev/state-committees/run-node/commands#generate-config) - [generate-docker-compose](https://docs.lagrange.dev/state-committees/run-node/commands#generate-docker-compose) - [deploy](https://docs.lagrange.dev/state-committees/run-node/commands#deploy) +- [deploy-signer](https://docs.lagrange.dev/state-committees/run-node/commands#deploy-signer) - [generate-config-deploy](https://docs.lagrange.dev/state-committees/run-node/commands#generate-config-deploy) +- [bulk-generate-config-deploy](https://docs.lagrange.dev/state-committees/run-node/commands#bulk-generate-config-deploy) ### Post Deployment diff --git a/cmd/main.go b/cmd/main.go index 322c343..419c292 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -84,7 +84,7 @@ var ( } dockerImageFlag = &cli.StringFlag{ Name: flagDockerImage, - Value: "lagrangelabs/lagrange-node:v1.0.0", + Value: "lagrangelabs/lagrange-node:v1.1.5", Usage: "Docker `IMAGE`", Aliases: []string{"i"}, } @@ -106,7 +106,11 @@ func main() { Usage: "Prints the version of the Lagrange Client CLI", Action: func(c *cli.Context) error { w := os.Stdout +<<<<<<< HEAD fmt.Fprintf(w, "Version: %s\n", "v1.1.0") +======= + fmt.Fprintf(w, "Version: %s\n", "v1.1.2") +>>>>>>> 0447937 (fix: the signer config (#138)) fmt.Fprintf(w, "Go version: %s\n", runtime.Version()) fmt.Fprintf(w, "OS/Arch: %s/%s\n", runtime.GOOS, runtime.GOARCH) return nil diff --git a/config/config.go b/config/config.go index c483fd2..3133492 100644 --- a/config/config.go +++ b/config/config.go @@ -173,6 +173,13 @@ func LoadCLIConfig(ctx *cli.Context) (*CLIConfig, error) { return nil, err } + // check the empty TLS config + if cfg.CertConfig != nil { + if len(cfg.CertConfig.CACertPath) == 0 || len(cfg.CertConfig.NodeKeyPath) == 0 || len(cfg.CertConfig.NodeCertPath) == 0 { + cfg.CertConfig = nil + } + } + return &cfg, nil } @@ -265,6 +272,13 @@ func LoadCLIBulkConfig(ctx *cli.Context) (*CLIBulkConfig, error) { return nil, err } + // check the empty TLS config + if cfg.CertConfig != nil { + if len(cfg.CertConfig.CACertPath) == 0 || len(cfg.CertConfig.NodeKeyPath) == 0 || len(cfg.CertConfig.NodeCertPath) == 0 { + cfg.CertConfig = nil + } + } + return &cfg, nil } diff --git a/config/default.go b/config/default.go index 6e65e5f..25b108c 100644 --- a/config/default.go +++ b/config/default.go @@ -19,11 +19,12 @@ BLSKeyAccountID = "{{.BLSKeyAccountID}}" SignerKeyAccountID = "{{.SignerKeyAccountID}}" PullInterval = "1000ms" BLSCurve = "{{.BLSCurve}}" - + {{ if .CertConfig }} [Client.TLSConfig] - CACertPath = "/app/config/ca.crt" - NodeKeyPath = "/app/config/node.key" - NodeCertPath = "/app/config/node.crt" + CACertPath = "{{.CertConfig.CACertPath}}" + NodeKeyPath = "{{.CertConfig.NodeKeyPath}}" + NodeCertPath = "{{.CertConfig.NodeCertPath}}" + {{ end }} [RpcClient] {{ if eq .ChainName "optimism" "base" }} diff --git a/templates/docker-compose_signer.yml b/templates/docker-compose_signer.yml new file mode 100644 index 0000000..5dccce9 --- /dev/null +++ b/templates/docker-compose_signer.yml @@ -0,0 +1,34 @@ +version: "3.7" +services: + lagrange_signer: + container_name: lagrange_signer + image: lagrangelabs/lagrange-node:{{.Version}} + restart: always + ports: + - "{{.HostBindingPort}}:{{.SignerGRPCServerPort}}" + volumes: + - {{.SignerConfigFilePath}}:/app/config/config_signer.toml + + - {{--- Path to BLS Private Key ---}}:/app/config/{{--- Account ID like operator_bls_key ---}}.key + + - {{--- Path to BLS Keystore Password ---}}:/app/config/{{--- Account ID like operator_bls_key ---}}.pass + + - {{--- Path to ECDSA Private Key ---}}:/app/config/{{--- Account ID like signer_ecdsa_key ---}}.key + + - {{--- Path to ECDSA Keystore Password ---}}:/app/config/{{--- Account ID like signer_ecdsa_key ---}}.pass + + + - {{--- Path to CA certificate ---}}:/app/config/ca-crt.pem + + - {{--- Path to Node Certificate ---}}:/app/config/server-crt.pem + + - {{--- Path to Node Key ---}}:/app/config/server-key.pem + command: + - "/bin/sh" + - "-c" + - "/app/lagrange-node run-signer -c /app/config/config_signer.toml" + logging: + driver: "json-file" + options: + max-size: "10m" + max-file: "10" diff --git a/templates/signer_config.toml b/templates/signer_config.toml new file mode 100644 index 0000000..4561a1b --- /dev/null +++ b/templates/signer_config.toml @@ -0,0 +1,22 @@ +GRPCPort = "--- Signer GRPC Server PORT like 9091 ---" + +[TLSConfig] + CACertPath = "--- Path to CA certificate ---" + NodeKeyPath = "--- Path to Node Key ---" + NodeCertPath = "--- Path to Node Certificate ---" + +[[ProviderConfigs]] + Type = "local" + [ProviderConfigs.LocalConfig] + AccountID = "--- Account ID like operator_bls_key ---" + KeyType = "--- Key Type like BN254 ---" + PrivateKeyPath = "--- Path to BLS Private Key ---" + PasswordKeyPath = "--- Path to BLS Keystore Password ---" + +[[ProviderConfigs]] + Type = "local" + [ProviderConfigs.LocalConfig] + AccountID = "--- Account ID like signer_ecdsa_key ---" + KeyType = "--- Key Type like ECDSA ---" + PrivateKeyPath = "--- Path to ECDSA Private Key ---" + PasswordKeyPath = "--- Path to ECDSA Keystore Password ---" \ No newline at end of file diff --git a/utils/docker.go b/utils/docker.go index 661c265..1c0d932 100644 --- a/utils/docker.go +++ b/utils/docker.go @@ -28,9 +28,11 @@ services: - "/app/lagrange-node run-client -c /app/config/client.toml" volumes: - {{.ConfigFilePath}}:/app/config/client.toml +{{if .CertConfig}} - {{.CertConfig.CACertPath}}:/app/config/ca.crt - {{.CertConfig.NodeKeyPath}}:/app/config/node.key - {{.CertConfig.NodeCertPath}}:/app/config/node.crt +{{end}} - lagrange_{{.Network}}_{{.ChainName}}_{{.BLSPubKeyPrefix}}:$HOME/.lagrange logging: driver: "json-file" @@ -53,10 +55,10 @@ services: volumes: - {{.ConfigFilePath}}:/app/config/config_signer.toml {{ range $key, $value := .KeyStorePaths }} - - {{$key}}:{{$value}} + - {{$value}}:{{$key}} {{ end }} {{ range $key, $value := .PasswordPaths }} - - {{$key}}:{{$value}} + - {{$value}}:{{$key}} {{ end }} {{ range $key, $value := .CertPaths }} - {{$key}}:{{$value}} @@ -121,8 +123,8 @@ func GenerateSignerConfigFile(cfg *signer.Config, imageName string) (string, err } keyPath := fmt.Sprintf("/app/config/%s.key", filepath.Base(provider.LocalConfig.AccountID)) passPath := fmt.Sprintf("/app/config/%s.pass", filepath.Base(provider.LocalConfig.AccountID)) - signerConfig.KeyStorePaths[provider.LocalConfig.PrivateKeyPath] = keyPath - signerConfig.PasswordPaths[provider.LocalConfig.PasswordKeyPath] = passPath + signerConfig.KeyStorePaths[keyPath] = provider.LocalConfig.PrivateKeyPath + signerConfig.PasswordPaths[passPath] = provider.LocalConfig.PasswordKeyPath provider.LocalConfig.PrivateKeyPath = keyPath provider.LocalConfig.PasswordKeyPath = passPath } From 7f561405f20d70a27c77238296ce7878a8e7a076 Mon Sep 17 00:00:00 2001 From: mastereng12 Date: Mon, 23 Sep 2024 13:45:33 -0400 Subject: [PATCH 2/2] fix conflicts --- cmd/main.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 419c292..5ed2476 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -106,11 +106,7 @@ func main() { Usage: "Prints the version of the Lagrange Client CLI", Action: func(c *cli.Context) error { w := os.Stdout -<<<<<<< HEAD - fmt.Fprintf(w, "Version: %s\n", "v1.1.0") -======= fmt.Fprintf(w, "Version: %s\n", "v1.1.2") ->>>>>>> 0447937 (fix: the signer config (#138)) fmt.Fprintf(w, "Go version: %s\n", runtime.Version()) fmt.Fprintf(w, "OS/Arch: %s/%s\n", runtime.GOOS, runtime.GOARCH) return nil