Skip to content

Commit 3649950

Browse files
committed
fixed HA bugs and docs
1 parent aad74a5 commit 3649950

File tree

5 files changed

+49
-59
lines changed

5 files changed

+49
-59
lines changed

lib/fantom/README.md

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This blueprint is designed to assist in deploying a single node or a Highly Avai
1111
## Overview of Deployment Architectures
1212

1313
### Single Node setup
14-
![Single Nodes Deployment](./doc/assets/Architecture-Single-Fantom-Node-Runners.drawio.png)
14+
![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.
1717
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).
@@ -20,7 +20,7 @@ This blueprint is designed to assist in deploying a single node or a Highly Avai
2020

2121
### Highly Available setup
2222

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

2525
1. The CDK is used to deploy a 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.
2626
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).
@@ -82,7 +82,7 @@ cd aws-blockchain-node-runners
8282
npm install
8383
```
8484

85-
### Deploy the HA Nodes
85+
### Prepare to deploy nodes
8686

8787
1. Make sure you are in the root directory of the cloned repository
8888

@@ -101,9 +101,9 @@ npm install
101101
Create your own copy of `.env` file and edit it to update with your AWS Account ID, AWS Region, and optionally the Fantom SNAPSHOTS URI:
102102
103103
```bash
104-
# Make sure you are in aws-blockchain-node-runners/lib/fantom
105104
cd lib/fantom
106105
pwd
106+
# Make sure you are in aws-blockchain-node-runners/lib/fantom
107107
cp ./sample-configs/.env-sample-read .env
108108
nano .env
109109
```
@@ -152,25 +152,19 @@ Alternatively, you can manually check [Geth Syncing Status](https://geth.ethereu
152152
153153
```javascript
154154
{
155-
"jsonrpc": "2.0",
156-
"id": 1,
157-
"result": {
158-
"currentBlock": "0x211f0d8",
159-
"healedBytecodeBytes": "0x0",
160-
"healedBytecodes": "0x0",
161-
"healedTrienodeBytes": "0x0",
162-
"healedTrienodes": "0x0",
163-
"healingBytecode": "0x0",
164-
"healingTrienodes": "0x0",
165-
"highestBlock": "0x2123bff",
166-
"startingBlock": "0x20910d7",
167-
"syncedAccountBytes": "0x0",
168-
"syncedAccounts": "0x0",
169-
"syncedBytecodeBytes": "0x0",
170-
"syncedBytecodes": "0x0",
171-
"syncedStorage": "0x0",
172-
"syncedStorageBytes": "0x0"
173-
}
155+
jsonrpc: "2.0",
156+
id: 1,
157+
result: {
158+
currentBlock: 37676547,
159+
currentBlockHash: "0x0001ab120000187fd8069d3a4f6501d48ad4800778f40a76d79cf02469272a43",
160+
currentBlockTime: "0x16ec7a4b9a82ebfe",
161+
currentEpoch: "0x1ab13",
162+
highestBlock: 80196141,
163+
highestEpoch: "0x44343",
164+
knownStates: 0,
165+
pulledStates: 0,
166+
startingBlock: 0
167+
}
174168
}
175169
```
176170
@@ -192,7 +186,7 @@ Alternatively, you can manually check [Geth Syncing Status](https://geth.ethereu
192186
193187
### Option 2: Highly Available RPC Nodes
194188
195-
1. The inital deployment of a Fantom Fullnode and downloading its snapshot typically takes about 2-3 hours. The Full node uses snapshots data, and downloading and decompressing the data takes time. You can grab a cup of coffee☕️ and patiently wait during this process. Maybe two. After deployment, you'll need to wait for another half a day to a day for your nodes to synchronize with the Fantom Blockchain Network, depending on how fresh the snapshot was.
189+
1. The inital deployment of a Fantom Full node and downloading its snapshot typically takes about 6 hours. The Full node uses snapshots data, and downloading and decompressing the data takes time. You can grab a cup of coffee☕️ and patiently wait during this process. Maybe two. After deployment, you'll need to wait for hour or more for your nodes to synchronize with the Fantom Blockchain Network, depending on how fresh the snapshot was.
196190
197191
```bash
198192
pwd
@@ -218,24 +212,18 @@ Alternatively, you can manually check [Geth Syncing Status](https://geth.ethereu
218212
219213
```javascript
220214
{
221-
"jsonrpc": "2.0",
222-
"id": 1,
223-
"result": {
224-
"currentBlock": "0x211f0d8",
225-
"healedBytecodeBytes": "0x0",
226-
"healedBytecodes": "0x0",
227-
"healedTrienodeBytes": "0x0",
228-
"healedTrienodes": "0x0",
229-
"healingBytecode": "0x0",
230-
"healingTrienodes": "0x0",
231-
"highestBlock": "0x2123bff",
232-
"startingBlock": "0x20910d7",
233-
"syncedAccountBytes": "0x0",
234-
"syncedAccounts": "0x0",
235-
"syncedBytecodeBytes": "0x0",
236-
"syncedBytecodes": "0x0",
237-
"syncedStorage": "0x0",
238-
"syncedStorageBytes": "0x0"
215+
jsonrpc: "2.0",
216+
id: 1,
217+
result: {
218+
currentBlock: 37676547,
219+
currentBlockHash: "0x0001ab120000187fd8069d3a4f6501d48ad4800778f40a76d79cf02469272a43",
220+
currentBlockTime: "0x16ec7a4b9a82ebfe",
221+
currentEpoch: "0x1ab13",
222+
highestBlock: 80196141,
223+
highestEpoch: "0x44343",
224+
knownStates: 0,
225+
pulledStates: 0,
226+
startingBlock: 0
239227
}
240228
}
241229
```

lib/fantom/lib/assets/download-snapshot.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ echo "Downloading FANTOM snapshot."
77

88
cd /data
99

10-
for FILE in `curl https://snapshot.fantom.network/files/snapsync/latest/listtgzfiles.txt`; do
11-
echo $FILE;
12-
axel -n 20 https://snapshot.fantom.network/files/snapsync/$FILE && \
13-
tar --use-compress-program="pigz -d" -xvf ${FILE##*/} && \
14-
rm ${FILE##*/} || \
15-
echo "Problem with downloading or expanding file $FILE"
16-
done
10+
if [[ -n ${FANTOM_SNAPSHOTS_URI} && ${FANTOM_SNAPSHOTS_URI} != "none" ]]; then
11+
for FILE in `curl ${FANTOM_SNAPSHOTS_URI}`; do
12+
echo $FILE;
13+
axel -n 20 ${FANTOM_SNAPSHOTS_URI%%/latest/listtgzfiles.txt}/$FILE && \
14+
tar --use-compress-program="pigz -d" -xvf ${FILE##*/} && \
15+
rm ${FILE##*/} || \
16+
echo "Problem with downloading or expanding file $FILE"
17+
done
18+
fi
1719

1820
echo "Downloading FANTOM snapshot finished"
1921

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ FANTOM_SYNC_STATS=$(su bcuser -c '/home/bcuser/go-opera/build/opera attach --dat
1818
# Synced status results:
1919
#
2020
# false
21+
#
22+
# TODO: if a node falls behind, does it revert to syncing?
2123

2224
# If false, then get current block number:
23-
if $FANTOM_SYNC_STATS == false; then
25+
if $FANTOM_SYNC_STATS != false; then
2426

2527
FANTOM_SYNC_BLOCK=$(echo $FANTOM_SYNC_STATS | jq -r ".currentBlock")
2628
FANTOM_HIGHEST_BLOCK=$(echo $FANTOM_SYNC_STATS | jq -r ".highestBlock")

lib/fantom/lib/assets/setup-instance-store-volumes.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ source /etc/environment
44

55
if [[ "$DATA_VOLUME_TYPE" == "instance-store" ]]; then
66
echo "Data volume type is instance store"
7-
export DATA_VOLUME_ID=/dev/$(lsblk -lnb | awk -v VOLUME_SIZE_BYTES="$DATA_VOLUME_SIZE" '{if ($4== VOLUME_SIZE_BYTES) {print $1}}')
7+
export DATA_VOLUME_ID=/dev/$(lsblk -lnb | awk 'max < $4 {max = $4; vol = $1} END {print vol}')
88
fi
99

1010
if [ -n "$DATA_VOLUME_ID" ]; then
@@ -30,8 +30,6 @@ if [ -n "$DATA_VOLUME_ID" ]; then
3030

3131
sudo mount -a
3232

33-
/opt/download-snapshot.sh
34-
3533
chown bcuser:bcuser -R /data
3634
else
3735
echo "Data volume is mounted, nothing changed"

lib/fantom/sample-configs/.env-sample-read

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@
44

55
## Set the AWS account is and region for your environment ##
66
AWS_ACCOUNT_ID="xxxxxxxxxxx"
7-
AWS_REGION="ap-southeast-2"
7+
AWS_REGION="us-east-1"
88

99
## Optional FANTOM snapshots download link # IMPORTANT !!! Make sure the url is valid before you use it!
10-
#FANTOM_SNAPSHOTS_URI=https://snapshot.fantom.network/files/snapsync/ # Optional param. We extract the actual URL from https://raw.githubusercontent.com/48Club/fantom-snapshots/main/data.json if nothing is specified. Otherwise, check the latest vesion for Full node here: https://github.com/48Club/fantom-snapshots
10+
FANTOM_SNAPSHOTS_URI=https://snapshot.fantom.network/files/snapsync/latest/listtgzfiles.txt # Optional param. Do a full sync if not provided.
1111

1212
## Common configuration parameters ##
1313
FANTOM_NETWORK="mainnet" # All options: "mainnet", "testnet"
1414
FANTOM_NODE_CONFIGURATION="read" # All options: "read", "api", "validator"
1515

1616
## Instance Nodes
17-
FANTOM_INSTANCE_TYPE="m6a.2xlarge"
17+
FANTOM_INSTANCE_TYPE="i3en.xlarge"
1818
FANTOM_CPU_TYPE="x86_64" # All options: "x86_64", "ARM_64". IMPORTANT: Make sure the CPU type matches the instance type used
1919

2020
# Data volume configuration
21-
FANTOM_DATA_VOL_TYPE="gp3" # Other options: "io1" | "io2" | "gp3" | "instance-store" . IMPORTANT: Use "instance-store" option only with instance types that support that feature, like popular for node im4gn, d3, i3en, and i4i instance families
21+
FANTOM_DATA_VOL_TYPE="instance-store" # Other options: "io1" | "io2" | "gp3" | "instance-store" . IMPORTANT: Use "instance-store" option only with instance types that support that feature, like popular for node im4gn, d3, i3en, and i4i instance families
2222
FANTOM_DATA_VOL_SIZE="2000" # Current required data size to keep both snapshot archive and unarchived version of it
23-
FANTOM_DATA_VOL_IOPS="7000" # Max IOPS for EBS volumes (not applicable for "instance-store")
23+
FANTOM_DATA_VOL_IOPS="7000" # Max IOPS for EBS volumes (not applicable for "instance-store")
2424
FANTOM_DATA_VOL_THROUGHPUT="400" # Max throughput for EBS gp3 volumes (not applicable for "io1" | "io2" | "instance-store")
2525

2626
## HA nodes configuration ##
2727
FANTOM_HA_NUMBER_OF_NODES="2" # Total number of RPC nodes to be provisioned. Default: 2
28-
FANTOM_HA_ALB_HEALTHCHECK_GRACE_PERIOD_MIN="300" # Time enough to initialize the instance
28+
FANTOM_HA_ALB_HEALTHCHECK_GRACE_PERIOD_MIN="10080" # Time enough to initialize the instance
2929
FANTOM_HA_NODES_HEARTBEAT_DELAY_MIN="120" # Time sufficient enough for a node do sync

0 commit comments

Comments
 (0)