diff --git a/geth-poa/add_member.sh b/geth-poa/add_member.sh new file mode 100755 index 000000000000..b3118ca5bc4a --- /dev/null +++ b/geth-poa/add_member.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -exu + +export MEMBER_NODE_VOLUME=${MEMBER_NODE_VOLUME:-"geth-data-member"} +export MEMBER_NODE_PORT=${MEMBER_NODE_PORT:-60605} +export SIGNER_NODE_IP=${SIGNER_NODE_IP:-"172.29.0.103"} + +docker-compose -f docker-compose-add-member.yml --profile settlement up -d --build diff --git a/geth-poa/add_signer.md b/geth-poa/add_signer.md new file mode 100644 index 000000000000..3572deb81ad9 --- /dev/null +++ b/geth-poa/add_signer.md @@ -0,0 +1,43 @@ +# Signer Node Setup Script + +## Overview + +This script facilitates the setup and registration of a signer node within a blockchain network using Docker and Geth. It exports several environment variables essential for configuring the signer node, initializes the Docker containers required for the node's operation, and proposes the node as a signer to the network. + +## Prerequisites + +- Docker and Docker Compose installed on your machine. +- Geth (Go Ethereum) client installed within the Docker containers. +- A running Ethereum network that supports the Clique consensus mechanism (Proof of Authority). + +## Configuration + +The script uses several environment variables for configuration, which can be set directly in the script or passed as environment variables before execution. Defaults are provided for each variable: + +- `SIGNER_NODE_ADDRESS`: The Ethereum address of the signer node. Default is `0x57949c3552159532c324c6fa8b102696cf4504bc`. +- `SIGNER_NODE_PRIVATE_KEY`: The private key associated with the signer node's address. Default is `0x0300633b02bab7305e17a2eabc6477f5caa3bc705994d2e19f55e8427c38536e`. +- `SIGNER_NODE_VOLUME`: The Docker volume name for storing node data. Default is `geth-data-signer`. +- `SIGNER_NODE_PORT`: The port on which the signer node will listen. Default is `60605`. +- `SIGNER_NODE_IP`: The IP address of the signer node. Default is `172.29.0.102`. + +## Usage + +1. **Prepare Docker Compose File**: Ensure you have a `docker-compose-add-signer.yml` file configured for your Docker environment. This file should define the services required for your signer node, including the Ethereum client (Geth). + +2. **Set Environment Variables (Optional)**: If you wish to use custom values for any of the configuration variables, export them before running the script: + +```sh + export SIGNER_NODE_ADDRESS="0xYourSignerAddress" + export SIGNER_NODE_PRIVATE_KEY="0xYourPrivateKey" + export SIGNER_NODE_VOLUME="YourVolumeName" + export SIGNER_NODE_PORT=YourPortNumber + export SIGNER_NODE_IP="YourNodeIP" +``` + +3. **Execute the Script**: Run the script by passing the names of the containers where you want to propose the signer node as an argument. Ensure you have the necessary permissions to execute the script: + +```sh + export ./add_signer.sh ... +``` + +4. **Verify Signer Node**: After execution, verify that the signer node has been successfully proposed and added to your Ethereum network as a signer. This can usually be done by checking the logs of your Ethereum client or using Geth's console. diff --git a/geth-poa/add_signer.sh b/geth-poa/add_signer.sh new file mode 100755 index 000000000000..4419cbf89e2d --- /dev/null +++ b/geth-poa/add_signer.sh @@ -0,0 +1,15 @@ +#!/bin/sh +set -exu + +export SIGNER_NODE_ADDRESS=${SIGNER_NODE_ADDRESS:-"0x57949c3552159532c324c6fa8b102696cf4504bc"} +export SIGNER_NODE_PRIVATE_KEY=${SIGNER_NODE_PRIVATE_KEY:-"0x0300633b02bab7305e17a2eabc6477f5caa3bc705994d2e19f55e8427c38536e"} +export SIGNER_NODE_VOLUME=${SIGNER_NODE_VOLUME:-"geth-data-signer"} +export SIGNER_NODE_PORT=${SIGNER_NODE_PORT:-60605} +export SIGNER_NODE_IP=${SIGNER_NODE_IP:-"172.29.0.102"} + +docker-compose -f docker-compose-add-signer.yml --profile settlement up -d --build + +for var in "$@" +do + docker exec $var geth attach --exec "clique.propose(\"$SIGNER_NODE_ADDRESS\", true)" /data/geth.ipc +done diff --git a/geth-poa/docker-compose-add-member.yml b/geth-poa/docker-compose-add-member.yml new file mode 100644 index 000000000000..d820d2608164 --- /dev/null +++ b/geth-poa/docker-compose-add-member.yml @@ -0,0 +1,55 @@ +version: '3' +services: + sl-node-member: + build: + context: .. + dockerfile: geth-poa/Dockerfile + environment: + - GETH_NODE_TYPE=member + - BOOTNODE_ENDPOINT=enode://34a2a388ad31ca37f127bb9ffe93758ee711c5c2277dff6aff2e359bcf2c9509ea55034196788dbd59ed70861f523c1c03d54f1eabb2b4a5c1c129d966fe1e65@172.29.0.98:30301 + - NET_RESTRICT=172.29.0.0/16 + networks: + primev_net: + ipv4_address: ${MEMBER_IP_ADDRESS} + ports: + - ${MEMBER_NODE_PORT}:60601 + volumes: + - geth-data-member-node:/data + profiles: + - settlement + labels: + com.datadoghq.ad.check_names: '["openmetrics"]' + com.datadoghq.ad.init_configs: '[{}]' + com.datadoghq.ad.instances: | + [ + { + "openmetrics_endpoint": "http://%%host%%:6060/debug/metrics/prometheus", + "namespace": "geth-poa", + "metrics": [ + "txpool*", + "trie*", + "system*", + "state*", + "rpc*", + "p2p*", + "eth*", + "chain*", + "clique*" + "vm*" + ] + } + ] + +networks: + primev_net: + external: true + l1_net: + driver: bridge + ipam: + driver: default + config: + - subnet: 172.14.0.0/16 + +volumes: + geth-data-member-node: + diff --git a/geth-poa/docker-compose-add-signer.yml b/geth-poa/docker-compose-add-signer.yml new file mode 100644 index 000000000000..06359014ac5e --- /dev/null +++ b/geth-poa/docker-compose-add-signer.yml @@ -0,0 +1,57 @@ +version: '3' +services: + sl-node-signer: + build: + context: .. + dockerfile: geth-poa/Dockerfile + environment: + - GETH_NODE_TYPE=signer + - BLOCK_SIGNER_ADDRESS=${SIGNER_NODE_ADDRESS} + - BLOCK_SIGNER_PRIVATE_KEY=${SIGNER_NODE_PRIVATE_KEY} + - BOOTNODE_ENDPOINT=enode://34a2a388ad31ca37f127bb9ffe93758ee711c5c2277dff6aff2e359bcf2c9509ea55034196788dbd59ed70861f523c1c03d54f1eabb2b4a5c1c129d966fe1e65@172.29.0.98:30301 + - NET_RESTRICT=172.29.0.0/16 + networks: + primev_net: + ipv4_address: ${SIGNER_NODE_IP} + ports: + - ${SIGNER_NODE_PORT}:60601 + volumes: + - geth-data-signer-node:/data + profiles: + - settlement + labels: + com.datadoghq.ad.check_names: '["openmetrics"]' + com.datadoghq.ad.init_configs: '[{}]' + com.datadoghq.ad.instances: | + [ + { + "openmetrics_endpoint": "http://%%host%%:6060/debug/metrics/prometheus", + "namespace": "geth-poa", + "metrics": [ + "txpool*", + "trie*", + "system*", + "state*", + "rpc*", + "p2p*", + "eth*", + "chain*", + "clique*" + "vm*" + ] + } + ] + +networks: + primev_net: + external: true + l1_net: + driver: bridge + ipam: + driver: default + config: + - subnet: 172.14.0.0/16 + +volumes: + geth-data-signer-node: + diff --git a/geth-poa/docker-compose.yml b/geth-poa/docker-compose.yml index 530e4d9c7596..5c61f5425988 100644 --- a/geth-poa/docker-compose.yml +++ b/geth-poa/docker-compose.yml @@ -223,6 +223,7 @@ services: - 60604:60601 volumes: - geth-data-node3:/data + - geth-data-backup:/backup profiles: - settlement labels: @@ -340,6 +341,7 @@ volumes: geth-data-node1: geth-data-node2: geth-data-node3: + geth-data-backup: geth-data-l1-bootnode: geth-data-l1-first-signer: geth-data-l1-second-signer: diff --git a/geth-poa/export_chaindata.md b/geth-poa/export_chaindata.md new file mode 100644 index 000000000000..f93ec257ed1c --- /dev/null +++ b/geth-poa/export_chaindata.md @@ -0,0 +1,36 @@ +# Blockchain Data Export Script README + +## Overview + +This script is designed to export blockchain data from a specific range of blocks. It stops a running Docker container that runs a blockchain node, exports the specified block range data into a file, and then restarts the container. This process is crucial for backing up blockchain data or analyzing the blockchain at a specific point in time. + +## Prerequisites + +- Docker installed on your machine. +- A running Docker container hosting a blockchain node. +- Geth (Go Ethereum) or a compatible Ethereum client installed for blockchain operations. +- Sufficient disk space for the export data. + +## Usage + +The script requires five arguments to run: + +1. `containerId`: The ID or name of the Docker container running the blockchain node. +2. `chaindata`: The path to the blockchain data directory (`datadir`). +3. `exportdata`: The path and filename where the exported data will be saved. +4. `startBlock`: The starting block number from which to begin the export. +5. `endBlock`: The ending block number where the export will stop. + +### Command Syntax + +```sh +./export-chaindata.sh +``` + +### Example + +```sh +./export-chaindata.sh ethereum-node /path/to/chaindata /path/to/exportedData 0 2000 +``` + +This command will stop the ethereum-node (better to stop member node) container, export blocks 0 to 2000 from the specified chain data directory to the specified file, and then restart the ethereum-node container. diff --git a/geth-poa/export_chaindata.sh b/geth-poa/export_chaindata.sh new file mode 100755 index 000000000000..67a8265d0ae5 --- /dev/null +++ b/geth-poa/export_chaindata.sh @@ -0,0 +1,16 @@ +#!/bin/sh +set -exu + +if [ "$#" -ne 5 ]; then + echo "Usage: $0 " + exit 1 +fi + +CONTAINER_ID=$1 +CHAIN_DATA=$2 +EXPORT_DATA=$3 +START_BLOCK=$4 +END_BLOCK=$5 +docker stop "${CONTAINER_ID}" +geth --datadir "${CHAIN_DATA}" export "${EXPORT_DATA}" ${START_BLOCK} ${END_BLOCK} +docker start "${CONTAINER_ID}" diff --git a/geth-poa/stop_member.sh b/geth-poa/stop_member.sh new file mode 100644 index 000000000000..2f9bdc47f226 --- /dev/null +++ b/geth-poa/stop_member.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -exu + +docker-compose -f docker-compose-add-member.yml --profile settlement down diff --git a/geth-poa/stop_signer.sh b/geth-poa/stop_signer.sh new file mode 100755 index 000000000000..cc36d2e60df0 --- /dev/null +++ b/geth-poa/stop_signer.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -exu + +docker-compose -f docker-compose-add-signer.yml --profile settlement down + +for var in "$@" +do + docker exec $var geth attach --exec "clique.propose(\"$SIGNER_NODE_ADDRESS\", false)" /data/geth.ipc +done