Skip to content
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

added several scripts #22

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions geth-poa/add_member.sh
Original file line number Diff line number Diff line change
@@ -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
43 changes: 43 additions & 0 deletions geth-poa/add_signer.md
Original file line number Diff line number Diff line change
@@ -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 <container_id_1> <container_id_2> ...
```

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.
15 changes: 15 additions & 0 deletions geth-poa/add_signer.sh
Original file line number Diff line number Diff line change
@@ -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
55 changes: 55 additions & 0 deletions geth-poa/docker-compose-add-member.yml
Original file line number Diff line number Diff line change
@@ -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:

57 changes: 57 additions & 0 deletions geth-poa/docker-compose-add-signer.yml
Original file line number Diff line number Diff line change
@@ -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:

2 changes: 2 additions & 0 deletions geth-poa/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ services:
- 60604:60601
volumes:
- geth-data-node3:/data
- geth-data-backup:/backup
profiles:
- settlement
labels:
Expand Down Expand Up @@ -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:
Expand Down
36 changes: 36 additions & 0 deletions geth-poa/export_chaindata.md
Original file line number Diff line number Diff line change
@@ -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 <containerId> <chaindata> <exportdata> <startBlock> <endBlock>
```

### 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.
16 changes: 16 additions & 0 deletions geth-poa/export_chaindata.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh
set -exu

if [ "$#" -ne 5 ]; then
echo "Usage: $0 <containerId> <chaindata> <exportdata> <startBlock> <endBlock>"
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}"
4 changes: 4 additions & 0 deletions geth-poa/stop_member.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
set -exu

docker-compose -f docker-compose-add-member.yml --profile settlement down
9 changes: 9 additions & 0 deletions geth-poa/stop_signer.sh
Original file line number Diff line number Diff line change
@@ -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
Loading