Skip to content

Add local Bitcoin network simulation #690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/config/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"chains": "Chains Directive Syntax",
"relayers": "Relayers Directive Syntax",
"features": "Feature Toggles",
"ethereum": "Ethereum"
"ethereum": "Ethereum",
"bitcoin": "Bitcoin"
}
19 changes: 19 additions & 0 deletions docs/config/bitcoin.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Bitcoin Chain Configuration in Starship

Starship now supports running a local Bitcoin network alongside Cosmos and Ethereum chains.
The configuration mirrors other chains and can be added in the `chains` section of your
Starship config file.

## Example Configuration
```yaml
chains:
- id: bitcoin-local
name: bitcoin
numValidators: 1
ports:
rpc: 18443
p2p: 18444
```

This will start a single `bitcoind` node in regtest mode exposing RPC on `18443` and
P2P on `18444` which you can port-forward to localhost.
12 changes: 12 additions & 0 deletions starship/charts/devnet/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,18 @@ defaultChains:
- --chain-config-file=/etc/config/config.yml
- --suggested-fee-recipient=0x0C46c2cAFE097b4f7e1BB868B89e5697eE65f934

bitcoin:
image: ruimarinho/bitcoin-core:latest
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be just a random docker image, and seems to be outdated.

home: /bitcoin
binary: bitcoind
prefix: btc
denom: satoshi
prettyName: Bitcoin
coins: 2100000000000000satoshi
hdPath: m/44'/0'/0'/0/0
coinType: 0
repo: https://github.com/bitcoin/bitcoin

defaultRelayers:
ts-relayer:
image: ghcr.io/cosmology-tech/starship/ts-relayer:0.9.0
Expand Down
27 changes: 27 additions & 0 deletions starship/charts/devnet/templates/chains/bitcoin/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{- range $chain := .Values.chains }}
{{- if hasPrefix "bitcoin" $chain.name }}
{{ $defaultFile := $.Files.Get "defaults.yaml" | fromYaml }}
{{ $chain := include "devnet.fullchain" (dict "name" $chain.id "file" $defaultFile "context" $) | fromJson }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ $chain.name }}-{{ $chain.id }}
labels:
app.kubernetes.io/name: {{ $chain.name }}-{{ $chain.id }}
spec:
clusterIP: None
ports:
- name: rpc
port: {{ $chain.ports.rpc | default 18443 }}
protocol: TCP
targetPort: {{ $chain.ports.rpc | default 18443 }}
- name: p2p
port: {{ $chain.ports.p2p | default 18444 }}
protocol: TCP
targetPort: {{ $chain.ports.p2p | default 18444 }}
selector:
app.kubernetes.io/name: {{ $chain.name }}-{{ $chain.id }}
---
{{- end }}
{{- end }}
39 changes: 39 additions & 0 deletions starship/charts/devnet/templates/chains/bitcoin/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{{- range $chain := .Values.chains }}
{{- if hasPrefix "bitcoin" $chain.name }}
{{ $defaultFile := $.Files.Get "defaults.yaml" | fromYaml }}
{{ $chain := include "devnet.fullchain" (dict "name" $chain.id "file" $defaultFile "context" $) | fromJson }}
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ $chain.name }}-{{ $chain.id }}
spec:
serviceName: {{ $chain.name }}-{{ $chain.id }}
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: {{ $chain.name }}-{{ $chain.id }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ $chain.name }}-{{ $chain.id }}
app.kubernetes.io/type: {{ $chain.id }}
spec:
containers:
- name: bitcoind
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need some init containers so that the btc nodes are more configureable.

image: {{ $chain.image }}
args:
- "-regtest"
- "-server"
- "-txindex"
- "-rpcallowip=0.0.0.0/0"
- "-rpcbind=0.0.0.0"
- "-port={{ $chain.ports.p2p | default 18444 }}"
- "-rpcport={{ $chain.ports.rpc | default 18443 }}"
ports:
- containerPort: {{ $chain.ports.rpc | default 18443 }}
name: rpc
- containerPort: {{ $chain.ports.p2p | default 18444 }}
name: p2p
{{- end }}
{{- end }}
3 changes: 2 additions & 1 deletion starship/charts/devnet/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@
"hyperweb",
"noble",
"xpla",
"ethereum"
"ethereum",
"bitcoin"
]
},
"numValidators": {
Expand Down
Loading