Skip to content

Commit f73ebfb

Browse files
committed
Ethereum. Changed README for Sync node deployment
1 parent d2f964e commit f73ebfb

File tree

2 files changed

+57
-41
lines changed

2 files changed

+57
-41
lines changed

lib/ethereum/README.md

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ This is the Well-Architected checklist for Ethereum nodes implementation of the
5959

6060
### Open AWS CloudShell
6161

62-
To begin, ensure you login to your AWS account with permissions to create and modify resources in IAM, EC2, EBS, VPC, S3, KMS, and Secrets Manager.
62+
To begin, ensure you login to your AWS account with permissions to create and modify resources in IAM, EC2, EBS, VPC, and S3.
6363

6464
From the AWS Management Console, open the [AWS CloudShell](https://docs.aws.amazon.com/cloudshell/latest/userguide/welcome.html), a web-based shell environment. If unfamiliar, review the [2-minute YouTube video](https://youtu.be/fz4rbjRaiQM) for an overview and check out [CloudShell with VPC environment](https://docs.aws.amazon.com/cloudshell/latest/userguide/creating-vpc-environment.html) that we'll use to test nodes API from internal IP address space.
6565

@@ -73,9 +73,7 @@ cd aws-blockchain-node-runners
7373
npm install
7474
```
7575

76-
> **NOTE:** *In this tutorial we will set all major configuration through environment variables, but you also can modify parameters in `config/config.ts`.*
77-
78-
### Prepare to deploy nodes
76+
### Prepare AWS account to deploy nodes
7977

8078
1. Make sure you are in the root directory of the cloned repository
8179

@@ -89,11 +87,11 @@ aws ec2 create-default-vpc
8987
9088
> **NOTE:** *The default VPC must have at least two public subnets in different Availability Zones, and public subnet must set `Auto-assign public IPv4 address` to `YES`*
9189
92-
3. With the [Node Runners blueprints for Ethereum](https://github.com/aws-samples/aws-blockchain-node-runners/tree/main/lib/ethereum), you can deploy both single Ethereum nodes and multi-node high-availability configurations on AWS. Furthermore, Node Runners is designed to support client diversity, with configurations available for a variety of client combinations for the Execution Layer (EL) and Consensus Layer (CL).
90+
### Configure your setup
9391

94-
Configure your setup.
92+
#### Execution and Consensus Layer Client Options
9593

96-
### Execution and Consensus Layer Client Options
94+
With the [Node Runners blueprints for Ethereum](https://github.com/aws-samples/aws-blockchain-node-runners/tree/main/lib/ethereum), you can deploy both single Ethereum nodes and multi-node high-availability configurations on AWS. Furthermore, Node Runners is designed to support client diversity, with configurations available for a variety of client combinations for the Execution Layer (EL) and Consensus Layer (CL).
9795

9896
<details>
9997

@@ -135,17 +133,17 @@ nano .env
135133

136134
<details>
137135

138-
<summary>Erigon Prysm</summary>
136+
<summary>Reth Lighthouse</summary>
139137
<br/>
140138

141-
**Configure your Node Runners Ethereum - Erigon Prysm**
139+
**Configure your Node Runners Ethereum - Reth Lighthouse**
142140

143-
To specify the Ethereum client combination you wish to deploy, create your own copy of `.env` file and edit it using your preferred text editor. The contents of your file for a Erigon / Prysm node deployment is as follows, which uses a sample config from the repository:
141+
To specify the Ethereum client combination you wish to deploy, create your own copy of `.env` file and edit it using your preferred text editor. The contents of your file for a Reth / Lighthouse node deployment is as follows, which uses a sample config from the repository:
144142
```bash
145143
# Make sure you are in aws-blockchain-node-runners/lib/ethereum
146144
cd lib/ethereum
147145
pwd
148-
cp ./sample-configs/.env-erigon-prysm .env
146+
cp ./sample-configs/.env-erigon-lighthouse .env
149147
nano .env
150148
```
151149
> **NOTE:** *You can find more examples inside the `sample-configs` directory, which illustrate other Ethereum client combinations.*
@@ -201,9 +199,32 @@ pwd
201199
npx cdk deploy eth-common
202200
```
203201

204-
### Option 1: Single RPC Node
202+
### [OPTIONAL] (required only when ETH_SNAPSHOT_TYPE="s3") Deploy Sync Node
203+
204+
Sync node will sync with the network and periodically create data snapshots on S3 to speed up RPC nodes setup when `ETH_SNAPSHOT_TYPE="s3"`. It has no effect if `ETH_SNAPSHOT_TYPE="none"`.
205+
206+
1. Deploy `eth-sync-node` stack
207+
208+
```bash
209+
pwd
210+
# Make sure you are in aws-blockchain-node-runners/lib/ethereum
211+
npx cdk deploy eth-sync-node --json --outputs-file sync-node-deploy.json
212+
```
213+
214+
2. After starting the node you need to wait for the inital syncronization process to finish. It may take from half a day to about 6-10 days depending on the client combination and the state of the network. You can use Amazon CloudWatch to track the progress. There is a script that publishes CloudWatch metrics every 5 minutes, where you can watch `sync distance` for consensus client and `blocks behind` for execution client. When the node is fully synced those two metrics shold show 0. To see them:
215+
216+
- Navigate to [CloudWatch service](https://console.aws.amazon.com/cloudwatch/) (make sure you are in the region you have specified for `AWS_REGION`)
217+
- Open `Dashboards` and select `eth-sync-node-<your-eth-client-combination>` from the list of dashboards.
218+
219+
Once synchronization process is over, the script will automatically stop both clients and copy all the contents of the `/data` directory to your snapshot S3 bucket. That may take from 30 minutes to about 2 hours. During the process on the dashboard you will see lower CPU and RAM utilization but high data disc throughput and outbound network traffic. The script will automatically start the clients after the process is done.
220+
221+
> **Note:** *The snapshot backup process will automatically run ever day at midnight time of the time zone were the sync node runs. To change the schedule, modify `crontab` of the root user on the node's EC2 instance.*
222+
223+
### Deploy Standalone RPC Node
224+
225+
> **NOTE:** *If `ETH_SNAPSHOT_TYPE="s3"` make sure you [deployed the Sync Node first](#deploy-sync-node-required-only-when-eth_snapshot_types3).*
205226
206-
1. Deploy Single RPC Node
227+
1. Deploy `eth-single-node` stack
207228

208229
```bash
209230
pwd
@@ -212,12 +233,12 @@ npx cdk deploy eth-single-node --json --outputs-file single-node-deploy.json
212233
```
213234
> **NOTE:** *The default VPC must have at least two public subnets in different Availability Zones, and public subnet must set `Auto-assign public IPv4 address` to `YES`*
214235
215-
2. After starting the node you need to wait for the inital syncronization process to finish. It may take from half a day to about 6-10 days depending on the client combination and the state of the network. You can use Amazon CloudWatch to track the progress. There is a script that publishes CloudWatch metrics every 5 minutes, where you can watch `sync distance` for consensus client and `blocks behind` for execution client. When the node is fully synced those two metrics shold show 0. To see them:
236+
2. If you haven't used `ETH_SNAPSHOT_TYPE="s3"` with Sync Node, then your node will start syncing by itself. In that case, after starting the node you need to wait for the inital syncronization process to finish. It may take from half a day to about 6-10 days depending on the client combination and the state of the network. You can use Amazon CloudWatch to track the progress. There is a script that publishes CloudWatch metrics every 5 minutes, where you can watch `sync distance` for consensus client and `blocks behind` for execution client. When the node is fully synced those two metrics shold show 0. To see them:
216237

217238
- Navigate to [CloudWatch service](https://console.aws.amazon.com/cloudwatch/) (make sure you are in the region you have specified for `AWS_REGION`)
218-
- Open `Dashboards` and select `eth-sync-node-<your-eth-client-combination>` from the list of dashboards.
239+
- Open `Dashboards` and select `eth-single-node-<your-eth-client-combination>` from the list of dashboards.
219240

220-
4. 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. Turn the following query against the private IP of the single RPC node you deployed:
241+
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. Turn the following query against the private IP of the single RPC node you deployed:
221242

222243
```bash
223244
INSTANCE_ID=$(cat single-node-deploy.json | jq -r '..|.node-instance-id? | select(. != null)')
@@ -240,35 +261,25 @@ The result should be like this (the actual balance might change):
240261
{"jsonrpc":"2.0","id":1,"result":"0xe791d050f91d9949d344d"}
241262
```
242263

243-
### Option 2: Highly Available RPC Nodes
244-
245-
1. Deploy Sync Node
246-
247-
```bash
248-
pwd
249-
# Make sure you are in aws-blockchain-node-runners/lib/ethereum
250-
npx cdk deploy eth-sync-node --json --outputs-file sync-node-deploy.json
251-
```
252-
**NOTE:** *The default VPC must have at least two public subnets in different Availability Zones, and public subnet must set `Auto-assign public IPv4 address` to `YES`*
264+
### Deploy Highly Available RPC Nodes
253265

254-
2. After starting the node you need to wait for the inital syncronization process to finish. It may take from half a day to about 6-10 days depending on the client combination and the state of the network. You can use Amazon CloudWatch to track the progress. There is a script that publishes CloudWatch metrics every 5 minutes, where you can watch `sync distance` for consensus client and `blocks behind` for execution client. When the node is fully synced those two metrics shold show 0. To see them:
266+
> **NOTE:** *If `ETH_SNAPSHOT_TYPE="s3"` make sure you [deployed the Sync Node first](#deploy-sync-node-required-only-when-eth_snapshot_types3).*
255267
256-
- Navigate to [CloudWatch service](https://console.aws.amazon.com/cloudwatch/) (make sure you are in the region you have specified for `AWS_REGION`)
257-
- Open `Dashboards` and select `eth-sync-node-<your-eth-client-combination>` from the list of dashboards.
268+
> **NOTE:** *The default VPC must have at least two public subnets in different Availability Zones, and public subnet must set `Auto-assign public IPv4 address` to `YES`*
258269
259-
Once synchronization process is over, the script will automatically stop both clients and copy all the contents of the `/data` directory to your snapshot S3 bucket. That may take from 30 minutes to about 2 hours. During the process on the dashboard you will see lower CPU and RAM utilization but high data disc throughput and outbound network traffic. The script will automatically start the clients after the process is done.
270+
1. Deploy Sync Node
260271

261-
> **Note:** *The snapshot backup process will automatically run ever day at midnight time of the time zone were the sync node runs. To change the schedule, modify `crontab` of the root user on the node's EC2 instance.*
272+
Use instructions from earlier: [Deploy Sync Node](#deploy-sync-node-required-only-when-eth_snapshot_types3)
262273

263-
3. Configure and deploy 2 RPC Nodes
274+
2. Deploy `eth-rpc-nodes` stack
264275

265276
```bash
266277
pwd
267278
# Make sure you are in aws-blockchain-node-runners/lib/ethereum
268279
npx cdk deploy eth-rpc-nodes --json --outputs-file rpc-node-deploy.json
269280
```
270281

271-
4. Give the new RPC nodes about 30 minutes (up to 2 hours for Erigon) to initialize and then run the following query against the load balancer behind the RPC node created
282+
3. Give the new RPC nodes about 30 minutes (up to 2 hours for Erigon) to initialize and then run the following query against the load balancer in front of your nods:
272283

273284
```bash
274285
export ETH_RPC_ABL_URL=$(cat rpc-node-deploy.json | jq -r '..|.alburl? | select(. != null)')
@@ -288,7 +299,7 @@ The result should be like this (the actual balance might change):
288299
{"jsonrpc":"2.0","id":1,"result":"0xe791d050f91d9949d344d"}
289300
```
290301

291-
If the nodes are still starting and catching up with the chain, you will see the following repsonse:
302+
If the nodes are still starting and catching up with the chain, you will see the following response:
292303

293304
```HTML
294305
<html>
@@ -298,7 +309,7 @@ The result should be like this (the actual balance might change):
298309
</body>
299310
```
300311

301-
> **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.
312+
> **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.*
302313
303314
### Clearing up and undeploying everything
304315

lib/ethereum/lib/assets/user-data-alinux.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ chmod 600 /etc/cdk_environment
66

77
{
88
echo "AWS_REGION=${_REGION_}"
9+
echo "ETH_SNAPSHOT_TYPE=${_ETH_SNAPSHOT_TYPE_}"
910
echo "SNAPSHOT_S3_PATH=${_SNAPSHOT_S3_PATH_}"
1011
echo "ETH_CLIENT_COMBINATION=${_ETH_CLIENT_COMBINATION_}"
1112
echo "ETH_NETWORK=${_ETH_NETWORK_}"
@@ -190,8 +191,10 @@ if [ "$NODE_ROLE" == "sync-node" ] || [ "$NODE_ROLE" == "single-node" ]; then
190191
if [ "$AUTOSTART_CONTAINER" == "false" ]; then
191192
echo "Single node. Autostart disabled. Start docker-compose manually!"
192193
else
193-
echo "Single node. Autostart enabled. Starting docker compose"
194-
docker compose -f /home/bcuser/docker-compose.yml up -d
194+
if [ "$ETH_SNAPSHOT_TYPE" == "none" ]; then
195+
echo "Snapshot is not provided. Autostart enabled. Starting docker compose"
196+
docker compose -f /home/bcuser/docker-compose.yml up -d
197+
fi
195198
fi
196199
fi
197200

@@ -200,10 +203,12 @@ if [ "$NODE_ROLE" == "sync-node" ]; then
200203
chmod 766 /opt/instance/storage/copy-data-to-s3.sh
201204
fi
202205

203-
if [ "$NODE_ROLE" == "rpc-node" ]; then
204-
echo "RPC node. Starting copy data script"
205-
chmod 766 /opt/instance/storage/copy-data-from-s3.sh
206-
echo "/opt/instance/storage/copy-data-from-s3.sh" | at now +3 minutes
206+
if [ "$NODE_ROLE" == "rpc-node" ] || [ "$NODE_ROLE" == "single-node" ]; then
207+
if [ "$ETH_SNAPSHOT_TYPE" == "s3" ]; then
208+
echo "RPC node. Snapshot on S3. Starting copy data script"
209+
chmod 766 /opt/instance/storage/copy-data-from-s3.sh
210+
echo "/opt/instance/storage/copy-data-from-s3.sh" | at now +3 minutes
211+
fi
207212
fi
208213

209214
echo "All Done!!"

0 commit comments

Comments
 (0)