Skip to content

Commit

Permalink
Kubernetes configuration for Keep Maintainer bot (#3689)
Browse files Browse the repository at this point in the history
In this PR we update the configuration of keep-client maintainer
deployment running in keep-test and keep-prd.

### Template
We define a template for running the keep-client in maintainer mode with
all the available modules:
- spv
- walletCoordination
- bitcoinDifficulty

### keep-prd

In keep-prd cluster we replaced the previously running Bitcoin
difficulty maintainer with a new instance of all-in-one maintainer bot.

### keep-test

In keep-test we have to adjust the setup to work correctly with the
`LightRelay` contract.

Bitcoin Relay used by the tTBTC system on testnet environment is an
optimized version of the Light Relay implemented by
[GoerliLightRelay](https://github.com/keep-network/tbtc-v2/blob/main/solidity/contracts/test/GoerliLightRelay.sol)
contract. The reason the Light Relay had to be modified for testnet is
that on Bitcoin testnet difficulty often drops to `1`, which makes the
blocks validation on such change impossible to the regular Light Relay
contract.

The `GoerliLightRelay` version doesn't require a maintainer bot to
submit block headers on difficulty change. It accepts ad-hoc difficulty
alignment according to the tests needs.

For these reasons, we are running two instances of keep-maintainer.

The first instance `keep-maintainer` is connected to Bitcoin testnet and
runs `spv` and `walletCoordination` modules.

The second instance `keep-maintainer-staging` is connected to Bitcoin
mainnet and runs only `bitcoinDifficulty` module.

The test environment setup for the relay contract is subject to change
in the coming weeks, so the configuration defined in this PR for the
keep-test is expected to be modified then.
  • Loading branch information
lukasz-zimnoch authored Jul 19, 2023
2 parents 08ee58c + 8a1d59b commit 6a07fb8
Show file tree
Hide file tree
Showing 10 changed files with 237 additions and 197 deletions.
27 changes: 0 additions & 27 deletions infrastructure/kube/keep-prd/btc-difficulty/kustomization.yaml

This file was deleted.

This file was deleted.

33 changes: 33 additions & 0 deletions infrastructure/kube/keep-prd/keep-maintainer/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
resources:
- ../../templates/keep-maintainer

namespace: default

commonLabels:
app: keep-maintainer
type: all
network: mainnet

images:
- name: keep-maintainer
newName: gcr.io/keep-prd-210b/keep-client
newTag: v2.0.0-m4-rc

configMapGenerator:
- name: keep-maintainer-config
behavior: merge
literals:
- network=mainnet
- electrum-api-url=ws://electrumx.bitcoin:8080
files:
- .secret/keep-maintainer-keyfile

secretGenerator:
- name: keep-maintainer-eth-account-password
files:
- .secret/keep-maintainer-password

generatorOptions:
disableNameSuffixHash: true
annotations:
note: generated
27 changes: 0 additions & 27 deletions infrastructure/kube/keep-test/btc-difficulty/kustomization.yaml

This file was deleted.

This file was deleted.

14 changes: 14 additions & 0 deletions infrastructure/kube/keep-test/keep-maintainer-staging/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Keep Maintainer Staging Mainnet

Bitcoin Relay used by the tTBTC system on testnet environment is an optimized version
of the Light Relay implemented by [GoerliLightRelay](https://github.com/keep-network/tbtc-v2/blob/main/solidity/contracts/test/GoerliLightRelay.sol)
contract. The reason the Light Relay had to be modified for testnet is that on
Bitcoin testnet difficulty often drops to `1`, which makes the blocks validation
on such change impossible to the regular Light Relay contract.

The `GoerliLightRelay` version doesn't require a maintainer bot to submit block
headers on difficulty change. It accepts ad-hoc difficulty alignment according to
the tests needs.

The setup defined in this directory is meant for testing the bitcoin difficulty module
of the maintainer bot with the Bitcoin mainnet blockchain state.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
resources:
- ../../templates/keep-maintainer

namespace: default

# Regular testnet maintainer doesn't run bitcoinDifficulty module due to specifics
# of LightRelay running on testnet (GoerliLightRelay). This setup is running
# the `bitcoinDifficulty` module of maintainer connected to Bitcoin mainnet.
nameSuffix: -staging

commonLabels:
app: keep-maintainer-staging
type: bitcoinDifficulty
network: goerli

images:
- name: keep-maintainer
newName: gcr.io/keep-test-f3e0/keep-client
newTag: latest

configMapGenerator:
- name: keep-maintainer-config
behavior: merge
literals:
- network=testnet
- electrum-api-url=wss://electrumx-server.tbtc.network:8443
files:
- .secret/keep-maintainer-keyfile

secretGenerator:
- name: keep-maintainer-eth-account-password
files:
- .secret/keep-maintainer-password

patches:
- target:
kind: StatefulSet
name: keep-maintainer
patch: |-
- op: add
path: /spec/template/spec/containers/0/args/-
value: --bitcoinDifficulty
- op: replace
path: /spec/template/spec/containers/0/env/0/valueFrom/secretKeyRef/name
value: eth-network-goerli
generatorOptions:
disableNameSuffixHash: true
annotations:
note: generated
54 changes: 54 additions & 0 deletions infrastructure/kube/keep-test/keep-maintainer/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
resources:
- ../../templates/keep-maintainer

namespace: default

commonLabels:
app: keep-maintainer
# The current setup runs spv and walletCoordination modules as a workaround
# for reasons mentioned in `patches` property below.
type: all
network: goerli

images:
- name: keep-maintainer
newName: gcr.io/keep-test-f3e0/keep-client
newTag: latest

configMapGenerator:
- name: keep-maintainer-config
behavior: merge
literals:
- network=testnet
- electrum-api-url=ws://electrumx.bitcoin-testnet:8080
files:
- .secret/keep-maintainer-keyfile

secretGenerator:
- name: keep-maintainer-eth-account-password
files:
- .secret/keep-maintainer-password

patches:
# Testnet's maintainer shouldn't run `--bitcoinDifficulty` module, as the testnet
# uses modified version of LightRelay contract (GoerliLightRelay) that doesn't
# require the bitcoin difficulty to be submitted. This patch defines manually
# which modules should be started.
- target:
kind: StatefulSet
name: keep-maintainer
patch: |-
- op: add
path: /spec/template/spec/containers/0/args/-
value: --spv
- op: add
path: /spec/template/spec/containers/0/args/-
value: --walletCoordination
- op: replace
path: /spec/template/spec/containers/0/env/0/valueFrom/secretKeyRef/name
value: eth-network-goerli
generatorOptions:
disableNameSuffixHash: true
annotations:
note: generated
17 changes: 17 additions & 0 deletions infrastructure/kube/templates/keep-maintainer/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
resources:
- maintainer-statefulset.yaml

commonLabels:
app: keep-maintainer
type: all

configMapGenerator:
- name: keep-maintainer-config
literals:
- log-level=info
- log-format=json

generatorOptions:
disableNameSuffixHash: true
annotations:
note: generated
Loading

0 comments on commit 6a07fb8

Please sign in to comment.