devnet: add algorand sandnet

As far as I can tell, both primary and node are happy. We can't use
https://github.com/algorand/sandbox since it makes too many
assumptions about its environment (docker-compose, interactive
development vs. reproducible CI usage).

Instead, use the official mainnet Docker images and ship our own config.

Caveat: "goal network create" is not reproducible and each Docker
build will generate a new set of root keys. We can presumably avoid
this by hardcoding the output of "goal network create"
(using --noimportkeys to avoid having to vendor a SQLite DB.. we'd
just re-import them to kmd at runtime, which is what goal is doing
internally: f51d2d7d5a/netdeploy/networkTemplate.go (L131))

Change-Id: I8c99c6150c9c244c9f12b68a58184c2d5697cee8
This commit is contained in:
Leo 2021-12-09 01:32:16 +01:00 committed by Josh Siegel
parent 982956fcb4
commit e4802d42d7
8 changed files with 179 additions and 0 deletions

View File

@ -178,3 +178,13 @@ Run the bridge UI in devnet by supplying the `--bridge_ui` flag:
tilt up -- --bridge_ui
### Algorand
Node logs:
kubectl exec -c algod algorand-0 -- tail -f /network/Node/node.log
kubectl exec -c algod algorand-0 -- tail -f /network/Primary/node.log
Account list:
kubectl exec -c goal-kmd algorand-0 -- ./goal account list

View File

@ -286,6 +286,24 @@ if bridge_ui:
trigger_mode = trigger_mode,
)
# algorand
k8s_yaml_with_ns("devnet/algorand.yaml")
docker_build(
ref = "algorand",
context = "third_party/algorand",
dockerfile = "third_party/algorand/Dockerfile",
)
k8s_resource(
"algorand",
port_forwards = [
port_forward(4001, name = "Algorand RPC [:4001]", host = webHost),
port_forward(4002, name = "Algorand KMD [:4002]", host = webHost),
],
trigger_mode = trigger_mode,
)
# bigtable
def build_cloud_function(container_name, go_func_name, path, builder):

62
devnet/algorand.yaml Normal file
View File

@ -0,0 +1,62 @@
---
apiVersion: v1
kind: Service
metadata:
name: algorand
labels:
app: algorand
spec:
clusterIP: None
selector:
app: algorand
ports:
- name: algod
port: 4001
targetPort: algod
- name: kmd
port: 4002
targetPort: kmd
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: algorand
spec:
selector:
matchLabels:
app: algorand
serviceName: algorand
template:
metadata:
labels:
app: algorand
spec:
restartPolicy: Always
terminationGracePeriodSeconds: 0
containers:
- name: algod
image: algorand
command:
- /bin/sh
- -c
- ./goal network start -r /network && sleep infinity
ports:
- containerPort: 4001
name: algod
protocol: TCP
readinessProbe:
tcpSocket:
port: 4001
- name: goal-kmd
image: algorand
command:
- /bin/sh
- -c
- ./goal kmd start -d /network/Node && ./goal account list && sleep infinity
ports:
- containerPort: 4002
name: kmd
protocol: TCP
readinessProbe:
tcpSocket:
port: 4002

16
third_party/algorand/Dockerfile vendored Normal file
View File

@ -0,0 +1,16 @@
# syntax=docker/dockerfile:1.2
FROM docker.io/algorand/stable:3.2.1@sha256:0a87978492680fd98e2cc410f59f2bfd7fef979f035eb060685d56a6e916b5bd
RUN mkdir -p /setup
ADD template.json /setup/
RUN ./goal network create -n sandnet -r /network -t /setup/template.json && echo rawr
RUN mkdir -p /network/Node/kmd-v0.5
ADD token /network/Node/algod.token
ADD token /network/Node/kmd-v0.5/kmd.token
ADD config.json /network/Node/config.json
ADD kmd_config.json /network/Node/kmd-v0.5/kmd_config.json
ENV ALGORAND_DATA=/network/Node

10
third_party/algorand/config.json vendored Normal file
View File

@ -0,0 +1,10 @@
{
"Version": 12,
"GossipFanout": 1,
"EndpointAddress": "0.0.0.0:4001",
"DNSBootstrapID": "",
"IncomingConnectionsLimit": 0,
"Archival": false,
"isIndexerActive": false,
"EnableDeveloperAPI": true
}

6
third_party/algorand/kmd_config.json vendored Normal file
View File

@ -0,0 +1,6 @@
{
"address": "0.0.0.0:4002",
"allowed_origins": [
"*"
]
}

56
third_party/algorand/template.json vendored Normal file
View File

@ -0,0 +1,56 @@
{
"Genesis": {
"NetworkName": "",
"Wallets": [
{
"Name": "Wallet1",
"Stake": 10,
"Online": true
},
{
"Name": "Wallet2",
"Stake": 40,
"Online": true
},
{
"Name": "Wallet3",
"Stake": 40,
"Online": false
},
{
"Name": "Wallet4",
"Stake": 10,
"Online": false
}
]
},
"Nodes": [
{
"Name": "Primary",
"IsRelay": true,
"Wallets": [
{
"Name": "Wallet1",
"ParticipationOnly": false
}
]
},
{
"Name": "Node",
"Wallets": [
{
"Name": "Wallet2",
"ParticipationOnly": false
},
{
"Name": "Wallet3",
"ParticipationOnly": false
},
{
"Name": "Wallet4",
"ParticipationOnly": false
}
]
}
]
}

1
third_party/algorand/token vendored Normal file
View File

@ -0,0 +1 @@
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa