Skip to content

Commit 0c85f48

Browse files
committed
infa: wire ethapi token and cors options
Signed-off-by: Sander Pick <sanderpick@gmail.com>
1 parent 464d8e2 commit 0c85f48

File tree

9 files changed

+77
-11
lines changed

9 files changed

+77
-11
lines changed

fendermint/app/settings/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ impl Settings {
332332
.with_list_parse_key("resolver.connection.external_addresses")
333333
.with_list_parse_key("resolver.discovery.static_addresses")
334334
.with_list_parse_key("resolver.membership.static_subnets")
335-
.with_list_parse_key("resolver.membership.static_subnets")
336335
.with_list_parse_key("eth.cors.allowed_origins")
337336
.with_list_parse_key("eth.cors.allowed_methods")
338337
.with_list_parse_key("eth.cors.allowed_headers"),

infra/fendermint/Makefile.toml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,21 @@ BASE_FEE = { value = "1000", condition = { env_not_set = ["BASE_FEE"] } }
3737
TIMESTAMP = { value = "1680101412", condition = { env_not_set = ["TIMESTAMP"] } }
3838
POWER_SCALE = { value = "3", condition = { env_not_set = ["POWER_SCALE"] } }
3939

40+
# ETH related parameters
41+
ETHAPI_ALLOWED_ORIGINS = { value = "*", condition = { env_not_set = [
42+
"ETHAPI_ALLOWED_ORIGINS",
43+
] } }
44+
ETHAPI_ALLOWED_METHODS = { value = "GET,HEAD,OPTIONS,POST", condition = { env_not_set = [
45+
"ETHAPI_ALLOWED_METHODS",
46+
] } }
47+
ETHAPI_ALLOWED_HEADERS = { value = "Accept,Authorization,Content-Type,Origin", condition = { env_not_set = [
48+
"ETHAPI_ALLOWED_HEADERS",
49+
] } }
50+
4051
# IPC subnet related parameters
4152
# Use calibration as default value
4253
NODE_NAME = { value = "ipc-node", condition = { env_not_set = ["NODE_NAME"] } }
43-
PARENT_ENDPOINT = { value = "https://api.calibration.node.glif.io/rpc/v1", condition = { env_not_set = [
54+
PARENT_ENDPOINT = { value = "https://calibration.node.glif.io/archive/lotus/rpc/v1", condition = { env_not_set = [
4455
"PARENT_ENDPOINT",
4556
] } }
4657
PARENT_GATEWAY = { value = "0x56948d2CFaa2EF355B8C08Ac925202db212146D1", condition = { env_not_set = [
@@ -57,6 +68,9 @@ TOPDOWN_PROPOSAL_DELAY = { value = "2", condition = { env_not_set = ["TOPDOWN_PR
5768
TOPDOWN_MAX_PROPOSAL_RANGE = { value = "100", condition = { env_not_set = [
5869
"TOPDOWN_MAX_PROPOSAL_RANGE",
5970
] } }
71+
TOPDOWN_MAX_CACHE_BLOCKS = { value = "20000", condition = { env_not_set = [
72+
"TOPDOWN_MAX_CACHE_BLOCKS",
73+
] } }
6074
# Comma-separated list of bootstrap nodes to be used by the CometBFT node.
6175
BOOTSTRAPS = { value = "", condition = { env_not_set = ["BOOTSTRAPS"] } }
6276
# Comma-separate list of addresses that's allowed to deploy contracts to this subnet.

infra/fendermint/scripts/ethapi.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ docker run \
77
--user $(id -u) \
88
--network ${NETWORK_NAME} \
99
--publish ${ETHAPI_HOST_PORT}:8545 \
10+
--env FM_ETH__CORS__ALLOWED_ORIGINS=${ETHAPI_ALLOWED_ORIGINS} \
11+
--env FM_ETH__CORS__ALLOWED_METHODS=${ETHAPI_ALLOWED_METHODS} \
12+
--env FM_ETH__CORS__ALLOWED_HEADERS=${ETHAPI_ALLOWED_HEADERS} \
1013
--env TENDERMINT_RPC_URL=http://${CMT_CONTAINER_NAME}:26657 \
1114
--env TENDERMINT_WS_URL=ws://${CMT_CONTAINER_NAME}:26657/websocket \
1215
--env LOG_LEVEL=${ETHAPI_LOG_LEVEL} \

infra/fendermint/scripts/fendermint.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,15 @@ docker run \
6161
--env FM_IPC__TOPDOWN__CHAIN_HEAD_DELAY=${TOPDOWN_CHAIN_HEAD_DELAY} \
6262
--env FM_IPC__TOPDOWN__PARENT_HTTP_ENDPOINT=${PARENT_ENDPOINT} \
6363
--env FM_IPC__TOPDOWN__PARENT_HTTP_TIMEOUT=60 \
64+
--env FM_IPC__TOPDOWN__PARENT_HTTP_AUTH_TOKEN=${PARENT_HTTP_AUTH_TOKEN} \
6465
--env FM_IPC__TOPDOWN__PARENT_REGISTRY=${PARENT_REGISTRY} \
6566
--env FM_IPC__TOPDOWN__PARENT_GATEWAY=${PARENT_GATEWAY} \
6667
--env FM_IPC__TOPDOWN__EXPONENTIAL_BACK_OFF=5 \
6768
--env FM_IPC__TOPDOWN__EXPONENTIAL_RETRY_LIMIT=5 \
6869
--env FM_IPC__TOPDOWN__POLLING_INTERVAL=10 \
6970
--env FM_IPC__TOPDOWN__PROPOSAL_DELAY=${TOPDOWN_PROPOSAL_DELAY} \
7071
--env FM_IPC__TOPDOWN__MAX_PROPOSAL_RANGE=${TOPDOWN_MAX_PROPOSAL_RANGE} \
72+
--env FM_IPC__TOPDOWN__MAX_CACHE_BLOCKS=${TOPDOWN_MAX_CACHE_BLOCKS} \
7173
--env FM_RESOLVER__NETWORK__LOCAL_KEY=/data/${NODE_NAME}/${NETWORK_PRIV_KEY_PATH} \
7274
--env FM_RESOLVER__CONNECTION__LISTEN_ADDR=/ip4/0.0.0.0/tcp/${RESOLVER_HOST_PORT} \
7375
--env FM_RESOLVER__DISCOVERY__STATIC_ADDRESSES=${RESOLVER_BOOTSTRAPS} \

infra/fendermint/scripts/subnet.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ run_task = { name = [
104104
"ethapi-start",
105105
"proxy-start",
106106
"ipfs-start",
107+
"node-report",
107108
] }
108109

109110
[tasks.child-validator-restart-no-parent]
@@ -119,6 +120,7 @@ run_task = { name = [
119120
"ethapi-start",
120121
"proxy-start",
121122
"ipfs-start",
123+
"node-report",
122124
] }
123125

124126
[tasks.child-fullnode-down]

scripts/deploy_subnet_no_parent/restart.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ do
5050
-e IPFS_GATEWAY_HOST_PORT=${IPFS_GATEWAY_HOST_PORTS[i]} \
5151
-e IPFS_PROFILE="local-discovery" \
5252
-e FM_PULL_SKIP=1 \
53-
-e FM_LOG_LEVEL="info" \
53+
-e FM_LOG_LEVEL="info,fendermint=debug" \
5454
child-validator-restart-no-parent
5555
done
5656

scripts/deploy_subnet_no_parent/start.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ bootstrap_output=$(cargo make --makefile infra/fendermint/Makefile.toml \
228228
-e IPFS_GATEWAY_HOST_PORT=${IPFS_GATEWAY_HOST_PORTS[0]} \
229229
-e IPFS_PROFILE="local-discovery" \
230230
-e FM_PULL_SKIP=1 \
231-
-e FM_LOG_LEVEL="info" \
231+
-e FM_LOG_LEVEL="info,fendermint=debug" \
232232
child-validator-no-parent 2>&1)
233233
echo "$bootstrap_output"
234234
bootstrap_node_id=$(echo "$bootstrap_output" | sed -n '/CometBFT node ID:/ {n;p;}' | tr -d "[:blank:]")
@@ -261,7 +261,7 @@ do
261261
-e RESOLVER_BOOTSTRAPS=${bootstrap_resolver_endpoint} \
262262
-e BOOTSTRAPS=${bootstrap_node_endpoint} \
263263
-e FM_PULL_SKIP=1 \
264-
-e FM_LOG_LEVEL="info" \
264+
-e FM_LOG_LEVEL="info,fendermint=debug" \
265265
child-validator-no-parent
266266
done
267267

scripts/deploy_subnet_under_calibration_net/deploy.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ eval `ssh-agent -s`
1414
ssh-add
1515
ssh-add ${HOME}/.ssh/id_rsa.ipc
1616

17+
if [[ ! -v PARENT_HTTP_AUTH_TOKEN ]]; then
18+
echo "PARENT_HTTP_AUTH_TOKEN is not set"
19+
exit 1
20+
fi
21+
1722
DASHES='------'
1823
if [[ ! -v IPC_FOLDER ]]; then
1924
IPC_FOLDER=${HOME}/ipc
@@ -237,10 +242,11 @@ bootstrap_output=$(cargo make --makefile infra/fendermint/Makefile.toml \
237242
-e IPFS_RPC_HOST_PORT=${IPFS_RPC_HOST_PORTS[0]} \
238243
-e IPFS_GATEWAY_HOST_PORT=${IPFS_GATEWAY_HOST_PORTS[0]} \
239244
-e IPFS_PROFILE="local-discovery" \
245+
-e PARENT_HTTP_AUTH_TOKEN=${PARENT_HTTP_AUTH_TOKEN} \
240246
-e PARENT_REGISTRY=${parent_registry_address} \
241247
-e PARENT_GATEWAY=${parent_gateway_address} \
242248
-e FM_PULL_SKIP=1 \
243-
-e FM_LOG_LEVEL="info" \
249+
-e FM_LOG_LEVEL="info,fendermint=debug" \
244250
child-validator 2>&1)
245251
echo "$bootstrap_output"
246252
bootstrap_node_id=$(echo "$bootstrap_output" | sed -n '/CometBFT node ID:/ {n;p;}' | tr -d "[:blank:]")
@@ -272,10 +278,11 @@ do
272278
-e IPFS_PROFILE="local-discovery" \
273279
-e RESOLVER_BOOTSTRAPS=${bootstrap_resolver_endpoint} \
274280
-e BOOTSTRAPS=${bootstrap_node_endpoint} \
281+
-e PARENT_HTTP_AUTH_TOKEN=${PARENT_HTTP_AUTH_TOKEN} \
275282
-e PARENT_REGISTRY=${parent_registry_address} \
276283
-e PARENT_GATEWAY=${parent_gateway_address} \
277284
-e FM_PULL_SKIP=1 \
278-
-e FM_LOG_LEVEL="info" \
285+
-e FM_LOG_LEVEL="info,fendermint=debug" \
279286
child-validator
280287
done
281288

scripts/deploy_subnet_under_calibration_net/redeploy.sh

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ eval `ssh-agent -s`
1414
ssh-add
1515
ssh-add ${HOME}/.ssh/id_rsa.ipc
1616

17+
if [[ ! -v PARENT_HTTP_AUTH_TOKEN ]]; then
18+
echo "PARENT_HTTP_AUTH_TOKEN is not set"
19+
exit 1
20+
fi
21+
1722
DASHES='------'
1823
if [[ ! -v IPC_FOLDER ]]; then
1924
IPC_FOLDER=${HOME}/ipc
@@ -133,10 +138,41 @@ cd ${IPC_FOLDER}/fendermint
133138
make clean
134139
make docker-build
135140

136-
# Step 4.2: Start other validator node
137-
echo "$DASHES Restart validator nodes"
141+
# Step 4.2: Start first validator node as bootstrap
142+
echo "$DASHES Start first validator node as bootstrap"
138143
cd ${IPC_FOLDER}
139-
for i in {0..2}
144+
bootstrap_output=$(cargo make --makefile infra/fendermint/Makefile.toml \
145+
-e NODE_NAME=validator-0 \
146+
-e PRIVATE_KEY_PATH=${IPC_CONFIG_FOLDER}/validator_0.sk \
147+
-e SUBNET_ID=${subnet_id} \
148+
-e CMT_P2P_HOST_PORT=${CMT_P2P_HOST_PORTS[0]} \
149+
-e CMT_RPC_HOST_PORT=${CMT_RPC_HOST_PORTS[0]} \
150+
-e ETHAPI_HOST_PORT=${ETHAPI_HOST_PORTS[0]} \
151+
-e RESOLVER_HOST_PORT=${RESOLVER_HOST_PORTS[0]} \
152+
-e PROXY_HOST_PORT=${PROXY_HOST_PORTS[0]} \
153+
-e IPFS_SWARM_HOST_PORT=${IPFS_SWARM_HOST_PORTS[0]} \
154+
-e IPFS_RPC_HOST_PORT=${IPFS_RPC_HOST_PORTS[0]} \
155+
-e IPFS_GATEWAY_HOST_PORT=${IPFS_GATEWAY_HOST_PORTS[0]} \
156+
-e IPFS_PROFILE="local-discovery" \
157+
-e PARENT_HTTP_AUTH_TOKEN=${PARENT_HTTP_AUTH_TOKEN} \
158+
-e PARENT_REGISTRY=${parent_registry_address} \
159+
-e PARENT_GATEWAY=${parent_gateway_address} \
160+
-e FM_PULL_SKIP=1 \
161+
-e FM_LOG_LEVEL="info,fendermint=debug" \
162+
child-validator-restart 2>&1)
163+
echo "$bootstrap_output"
164+
bootstrap_node_id=$(echo "$bootstrap_output" | sed -n '/CometBFT node ID:/ {n;p;}' | tr -d "[:blank:]")
165+
bootstrap_peer_id=$(echo "$bootstrap_output" | sed -n '/IPLD Resolver Multiaddress:/ {n;p;}' | tr -d "[:blank:]" | sed 's/.*\/p2p\///')
166+
echo "Bootstrap node started. Node id ${bootstrap_node_id}, peer id ${bootstrap_peer_id}"
167+
168+
bootstrap_node_endpoint=${bootstrap_node_id}@validator-0-cometbft:${CMT_P2P_HOST_PORTS[0]}
169+
echo "Bootstrap node endpoint: ${bootstrap_node_endpoint}"
170+
bootstrap_resolver_endpoint="/dns/validator-0-fendermint/tcp/${RESOLVER_HOST_PORTS[0]}/p2p/${bootstrap_peer_id}"
171+
echo "Bootstrap resolver endpoint: ${bootstrap_resolver_endpoint}"
172+
173+
# Step 4.3: Start other validator node
174+
echo "$DASHES Start the other validator nodes"
175+
for i in {1..2}
140176
do
141177
cargo make --makefile infra/fendermint/Makefile.toml \
142178
-e NODE_NAME=validator-${i} \
@@ -151,10 +187,13 @@ do
151187
-e IPFS_RPC_HOST_PORT=${IPFS_RPC_HOST_PORTS[i]} \
152188
-e IPFS_GATEWAY_HOST_PORT=${IPFS_GATEWAY_HOST_PORTS[i]} \
153189
-e IPFS_PROFILE="local-discovery" \
190+
-e RESOLVER_BOOTSTRAPS=${bootstrap_resolver_endpoint} \
191+
-e BOOTSTRAPS=${bootstrap_node_endpoint} \
192+
-e PARENT_HTTP_AUTH_TOKEN=${PARENT_HTTP_AUTH_TOKEN} \
154193
-e PARENT_REGISTRY=${parent_registry_address} \
155194
-e PARENT_GATEWAY=${parent_gateway_address} \
156195
-e FM_PULL_SKIP=1 \
157-
-e FM_LOG_LEVEL="info" \
196+
-e FM_LOG_LEVEL="info,fendermint=debug" \
158197
child-validator-restart
159198
done
160199

0 commit comments

Comments
 (0)