Skip to content

Commit bf10817

Browse files
committed
support full google secret manager names
1 parent a7e02c6 commit bf10817

File tree

9 files changed

+25
-36
lines changed

9 files changed

+25
-36
lines changed

DEPLOYMENT_GUIDE.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ This guide will walk you through the process of deploying wPOKT Validators on Go
2626

2727
4. Update the MintController Smart Contract on the Ethereum network with the Ethereum addresses of the N validators. The MintController Smart Contract will utilize these addresses to validate signatures from the deployed validators during the bridging process.
2828

29-
### Step 4: Store Private Keys in Secret Manager
29+
### Step 4: Store Secrets in Secret Manager
3030

3131
1. Add all the Ethereum and Pocket private keys to the Secret Manager on GCP. Ensure you securely store these keys as they are crucial for your validator's operation.
3232

33-
2. Note down the names of all the secrets created in Secret Manager. You will use these secret names during the deployment process.
33+
2. Also add the MongoDB URI with read-and-write permissions to the Secret Manager. This URI will be used to connect to the MongoDB cluster.
3434

35-
3. Additionally, consider storing copies of the private keys in other secure places for additional redundancy and security. You might want to use hardware wallets, cold storage devices, or other secure offline storage methods to safeguard your validator's private keys.
35+
3. Note down the names of all the secrets created in Secret Manager. You will use these secret names during the deployment process.
36+
37+
4. Additionally, consider storing copies of the private keys in other secure places for additional redundancy and security. You might want to use hardware wallets, cold storage devices, or other secure offline storage methods to safeguard your validator's private keys.
3638

3739
### Step 5: Optional - Create Service Accounts and Separate Key Pairs
3840

@@ -44,15 +46,13 @@ This guide will walk you through the process of deploying wPOKT Validators on Go
4446

4547
1. Create a VM template on GCP's "Compute Engine" that includes the docker image for the wPOKT Validator and valid environment variables.
4648

47-
2. Set the following environment variables:
48-
49-
- MongoDB URI with read-and-write permissions: Provide the URI to access the MongoDB cluster with read-and-write permissions.
49+
2. Set the default environment variables for:
5050

51-
- Ethereum network configuration: Use the valid Ethereum private key secret name from Secret Manager, Ethereum RPC URL, and chain ID.
51+
- Ethereum network configuration
5252

53-
- Pocket network configuration: Utilize the valid Pocket private key secret name from Secret Manager, Pocket RPC URL, chain ID, and the generated Pocket multisig address.
53+
- Pocket network configuration
5454

55-
- Google Cloud Project ID: Add the project ID for your GCP project to ensure proper authentication and billing.
55+
- Google secret manager configuration
5656

5757
Refer to the sample `config.sample.yml` or `sample.env` files for reference on how to structure the environment variables.
5858

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ENV POKT_MULTISIG_PUBLIC_KEYS ${POKT_MULTISIG_PUBLIC_KEYS}
4646

4747
# google secret manager
4848
ENV GOOGLE_SECRET_MANAGER_ENABLED ${GOOGLE_SECRET_MANAGER_ENABLED}
49-
ENV GOOGLE_PROJECT_ID ${GOOGLE_PROJECT_ID}
49+
ENV GOOGLE_MONGO_SECRET_NAME ${GOOGLE_MONGO_SECRET_NAME}
5050
ENV GOOGLE_POKT_SECRET_NAME ${GOOGLE_POKT_SECRET_NAME}
5151
ENV GOOGLE_ETH_SECRET_NAME ${GOOGLE_ETH_SECRET_NAME}
5252

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ The wPOKT Validator can be configured in the following ways:
6969
ETH_PRIVATE_KEY="your_eth_private_key" ETH_RPC_URL="your_eth_rpc_url" ... go run .
7070
```
7171

72-
If both a config file and an env file are provided, the `config.yml` file will be loaded first, and then the env file will be read. Any falsy values in the config will be updated with corresponding values from the env file.
72+
If both a config file and an env file are provided, the config file will be loaded first, followed by the env file. Non-empty values from the env file or provided through environment variables will take precedence over the corresponding values from the config file.
7373

7474
### Using Docker Compose
7575

76-
You can also run the wPOKT Validator using `docker-compose` with the provided `.env` file. Execute the following command in the project directory:
76+
You can also run the wPOKT Validator using `docker-compose`. Execute the following command in the project directory:
7777

7878
```bash
79-
docker-compose --env-file .env up
79+
docker-compose --env-file .env up --build
8080
```
8181

8282
## Valid Memo
@@ -94,7 +94,7 @@ Transactions with memos not conforming to this format will not be processed by t
9494
9595
## Docker Image
9696
97-
The wPOKT Validator is also available as a Docker image hosted on Docker Hub. You can run the validator in a Docker container using the following command:
97+
The wPOKT Validator is also available as a Docker image hosted on [Docker Hub](https://hub.docker.com/r/dan13ram/wpokt-validator). You can run the validator in a Docker container using the following command:
9898
9999
```bash
100100
docker run -d --env-file .env docker.io/dan13ram/wpokt-validator:latest

app/env.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func readConfigFromENV(envFile string) {
127127
if os.Getenv("POKT_VAULT_ADDRESS") != "" {
128128
Config.Pocket.VaultAddress = os.Getenv("POKT_VAULT_ADDRESS")
129129
}
130-
if Config.Pocket.MultisigPublicKeys == nil || len(Config.Pocket.MultisigPublicKeys) == 0 {
130+
if os.Getenv("POKT_MULTISIG_PUBLIC_KEYS") != "" {
131131
multisigPublicKeys := os.Getenv("POKT_MULTISIG_PUBLIC_KEYS")
132132
Config.Pocket.MultisigPublicKeys = strings.Split(multisigPublicKeys, ",")
133133
}
@@ -241,7 +241,7 @@ func readConfigFromENV(envFile string) {
241241
}
242242

243243
// health check
244-
if Config.HealthCheck.IntervalSecs == 0 {
244+
if os.Getenv("HEALTH_CHECK_INTERVAL_SECS") != "" {
245245
intervalSecs, err := strconv.ParseInt(os.Getenv("HEALTH_CHECK_INTERVAL_SECS"), 10, 64)
246246
if err != nil {
247247
log.Warn("[ENV] Error parsing HEALTH_CHECK_INTERVAL_SECS: ", err.Error())
@@ -251,7 +251,7 @@ func readConfigFromENV(envFile string) {
251251
}
252252

253253
// logging
254-
if Config.Logger.Level == "" {
254+
if os.Getenv("LOG_LEVEL") != "" {
255255
logLevel := os.Getenv("LOG_LEVEL")
256256
if logLevel == "" {
257257
log.Warn("[ENV] Setting LogLevel to debug")
@@ -262,24 +262,21 @@ func readConfigFromENV(envFile string) {
262262
}
263263

264264
// google secret manager
265-
if Config.GoogleSecretManager.Enabled == false && os.Getenv("GOOGLE_SECRET_MANAGER_ENABLED") != "" {
265+
if os.Getenv("GOOGLE_SECRET_MANAGER_ENABLED") != "" {
266266
enabled, err := strconv.ParseBool(os.Getenv("GOOGLE_SECRET_MANAGER_ENABLED"))
267267
if err != nil {
268268
log.Warn("[ENV] Error parsing GOOGLE_SECRET_MANAGER_ENABLED: ", err.Error())
269269
} else {
270270
Config.GoogleSecretManager.Enabled = enabled
271271
}
272272
}
273-
if Config.GoogleSecretManager.ProjectId == "" {
274-
Config.GoogleSecretManager.ProjectId = os.Getenv("GOOGLE_PROJECT_ID")
275-
}
276-
if Config.GoogleSecretManager.MongoSecretName == "" {
273+
if os.Getenv("GOOGLE_MONGO_SECRET_NAME") != "" {
277274
Config.GoogleSecretManager.MongoSecretName = os.Getenv("GOOGLE_MONGO_SECRET_NAME")
278275
}
279-
if Config.GoogleSecretManager.PoktSecretName == "" {
276+
if os.Getenv("GOOGLE_POKT_SECRET_NAME") != "" {
280277
Config.GoogleSecretManager.PoktSecretName = os.Getenv("GOOGLE_POKT_SECRET_NAME")
281278
}
282-
if Config.GoogleSecretManager.EthSecretName == "" {
279+
if os.Getenv("GOOGLE_ETH_SECRET_NAME") != "" {
283280
Config.GoogleSecretManager.EthSecretName = os.Getenv("GOOGLE_ETH_SECRET_NAME")
284281
}
285282

app/gsm.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package app
22

33
import (
44
"context"
5-
"fmt"
65

76
secretmanager "cloud.google.com/go/secretmanager/apiv1"
87
"cloud.google.com/go/secretmanager/apiv1/secretmanagerpb"
@@ -11,7 +10,7 @@ import (
1110

1211
func accessSecretVersion(client *secretmanager.Client, name string) (string, error) {
1312
req := &secretmanagerpb.AccessSecretVersionRequest{
14-
Name: fmt.Sprintf("projects/%s/secrets/%s/versions/latest", Config.GoogleSecretManager.ProjectId, name),
13+
Name: name,
1514
}
1615

1716
result, err := client.AccessSecretVersion(context.Background(), req)
@@ -30,10 +29,6 @@ func readKeysFromGSM() {
3029
return
3130
}
3231

33-
if Config.GoogleSecretManager.ProjectId == "" {
34-
log.Fatalf("[GSM] ProjectId is empty")
35-
}
36-
3732
ctx := context.Background()
3833
client, err := secretmanager.NewClient(ctx)
3934
if err != nil {

config.sample.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ logger:
6363

6464
google_secret_manager:
6565
enabled: false
66-
project_id: ""
67-
mongo_secret_name: ""
66+
mongo_secret_name: "" # projects/<project-id>/secrets/<secret-name>/versions/latest
6867
pokt_secret_name: ""
6968
eth_secret_name: ""

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ services:
3535

3636
# google secret manager
3737
GOOGLE_SECRET_MANAGER_ENABLED: ${GOOGLE_SECRET_MANAGER_ENABLED}
38-
GOOGLE_PROJECT_ID: ${GOOGLE_PROJECT_ID}
38+
GOOGLE_MONGO_SECRET_NAME: ${GOOGLE_MONGO_SECRET_NAME}
3939
GOOGLE_POKT_SECRET_NAME: ${GOOGLE_POKT_SECRET_NAME}
4040
GOOGLE_ETH_SECRET_NAME: ${GOOGLE_ETH_SECRET_NAME}
4141

models/config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ type Config struct {
1717

1818
type GoogleSecretManagerConfig struct {
1919
Enabled bool `yaml:"enabled" json:"enabled"`
20-
ProjectId string `yaml:"project_id" json:"project_id"`
2120
MongoSecretName string `yaml:"mongo_secret_name" json:"mongo_secret_name"`
2221
PoktSecretName string `yaml:"pokt_secret_name" json:"pokt_secret_name"`
2322
EthSecretName string `yaml:"eth_secret_name" json:"eth_secret_name"`

sample.env

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ COMPOSE_PROJECT_NAME=
2929
# google secret manager
3030
GOOGLE_APPLICATION_CREDENTIALS= # only for local development
3131
GOOGLE_SECRET_MANAGER_ENABLED=
32-
GOOGLE_PROJECT_ID=
33-
GOOGLE_MONGO_SECRET_NAME=
32+
GOOGLE_MONGO_SECRET_NAME=projects/<project-id>/secrets/<secret-name>/versions/latest
3433
GOOGLE_POKT_SECRET_NAME=
3534
GOOGLE_ETH_SECRET_NAME=
3635

0 commit comments

Comments
 (0)