Blockchain 以太坊geth无法连接到bootnode以访问私有以太坊网络
以下Blockchain 以太坊geth无法连接到bootnode以访问私有以太坊网络,blockchain,ethereum,go-ethereum,geth,Blockchain,Ethereum,Go Ethereum,Geth,以下docker compose.yml用于启动以太坊geth节点,该节点需要连接到引导节点才能访问专用以太坊网络 version: '2' geth: image: ethereum/client-go:latest volumes: - ./node:/root/.ethereum - ./files/genesis.json:/root/genesis.json:ro ports: - "30303:303
docker compose.yml
用于启动以太坊geth
节点,该节点需要连接到引导节点才能访问专用以太坊网络
version: '2'
geth:
image: ethereum/client-go:latest
volumes:
- ./node:/root/.ethereum
- ./files/genesis.json:/root/genesis.json:ro
ports:
- "30303:30303"
- "30303:30303/udp"
- 8543:8545
command: --rpc --rpcaddr 0.0.0.0 --networkid 13377331 --bootnodes="enode://692b8eda368ffc427fc1a047850557536a0ef0bfa3b66f998e03e8b83c3fd8f786e3c2b710a20e2e821a9eff34fc7b34ffa326a8a5fbcf3634b55b44596ada43@159.999.999.999:30303" --nodiscover
但是,在运行了docker compose up
之后,我们看到回显的链配置是默认配置,而不是bootnode正在使用的配置
初始化链配置配置=“{ChainID:1 Homestead:1150000 DAO:1920000 DAO支持:true EIP150:2463000 EIP155:2675000 EIP158:2675000拜占庭:4370000君士坦丁堡:引擎:ethash}”
问题:为什么geth
没有连接到bootnode,并且没有使用bootnode在其genesis.json
中的配置
docker编写输出:
geth_1 | WARN [07-15|00:48:33.310] Sanitizing cache to Go's GC limits provided=1024 updated=666
geth_1 | INFO [07-15|00:48:33.310] Maximum peer count ETH=25 LES=0 total=25
geth_1 | INFO [07-15|00:48:33.317] Starting peer-to-peer node instance=Geth/v1.8.13-unstable-2e0391ea/linux-amd64/go1.10.3
geth_1 | INFO [07-15|00:48:33.317] Allocated cache and file handles database=/root/.ethereum/geth/chaindata cache=499 handles=1024
geth_1 | INFO [07-15|00:48:33.331] Writing default main-net genesis block
geth_1 | INFO [07-15|00:48:33.632] Persisted trie from memory database nodes=12356 size=1.88mB time=84.3549ms gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
geth_1 | INFO [07-15|00:48:33.636] Initialised chain configuration config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: <nil> Engine: ethash}"
geth_1 | INFO [07-15|00:48:33.636] Disk storage enabled for ethash caches dir=/root/.ethereum/geth/ethash count=3
geth_1 | INFO [07-15|00:48:33.636] Disk storage enabled for ethash DAGs dir=/root/.ethash count=2
geth_1 | INFO [07-15|00:48:33.636] Initialising Ethereum protocol versions="[63 62]" network=1
geth_1 | INFO [07-15|00:48:33.637] Loaded most recent local header number=0 hash=d4e567…cb8fa3 td=17179869184
geth_1 | INFO [07-15|00:48:33.637] Loaded most recent local full block number=0 hash=d4e567…cb8fa3 td=17179869184
geth_1 | INFO [07-15|00:48:33.637] Loaded most recent local fast block number=0 hash=d4e567…cb8fa3 td=17179869184
geth_1 | INFO [07-15|00:48:33.640] Regenerated local transaction journal transactions=0 accounts=0
geth_1 | INFO [07-15|00:48:33.640] Starting P2P networking
geth_1 | INFO [07-15|00:48:33.641] RLPx listener up self="enode://27175216e04387fb93e87a4069021b640fc6f87f985c86940e3297103a2b5e348bdecec4eea98af6ee2f106890fd28b49e1d983b6c5b8ce9ae1571c032bf2d5c@[::]:30303?discport=0"
geth_1 | INFO [07-15|00:48:33.644] IPC endpoint opened url=/root/.ethereum/geth.ipc
geth_1 | INFO [07-15|00:48:33.645] HTTP endpoint opened url=http://0.0.0.0:8545 cors= vhosts=localhost
看起来您使用的是默认的datadir,而不是用genesis.json初始化的私有datadir。因此,geth通过使用默认的datadir(请参见输出中的
database=/root/.ethereum/geth/chaindata
和versions=“[63 62]”network=1
)作为主网络节点启动
要启动专用节点,请尝试以下步骤:
geth--datadir path/to/custom/data/folder init genesis.json
geth--datadir path/to/custom/data/folder--networkid 13377331
--datadir
选项
有关更多信息,请参阅。将来可能帮助您进行网络对等的一般说明
- 网络上的不同节点将始终具有不同的端口和rpcports
- 引导节点充当不同网络(如果需要,甚至在同一网络上)上的对等节点的连接节点。因此,最好知道承载bootnode的机器的IP地址,并在添加的对等机上调用Geth时引用它
- Genesis文件应始终相同,即使跨不同的节点。您可以在Genesis文件中声明所有签名者,甚至在其他机器上旋转节点之前,也可以在之后添加签名者
- 所有对等节点的网络ID也相同李>
{
"config": {
"chainId": 13377331,
"homesteadBlock": 1,
"eip150Block": 2,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 3,
"eip158Block": 3,
"byzantiumBlock": 4,
"clique": {
"period": 15,
"epoch": 30000
}
},
....