Skip to content

Geth-1.11.6-PoW机制 #5

@cxbl-ops

Description

@cxbl-ops

测试环境

  • ubuntu22.04
  • Geth-1.11.6

1.拉取代码

cd /usr/local
git clone https://github.com/ethereum/go-ethereum.git

切换分支

git checkout  v1.11.6

查看当前分支

git branch

编译geth

make geth

设置软链接

ln -s /usr/local/go-ethereum/build/bin/geth geth
ln -s /usr/local/go-ethereum/build/bin/bootnode bootnode

查看版本

geth version

2.搭建私链

创建数据目录

cd /mnt
mkdir myeth
cd mygeth
mkdir node1

创建账号

geth --datadir node1/ account new

记录账号密码

echo "0x00000000000000000000000000000000" >> account.txt
echo '1234' > node1/password.txt

创建创始区块文件

vim genesis.json

内容

{
  "config": {
    "chainId": 7874,
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip155Block": 0,
    "eip158Block": 0,
    "byzantiumBlock": 0,
    "constantinopleBlock": 0,
    "petersburgBlock": 0,
    "istanbulBlock": 0,
    "berlinBlock": 0,
    "londonBlock": 0
  },
  "alloc": {},
  "nonce": "0x0000000000000042",
  "difficulty": "0x20000",
  "coinbase": "0x000000000000000000000000000000000",
  "extraData": "",
  "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "gasLimit": "0x2fefd8",
  "timestamp": "0x00"
}

查看当前目录

tree ./

初始化私链

geth --datadir node1 init genesis.json

编写启动脚本(vim genesis.json)

geth --datadir /mnt/myeth/node1 --identity "node1" --networkid 7874 --http --http.addr "127.0.0.1" --http.port 8545 --http.api "eth,net,web3,personal,miner" --mine --miner.threads=1 --miner.etherbase=0x0000000000000000000000000000000000000000 --allow-insecure-unlock --unlock "0x00000000000000000000000000000000000" --password node1/password.txt > node1.log 2>&1 &

编写控制台脚本(vim console1.sh)

geth attach ipc:/mnt/myeth/node1/geth.ipc

修改权限

chmod u+rwx ./node1.sh ./console1.sh

启动脚本

./node1.sh && ./console1.sh

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions