forked from MSevey/celestia-da-node-package
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.star
116 lines (110 loc) · 3.48 KB
/
main.star
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
NETWORK = "arabica"
DEFAULT_CONFIG = {
"arabica": {
# "da_image": "ghcr.io/celestiaorg/celestia-node:v0.18.1-arabica",
"da_image": "celestia-node:v0.18.1-arabica-fix", # custom local image until PR is merged
"core_ip": "validator-1.celestia-arabica-11.com",
},
"mocha": {
"da_image": "ghcr.io/celestiaorg/celestia-node:v0.18.1-mocha",
"core_ip": "full.consensus.mocha-4.celestia-mocha.com",
},
}
def run(
plan,
node_type="light",
da_image=DEFAULT_CONFIG[NETWORK]["da_image"],
core_ip=DEFAULT_CONFIG[NETWORK]["core_ip"],
p2p_network=NETWORK,
):
# Add celestia da node from docker image
da_node_service_name = "celestia-{0}-{1}".format(node_type, p2p_network)
da_node = plan.add_service(
name=da_node_service_name,
config=ServiceConfig(
image=da_image,
# Expose the RPC port
ports={
"rpc": PortSpec(
number=26658,
transport_protocol="TCP",
application_protocol="http",
),
},
public_ports={
"rpc": PortSpec(
number=26658,
transport_protocol="TCP",
application_protocol="http",
),
},
# Set environment variables used by the docker image
env_vars={
"NODE_TYPE": node_type,
"P2P_NETWORK": p2p_network,
},
# Set the command to start the node
cmd=[
"celestia",
node_type,
"start",
"--core.ip",
core_ip,
"--p2p.network",
p2p_network,
],
),
)
# General notes on the following steps:
# - jq -r requests the raw output from jq, without quotes
# - tr -d '\n' removes the newline character from the output
# Get the node's address
get_address_result = plan.exec(
service_name=da_node_service_name,
recipe=ExecRecipe(
command=[
"sh",
"-c",
"celestia state account-address | jq -r .result | tr -d '\n'",
],
),
acceptable_codes=[0],
description="Getting address of node",
)
address = get_address_result["output"]
# Get the node's auth token
get_auth_token_result = plan.exec(
service_name=da_node_service_name,
recipe=ExecRecipe(
command=[
"sh",
"-c",
"celestia {0} auth write --p2p.network {1} | tr -d '\n'".format(
node_type, p2p_network
),
],
),
acceptable_codes=[0],
description="Getting auth token of node",
)
auth_token = get_auth_token_result["output"]
# Get the node's current network height
get_height_result = plan.exec(
service_name=da_node_service_name,
recipe=ExecRecipe(
command=[
"sh",
"-c",
"celestia header network-head | jq -r .result.header.height | tr -d '\n'",
],
),
acceptable_codes=[0],
description="Getting network head height of node",
)
height = get_height_result["output"]
return (
"http://{0}:{1}".format(da_node.ip_address, da_node.ports["rpc"].number),
auth_token,
address,
height,
)