Configs/env vars: s/OPT_/ABC_. (#565)

* Transition to Abacus-themed env var prefix.

Previously we had lots of environment variables prefixed with OPT
as a holdover from the Optics fork. This PR tries to migrate them to
Abacus-specific prefix of ABC, which is something we'd like to do
prior to handing operational responsibility for running agents to
any third parties, since there will be some inherent resistance in
persuading a group like that to rename all configuration variables.

* Update image to use ABC_ instead of OPT_, rm --debug --dry-run flags from agent helm command

Co-authored-by: Trevor Porter <trkporter@ucdavis.edu>
nambrot/remove-dependabot
webbhorn 2 years ago committed by GitHub
parent 588836278b
commit 3ec86b0e26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      rust/abacus-base/src/macros.rs
  2. 8
      rust/abacus-base/src/settings/mod.rs
  3. 6
      rust/helm/abacus-agent/templates/_helpers.tpl
  4. 2
      rust/helm/abacus-agent/templates/checkpointer-external-secret.yaml
  5. 2
      rust/helm/abacus-agent/templates/checkpointer-statefulset.yaml
  6. 14
      rust/helm/abacus-agent/templates/configmap.yaml
  7. 4
      rust/helm/abacus-agent/templates/external-secret.yaml
  8. 2
      rust/helm/abacus-agent/templates/kathy-external-secret.yaml
  9. 2
      rust/helm/abacus-agent/templates/kathy-statefulset.yaml
  10. 2
      rust/helm/abacus-agent/templates/relayer-external-secret.yaml
  11. 2
      rust/helm/abacus-agent/templates/relayer-statefulset.yaml
  12. 2
      rust/helm/abacus-agent/templates/validator-external-secret.yaml
  13. 2
      rust/helm/abacus-agent/templates/validator-statefulset.yaml
  14. 66
      rust/run-locally.sh
  15. 2
      typescript/infra/config/environments/testnet2/agent.ts
  16. 24
      typescript/infra/src/agents/index.ts

@ -104,9 +104,9 @@ macro_rules! decl_settings {
/// env vars. `RUN_ENV/BASECONFIG`
/// 2. The file specified by the `RUN_ENV` env var and the
/// agent's name. `RUN_ENV/AGENT-partial.json`
/// 3. Configuration env vars with the prefix `OPT_BASE` intended
/// 3. Configuration env vars with the prefix `ABC_BASE` intended
/// to be shared by multiple agents in the same environment
/// 4. Configuration env vars with the prefix `OPT_AGENTNAME`
/// 4. Configuration env vars with the prefix `ABC_AGENTNAME`
/// intended to be used by a specific agent.
///
/// Specify a configuration directory with the `RUN_ENV` env
@ -123,10 +123,10 @@ macro_rules! decl_settings {
s.merge(config::File::with_name(&format!("./config/{}/{}-partial", env, stringify!($name).to_lowercase())).required(false))?;
// Use a base configuration env variable prefix
s.merge(config::Environment::with_prefix(&"OPT_BASE").separator("_"))?;
s.merge(config::Environment::with_prefix(&"ABC_BASE").separator("_"))?;
// Derive additional prefix from agent name
let prefix = format!("OPT_{}", stringify!($name).to_ascii_uppercase());
let prefix = format!("ABC_{}", stringify!($name).to_ascii_uppercase());
s.merge(config::Environment::with_prefix(&prefix).separator("_"))?;
s.try_into()

@ -29,12 +29,12 @@
//! 2. The config file specified by the `RUN_ENV` env var and the
//! agent's name. `$RUN_ENV/{agent}-partial.json`.
//! E.g. `$RUN_ENV/validator-partial.json`
//! 3. Configuration env vars with the prefix `OPT_BASE` intended
//! 3. Configuration env vars with the prefix `ABC_BASE` intended
//! to be shared by multiple agents in the same environment
//! E.g. `export OPT_BASE_INBOXES_KOVAN_DOMAIN=3000`
//! 4. Configuration env vars with the prefix `OPT_{agent name}`
//! E.g. `export ABC_BASE_INBOXES_KOVAN_DOMAIN=3000`
//! 4. Configuration env vars with the prefix `ABC_{agent name}`
//! intended to be used by a specific agent.
//! E.g. `export OPT_KATHY_CHAT_TYPE="static message"`
//! E.g. `export ABC_KATHY_CHAT_TYPE="static message"`
use std::{collections::HashMap, env, sync::Arc};

@ -72,7 +72,7 @@ The name of the ClusterSecretStore
{{/*
Recursively converts a config object into environment variables than can
be parsed by rust. For example, a config of { foo: { bar: { baz: 420 }, boo: 421 } } will
be: OPT_FOO_BAR_BAZ=420 and OPT_FOO_BOO=421
be: ABC_FOO_BAR_BAZ=420 and ABC_FOO_BOO=421
Env vars can be formatted in FOO=BAR format if .dot_env_format is true, otherwise
they will be formatted as YAML-friendly environment variables
*/}}
@ -89,9 +89,9 @@ they will be formatted as YAML-friendly environment variables
{{- define "abacus-agent.config-env-var" }}
{{- if .dot_env_format }}
OPT_{{ .agent_name | upper }}_{{ .key | upper }}={{ .value | quote }}
ABC_{{ .agent_name | upper }}_{{ .key | upper }}={{ .value | quote }}
{{- else }}
- name: OPT_{{ .agent_name | upper }}_{{ .key | upper }}
- name: ABC_{{ .agent_name | upper }}_{{ .key | upper }}
value: {{ .value | quote }}
{{- end }}
{{- end }}

@ -23,7 +23,7 @@ spec:
data:
{{- range .Values.abacus.checkpointer.signers }}
{{- if eq .keyConfig.type "hexKey" }}
OPT_BASE_SIGNERS_{{ .name | upper }}_KEY: {{ printf "'{{ .%s_signer_key | toString }}'" .name }}
ABC_BASE_SIGNERS_{{ .name | upper }}_KEY: {{ printf "'{{ .%s_signer_key | toString }}'" .name }}
{{- end }}
{{- end }}
{{- if .Values.abacus.checkpointer.aws }}

@ -60,7 +60,7 @@ spec:
{{- include "abacus-agent.config-env-vars" (dict "config" .keyConfig "agent_name" "base" "key_name_prefix" (printf "SIGNERS_%s_" (.name | upper))) | indent 10 }}
{{- end }}
{{- if .Values.abacus.tracing.uri }}
- name: OPT_BASE_TRACING_JAEGER_NAME
- name: ABC_BASE_TRACING_JAEGER_NAME
value: {{ include "abacus-agent.fullname" . }}-checkpointer
{{- end }}
resources:

@ -8,18 +8,18 @@ data:
RUN_ENV: {{ .Values.abacus.runEnv | quote }}
BASE_CONFIG: {{ .Values.abacus.baseConfig }}
RUST_BACKTRACE: {{ .Values.abacus.rustBacktrace }}
OPT_BASE_DB: {{ .Values.abacus.dbPath }}
OPT_BASE_TRACING_FMT: {{ .Values.abacus.tracing.format }}
OPT_BASE_TRACING_LEVEL: {{ .Values.abacus.tracing.level }}
ABC_BASE_DB: {{ .Values.abacus.dbPath }}
ABC_BASE_TRACING_FMT: {{ .Values.abacus.tracing.format }}
ABC_BASE_TRACING_LEVEL: {{ .Values.abacus.tracing.level }}
{{- if .Values.abacus.outboxChain.connectionType }}
OPT_BASE_OUTBOX_CONNECTION_TYPE: {{ .Values.abacus.outboxChain.connectionType }}
ABC_BASE_OUTBOX_CONNECTION_TYPE: {{ .Values.abacus.outboxChain.connectionType }}
{{- end }}
{{- range .Values.abacus.inboxChains }}
{{- if .address }}
OPT_BASE_INBOXES_{{ .name | upper }}_ADDRESS: {{ .address }}
ABC_BASE_INBOXES_{{ .name | upper }}_ADDRESS: {{ .address }}
{{- end }}
{{- end }}
{{- if .Values.abacus.tracing.uri }}
OPT_BASE_TRACING_JAEGER_COLLECTOR_URI: {{ .Values.abacus.tracing.uri }}
ABC_BASE_TRACING_JAEGER_COLLECTOR_URI: {{ .Values.abacus.tracing.uri }}
{{- end }}
OPT_BASE_METRICS: {{ .Values.abacus.metrics.port | quote }}
ABC_BASE_METRICS: {{ .Values.abacus.metrics.port | quote }}

@ -21,14 +21,14 @@ spec:
{{- include "abacus-agent.labels" . | nindent 10 }}
data:
{{/* RPC URLs */}}
OPT_BASE_OUTBOX_CONNECTION_URL: {{ print "'{{ .home_rpc | toString }}'" }}
ABC_BASE_OUTBOX_CONNECTION_URL: {{ print "'{{ .home_rpc | toString }}'" }}
{{/*
* For each network, create an environment variable with the RPC endpoint.
* The templating of external-secrets will use the data section below to know how
* to replace the correct value in the created secret.
*/}}
{{- range .Values.abacus.inboxChains }}
OPT_BASE_INBOXES_{{ .name | upper }}_CONNECTION_URL: {{ printf "'{{ .%s_rpc | toString }}'" .name }}
ABC_BASE_INBOXES_{{ .name | upper }}_CONNECTION_URL: {{ printf "'{{ .%s_rpc | toString }}'" .name }}
{{- end }}
data:
- secretKey: home_rpc

@ -23,7 +23,7 @@ spec:
data:
{{- range .Values.abacus.kathy.signers }}
{{- if eq .keyConfig.type "hexKey" }}
OPT_BASE_SIGNERS_{{ .name | upper }}_KEY: {{ printf "'{{ .%s_signer_key | toString }}'" .name }}
ABC_BASE_SIGNERS_{{ .name | upper }}_KEY: {{ printf "'{{ .%s_signer_key | toString }}'" .name }}
{{- end }}
{{- end }}
{{- if .Values.abacus.kathy.aws }}

@ -60,7 +60,7 @@ spec:
{{- include "abacus-agent.config-env-vars" (dict "config" .keyConfig "agent_name" "base" "key_name_prefix" (printf "SIGNERS_%s_" (.name | upper))) | indent 10 }}
{{- end }}
{{- if .Values.abacus.tracing.uri }}
- name: OPT_BASE_TRACING_JAEGER_NAME
- name: ABC_BASE_TRACING_JAEGER_NAME
value: {{ include "abacus-agent.fullname" . }}-kathy
{{- end }}
resources:

@ -23,7 +23,7 @@ spec:
data:
{{- range .Values.abacus.relayer.signers }}
{{- if eq .keyConfig.type "hexKey" }}
OPT_BASE_SIGNERS_{{ .name | upper }}_KEY: {{ printf "'{{ .%s_signer_key | toString }}'" .name }}
ABC_BASE_SIGNERS_{{ .name | upper }}_KEY: {{ printf "'{{ .%s_signer_key | toString }}'" .name }}
{{- end }}
{{- end }}
{{- if .Values.abacus.relayer.aws }}

@ -60,7 +60,7 @@ spec:
{{- include "abacus-agent.config-env-vars" (dict "config" .keyConfig "agent_name" "base" "key_name_prefix" (printf "SIGNERS_%s_" (.name | upper))) | indent 10 }}
{{- end }}
{{- if .Values.abacus.tracing.uri }}
- name: OPT_BASE_TRACING_JAEGER_NAME
- name: ABC_BASE_TRACING_JAEGER_NAME
value: {{ include "abacus-agent.fullname" . }}-relayer
{{- end }}
resources:

@ -25,7 +25,7 @@ spec:
{{- range .Values.abacus.validator.configs }}
validator-{{ $index }}.env: |
{{- if eq .validator.type "hexKey" }}
OPT_VALIDATOR_VALIDATOR_KEY={{ printf "'{{ .signer_key_%d | toString }}'" $index }}
ABC_VALIDATOR_VALIDATOR_KEY={{ printf "'{{ .signer_key_%d | toString }}'" $index }}
{{- end }}
{{- if or (eq .checkpointSyncer.type "s3") $.Values.abacus.aws }}
AWS_ACCESS_KEY_ID={{ printf "'{{ .aws_access_key_id_%d | toString }}'" $index }}

@ -65,7 +65,7 @@ spec:
fieldRef:
fieldPath: metadata.name
{{- if .Values.abacus.tracing.uri }}
- name: OPT_BASE_TRACING_JAEGER_NAME
- name: ABC_BASE_TRACING_JAEGER_NAME
value: {{ include "abacus-agent.fullname" . }}-validator
{{- end }}
resources:

@ -27,27 +27,27 @@ VALIDATOR_DB="${ROCKS_DB_DIR?}/validator"
function relayer {(
declare -xr \
OPT_BASE_OUTBOX_CONNECTION_URL="http://localhost:8545" \
OPT_BASE_INBOXES_TEST2_CONNECTION_URL="http://localhost:8545" \
OPT_BASE_INBOXES_TEST3_CONNECTION_URL="http://localhost:8545" \
ABC_BASE_OUTBOX_CONNECTION_URL="http://localhost:8545" \
ABC_BASE_INBOXES_TEST2_CONNECTION_URL="http://localhost:8545" \
ABC_BASE_INBOXES_TEST3_CONNECTION_URL="http://localhost:8545" \
BASE_CONFIG="test1_config.json" \
RUN_ENV="test" \
OPT_BASE_METRICS="9092" \
OPT_BASE_TRACING_FMT="pretty" \
OPT_BASE_TRACING_LEVEL="info" \
OPT_BASE_DB="${RELAYER_DB?}" \
OPT_BASE_SIGNERS_TEST1_KEY="8166f546bab6da521a8369cab06c5d2b9e46670292d85c875ee9ec20e84ffb61" \
OPT_BASE_SIGNERS_TEST1_TYPE="hexKey" \
OPT_BASE_SIGNERS_TEST2_KEY="f214f2b2cd398c806f84e317254e0f0b801d0643303237d97a22a48e01628897" \
OPT_BASE_SIGNERS_TEST2_TYPE="hexKey" \
OPT_BASE_SIGNERS_TEST3_KEY="701b615bbdfb9de65240bc28bd21bbc0d996645a3dd57e7b12bc2bdf6f192c82" \
OPT_BASE_SIGNERS_TEST3_TYPE="hexKey" \
OPT_RELAYER_WHITELIST='[{"sourceAddress": "*", "destinationDomain": ["13372", "13373"], "destinationAddress": "*"}]' \
OPT_RELAYER_SIGNEDCHECKPOINTPOLLINGINTERVAL="5" \
OPT_RELAYER_MAXPROCESSINGRETRIES="5" \
OPT_RELAYER_MULTISIGCHECKPOINTSYNCER_THRESHOLD="1" \
OPT_RELAYER_MULTISIGCHECKPOINTSYNCER_CHECKPOINTSYNCERS_0x70997970c51812dc3a010c7d01b50e0d17dc79c8_TYPE="localStorage" \
OPT_RELAYER_MULTISIGCHECKPOINTSYNCER_CHECKPOINTSYNCERS_0x70997970c51812dc3a010c7d01b50e0d17dc79c8_PATH="${CHECKPOINTS_DIR?}"
ABC_BASE_METRICS="9092" \
ABC_BASE_TRACING_FMT="pretty" \
ABC_BASE_TRACING_LEVEL="info" \
ABC_BASE_DB="${RELAYER_DB?}" \
ABC_BASE_SIGNERS_TEST1_KEY="8166f546bab6da521a8369cab06c5d2b9e46670292d85c875ee9ec20e84ffb61" \
ABC_BASE_SIGNERS_TEST1_TYPE="hexKey" \
ABC_BASE_SIGNERS_TEST2_KEY="f214f2b2cd398c806f84e317254e0f0b801d0643303237d97a22a48e01628897" \
ABC_BASE_SIGNERS_TEST2_TYPE="hexKey" \
ABC_BASE_SIGNERS_TEST3_KEY="701b615bbdfb9de65240bc28bd21bbc0d996645a3dd57e7b12bc2bdf6f192c82" \
ABC_BASE_SIGNERS_TEST3_TYPE="hexKey" \
ABC_RELAYER_WHITELIST='[{"sourceAddress": "*", "destinationDomain": ["13372", "13373"], "destinationAddress": "*"}]' \
ABC_RELAYER_SIGNEDCHECKPOINTPOLLINGINTERVAL="5" \
ABC_RELAYER_MAXPROCESSINGRETRIES="5" \
ABC_RELAYER_MULTISIGCHECKPOINTSYNCER_THRESHOLD="1" \
ABC_RELAYER_MULTISIGCHECKPOINTSYNCER_CHECKPOINTSYNCERS_0x70997970c51812dc3a010c7d01b50e0d17dc79c8_TYPE="localStorage" \
ABC_RELAYER_MULTISIGCHECKPOINTSYNCER_CHECKPOINTSYNCERS_0x70997970c51812dc3a010c7d01b50e0d17dc79c8_PATH="${CHECKPOINTS_DIR?}"
declare -xr \
RUST_BACKTRACE=full
@ -57,22 +57,22 @@ function relayer {(
function validator {(
declare -xr \
OPT_BASE_OUTBOX_CONNECTION_URL="http://127.0.0.1:8545" \
OPT_BASE_INBOXES_TEST2_CONNECTION_URL="http://127.0.0.1:8545" \
OPT_BASE_INBOXES_TEST3_CONNECTION_URL="http://127.0.0.1:8545" \
ABC_BASE_OUTBOX_CONNECTION_URL="http://127.0.0.1:8545" \
ABC_BASE_INBOXES_TEST2_CONNECTION_URL="http://127.0.0.1:8545" \
ABC_BASE_INBOXES_TEST3_CONNECTION_URL="http://127.0.0.1:8545" \
BASE_CONFIG="test1_config.json" \
RUN_ENV="test" \
OPT_BASE_METRICS="9091" \
OPT_BASE_TRACING_FMT="pretty" \
OPT_BASE_TRACING_LEVEL="info" \
OPT_BASE_DB=""${VALIDATOR_DB?}"" \
OPT_VALIDATOR_VALIDATOR_KEY="59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d" \
OPT_VALIDATOR_VALIDATOR_TYPE="hexKey" \
OPT_VALIDATOR_REORGPERIOD="0" \
OPT_VALIDATOR_INTERVAL="5" \
OPT_VALIDATOR_CHECKPOINTSYNCER_THRESHOLD="1" \
OPT_VALIDATOR_CHECKPOINTSYNCER_TYPE="localStorage" \
OPT_VALIDATOR_CHECKPOINTSYNCER_PATH="${CHECKPOINTS_DIR?}"
ABC_BASE_METRICS="9091" \
ABC_BASE_TRACING_FMT="pretty" \
ABC_BASE_TRACING_LEVEL="info" \
ABC_BASE_DB=""${VALIDATOR_DB?}"" \
ABC_VALIDATOR_VALIDATOR_KEY="59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d" \
ABC_VALIDATOR_VALIDATOR_TYPE="hexKey" \
ABC_VALIDATOR_REORGPERIOD="0" \
ABC_VALIDATOR_INTERVAL="5" \
ABC_VALIDATOR_CHECKPOINTSYNCER_THRESHOLD="1" \
ABC_VALIDATOR_CHECKPOINTSYNCER_TYPE="localStorage" \
ABC_VALIDATOR_CHECKPOINTSYNCER_PATH="${CHECKPOINTS_DIR?}"
declare -xr \
RUST_BACKTRACE=full

@ -9,7 +9,7 @@ export const agent: AgentConfig<TestnetChains> = {
runEnv: 'testnet2',
docker: {
repo: 'gcr.io/abacus-labs-dev/abacus-agent',
tag: 'sha-d664980',
tag: 'sha-9ab7525',
},
aws: {
region: 'us-east-1',

@ -80,11 +80,11 @@ export async function getAgentEnvVars<Chain extends ChainName>(
let envVars: string[] = [];
const rpcEndpoints = await getSecretRpcEndpoints(agentConfig);
envVars.push(
`OPT_BASE_OUTBOX_CONNECTION_URL=${rpcEndpoints[outboxChainName]}`,
`ABC_BASE_OUTBOX_CONNECTION_URL=${rpcEndpoints[outboxChainName]}`,
);
valueDict.abacus.inboxChains.forEach((inboxChain: any) => {
envVars.push(
`OPT_BASE_INBOXES_${inboxChain.name.toUpperCase()}_CONNECTION_URL=${
`ABC_BASE_INBOXES_${inboxChain.name.toUpperCase()}_CONNECTION_URL=${
rpcEndpoints[inboxChain.name]
}`,
);
@ -93,10 +93,10 @@ export async function getAgentEnvVars<Chain extends ChainName>(
// Base vars from config map
envVars.push(`BASE_CONFIG=${valueDict.abacus.baseConfig}`);
envVars.push(`RUN_ENV=${agentConfig.runEnv}`);
envVars.push(`OPT_BASE_METRICS=9090`);
envVars.push(`OPT_BASE_TRACING_LEVEL=info`);
envVars.push(`ABC_BASE_METRICS=9090`);
envVars.push(`ABC_BASE_TRACING_LEVEL=info`);
envVars.push(
`OPT_BASE_DB=/tmp/${agentConfig.environment}-${role}-${outboxChainName}${
`ABC_BASE_DB=/tmp/${agentConfig.environment}-${role}-${outboxChainName}${
role === KEY_ROLE_ENUM.Validator ? `-${index}` : ''
}-db`,
);
@ -119,18 +119,18 @@ export async function getAgentEnvVars<Chain extends ChainName>(
if (role === KEY_ROLE_ENUM.Checkpointer || role === KEY_ROLE_ENUM.Relayer) {
chainNames.forEach((name) => {
envVars.push(
`OPT_BASE_SIGNERS_${name.toUpperCase()}_KEY=${strip0x(
`ABC_BASE_SIGNERS_${name.toUpperCase()}_KEY=${strip0x(
gcpKeys[keyId].privateKey,
)}`,
);
envVars.push(`OPT_BASE_SIGNERS_${name.toUpperCase()}_TYPE=hexKey`);
envVars.push(`ABC_BASE_SIGNERS_${name.toUpperCase()}_TYPE=hexKey`);
});
} else if (role === KEY_ROLE_ENUM.Validator) {
const privateKey = gcpKeys[keyId].privateKey;
envVars.push(
`OPT_VALIDATOR_VALIDATOR_KEY=${strip0x(privateKey)}`,
`OPT_VALIDATOR_VALIDATOR_TYPE=hexKey`,
`ABC_VALIDATOR_VALIDATOR_KEY=${strip0x(privateKey)}`,
`ABC_VALIDATOR_VALIDATOR_TYPE=hexKey`,
);
}
} else {
@ -225,7 +225,7 @@ export async function getAgentEnvVars<Chain extends ChainName>(
// Recursively converts a config object into environment variables than can
// be parsed by rust. For example, a config of { foo: { bar: { baz: 420 }, boo: 421 } } will
// be: OPT_FOO_BAR_BAZ=420 and OPT_FOO_BOO=421
// be: ABC_FOO_BAR_BAZ=420 and ABC_FOO_BOO=421
function configEnvVars(
config: Record<string, any>,
role: string,
@ -245,7 +245,7 @@ function configEnvVars(
];
} else {
envVars.push(
`OPT_${role.toUpperCase()}_${key_name_prefix}${key.toUpperCase()}=${
`ABC_${role.toUpperCase()}_${key_name_prefix}${key.toUpperCase()}=${
config[key]
}`,
);
@ -331,7 +331,7 @@ export async function runAgentHelmCommand<Chain extends ChainName>(
return execCmd(
`helm ${action} ${outboxChainName} ../../rust/helm/abacus-agent/ --create-namespace --namespace ${
agentConfig.namespace
} ${values.join(' ')} --debug --dry-run ${extraPipe}`,
} ${values.join(' ')} ${extraPipe}`,
{},
false,
true,

Loading…
Cancel
Save