Skip to content

Bitcoin Core Implementation #185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 119 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
4ce981c
Bitcoin Core initial commit
Mar 28, 2025
4686b08
Update README.md
racket2000 Mar 28, 2025
12a990d
Update README.md
racket2000 Mar 28, 2025
99e33ce
Fix formatting
racket2000 Mar 28, 2025
c4b1782
Fix path
racket2000 Mar 28, 2025
bb00a03
Fix command
racket2000 Mar 28, 2025
7cf4620
Update README.md
racket2000 Mar 28, 2025
038e799
Update bitcoin.conf
racket2000 Mar 28, 2025
ec039e6
Update README.md
racket2000 Mar 31, 2025
210d050
Add clean up instructions
racket2000 Apr 1, 2025
e17e766
Add info about ALB cookie
racket2000 Apr 1, 2025
66ffdca
incorporate to website
Apr 1, 2025
fff4884
fix pre-commit errors
Apr 1, 2025
d82ade9
fix test and remove printed password from generateRPCAuth
Apr 1, 2025
f983100
fix pre-commit again
Apr 1, 2025
689a0cb
refresh package.json
Apr 1, 2025
f90c731
trying to fix website build error
Apr 1, 2025
97b375f
fix package-lock
Apr 1, 2025
8fe84a1
fix website build error
Apr 1, 2025
fc9b08a
fix website build error pt3
Apr 1, 2025
892b87d
Update README.md
racket2000 Apr 1, 2025
7322b92
fix website dependecy issues
Apr 1, 2025
a0d6b94
fix build dependecy issue
Apr 1, 2025
7a534ab
fix website build
Apr 1, 2025
a1b814c
fix website build pt2
Apr 1, 2025
689e531
fix website build pt3
Apr 1, 2025
57e092c
implement .env and remove local packages
Apr 3, 2025
8bc79d9
fix pre-commit
Apr 3, 2025
0795d9d
modify local package.json
Apr 3, 2025
79d8e70
fix file path
Apr 3, 2025
a707c89
update readme
Apr 3, 2025
2734a5a
fix precommit
Apr 3, 2025
a9c2482
update readme formatting
Apr 3, 2025
2e5662d
clarify credential rotation
Apr 3, 2025
0295682
Base. Upgrade and refactored to address common operational problems
vlasonfa Apr 8, 2025
eab895b
Merge pull request #189 from aws-samples/base
frbrkoala Apr 8, 2025
1444e67
increase EBS vol size
racket2000 Apr 8, 2025
ee9c460
Updated the default EBS vol size
racket2000 Apr 8, 2025
fc79b2d
Update README.md
anirudhmarc Apr 9, 2025
ca6e5c1
feedback incorp'd
Apr 10, 2025
7c62ebc
fix pre-commmit and add placeholder account ID
Apr 10, 2025
7f55a3e
update HA arch
Apr 10, 2025
ae0e262
fix path in readme
racket2000 Apr 10, 2025
d2cbe9f
update account id
racket2000 Apr 10, 2025
2b6f9b5
Remove .env file from repo
Apr 10, 2025
f83fdef
fix tests
Apr 10, 2025
1593a83
update readme regarding secrets manager
Apr 10, 2025
6a308a5
fix typo in env var
Apr 10, 2025
ba32139
clarify directory in command
Apr 10, 2025
7a5b647
add GP3_THROUGHPUT .env
Apr 10, 2025
f6ddf77
fix pre-commit
Apr 10, 2025
50dc0ac
update package.json
Apr 10, 2025
47d6254
fix precommit
Apr 10, 2025
480d7a6
add note regarding auth creds
Apr 10, 2025
47f188e
fix pre-commit
Apr 10, 2025
f749e51
add SSM note to payments
Apr 10, 2025
c62de10
fix typo
Apr 10, 2025
d23b858
Merge pull request #190 from anirudhmarc/patch-1
frbrkoala Apr 16, 2025
4eabb3d
BSC. Changes to snapshot download script
vlasonfa Apr 30, 2025
44cbb2e
Merge pull request #194 from aws-samples/bsc
frbrkoala Apr 30, 2025
772d8fb
Base. Fixed setup scripts to reflect recent updates in Base node setu…
vlasonfa May 2, 2025
d0bb870
Merge branch 'main' into base
frbrkoala May 2, 2025
f4f53aa
Merge pull request #195 from aws-samples/base
frbrkoala May 2, 2025
fd38dc4
Fantom. Deprecating the blueprint
vlasonfa May 5, 2025
6e85899
Website. Updated dependencies
vlasonfa May 5, 2025
918e683
Merge pull request #196 from aws-samples/website
frbrkoala May 5, 2025
d84f43b
Bitcoin Core initial commit
Mar 28, 2025
0d379bd
Update README.md
racket2000 Mar 28, 2025
831b93e
Update README.md
racket2000 Mar 28, 2025
721c662
Fix formatting
racket2000 Mar 28, 2025
0dbd577
Fix path
racket2000 Mar 28, 2025
2b20153
Fix command
racket2000 Mar 28, 2025
310788f
Update README.md
racket2000 Mar 28, 2025
97aa6b9
Update bitcoin.conf
racket2000 Mar 28, 2025
488dadc
Update README.md
racket2000 Mar 31, 2025
3952e83
Add clean up instructions
racket2000 Apr 1, 2025
0b630ad
Add info about ALB cookie
racket2000 Apr 1, 2025
b7db8a5
incorporate to website
Apr 1, 2025
217abed
fix pre-commit errors
Apr 1, 2025
9aa9338
fix test and remove printed password from generateRPCAuth
Apr 1, 2025
dbf962c
fix pre-commit again
Apr 1, 2025
d93b4d0
refresh package.json
Apr 1, 2025
e85b961
trying to fix website build error
Apr 1, 2025
5eb2383
fix package-lock
Apr 1, 2025
db32831
fix website build error
Apr 1, 2025
8e913bb
fix website build error pt3
Apr 1, 2025
5df7f6f
Update README.md
racket2000 Apr 1, 2025
d0e1953
fix website dependecy issues
Apr 1, 2025
996b489
fix build dependecy issue
Apr 1, 2025
ecc451d
fix website build
Apr 1, 2025
54e24b5
fix website build pt2
Apr 1, 2025
6f4513c
fix website build pt3
Apr 1, 2025
18cc33a
implement .env and remove local packages
Apr 3, 2025
377983d
fix pre-commit
Apr 3, 2025
ba71cdf
modify local package.json
Apr 3, 2025
b4c7bcd
fix file path
Apr 3, 2025
3c5375b
update readme
Apr 3, 2025
ae4acd9
fix precommit
Apr 3, 2025
936d19b
update readme formatting
Apr 3, 2025
a5f6f25
clarify credential rotation
Apr 3, 2025
96a736f
feedback incorp'd
Apr 10, 2025
41eb7e7
fix pre-commmit and add placeholder account ID
Apr 10, 2025
d7dbfcb
update HA arch
Apr 10, 2025
0bba922
fix path in readme
racket2000 Apr 10, 2025
b14fc5e
update account id
racket2000 Apr 10, 2025
a9912f7
Remove .env file from repo
Apr 10, 2025
3f3e660
fix tests
Apr 10, 2025
c066dfd
update readme regarding secrets manager
Apr 10, 2025
0a807db
fix typo in env var
Apr 10, 2025
197e302
clarify directory in command
Apr 10, 2025
75cccc8
add GP3_THROUGHPUT .env
Apr 10, 2025
6ed20a1
fix pre-commit
Apr 10, 2025
4b0ce37
update package.json
Apr 10, 2025
92a0d40
fix precommit
Apr 10, 2025
f70b0e5
add note regarding auth creds
Apr 10, 2025
5f2194b
fix pre-commit
Apr 10, 2025
74930b5
add SSM note to payments
Apr 10, 2025
1366ef8
fix typo
Apr 10, 2025
dcd7f69
Merge branch 'bitcoin-core' of https://github.com/aws-samples/aws-blo…
vlasonfa May 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ aws ssm start-session --target $INSTANCE_ID --region $AWS_REGION
```bash
sudo su bcuser
# Execution client logs:
docker logs --tail 50 node_execution_1 -f
docker logs --tail 50 node-execution-1 -f
# Base client logs:
docker logs --tail 50 node_node_1 -f
docker logs --tail 50 node-node-1 -f
```
2. How to check the logs from the EC2 user-data script?

Expand Down
6 changes: 4 additions & 2 deletions lib/base/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ new BaseCommonStack(app, "base-common", {
});

new BaseSingleNodeStack(app, "base-single-node", {
stackName: `base-single-node-${config.baseNodeConfig.baseNodeConfiguration}-${config.baseNodeConfig.baseNetworkId}`,
stackName: `base-single-node-${config.baseNodeConfig.baseClient}-${config.baseNodeConfig.baseNodeConfiguration}-${config.baseNodeConfig.baseNetworkId}`,
env: { account: config.baseConfig.accountId, region: config.baseConfig.region },

instanceType: config.baseNodeConfig.instanceType,
instanceCpuType: config.baseNodeConfig.instanceCpuType,
baseNetworkId: config.baseNodeConfig.baseNetworkId,
baseClient: config.baseNodeConfig.baseClient,
baseNodeConfiguration: config.baseNodeConfig.baseNodeConfiguration,
restoreFromSnapshot: config.baseNodeConfig.restoreFromSnapshot,
l1ExecutionEndpoint: config.baseNodeConfig.l1ExecutionEndpoint,
Expand All @@ -32,12 +33,13 @@ new BaseSingleNodeStack(app, "base-single-node", {
});

new BaseHANodesStack(app, "base-ha-nodes", {
stackName: `base-ha-nodes-${config.baseNodeConfig.baseNodeConfiguration}-${config.baseNodeConfig.baseNetworkId}`,
stackName: `base-ha-nodes-${config.baseNodeConfig.baseClient}-${config.baseNodeConfig.baseNodeConfiguration}-${config.baseNodeConfig.baseNetworkId}`,
env: { account: config.baseConfig.accountId, region: config.baseConfig.region },

instanceType: config.baseNodeConfig.instanceType,
instanceCpuType: config.baseNodeConfig.instanceCpuType,
baseNetworkId: config.baseNodeConfig.baseNetworkId,
baseClient: config.baseNodeConfig.baseClient,
baseNodeConfiguration: config.baseNodeConfig.baseNodeConfiguration,
restoreFromSnapshot: config.baseNodeConfig.restoreFromSnapshot,
l1ExecutionEndpoint: config.baseNodeConfig.l1ExecutionEndpoint,
Expand Down
10 changes: 0 additions & 10 deletions lib/base/lib/assets/base/node-start.sh

This file was deleted.

9 changes: 0 additions & 9 deletions lib/base/lib/assets/base/node-stop.sh

This file was deleted.

40 changes: 40 additions & 0 deletions lib/base/lib/assets/instance/cfn-hup/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

if [ -n "$1" ]; then
export STACK_ID=$1
else
echo "Error: No Stack ID is provided"
echo "Usage: instance/cfn-hup/setup.sh <stack_id> <aws_region>"
exit 1
fi

if [ -n "$2" ]; then
export AWS_REGION=$2
else
echo "Error: No AWS Region is provided"
echo "Usage: instance/cfn-hup/setup.sh <stack_id> <aws_region>"
exit 1
fi

echo "Install CloudFormation helper scripts"
mkdir -p /opt/aws/
pip3 install --break-system-packages https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz
ln -s /usr/local/init/ubuntu/cfn-hup /etc/init.d/cfn-hup

echo "Configuring CloudFormation helper scripts"
mkdir -p /etc/cfn/
mv /opt/instance/cfn-hup/cfn-hup.conf /etc/cfn/cfn-hup.conf
sed -i "s;__AWS_STACK_ID__;\"$STACK_ID\";g" /etc/cfn/cfn-hup.conf
sed -i "s;__AWS_REGION__;\"$AWS_REGION\";g" /etc/cfn/cfn-hup.conf

mkdir -p /etc/cfn/hooks.d/system
mv /opt/instance/cfn-hup/cfn-auto-reloader.conf /etc/cfn/hooks.d/cfn-auto-reloader.conf
sed -i "s;__AWS_STACK_NAME__;\"$STACK_NAME\";g" /etc/cfn/hooks.d/cfn-auto-reloader.conf
sed -i "s;__AWS_REGION__;\"$AWS_REGION\";g" /etc/cfn/hooks.d/cfn-auto-reloader.conf

echo "Starting CloudFormation helper scripts as a service"
mv /opt/instance/cfn-hup/cfn-hup.service /etc/systemd/system/cfn-hup.service

systemctl daemon-reload
systemctl enable --now cfn-hup
systemctl start cfn-hup.service
76 changes: 76 additions & 0 deletions lib/base/lib/assets/instance/storage/restore-from-snapshot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash
set +e

source /etc/cdk_environment

echo "Downloading Snapshot."

cd /data

SNAPSHOT_FILE_NAME=snapshot.tar.gz
SNAPSHOT_DIR=/data
SNAPSHOT_DOWNLOAD_STATUS=-1

if [ "$SNAPSHOT_URL" == "none" ] || [ -z "${SNAPSHOT_URL}" ]; then

case $BASE_CLIENT in
"geth")
LATEST_SNAPSHOT_FILE_NAME=$(curl https://$NETWORK_ID-full-snapshots.base.org/latest)
SNAPSHOT_URL=https://$NETWORK_ID-full-snapshots.base.org/$LATEST_SNAPSHOT_FILE_NAME
;;
"reth")
LATEST_SNAPSHOT_FILE_NAME=$(curl https://$NETWORK_ID-reth-archive-snapshots.base.org/latest)
SNAPSHOT_URL=https://$NETWORK_ID-reth-archive-snapshots.base.org/$LATEST_SNAPSHOT_FILE_NAME
;;
*)
# Geth
LATEST_SNAPSHOT_FILE_NAME=$(curl https://$NETWORK_ID-full-snapshots.base.org/latest)
SNAPSHOT_URL=https://$NETWORK_ID-full-snapshots.base.org/$LATEST_SNAPSHOT_FILE_NAME
;;
esac
fi

while (( SNAPSHOT_DOWNLOAD_STATUS != 0 ))
do
PIDS=$(pgrep wget)
if [ -z "$PIDS" ]; then
wget $SNAPSHOT_URL -P $SNAPSHOT_DIR -O $SNAPSHOT_FILE_NAME
fi
SNAPSHOT_DOWNLOAD_STATUS=$?
pid=$(pidof wget)
wait $pid
echo "wget exit."
case $SNAPSHOT_DOWNLOAD_STATUS in
8)
echo "Server error."
exit 8
;;
3)
echo "No space left on device."
exit 3
;;
*)
continue
;;
esac
done
echo "Downloading Snapshot script finished"

sleep 60

echo "Starting snapshot decompression ..."

tar --use-compress-program=unzstd -xvf $SNAPSHOT_DIR/$SNAPSHOT_FILE_NAME -C /data 2>&1 | tee unzip.log && echo "decompressed successfully..." || echo "decompression failed..." >> snapshots-decompression.log

echo "Decompressed snapshot, cleaning up..."

mv /data/snapshots/$NETWORK_ID/download/* /data && \
rm -rf /data/snapshots && \
rm -rf $SNAPSHOT_DIR/$SNAPSHOT_FILE_NAME

echo "Snapshot is ready, starting the service.."

chown -R bcuser:bcuser /data

sudo systemctl daemon-reload
sudo systemctl enable --now node
130 changes: 130 additions & 0 deletions lib/base/lib/assets/instance/storage/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#!/bin/bash

make_fs () {
# If file system = to ext4 use mkfs.ext4, if xfs use mkfs.xfs
if [ -z "$1" ]; then
echo "Error: No file system type provided."
echo "Usage: make_fs <file system type [ xfs | ext4 ]> <target_volume_id>"
exit 1
fi

if [ -z "$2" ]; then
echo "Error: No target volume ID provided."
echo "Usage: make_fs <file system type [ xfs | ext4 ]> <target_volume_id>"
exit 1
fi

local file_system=$1
local volume_id=$2
if [ "$file_system" == "ext4" ]; then
mkfs -t ext4 "$volume_id"
return "$?"
else
mkfs.xfs -f "$volume_id"
return "$?"
fi
}

# We need an nvme disk that is not mounted and not partitioned
get_all_empty_nvme_disks () {
local all_not_mounted_nvme_disks
local all_mounted_nvme_partitions
local unmounted_nvme_disks=()
local sorted_unmounted_nvme_disks

#The disk will only be mounted when the nvme disk is larger than 100GB to avoid storing blockchain node data directly on the root EBS disk (which is 46GB by default)
all_not_mounted_nvme_disks=$(lsblk -lnb | awk '{if ($7 == "" && $4 > 100000000) {print $1}}' | grep nvme)
all_mounted_nvme_partitions=$(mount | awk '{print $1}' | grep /dev/nvme)
for disk in ${all_not_mounted_nvme_disks[*]}; do
if [[ ! "${all_mounted_nvme_partitions[*]}" =~ $disk ]]; then
unmounted_nvme_disks+=("$disk")
fi
done
# Sort the array
sorted_unmounted_nvme_disks=($(printf '%s\n' "${unmounted_nvme_disks[*]}" | sort))
echo "${sorted_unmounted_nvme_disks[*]}"
}

get_next_empty_nvme_disk () {
local sorted_unmounted_nvme_disks
sorted_unmounted_nvme_disks=($(get_all_empty_nvme_disks))
# Return the first unmounted nvme disk
echo "/dev/${sorted_unmounted_nvme_disks[0]}"
}

# Add input as command line parameters for name of the directory to mount
if [ -n "$1" ]; then
DIR_NAME=$1
else
echo "Error: No data file system mount path is provided."
echo "Usage: instance/storage/setup.sh <file_system_mount_path> <file_system_type [ xfs | ext4 ]> <target_volume_size_in_bytes> "
echo "Default file system type is ext4"
echo "If you skip <target_volume_size_in_bytes>, script will try to use the first unformatted volume ID."
echo "Usage example: instance/storage/setup.sh /data ext4 300000000000000"
exit 1
fi

# Case input for $2 between ext4 and xfs, use ext4 as default
case $2 in
ext4)
echo "File system set to ext4"
FILE_SYSTEM="ext4"
FS_CONFIG="defaults"
;;
xfs)
echo "File system set to xfs"
FILE_SYSTEM="xfs"
FS_CONFIG="noatime,nodiratime,nodiscard" # See more: https://cdrdv2-public.intel.com/686417/rocksdb-benchmark-tuning-guide-on-xeon.pdf
;;
*)
echo "File system set to ext4"
FILE_SYSTEM="ext4"
FS_CONFIG="defaults"
;;
esac

if [ -n "$3" ]; then
VOLUME_SIZE=$3
else
echo "The size of volume for $DIR_NAME is not specified. Will try to guess volume ID."
fi

echo "Checking if $DIR_NAME is mounted, and dont do anything if it is"
if [ $(df --output=target | grep -c "$DIR_NAME") -lt 1 ]; then

if [ -n "$VOLUME_SIZE" ]; then
VOLUME_ID=/dev/$(lsblk -lnb | awk -v VOLUME_SIZE_BYTES="$VOLUME_SIZE" '{if ($4== VOLUME_SIZE_BYTES) {print $1}}')
echo "Data volume size defined, use respective volume id: $VOLUME_ID"
else
VOLUME_ID=$(get_next_empty_nvme_disk)
echo "Data volume size undefined, trying volume id: $VOLUME_ID"
fi

make_fs $FILE_SYSTEM "$VOLUME_ID"

sleep 10
VOLUME_UUID=$(lsblk -fn -o UUID "$VOLUME_ID")
VOLUME_FSTAB_CONF="UUID=$VOLUME_UUID $DIR_NAME $FILE_SYSTEM $FS_CONFIG 0 2"
echo "VOLUME_ID=$VOLUME_ID"
echo "VOLUME_UUID=$VOLUME_UUID"
echo "VOLUME_FSTAB_CONF=$VOLUME_FSTAB_CONF"

# Check if data disc is already in fstab and replace the line if it is with the new disc UUID
echo "Checking fstab for volume $DIR_NAME"
if [ $(grep -c "$DIR_NAME" /etc/fstab) -gt 0 ]; then
SED_REPLACEMENT_STRING="$(grep -n "$DIR_NAME" /etc/fstab | cut -d: -f1)s#.*#$VOLUME_FSTAB_CONF#"
# if file exists, delete it
if [ -f /etc/fstab.bak ]; then
rm /etc/fstab.bak
fi
cp /etc/fstab /etc/fstab.bak
sed -i "$SED_REPLACEMENT_STRING" /etc/fstab
else
echo "$VOLUME_FSTAB_CONF" | tee -a /etc/fstab
fi

mount -a
chown -R bcuser:bcuser "$DIR_NAME"
else
echo "$DIR_NAME volume is mounted, nothing changed"
fi
15 changes: 15 additions & 0 deletions lib/base/lib/assets/node/node-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -e

source /etc/cdk_environment

export NETWORK_ENV=".env.$NETWORK_ID"
export CLIENT="$BASE_CLIENT"
export HOST_DATA_DIR="/data"

echo "Script is starting client $CLIENT on $NETWORK_ENV"
# Start the node
cd /home/bcuser/node
docker compose -f /home/bcuser/node/docker-compose.yml up -d

echo "Started"
13 changes: 13 additions & 0 deletions lib/base/lib/assets/node/node-stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e
source /etc/cdk_environment

export NETWORK_ENV=".env.$NETWORK_ID"
export CLIENT=geth

echo "Script is starting client $CLIENT on $NETWORK_ENV"
# Stop the node
cd /home/bcuser/node
docker compose -f /home/bcuser/node/docker-compose.yml down

echo "Stopped"
31 changes: 0 additions & 31 deletions lib/base/lib/assets/restore-from-snapshot-archive-s3.sh

This file was deleted.

Loading