Skip to content

Commit b29a170

Browse files
committed
feat(infra): migrate to standalone keyfunder package with ExternalSecrets
1 parent 2103db3 commit b29a170

18 files changed

Lines changed: 516 additions & 1671 deletions

File tree

pnpm-lock.yaml

Lines changed: 125 additions & 299 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typescript/infra/config/docker.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
1-
export const DockerImageRepos = {
2-
AGENT: 'gcr.io/abacus-labs-dev/hyperlane-agent',
3-
MONOREPO: 'gcr.io/abacus-labs-dev/hyperlane-monorepo',
4-
WARP_MONITOR: 'gcr.io/abacus-labs-dev/hyperlane-warp-monitor',
5-
REBALANCER: 'gcr.io/abacus-labs-dev/hyperlane-rebalancer',
1+
const GCR_REGISTRY = 'gcr.io/abacus-labs-dev';
2+
3+
export const DockerImageNames = {
4+
AGENT: 'hyperlane-agent',
5+
MONOREPO: 'hyperlane-monorepo',
6+
KEY_FUNDER: 'hyperlane-key-funder',
7+
WARP_MONITOR: 'hyperlane-warp-monitor',
8+
REBALANCER: 'hyperlane-rebalancer',
69
} as const;
710

11+
type DockerImageReposType = {
12+
[K in keyof typeof DockerImageNames]: `${typeof GCR_REGISTRY}/${(typeof DockerImageNames)[K]}`;
13+
};
14+
15+
export const DockerImageRepos = Object.fromEntries(
16+
Object.entries(DockerImageNames).map(([key, name]) => [
17+
key,
18+
`${GCR_REGISTRY}/${name}`,
19+
]),
20+
) as DockerImageReposType;
21+
822
interface AgentDockerTags {
923
relayer: string;
1024
relayerRC: string;

typescript/infra/config/environments/mainnet3/funding.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const keyFunderConfig: KeyFunderConfig<
3636
typeof mainnet3SupportedChainNames
3737
> = {
3838
docker: {
39-
repo: DockerImageRepos.MONOREPO,
39+
repo: DockerImageRepos.KEY_FUNDER,
4040
tag: mainnetDockerTags.keyFunder,
4141
},
4242
// We're currently using the same deployer/key funder key as mainnet2.

typescript/infra/config/environments/testnet4/funding.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const keyFunderConfig: KeyFunderConfig<
1010
typeof testnet4SupportedChainNames
1111
> = {
1212
docker: {
13-
repo: DockerImageRepos.MONOREPO,
13+
repo: DockerImageRepos.KEY_FUNDER,
1414
tag: testnetDockerTags.keyFunder,
1515
},
1616
// We're currently using the same deployer key as testnet2.

typescript/infra/helm/key-funder/templates/addresses-external-secret.yaml

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: key-funder-config
5+
labels:
6+
{{- include "hyperlane.labels" . | nindent 4 }}
7+
data:
8+
keyfunder.yaml: |
9+
{{ .Values.hyperlane.keyfunderConfig | indent 4 }}

typescript/infra/helm/key-funder/templates/cron-job.yaml

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ spec:
1010
jobTemplate:
1111
spec:
1212
backoffLimit: 0
13-
activeDeadlineSeconds: 14400 # 60 * 60 * 4 seconds = 4 hours
13+
activeDeadlineSeconds: 14400
1414
template:
1515
metadata:
1616
labels:
@@ -21,52 +21,33 @@ spec:
2121
- name: key-funder
2222
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
2323
imagePullPolicy: IfNotPresent
24-
command:
25-
- pnpm
26-
- exec
27-
- tsx
28-
- ./typescript/infra/scripts/funding/fund-keys-from-deployer.ts
29-
- -e
30-
- {{ .Values.hyperlane.runEnv }}
31-
- --context
32-
- {{ .Values.hyperlane.contextFundingFrom }}
33-
{{- range $context, $roles := .Values.hyperlane.contextsAndRolesToFund }}
34-
- --contexts-and-roles
35-
- {{ $context }}={{ join "," $roles }}
36-
{{- end }}
37-
{{- range $chain, $balance := .Values.hyperlane.desiredBalancePerChain }}
38-
- --desired-balance-per-chain
39-
- {{ $chain }}={{ $balance }}
40-
{{- end }}
41-
{{- range $chain, $balance := .Values.hyperlane.desiredKathyBalancePerChain }}
42-
- --desired-kathy-balance-per-chain
43-
- {{ $chain }}={{ $balance }}
44-
{{- end }}
45-
{{- range $chain, $balance := .Values.hyperlane.desiredRebalancerBalancePerChain }}
46-
- --desired-rebalancer-balance-per-chain
47-
- {{ $chain }}={{ $balance }}
48-
{{- end }}
49-
{{- range $chain, $balance := .Values.hyperlane.igpClaimThresholdPerChain }}
50-
- --igp-claim-threshold-per-chain
51-
- {{ $chain }}={{ $balance }}
52-
{{- end }}
53-
{{- if .Values.hyperlane.chainsToSkip }}
54-
- --chain-skip-override
55-
{{- range $index, $chain := .Values.hyperlane.chainsToSkip }}
56-
- {{ $chain }}
57-
{{- end }}
58-
{{- end }}
5924
env:
25+
- name: LOG_FORMAT
26+
value: json
27+
- name: LOG_LEVEL
28+
value: info
29+
- name: KEYFUNDER_CONFIG_FILE
30+
value: /config/keyfunder.yaml
31+
{{- if .Values.hyperlane.registryUri }}
32+
- name: REGISTRY_URI
33+
value: {{ .Values.hyperlane.registryUri }}
34+
{{- end }}
35+
{{- if .Values.hyperlane.skipIgpClaim }}
36+
- name: SKIP_IGP_CLAIM
37+
value: "true"
38+
{{- end }}
39+
{{- if .Values.hyperlane.prometheusPushGateway }}
6040
- name: PROMETHEUS_PUSH_GATEWAY
61-
value: {{ .Values.infra.prometheusPushGateway }}
41+
value: {{ .Values.hyperlane.prometheusPushGateway }}
42+
{{- end }}
6243
envFrom:
6344
- secretRef:
6445
name: key-funder-env-var-secret
6546
volumeMounts:
66-
- name: key-funder-addresses-secret
67-
mountPath: /addresses-secret
47+
- name: config
48+
mountPath: /config
49+
readOnly: true
6850
volumes:
69-
- name: key-funder-addresses-secret
70-
secret:
71-
secretName: key-funder-addresses-secret
72-
defaultMode: 0400
51+
- name: config
52+
configMap:
53+
name: key-funder-config

typescript/infra/helm/key-funder/templates/env-var-external-secret.yaml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ spec:
99
name: {{ include "hyperlane.cluster-secret-store.name" . }}
1010
kind: ClusterSecretStore
1111
refreshInterval: "1h"
12-
# The secret that will be created
1312
target:
1413
name: key-funder-env-var-secret
1514
template:
@@ -20,24 +19,14 @@ spec:
2019
annotations:
2120
update-on-redeploy: "{{ now }}"
2221
data:
23-
GCP_SECRET_OVERRIDES_ENABLED: "true"
24-
GCP_SECRET_OVERRIDE_HYPERLANE_{{ .Values.hyperlane.runEnv | upper }}_KEY_DEPLOYER: {{ print "'{{ .deployer_key | toString }}'" }}
25-
{{/*
26-
* For each network, create an environment variable with the RPC endpoint.
27-
* The templating of external-secrets will use the data section below to know how
28-
* to replace the correct value in the created secret.
29-
*/}}
22+
HYP_KEY: {{ print "'{{ $json := .funder_key | fromJson }}{{ $json.privateKey }}'" }}
3023
{{- range .Values.hyperlane.chains }}
31-
GCP_SECRET_OVERRIDE_{{ $.Values.hyperlane.runEnv | upper }}_RPC_ENDPOINTS_{{ . | upper }}: {{ printf "'{{ .%s_rpcs | toString }}'" . }}
24+
RPC_URL_{{ . | upper | replace "-" "_" }}: {{ printf "'{{ index (.%s_rpcs | fromJson) 0 }}'" . }}
3225
{{- end }}
3326
data:
34-
- secretKey: deployer_key
27+
- secretKey: funder_key
3528
remoteRef:
3629
key: {{ printf "hyperlane-%s-key-deployer" .Values.hyperlane.runEnv }}
37-
{{/*
38-
* For each network, load the secret in GCP secret manager with the form: environment-rpc-endpoint-network,
39-
* and associate it with the secret key networkname_rpc.
40-
*/}}
4130
{{- range .Values.hyperlane.chains }}
4231
- secretKey: {{ printf "%s_rpcs" . }}
4332
remoteRef:

typescript/infra/helm/key-funder/values.yaml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
image:
2-
repository: gcr.io/hyperlane-labs-dev/hyperlane-monorepo
3-
tag:
2+
repository: gcr.io/abacus-labs-dev/hyperlane-key-funder
3+
tag: latest
44
hyperlane:
5-
runEnv: testnet2
6-
# Used for fetching secrets
5+
runEnv: testnet4
76
chains: []
87
chainsToSkip: []
9-
contextFundingFrom: hyperlane
10-
# key = context, value = array of roles to fund
11-
contextsAndRolesToFund:
12-
hyperlane:
13-
- relayer
8+
registryUri: ''
9+
keyfunderConfig: ''
10+
skipIgpClaim: false
11+
prometheusPushGateway: ''
1412
cronjob:
15-
schedule: '*/10 * * * *' # Every 10 minutes
13+
schedule: '*/10 * * * *'
1614
successfulJobsHistoryLimit: 6
1715
failedJobsHistoryLimit: 10
1816
externalSecrets:

typescript/infra/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"@hyperlane-xyz/core": "workspace:*",
1919
"@hyperlane-xyz/helloworld": "workspace:*",
2020
"@hyperlane-xyz/http-registry-server": "workspace:*",
21+
"@hyperlane-xyz/keyfunder": "workspace:*",
2122
"@hyperlane-xyz/metrics": "workspace:*",
2223
"@hyperlane-xyz/rebalancer": "workspace:*",
2324
"@hyperlane-xyz/registry": "catalog:",

0 commit comments

Comments
 (0)