1import * as _ from 'lodash-es' 13const builtinTestnets = ['sepolia', 'holesky'] 15const gethDeploymentTmpl = ({name, ethNetwork, nodePort, image, networkConfig, configHash, syncMode}: { 16 name: string, ethNetwork: string, nodePort: number, image: string, 17 networkConfig: {bootnodes: string[], genesisJson?: string} | null, configHash: string | undefined, syncMode: string | undefined, 19 const jwtSecretName = ethNetwork + '-jwt' 20 const isCustomNetwork = !!networkConfig 21 const isBuiltinTestnet = builtinTestnets.includes(ethNetwork) 23 if (!isCustomNetwork && !isBuiltinTestnet) throwIf(() => ethNetwork != 'mainnet') 26 'geth', '--datadir', '/geth-pv', '--cache', '4096', 27 '--authrpc.jwtsecret', jwtPath, 28 '--authrpc.addr=0.0.0.0', 29 '--authrpc.port=8551', 32 '--http.api=eth,net,engine,admin,web3,txpool', 33 '--http.addr', '0.0.0.0', 35 '--http.corsdomain', '*', 40 if (isCustomNetwork) { 43 '--override.genesis=/config/genesis.json', 44 `--bootnodes=${networkConfig.bootnodes.join(',')}`, 47 } else if (isBuiltinTestnet) { 48 command = [...baseCmd, `--${ethNetwork}`, `--syncmode=${syncMode || 'snap'}`] 54 {mountPath: '/geth-pv', name}, 55 {mountPath: jwtPath, name: jwtSecretName, subPath: jwtSecretName}, 57 const volumes: Record<string, unknown>[] = [ 58 {name, persistentVolumeClaim: {claimName: name}}, 59 {name: jwtSecretName, secret: {secretName: jwtSecretName}}, 62 if (isCustomNetwork) { 63 const genesisConfigMapName = `${name}-genesis` 64 volumeMounts.push({mountPath: '/config', name: 'genesis-config'}) 65 volumes.push({name: 'genesis-config', configMap: {name: genesisConfigMapName}}) 68 const annotations = configHash ? {configHash} : undefined 71 apiVersion: 'apps/v1', 75 selector: {matchLabels: {name}}, 77 strategy: {type: 'Recreate'}, 79 metadata: {labels: {name, [deployLabel]: name}, annotations}, 82 name: 'geth', image, command, 85 httpGet: {path: '/', port: 8545, httpHeaders: [{name: 'Content-Type', value: 'application/json'}]}, 86 initialDelaySeconds: 30, 97export const doSyncGeth = async ({sizeGb, nodePort, ethNetwork, image, networkConfig, syncMode}: { 98 sizeGb: number, nodePort: number, ethNetwork: string, image: string, 99 networkConfig: {bootnodes: string[], genesisJson?: string} | null, syncMode?: string, 103 const name = `geth-${ethNetwork}` 105 let configHash, genesisConfigMap 106 if (networkConfig?.genesisJson) { 107 const genesisConfigMapName = `${name}-genesis` 108 const result = configMapWithHash({name: genesisConfigMapName, data: {'genesis.json': networkConfig.genesisJson}, mountPath: '/config'}) 109 configHash = result.configHash 110 genesisConfigMap = result.configMap 114 gethDeploymentTmpl({name, ethNetwork, nodePort, image, networkConfig, configHash, syncMode}), 120 if (genesisConfigMap) resources.push(genesisConfigMap)