Geth - Lodestar

Lodestar is an open-source Ethereum consensus client written in Typescript.

Setup Repository

Visit this Repository Testnet & Fork / Clone

A. Run these commands to enter this Cartenz Chain directory

cd gitshock-chain/cartenz 

B. Create a JWT Secret to create a new secret key by running this command

openssl rand -hex 32 | tr -d "\n" > "jwt.hex" 

C. Run this command to create a new execution layer account

geth account new --datadir "data" << data is folder PATH for your keystore

Your new account is locked with a password. Please give a password. Do not forget this password.
Password: (.............)
Create a password and remember it (as you wish)

a public address of the key will be generated (public address of the key will look like 0x.. something). Then a path of the secret key file will also be generated, save it .You’ll need to save them in a safe place directly and you can share the PUBLIC KEY, and don’t EVEN Share your path to the secret key

D. Run this command to write custom genesis block

geth --datadir /yourfolder/yourfolderwallet init /folder/to/genesis.json

# Example: 
geth --datadir /geth/geth-data init /execution/genesis.json

Before running the Node, we use the POSIX Nohup (No Hang UP) command which means (Do Not Close) a command in Linux systems that keeps the process running even after exiting the shell or terminal. Nohup prevents the process or job from receiving the SIGHUP (Signal Hang UP) signal. This is the signal sent to the process after closing or exiting the terminal.

Running Execution Layer

# Create Folder
mkdir logs 
cd logs 
touch geth_1.log 
cd ..

# Create Folder
mkdir logs 
cd logs 
touch geth_1.log 
cd ..

nohup geth \
--datadir "/PATH/YOUR/ACCOUNT" \
--http --http.api="engine,eth,web3,net,admin" \
--ws \
--ws.api="engine,eth,web3,net,debug" \
--http.corsdomain="*" \
--networkid=1881 \
--syncmode=full \
--authrpc.jwtsecret="/your/path/folder/jwt.hex" \
> /your/path/folder/log/geth_1.log &

# If You Need RPC Api, You Can Add This
--http.addr 0.0.0.0 
--http.port 8545 

Add Peer Node

geth attach http://localhost:8545

After entering the Geth Interactive Console Javascript, you must add a Manual Peer & Trusted Peer of at least 1 to connect to the blockchain, please take it in the  folder: consensus/bootnodes_enr.txt

Example: admin.addPeer("enode://03fc89e2035b52a609715a15dacad4179f57c0b1e51b3464a931f0fa913b9169d06df1b23515f41e4ed6d9be0e50f33175cbf836e7b6738c62eee00ad45250b0@212.47.241.173:30303")

Output: 
> True

Get Bootnodes

Get the Bootnode Inside the Geth Interactive Console, for You to Save Using Command

admin.nodeInfo.enode

Example Output: 
"enode://03fc89e2035b52a609715a15dacad4179f57c0b1e51b3464a931f0fa913b9169d06df1b23515f41e4ed6d9be0e50f33175cbf836e7b6738c62eee00ad45250b0@212.47.241.173:30303"

For this step you need NVM to compile all the Lodestar files. See Here

Installing Lodestar

# Installing Yarn 

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo  apt install yarn
yarn --version 
git clone -b stable https://github.com/chainsafe/lodestar.git

Switch to created directory.
cd lodestar
yarn install --ignore-optional
yarn run build
./lodestar --help

# If you want to move the lodestar file you can use: 
sudo cp lodestar /usr/local/bin
lodestar --version 

Running Consensus Layer

nohup lodestar beacon \
--suggestedFeeRecipient "" \
--execution.urls "http://127.0.0.1:8551" \
--jwt-secret /path/your/folder/jwt.hex \
--dataDir "/home/ubuntu/cartenz/data-2" \
--paramsFile "/home/ubuntu/cartenz/consensus/config.yaml" \
--genesisStateFile "/home/ubuntu/cartenz/consensus/genesis.ssz" \
--enr.ip 172.31.22.244 \
--rest.port 9599 \
--port 9001 \
--network.connectToDiscv5Bootnodes true \
--logLevel info \
--bootnodes="" \
> /home/ubuntu/cartenz/logs/beacon_2.log &

Getting ENR Key

curl http://localhost:5052/eth/v1/node/identity | jq 

Example Output: 
{
  "data": {
    "peer_id": "16Uiu2HAmGLNCWcsWgVR6Q2YvmGvGyyaEM3y5Tcq2rjmpv4dqo8JJ",
    "enr": "enr:-L24QCeN4AtWKWQfWMl9ubWXj_rWzxmVLG54qJtNQuXfEd9xPjPHrafoC3iyt_NUf4RNyiGaA-5yumvmSitnsd_Cx4SBiodhdHRuZXRziP__________hGV0aDKQWOqKlwJndzn__________4JpZIJ2NIJpcITUL_GtiXNlY3AyNTZrMaEDNqlqq2_MsiLqswykyIsqFIX10A-1COt29ZTpmlxf9teIc3luY25ldHMPg3RjcIIjKIN1ZHCCIyg",
    "p2p_addresses": [
      "/ip4/212.47.241.173/tcp/9000/p2p/16Uiu2HAmGLNCWcsWgVR6Q2YvmGvGyyaEM3y5Tcq2rjmpv4dqo8JJ"
    ],
    "discovery_addresses": [
      "/ip4/212.47.241.173/udp/9000/p2p/16Uiu2HAmGLNCWcsWgVR6Q2YvmGvGyyaEM3y5Tcq2rjmpv4dqo8JJ"
    ],
    "metadata": {
      "seq_number": "205",
      "attnets": "0xffffffffffffffff",
      "syncnets": "0x0f"
    }
  }
}

# SAVE YOUR ENR KEY!

Running Second Consensus Layer

nohup lodestar beacon \
--suggestedFeeRecipient "YOUR ADDRESS HERE" \
--execution.urls "http://127.0.0.1:8551" \
--jwt-secret /path/your/folder/jwt.hex \
--dataDir "/home/ubuntu/cartenz/data-2" \
--paramsFile "/home/ubuntu/cartenz/consensus/config.yaml" \
--genesisStateFile "/home/ubuntu/cartenz/consensus/genesis.ssz" \
--enr.ip 172.31.22.244 \
--rest.port 9599 \
--port 9001 \
--network.connectToDiscv5Bootnodes true \
--logLevel info \
--bootnodes="ADD YOUR ENR HERE AND ADDING MORE FROM THE CARTENZ TESTNET REPOSITORY" \
> /home/ubuntu/cartenz/logs/beacon_2.log &

Building a Staker To Be Good Validator

Visit the Staking Website and Select Deposit and Make a Deposit with Command:

// Example From Deposit 

deposit new-mnemonic --num_validators 200 --eth1_withdrawal_address 0x9adddA86C9479C45bD145BBa9FC28146FdF46C83

# Example Output Mnemonic: 
"vibrant refuse observe flag shy depth disagree proud race angle vote picnic fancy renew museum bonus arena people thumb there atom tuna abstract negative"

Running Validator Node

nohup lodestar validator \
--dataDir  "/path/your/folder/validator" \
--beaconNodes "http://127.0.0.1:9596" \
--suggestedFeeRecipient "YOUR ADDRESS HERE" \
--graffiti "YOUR UNIQUE GRAFFITI HERE" \
--paramsFile "/path/your/folder/consensus/config.yaml" \
--importKeystores "/path/your/folder/validator_keys" \
--importKeystoresPassword "/path/your/folder/validator_keys/password.txt" \
--logLevel info \
> /path/your/folder/logs/validator_1.log &

How long does it take to sync a node?

48-72 hours this cannot be an actual reference time. The sync process is very long and can take up to 48-72 hours. Sync speed depends on your internet speed and storage device write speed. Because data is stored in blocks and linked together, corruption in a single block can corrupt the entire data chain

Last updated