docker 容器中的以太坊私有链在生成块之前挂起

问题描述 投票:0回答:0

我正在努力将 docker 容器应用到我使用以太坊链的项目中。我的区块链部分有问题,此时它在挖掘新区块之前挂起:

private-chain-geth-miner-1         | INFO [05-06|04:51:29.155] Generating DAG in progress               epoch=1 percentage=98 elapsed=1m17.684s
private-chain-geth-miner-1         | INFO [05-06|04:51:30.221] Generating DAG in progress               epoch=1 percentage=99 elapsed=1m18.749s
private-chain-geth-miner-1         | INFO [05-06|04:51:30.223] Generated ethash verification cache      epoch=1 elapsed=1m18.751s

这是一个docker文件:

FROM ethereum/client-go:v1.10.1

COPY ./chain/accounts/swap.ethash.genesis.json /tmp

COPY ./chain/accounts/boot.key /tmp

RUN mkdir -p /tmp/keystore

COPY ./chain/accounts/keystore/${NODE_ACCOUNT_PWD_FILENAME} /tmp/keystore

RUN geth --datadir /tmp init /tmp/swap.ethash.genesis.json \
    && rm -f ~/.ethereum/geth/nodekey 

ENTRYPOINT ["geth"]

这里是一个撰写文件:

# Blockchain part is based on this materials: 
# https://medium.com/scb-digital/running-a-private-ethereum-blockchain-using-docker-589c8e6a4fe8

version: '3.8'

services:
  geth-bootnode:
    hostname: geth-bootnode
    env_file:
      - .env
    image: geth-client
    build:
      context: .
      args:
        - ACCOUNT_PASSWORD=${ACCOUNT_PASSWORD}
        - NODE_ACCOUNT_PWD_FILENAME=${NODE_1_ACCOUNT_PWD_FILENAME}
        - NODE_ACCOUNT_PWD=${NODE_1_ACCOUNT_PWD}
    command:
      --nodekeyhex="c26d705bd5933bc2be72813f1b74f140aa6b3726d2a71a43b163a5c084e9dcb4"
      --nodiscover
      --ipcdisable
      --networkid=${NETWORK_ID}
      --netrestrict="172.16.254.0/28"
    networks:
      priv-eth-net:

  geth-rpc-endpoint:
    hostname: geth-rpc-endpoint
    env_file:
      - .env
    image: geth-client
    build:
      context: .
      args: 
        - NODE_ACCOUNT_PWD_FILENAME=${NODE_2_ACCOUNT_PWD_FILENAME}
        - NODE_ACCOUNT_PWD=${NODE_2_ACCOUNT_PWD}
    depends_on:
      - geth-bootnode    
    command:
      --bootnodes="enode://a78e253e183c4460bdfdc11ae0798fa225fb431a57c875ff278b58b3f5d1ea7ff1aa240d27252a7d0a7bce958b34f62e4836d59281759fed1069ce781af67ef4@geth-bootnode:30303"
      --allow-insecure-unlock
      --http
      --http.addr="0.0.0.0"
      --http.api="eth,web3,net,admin,personal"
      --http.corsdomain="*"
      --networkid=${NETWORK_ID}
      --netrestrict="172.16.254.0/28"
    ports:
      - "8545:8545"
    networks:
      priv-eth-net:

  geth-miner:
    hostname: geth-miner
    env_file:
      - .env
    image: geth-client
    build:
      context: .
      args: 
        - NODE_ACCOUNT_PWD_FILENAME=${NODE_3_ACCOUNT_PWD_FILENAME}
        - NODE_ACCOUNT_PWD=${NODE_3_ACCOUNT_PWD}
        - ETHERBASE_ACCOUNT=${NODE_3_ACCOUNT}
    depends_on:
      - geth-bootnode
    command:
      --bootnodes="enode://a78e253e183c4460bdfdc11ae0798fa225fb431a57c875ff278b58b3f5d1ea7ff1aa240d27252a7d0a7bce958b34f62e4836d59281759fed1069ce781af67ef4@geth-bootnode:30303"
      --mine
      --miner.threads=1
      --miner.etherbase=0x46aF655eB60F0a863663Fc5D7D5fb11EC8808a51
      --miner.gasprice 1 
      --verbosity 3
      --networkid=${NETWORK_ID}
      --netrestrict="172.16.254.0/28"
    networks:
      priv-eth-net:

    # deploy:
    #   resources:
    #     limits:
    #       cpus: '2'
    #       memory: 1024M

networks:
  priv-eth-net:
    driver: bridge
    ipam:
      config:
      - subnet: 172.16.254.0/28

我的

.env
档案:

NETWORK_ID=50101

ACCOUNT_PASSWORD=my_node

NODE_1_ACCOUNT_PWD_FILENAME=UTC--2023-04-21T13-54-40.845472438Z--367103555b34eb9a46d92833e7293d540bfd7143
NODE_1_ACCOUNT_PWD=swapd1

NODE_2_ACCOUNT_PWD_FILENAME=UTC--2023-04-21T13-54-53.297432467Z--1a75262751ac4e6290ec8287d1de823f33036498
NODE_2_ACCOUNT_PWD=swapd2

NODE_3_ACCOUNT_PWD_FILENAME=UTC--2023-04-21T13-55-17.400128588Z--d9df253d1f92dcba495c8b0a9616e9d817bb12b7
NODE_3_ACCOUNT_PWD=swapd3
NODE_3_ACCOUNT=0xd9df253d1f92dcba495c8b0a9616e9d817bb12b7

我的

genesis.json
档案:

{
   "config":{
      "chainId":50101,
      "homesteadBlock":0,
      "eip150Block":0,
      "eip150Hash":"0x0000000000000000000000000000000000000000000000000000000000000000",
      "eip155Block":0,
      "eip158Block":0,
      "byzantiumBlock":0,
      "constantinopleBlock":0,
      "petersburgBlock":0,
      "istanbulBlock":0,
      "ethash":{
         
      }
   },
   "nonce":"0x0",
   "timestamp":"0x644256a2",
   "extraData":"0x0000000000000000000000000000000000000000000000000000000000000000",
   "gasLimit":"0x1C9C380",
   "difficulty":"1",
   "mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
   "coinbase":"0x0000000000000000000000000000000000000000",
   "alloc":{
      "0x9430b0AD2d1a2D5B30925BF8Dfa89327379868cc":{
         "balance":"0x200000000000000000000000000000000000000000000000000000000000000"
      },
      "0x04fabc66600915ad4572c227cc3917b1c61d371B":{
         "balance":"0x200000000000000000000000000000000000000000000000000000000000000"
      },
      "0x51Ea746CB88935f29d23ddFaB9e3D9f469D8fBF8":{
         "balance":"0x200000000000000000000000000000000000000000000000000000000000000"
      },
      "0x8755eE67882b67DB31BE736dfC0A69858b3aE61b":{
         "balance":"0x200000000000000000000000000000000000000000000000000000000000000"
      },
      "0xd0e36281A8B4852D15010cfb8a68c58fD6c2be6e":{
         "balance":"0x200000000000000000000000000000000000000000000000000000000000000"
      },
      "0x5136C3b985293C10A6882cE9DB4f5719c7C486a3":{
         "balance":"0x200000000000000000000000000000000000000000000000000000000000000"
      },
      "0x46aF655eB60F0a863663Fc5D7D5fb11EC8808a51":{
         "balance":"0x200000000000000000000000000000000000000000000000000000000000000"
      },
      "0xd9df253D1F92dcba495c8b0A9616E9D817BB12B7":{
         "balance":"0x200000000000000000000000000000000000000000000000000000000000000"
      },
      "0x1a75262751ac4E6290Ec8287d1De823F33036498":{
         "balance":"0x200000000000000000000000000000000000000000000000000000000000000"
      },
      "0x367103555b34Eb9a46D92833e7293D540bFd7143":{
         "balance":"0x200000000000000000000000000000000000000000000000000000000000000"
      }
   },
   "number":"0x0",
   "gasUsed":"0x0",
   "parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
   "baseFeePerGas":null
}

我的 docker compose 文件的区块链部分基于此 publication。 Origin docker file 为每个节点创建一个新帐户,但在我的例子中,我使用现有帐户预填充图像。我不确定复制密钥库文件夹(加密的公钥)是否足以将帐户添加到节点,但社区向我保证这就足够了。

问题出在创建原始图像的docker文件中,但我还没有弄清楚为什么会导致这个问题。

docker docker-compose ethereum private
© www.soinside.com 2019 - 2024. All rights reserved.