Skip to content

Commit

Permalink
TT-856 two geth chains in crib (#11964)
Browse files Browse the repository at this point in the history
* we were referencing 2 values: networkid and networkId, now we will use only the latter

* geth is not more using devmode, now it's PoA with 1 node; we have 2 ephemermal private testnets; support for customl CLL node chain-specific TOML configuration

* connect to first chain

* revert app label changes

---------

Co-authored-by: skudasov <[email protected]>
  • Loading branch information
Tofel and skudasov authored Feb 8, 2024
1 parent aab449c commit d98ced4
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 64 deletions.
2 changes: 1 addition & 1 deletion charts/chainlink-cluster/connect.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace = "cl-cluster"
network_name = "geth"
network_chain_id = 1337
network_private_key = "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
network_ws_url = "ws://geth:8546"
network_ws_url = "ws://geth-1337:8546"
network_http_url = "http://geth:8544"
cl_nodes_num = 6
cl_node_url_template = "http://app-node-%d:6688"
Expand Down
32 changes: 26 additions & 6 deletions charts/chainlink-cluster/devspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pipelines:
echo "############################################"
echo "Ingress Domains"
echo "############################################"
ingress_names="node1 node2 node3 node4 node5 node6 geth-http geth-ws"
ingress_names="node1 node2 node3 node4 node5 node6 geth-1337-http geth-1337-ws geth-2337-http geth-2337-ws"
for ingress in ${ingress_names}; do
echo "https://${DEVSPACE_NAMESPACE}-${ingress}.${DEVSPACE_INGRESS_BASE_DOMAIN}"
done
Expand Down Expand Up @@ -230,7 +230,9 @@ deployments:
version: v1.12.0
wsrpc-port: 8546
httprpc-port: 8544
networkid: 1337
chains:
- networkId: 1337
- networkId: 2337
blocktime: 1
resources:
requests:
Expand Down Expand Up @@ -364,22 +366,40 @@ deployments:
name: app-node-6
port:
number: 6688
- host: ${DEVSPACE_NAMESPACE}-geth-http.${DEVSPACE_INGRESS_BASE_DOMAIN}
- host: ${DEVSPACE_NAMESPACE}-geth-1337-http.${DEVSPACE_INGRESS_BASE_DOMAIN}
http:
paths:
- path: /
backend:
service:
name: geth
name: geth-1337
port:
number: 8544
- host: ${DEVSPACE_NAMESPACE}-geth-ws.${DEVSPACE_INGRESS_BASE_DOMAIN}
- host: ${DEVSPACE_NAMESPACE}-geth-1337-ws.${DEVSPACE_INGRESS_BASE_DOMAIN}
http:
paths:
- path: /
backend:
service:
name: geth
name: geth-1337
port:
number: 8546
- host: ${DEVSPACE_NAMESPACE}-geth-2337-http.${DEVSPACE_INGRESS_BASE_DOMAIN}
http:
paths:
- path: /
backend:
service:
name: geth-2337
port:
number: 8544
- host: ${DEVSPACE_NAMESPACE}-geth-2337-ws.${DEVSPACE_INGRESS_BASE_DOMAIN}
http:
paths:
- path: /
backend:
service:
name: geth-2337
port:
number: 8546
- host: ${DEVSPACE_NAMESPACE}-mockserver.${DEVSPACE_INGRESS_BASE_DOMAIN}
Expand Down
13 changes: 9 additions & 4 deletions charts/chainlink-cluster/templates/chainlink-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,20 @@ data:
AnnounceAddresses = ['0.0.0.0:6690']
DeltaDial = '500ms'
DeltaReconcile = '5s'
{{- range $chainCfg := $.Values.geth.chains }}
[[EVM]]
ChainID = '1337'
ChainID = {{ $chainCfg.networkId | quote }}
MinContractPayment = '0'
AutoCreateKey = true
FinalityDepth = 1
{{- if (hasKey $chainCfg "customEVMConfigToml") }}
{{- $chainCfg.customEVMConfigToml | nindent 4 }}
{{- end }}
[[EVM.Nodes]]
Name = 'node-0'
WSURL = 'ws://geth:8546'
HTTPURL = 'http://geth:8544'
Name = 'node-{{ $chainCfg.networkId }}'
WSURL = 'ws://geth-{{ $chainCfg.networkId }}:8546'
HTTPURL = 'http://geth-{{ $chainCfg.networkId }}:8544'
{{- end }}
[WebServer.TLS]
HTTPSPort = 0
{{ end }}
Expand Down
30 changes: 19 additions & 11 deletions charts/chainlink-cluster/templates/geth-config-map.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{{ if (hasKey .Values "geth") }}
{{- range $cfg := .Values.geth.chains }}
apiVersion: v1
kind: ConfigMap
metadata:
labels:
app: geth-cm
release: {{ .Release.Name }}
name: geth-cm
app: geth-{{ $cfg.networkId }}-cm
release: {{ $.Release.Name }}
name: geth-{{ $cfg.networkId }}-cm
data:
key1: |
{"address":"f39fd6e51aad88f6f4ce6ab8827279cfffb92266","crypto":{"cipher":"aes-128-ctr","ciphertext":"c36afd6e60b82d6844530bd6ab44dbc3b85a53e826c3a7f6fc6a75ce38c1e4c6","cipherparams":{"iv":"f69d2bb8cd0cb6274535656553b61806"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"80d5f5e38ba175b6b89acfc8ea62a6f163970504af301292377ff7baafedab53"},"mac":"f2ecec2c4d05aacc10eba5235354c2fcc3776824f81ec6de98022f704efbf065"},"id":"e5c124e9-e280-4b10-a27b-d7f3e516b408","version":3}
Expand Down Expand Up @@ -50,17 +51,18 @@ data:
password.txt: |
init.sh: |
#!/bin/bash
if [ ! -d /app/.ethereum/keystore ]; then
echo "/app/.ethereum/keystore not found, running 'geth init'..."
geth init /app/ethconfig/genesis.json
if [ ! -d /chain/chain-data/keystore ]; then
echo "/chain/chain-data/keystore not found, running 'geth init'..."
geth init --datadir /chain/chain-data/ /chain/genesis.json
echo "...done!"
cp /chain/config/key* /chain/chain-data/keystore
fi
geth "$@"
cd /chain/chain-data && geth "$@"
genesis.json: |
{
"config": {
"chainId": {{ .Values.geth.networkId }},
"chainId": {{ $cfg.networkId }},
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
Expand All @@ -72,14 +74,18 @@ data:
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"berlinBlock": 0,
"londonBlock": 0
"londonBlock": 0,
"clique": {
"period": 2,
"epoch": 30000
}
},
"nonce": "0x0000000000000042",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"difficulty": "1",
"coinbase": "0x3333333333333333333333333333333333333333",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "8000000000",
"alloc": {
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266": {
Expand Down Expand Up @@ -144,4 +150,6 @@ data:
}
}
}
{{ end }}
---
{{- end }}
{{ end }}
70 changes: 32 additions & 38 deletions charts/chainlink-cluster/templates/geth-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
{{ if (hasKey .Values "geth") }}
{{- range $cfg := .Values.geth.chains }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: geth
name: geth-{{ $cfg.networkId }}
spec:
selector:
matchLabels:
app: geth
release: {{ $.Release.Name }}
instance: geth-{{ $cfg.networkId }}
# Used for testing.
# havoc-component-group and havoc-network-group are used by "havoc" chaos testing tool
havoc-component-group: "blockchain"
havoc-network-group: "blockchain"
release: {{ .Release.Name }}
template:
metadata:
labels:
app: geth
instance: geth-{{ $cfg.networkId }}
release: {{ $.Release.Name }}
# Used for testing.
# havoc-component-group and havoc-network-group are used by "havoc" chaos testing tool
havoc-component-group: "blockchain"
havoc-network-group: "blockchain"
release: {{ .Release.Name }}
annotations:
{{- range $key, $value := .Values.podAnnotations }}
{{- range $key, $value := $.Values.podAnnotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
volumes:
- name: configmap-volume
configMap:
name: geth-cm
name: geth-{{ $cfg.networkId }}-cm
- name: devchain-volume
emptyDir: {}
securityContext:
Expand All @@ -38,43 +41,32 @@ spec:
- name: geth-network
securityContext:
{{- toYaml $.Values.geth.securityContext | nindent 12 }}
image: "{{ default "ethereum/client-go" .Values.geth.image }}:{{ default "stable" .Values.geth.version }}"
command: [ "sh", "/app/init.sh" ]
image: "{{ default "ethereum/client-go" $.Values.geth.image }}:{{ default "stable" $.Values.geth.version }}"
command: [ "sh", "/chain/init.sh" ]
volumeMounts:
- name: devchain-volume
mountPath: /app/.ethereum/devchain
mountPath: /chain/chain-data
- name : configmap-volume
mountPath: /app/init.sh
mountPath: /chain/genesis.json
subPath: genesis.json
- name : configmap-volume
mountPath: /chain/init.sh
subPath: init.sh
- name: configmap-volume
mountPath: /app/config
- name: configmap-volume
mountPath: /app/.ethereum/devchain/keystore/key1
subPath: key1
- name: configmap-volume
mountPath: /app/.ethereum/devchain/keystore/key2
subPath: key2
- name: configmap-volume
mountPath: /app/.ethereum/devchain/keystore/key3
subPath: key3
mountPath: /chain/config
args:
- '--dev'
- '--password'
- '/app/config/password.txt'
- '/chain/config/password.txt'
- '--datadir'
- '/app/.ethereum/devchain'
- '/chain/chain-data/'
- '--unlock'
- '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
- '--unlock'
- '0x70997970C51812dc3A010C7d01b50e0d17dc79C8'
- '--unlock'
- '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC'
- '--mine'
- '--miner.etherbase'
- '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
- '--ipcdisable'
- '--http.api'
- 'admin,debug,web3,eth,txpool,personal,miner,net'
- 'admin,debug,clique,eth,miner,net,personal,txpool,web3'
- '--http'
- '--http.vhosts'
- '*'
Expand All @@ -95,38 +87,40 @@ spec:
- '--http.corsdomain'
- '*'
- '--vmdebug'
- '--networkid={{ .Values.geth.networkid }}'
- '--networkid={{ $cfg.networkId }}'
- '--rpc.txfeecap'
- '0'
- '--dev.period'
- '{{ .Values.geth.blocktime }}'
- '{{ $.Values.geth.blocktime }}'
- '--miner.gasprice'
- '10000000000'
ports:
- name: http-rpc
containerPort: 8544
- name: ws-rpc
containerPort: 8546
{{ if (hasKey .Values.geth "resources") }}
{{ if (hasKey $.Values.geth "resources") }}
resources:
requests:
memory: {{ default "1024Mi" .Values.geth.resources.requests.memory }}
cpu: {{ default "1000m" .Values.geth.resources.requests.cpu }}
memory: {{ default "1024Mi" $.Values.geth.resources.requests.memory }}
cpu: {{ default "1000m" $.Values.geth.resources.requests.cpu }}
limits:
memory: {{ default "1024Mi" .Values.geth.resources.limits.memory }}
cpu: {{ default "1000m" .Values.geth.resources.limits.cpu }}
memory: {{ default "1024Mi" $.Values.geth.resources.limits.memory }}
cpu: {{ default "1000m" $.Values.geth.resources.limits.cpu }}
{{ else }}
{{ end }}
{{- with .Values.nodeSelector }}
{{- with $.Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
{{- with $.Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
{{- with $.Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
{{ end }}
---
{{- end }}
{{ end }}
9 changes: 6 additions & 3 deletions charts/chainlink-cluster/templates/geth-service.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{{ if (hasKey .Values "geth") }}
{{- range $cfg := .Values.geth.chains }}
apiVersion: v1
kind: Service
metadata:
name: geth
name: geth-{{ $cfg.networkId }}
spec:
selector:
app: geth
release: {{ .Release.Name }}
instance: geth-{{ $cfg.networkId }}
release: {{ $.Release.Name }}
ports:
- name: ws-rpc
port: {{ default "8546" $.Values.geth.wsrpc_port}}
Expand All @@ -15,4 +16,6 @@ spec:
port: {{ default "8544" $.Values.geth.httprpc_port}}
targetPort: http-rpc
type: ClusterIP
---
{{- end }}
{{ end }}
13 changes: 12 additions & 1 deletion charts/chainlink-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,19 @@ geth:
version: v1.12.0
wsrpc-port: 8546
httprpc-port: 8544
networkid: 1337
blocktime: 1
chains:
- networkId: 1337
# use to inject custom configuration for each chain, e.g. GasEstimator
# - customEVMConfigToml: |
# [EVM.GasEstimator]
# PriceMax = '200 gwei'
# LimitDefault = 6000000
# FeeCapDefault = '200 gwei'
# [EVM.GasEstimator.BlockHistory]
# BlockHistorySize = 200
# EIP1559FeeCapBufferBlocks = 0
- networkId: 2337
resources:
requests:
cpu: 1
Expand Down

0 comments on commit d98ced4

Please sign in to comment.