Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: the signer config (backport #138) #140

Merged
merged 2 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
}
Expand All @@ -106,7 +106,7 @@ func main() {
Usage: "Prints the version of the Lagrange Client CLI",
Action: func(c *cli.Context) error {
w := os.Stdout
fmt.Fprintf(w, "Version: %s\n", "v1.1.0")
fmt.Fprintf(w, "Version: %s\n", "v1.1.2")
fmt.Fprintf(w, "Go version: %s\n", runtime.Version())
fmt.Fprintf(w, "OS/Arch: %s/%s\n", runtime.GOOS, runtime.GOARCH)
return nil
Expand Down
14 changes: 14 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down
9 changes: 5 additions & 4 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" }}
Expand Down
34 changes: 34 additions & 0 deletions templates/docker-compose_signer.yml
Original file line number Diff line number Diff line change
@@ -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"
22 changes: 22 additions & 0 deletions templates/signer_config.toml
Original file line number Diff line number Diff line change
@@ -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 ---"
10 changes: 6 additions & 4 deletions utils/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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}}
Expand Down Expand Up @@ -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
}
Expand Down
Loading