3import * as _ from 'lodash-es' 22const tekuDeploymentTmpl = ({ 23 name, p2pPort, ethNetwork, wsCheckpointS, httpWeb3Prov, 24 execEngProv, jwtSecretName, keystoresSecName, ethRewardAddr, 25 enableValidator, relayHostPort, vcapiKeystorePwSecName, 26 vcapiKeystoresName, image, 28 name: string, p2pPort: number, ethNetwork: string, wsCheckpointS: string | null, 29 httpWeb3Prov: string, execEngProv: string, jwtSecretName: string, keystoresSecName: string, 30 ethRewardAddr: string, enableValidator: boolean, relayHostPort: string | null, 31 vcapiKeystorePwSecName: string, vcapiKeystoresName: string, image: string, 34 const dataDir = '/data' 35 const keystoresDir = '/keystores' 36 const vcapiPwPath = '/vcapidir/vcpw.txt' 37 const vcapiKeystoresDir = `/${vcapiKeystoresName}` 41 name: vcapiKeystoresName, 42 mountPath: vcapiKeystoresDir, 45 name: vcapiKeystorePwSecName, subPath: vcapiKeystorePwSecName, 46 mountPath: vcapiPwPath, 49 name: jwtSecretName, subPath: jwtSecretName, 60 name: vcapiKeystorePwSecName, 62 secretName: vcapiKeystorePwSecName 68 secretName: jwtSecretName 73 persistentVolumeClaim: { 78 name: vcapiKeystoresName, 79 persistentVolumeClaim: { 80 claimName: vcapiKeystoresName 85 const {checkpointSyncUrl} = checkpointSyncCtx.getStore() as {checkpointSyncUrl?: string} || {} 88 `--network=${ethNetwork}`, 89 `--eth1-endpoints=${httpWeb3Prov}`, 90 `--ee-endpoint=${execEngProv}`, 92 `--data-base-path=${dataDir}`, 93 '--validators-keystore-locking-enabled=false', // otherwise validator fails because can't create .lock file in secrets dir 94 wsCheckpointS && `--ws-checkpoint=${wsCheckpointS}`, 95 `--validators-proposer-default-fee-recipient=${ethRewardAddr}`, 96 `--p2p-port=${p2pPort}`, 97 '--log-destination=CONSOLE', 98 '--rest-api-enabled', // using to check sync status 99 `--rest-api-host-allowlist=*`, 100 relayHostPort && `--builder-endpoint=http://${relayHostPort}`, 101 relayHostPort && '--validators-builder-registration-default-enabled=true', 102 checkpointSyncUrl && `--checkpoint-sync-url=${checkpointSyncUrl}`, 103 ]).compact().value().join(' ').split(' ') 105 if (enableValidator) { 106 args = _.union(args, [ 107 `--validator-keys=${keystoresDir}:${keystoresDir}`, 109 volumes = _.union(volumes, [ 111 name: keystoresSecName, 113 secretName: keystoresSecName 117 volumeMounts = _.union(volumeMounts, [ 119 name: keystoresSecName, 120 mountPath: keystoresDir, 127 apiVersion: 'apps/v1', 159 image, command: [], args, 171export const tekuBeaconApiNodePortTmpl = ({name, selfName, port, nodePort}: {name: string, selfName: string, port: number, nodePort: number}) => { 196export const doApplyTeku = async ({ethNetwork, tekuNodePort: p2pPort, localValSecretsPath, ethRewardAddr, enableValidator, relayHostPort, eth1ClientName, wsCheckpointS, image, tekuBeaconApiNodePort, guardValidatorFn, ethValidatorNums}: { 197 ethNetwork: string, tekuNodePort: number, localValSecretsPath?: string, ethRewardAddr: string, 198 enableValidator: boolean, relayHostPort: string | null, eth1ClientName: string, 199 wsCheckpointS: string | null, image: string, tekuBeaconApiNodePort: number | null, 202 const name = `teku-${ethNetwork}` 206 const {execEngProv, httpWeb3Prov, jwtSecretName} = getEth2Vals({ethNetwork, eth1ClientName}) 208 const keystoresSecName = name + '-keystores' 210 const vcapiKeystorePwSecName = `${name}-vcapi-keystore-pw` 211 const vcapiKeystoresName = `${name}-vcapi-keystores` 213 const deployment = tekuDeploymentTmpl({ 215 name, ethNetwork, p2pPort, keystoresSecName, httpWeb3Prov, execEngProv, 216 jwtSecretName, ethRewardAddr, enableValidator, relayHostPort, 217 wsCheckpointS, vcapiKeystorePwSecName, vcapiKeystoresName 220 deployment, enabled: enableValidator === true && action != 'delete', 221 ethValidatorNum: ethValidatorNums?.[0], cluster_name, domainName: domainNames?.[0], cfApiKeySecretName, 225 ...(claimCheckConfigMap ? [claimCheckConfigMap] : []), 228 5051, // rest for check sync status 234 ...await genericPvcTmplA({action, cluster_name, name: vcapiKeystoresName, sizeGb: 40, useM2: true}), 237 if (tekuBeaconApiNodePort) { 239 tekuBeaconApiNodePortTmpl({name, selfName: name + 'privbeaconapi', port: 5051, nodePort: tekuBeaconApiNodePort}) 243 if (action != 'delete') { 247 if (enableValidator === true) { 250 await guardValidatorFn({ethNetwork, name, cluster_name, action}) 251 const {walletPassSecName} = getEth2Vals({ethNetwork, eth1ClientName}) 253 const secretsH: Record<string, string> = {} 254 if (action != 'delete') { 256 const keystoreFiles = _.filter(fs.readdirSync(localValSecretsPath), (path) => { 257 // filter .DS_Store, deposit_data files etc 258 return _.endsWith(path, '.json') && _.startsWith(path, 'keystore-') 260 _.each(keystoreFiles, (filename) => { 261 const passTxtFilename = _.replace(filename, '.json', '.txt') 262 const keystoreVal = fs.readFileSync([localValSecretsPath, filename].join('/'), 'utf8') 263 secretsH[filename] = keystoreVal 264 secretsH[passTxtFilename] = walletPassS 267 resources = _.union(resources, [ 272 resources = _.union(resources, cleanupResOnDelete({action, enabled: enableValidator, secNames: [keystoresSecName]}))