From c63c54aee689f35ae2b3d947d573e3ee489ec31f Mon Sep 17 00:00:00 2001
From: Slava <20563034+veaceslavdoina@users.noreply.github.com>
Date: Sat, 30 Mar 2024 15:12:19 +0200
Subject: [PATCH] Update docker-compose and guide (#10)
* Pass ports values via variables
* Update How to start section
---
README.md | 95 +++++++++++++++++++++------------------------
docker-compose.yaml | 14 +++----
2 files changed, 50 insertions(+), 59 deletions(-)
diff --git a/README.md b/README.md
index 1354a6f..8c31ce7 100644
--- a/README.md
+++ b/README.md
@@ -24,36 +24,46 @@ Using the Testnet Starter, you can run a (mostly preconfigured) Codex node on yo
```
3. Create an Ethereum public/private key pair
+
+ Use Docker
+
+ ```shell
+ # Generate keypair
+ docker run --rm gochain/web3 account create
+ ```
+
+
Use metamask
- 1. [Accounts and Addresses](https://support.metamask.io/hc/en-us/sections/4471975962907-Accounts-and-Addresses)
- 2. [How to export an account's private key](https://support.metamask.io/hc/en-us/articles/360015289632-How-to-export-an-account-s-private-key)
+ 1. [Accounts and Addresses](https://support.metamask.io/hc/en-us/sections/4471975962907-Accounts-and-Addresses)
+ 2. [How to export an account's private key](https://support.metamask.io/hc/en-us/articles/360015289632-How-to-export-an-account-s-private-key)
+
Use Python code
1. Create a venv
- ```shell
- pip3 install virtualenv
+ ```shell
+ pip3 install virtualenv
- venv=codex-eth-key
- mkdir $venv && cd $venv
+ venv=codex-eth-key
+ mkdir $venv && cd $venv
- python3 -m venv env
- source env/bin/activate
- ```
+ python3 -m venv env
+ source env/bin/activate
+ ```
2. Install required packages
- ```shell
- pip3 install web3
- ```
+ ```shell
+ pip3 install web3
+ ```
3. Create a script
- ```shell
- vi eth-keys.py
- ```
- ```python
+ ```shell
+ vi eth-keys.py
+ ```
+ ```python
from eth_account import Account
def generate_ethereum_keypair():
@@ -74,41 +84,18 @@ Using the Testnet Starter, you can run a (mostly preconfigured) Codex node on yo
# Print the keys
print("Private Key:", private_key)
print("Public Key (Ethereum Address):", public_key)
- ```
+ ```
- 4. Generate the keys
- ```shell
- python3 eth-keys.py
- ```
- 5. Cleanup
- ```shell
- deactivate
- cd .. && rm -rf $venv
- ```
+ 4. Generate the keys
+ ```shell
+ python3 eth-keys.py
+ ```
+ 5. Cleanup
+ ```shell
+ deactivate
+ cd .. && rm -rf $venv
+ ```
-
- Use Docker
-
- ```shell
- # Generate keystore
- docker \
- run --rm -it \
- -v ./geth-account:/data \
- ethereum/client-go \
- --datadir /data account new
-
- # Set keystore
- keystore=$(find geth-account -name "UTC--*" -exec basename {} \;)
-
- # Get private key
- docker run --rm \
- -v ./geth-account/keystore:/keystore \
- gochain/web3 \
- account extract \
- --keyfile /keystore/$keystore
- # --password password
- ```
-
```
# Example
@@ -119,9 +106,9 @@ Using the Testnet Starter, you can run a (mostly preconfigured) Codex node on yo
4. Define variables
```shell
export PRIV_KEY=0xacec4df7549199708a9f66b151aea7bf41b4d30bd325b96b26f017246226e1a3
+ export CODEX_LISTEN_ADDRS=/ip4/0.0.0.0/tcp/8070
+ export CODEX_DISC_PORT=8090
- # export CODEX_LISTEN_ADDRS=/ip4/0.0.0.0/tcp/8070
- # export CODEX_DISC_PORT=8090
# export CODEX_ETH_PROVIDER=https://rpc.testnet.codex.storage
# export CODEX_LOG_LEVEL=TRACE
#
@@ -136,6 +123,12 @@ Using the Testnet Starter, you can run a (mostly preconfigured) Codex node on yo
docker-compose up
```
+ 6. Setup port forwarding on your router for Codex, based on defined values
+ ```
+ TCP - CODEX_LISTEN_ADDRS=/ip4/0.0.0.0/tcp/8070
+ UDP - CODEX_DISC_PORT=8090
+ ```
+
## [How to get ready](#codex-testnet-starter)
When starting the Testnet Starter for the first time, (or restarting after a long pause) please keep in mind:
diff --git a/docker-compose.yaml b/docker-compose.yaml
index 9d04b73..69506a9 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -1,4 +1,3 @@
-version: '3.9'
services:
# Codex Node
codex:
@@ -20,8 +19,8 @@ services:
- CODEX_LOG_LEVEL=TRACE;warn:discv5,providers,manager,cache;warn:libp2p,multistream,switch,transport,tcptransport,semaphore,asyncstreamwrapper,lpstream,mplex,mplexchannel,noise,bufferstream,mplexcoder,secure,chronosstream,connection,connmanager,websock,ws-session
- CODEX_API_PORT=8080
- CODEX_API_BINDADDR=0.0.0.0
- - CODEX_LISTEN_ADDRS=/ip4/0.0.0.0/tcp/8070
- - CODEX_DISC_PORT=8090
+ - CODEX_LISTEN_ADDRS=${CODEX_LISTEN_ADDRS:-/ip4/0.0.0.0/tcp/8070}
+ - CODEX_DISC_PORT=${CODEX_DISC_PORT:-8090}
- NAT_PUBLIC_IP_AUTO=${NAT_PUBLIC_IP_AUTO:-https://ip.codex.storage}
- CODEX_ETH_PROVIDER=${CODEX_ETH_PROVIDER:-ws://geth:8546}
- CODEX_VALIDATOR=false
@@ -64,11 +63,10 @@ services:
- GETH_DATADIR=/data
- GETH_NETWORKID=789987
- GETH_SYNCMODE=snap
- # - GETH_NAT=extip:1.1.1.1
- - GETH_NAT=auto
- - GETH_DISCOVERY_PORT=8547
- - GETH_PORT=8548
- - GETH_VERBOSITY=${GETH_VERBOSITY:-3}
+ - GETH_NAT=${GETH_NAT:-auto}
+ - GETH_DISCOVERY_PORT=${GETH_DISCOVERY_PORT:-8547}
+ - GETH_PORT=${GETH_PORT:-8548}
+ - GETH_VERBOSITY=${GETH_VERBOSITY:-2}
- GETH_HTTP=true
- GETH_HTTP_PORT=8545
- GETH_HTTP_ADDR=0.0.0.0