Update docker-compose and guide (#10)

* Pass ports values via variables

* Update How to start section
This commit is contained in:
Slava 2024-03-30 15:12:19 +02:00 committed by GitHub
parent 10ed19a50d
commit c63c54aee6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 50 additions and 59 deletions

View File

@ -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
<details>
<summary>Use Docker</summary>
```shell
# Generate keypair
docker run --rm gochain/web3 account create
```
</details>
<details>
<summary>Use metamask</summary>
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)
</details>
<details>
<summary>Use Python code</summary>
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
```
</details>
<details>
<summary>Use Docker</summary>
```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
```
</details>
```
# 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:

View File

@ -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