Skip to content

Commit aaa97d8

Browse files
committed
updated TODOS, fixed syncchecker
1 parent cf11063 commit aaa97d8

File tree

2 files changed

+30
-38
lines changed

2 files changed

+30
-38
lines changed

lib/fantom/README.md

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ This blueprint is designed to assist in deploying a single node or a Highly Avai
1414
![Single Nodes Deployment](./doc/assets/Architecture-Single-Fantom-Node-Runners.drawio.png)
1515

1616
1. The AWS Cloud Development Kit (CDK) is used to deploy a single node. The CDK application stores assets like scripts and config files in S3 bucket to copy them to the EC2 instance when launching a Fantom Node.
17-
2. A single RPC Fantom Fullnode is deployed within in the [Default VPC](https://docs.aws.amazon.com/vpc/latest/userguide/default-vpc.html) and continuously synchronizes with the rest of nodes on Fantom Blockchain Network through [Internet Gateway](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Internet_Gateway.html).
17+
2. A single RPC Fantom Fullnode is deployed within the [Default VPC](https://docs.aws.amazon.com/vpc/latest/userguide/default-vpc.html) and continuously synchronizes with the rest of nodes on Fantom Blockchain Network through an [Internet Gateway](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Internet_Gateway.html).
1818
3. The Fantom node is accessed by dApps or development tools internally. JSON RPC API is not exposed to the Internet to protect the node from unauthorized access. dApps need to handle user authentication and API protection, like [in this example for dApps on AWS](https://aws.amazon.com/blogs/architecture/dapp-authentication-with-amazon-cognito-and-web3-proxy-with-amazon-api-gateway/).
1919
4. The Fantom node send various monitoring metrics for both EC2 and Fantom client to Amazon CloudWatch.
2020

2121
### Highly Available setup
2222

2323
![Highly Available Nodes Deployment](./doc/assets/Architecture-HA-Fantom-Node-Runners.drawio.png)
2424

25-
1. The CDK is used to deploy highly available (HA) architecture. An S3 bucket is utilized to store [User data](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html) and othether script and configuration files required when launching EC2 as the Fantom Node.
26-
2. A set of RPC Fantom Fullnodes are deployed within the [Auto Scaling Group](https://docs.aws.amazon.com/autoscaling/ec2/userguide/auto-scaling-groups.html) in the [Default VPC](https://docs.aws.amazon.com/vpc/latest/userguide/default-vpc.html) continuously synchronizes with the rest of nodes on Fantom Blockchain Network through [Internet Gateway](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Internet_Gateway.html).
27-
3. The Fantom nodes are accessed by dApps or development tools internally through [Application Load Balancer](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html). JSON RPC API is not exposed to the Internet to protect nodes from unauthorized access. dApps need to handle user authentication and API protection, like [in this example for dApps on AWS](https://aws.amazon.com/blogs/architecture/dapp-authentication-with-amazon-cognito-and-web3-proxy-with-amazon-api-gateway/).
25+
1. The CDK is used to deploy highly available (HA) architecture. An S3 bucket is utilized to store [User data](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html) and other scripts and configuration files required when launching EC2 as the Fantom Node.
26+
2. A set of RPC Fantom Fullnodes that are deployed within the [Auto Scaling Group](https://docs.aws.amazon.com/autoscaling/ec2/userguide/auto-scaling-groups.html) in the [Default VPC](https://docs.aws.amazon.com/vpc/latest/userguide/default-vpc.html) continuously synchronize with the rest of the nodes on Fantom Blockchain Network through an [Internet Gateway](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Internet_Gateway.html).
27+
3. The Fantom nodes are accessed by dApps or development tools internally through an [Application Load Balancer](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html). JSON RPC API is not exposed to the Internet to protect nodes from unauthorized access. dApps need to handle user authentication and API protection, like [in this example for dApps on AWS](https://aws.amazon.com/blogs/architecture/dapp-authentication-with-amazon-cognito-and-web3-proxy-with-amazon-api-gateway/).
2828
4. The Fantom nodes send various monitoring metrics for both EC2 and Fantom nodes to Amazon CloudWatch.
2929

3030
## Additional materials
@@ -180,14 +180,14 @@ Alternatively, you can manually check [Geth Syncing Status](https://geth.ethereu
180180
INSTANCE_ID=$(cat single-node-deploy.json | jq -r '..|.singleinstanceid? | select(. != null)')
181181
NODE_INTERNAL_IP=$(aws ec2 describe-instances --instance-ids $INSTANCE_ID --query 'Reservations[*].Instances[*].PrivateIpAddress' --output text)
182182
183-
# We query token balance of one of the system contracts: https://fantomscan.com/address/0x0000000000000000000000000000000000001006 TODO
184-
curl http://$NODE_INTERNAL_IP:8545 -X POST -H "Content-Type: application/json" \
185-
--data '{"method":"eth_getBalance","params":["0x0000000000000000000000000000000000001006", "latest"],"id":1,"jsonrpc":"2.0"}'
183+
# We query token balance of one of the system contracts: https://ftmscan.com/address/0x0000000000000000000000000000000000000001
184+
curl http://$NODE_INTERNAL_IP:18545 -X POST -H "Content-Type: application/json" \
185+
--data '{"method":"eth_getBalance","params":["0x0000000000000000000000000000000000000001", "latest"],"id":1,"jsonrpc":"2.0"}'
186186
```
187187
You will get a response similar to this:
188188
189189
```json
190-
{"jsonrpc":"2.0","id":1,"result":"0x3635c9adc5dea00000"}
190+
{"jsonrpc":"2.0","id":1,"result":"0xbe9fa76042c4daf622"}
191191
```
192192
193193
### Option 2: Highly Available RPC Nodes
@@ -207,10 +207,10 @@ Alternatively, you can manually check [Geth Syncing Status](https://geth.ethereu
207207
echo $RPC_ALB_URL
208208
```
209209
210-
Periodically check [Geth Syncing Status](https://geth.ethereum.org/docs/fundamentals/logs#syncing). Run the following query from within the same VPC and against the private IP of the load balancer fronting your nodes: TODO
210+
Periodically check [Fantom Syncing Status](https://docs.chainstack.com/reference/fantom-syncing). Run the following query from within the same VPC and against the private IP of the load balancer fronting your nodes:
211211
212212
```bash
213-
curl http://$RPC_ALB_URL:8545 -X POST -H "Content-Type: application/json" \
213+
curl http://$RPC_ALB_URL:18545 -X POST -H "Content-Type: application/json" \
214214
--data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}'
215215
```
216216
@@ -240,22 +240,22 @@ Alternatively, you can manually check [Geth Syncing Status](https://geth.ethereu
240240
}
241241
```
242242
243-
**NOTE:** By default and for security reasons the load balancer is available only from within the default VPC in the region where it is deployed. It is not available from the Internet and is not open for external connections. Before opening it up please make sure you protect your RPC APIs.
243+
**NOTE:** By default and for security reasons the load balancer is available only from inside the default VPC in the region where it is deployed. It is not available from the Internet and is not open for external connections. Before you consider opening it up to the internet, **please make sure you protect your RPC APIs**.
244244
245245
3. Once the initial synchronization is done, you should be able to access the RPC API of that node from within the same VPC. The RPC port is not exposed to the Internet. Run the following query against the private IP of the single RPC node you deployed:
246246
247247
```bash
248248
export RPC_ALB_URL=$(cat ha-nodes-deploy.json | jq -r '..|.alburl? | select(. != null)')
249249
echo $RPC_ALB_URL
250250
251-
# We query token balance of one of the system contracts: https://fantomscan.com/address/0x0000000000000000000000000000000000001006 TODO
251+
# We query token balance of one of the system contracts: https://ftmscan.com/address/0x0000000000000000000000000000000000000001
252252
curl http://$RPC_ALB_URL:18545 -X POST -H "Content-Type: application/json" \
253-
--data '{"method":"eth_getBalance","params":["0x0000000000000000000000000000000000001006", "latest"],"id":1,"jsonrpc":"2.0"}'
253+
--data '{"method":"eth_getBalance","params":["0x0000000000000000000000000000000000000001", "latest"],"id":1,"jsonrpc":"2.0"}'
254254
```
255255
You will get a response similar to this:
256256
257257
```json
258-
{"jsonrpc":"2.0","id":1,"result":"0x3635c9adc5dea00000"}
258+
{"jsonrpc":"2.0","id":1,"result":"0xbe9fa76042c4daf622"}
259259
```
260260
261261
### Clearing up and undeploy everything
@@ -334,21 +334,9 @@ sudo systemctl stop fantom && sleep 20 && sudo systemctl start fantom
334334
- View Fantom service configuration
335335
- `cat /etc/systemd/system/fantom.service`
336336
337-
5. Where can I find more information about Fantom RPC API?
338-
339-
TODO Fantom Docs link
340-
341-
Please refer to more [JSON-RPC API METHODS](https://ethereum.org/en/developers/docs/apis/json-rpc/#json-rpc-methods). The following are some commonly used API methods:
342-
- eth_blockNumber
343-
- eth_getBalance
344-
- eth_accounts
345-
- eth_call
346-
- eth_estimateGas
347-
- eth_signTransaction
348-
- eth_sendTransaction
349-
- eth_getBlockByHash
350-
- eth_getBlockByNumber
351-
- eth_getTransactionByHash
337+
5. Where can I find more information about Fantom?
338+
339+
Please refer to the [Fantom Developer Documentation](https://docs.fantom.foundation/)
352340
353341
## Upgrades
354342

lib/fantom/lib/assets/fantom-checker/syncchecker-fantom.sh

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#FANTOM_SYNC_STATS=$(curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"ftm_syncing","params":[],"id":1}' http://localhost:18545 | jq -r ".result")
44

55
FANTOM_SYNC_STATS=$(su bcuser -c '/home/bcuser/go-opera/build/opera attach --datadir=/data --exec "ftm.syncing"')
6+
# Syncing status results:
7+
#
68
# { currentBlock: 37676547,
79
# currentBlockHash: "0x0001ab120000187fd8069d3a4f6501d48ad4800778f40a76d79cf02469272a43",
810
# currentBlockTime: "0x16ec7a4b9a82ebfe",
@@ -12,22 +14,24 @@ FANTOM_SYNC_STATS=$(su bcuser -c '/home/bcuser/go-opera/build/opera attach --dat
1214
# knownStates: 0,
1315
# pulledStates: 0,
1416
# startingBlock: 0 }
17+
#
18+
# Synced status results:
19+
#
20+
# false
1521

22+
# If false, then get current block number:
23+
if $FANTOM_SYNC_STATS == false; then
1624

17-
# if [[ "$FANTOM_SYNC_STATS" == "false" ]]; then
18-
# FANTOM_SYNC_BLOCK_HEX=$(curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' http://localhost:18545 | jq -r ".result")
19-
# FANTOM_HIGHEST_BLOCK_HEX=$FANTOM_SYNC_BLOCK_HEX
20-
# else
21-
# FANTOM_SYNC_BLOCK_HEX=$(echo $FANTOM_SYNC_STATS | jq -r ".currentBlock")
22-
# FANTOM_HIGHEST_BLOCK_HEX=$(echo $FANTOM_SYNC_STATS | jq -r ".highestBlock")
23-
# fi
2425
FANTOM_SYNC_BLOCK=$(echo $FANTOM_SYNC_STATS | jq -r ".currentBlock")
2526
FANTOM_HIGHEST_BLOCK=$(echo $FANTOM_SYNC_STATS | jq -r ".highestBlock")
2627

27-
# FANTOM_HIGHEST_BLOCK=$(echo $((${FANTOM_HIGHEST_BLOCK_HEX})))
28-
# FANTOM_SYNC_BLOCK=$(echo $((${FANTOM_SYNC_BLOCK_HEX})))
2928
FANTOM_BLOCKS_BEHIND="$((FANTOM_HIGHEST_BLOCK-FANTOM_SYNC_BLOCK))"
3029

30+
else
31+
FANTOM_SYNC_BLOCK=$(su bcuser -c '/home/bcuser/go-opera/build/opera attach --datadir=/data --exec "ftm.blockNumber"')
32+
FANTOM_BLOCKS_BEHIND=0
33+
fi
34+
3135
# Sending data to CloudWatch
3236
TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
3337
INSTANCE_ID=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" -s http://169.254.169.254/latest/meta-data/instance-id)

0 commit comments

Comments
 (0)