docker部署polygon 0.3x

heimdall

初始化heimdall

# docker run -v /data2/apps/polygon/heimdall:/var/lib/heimdall:rw --entrypoint /usr/bin/heimdalld -it 0xpolygon/heimdall:0.3.3 init --home=/var/lib/heimdall
INFO [2023-05-04|09:28:47.243] Genesis file /var/lib/heimdall/config/genesis.json not found, writing genesis file
 module=cmd/heimdalld 
{
  "chain_id": "heimdall-Wcjf0b",
  "node_id": "c708bba92a12a45ba481f57c4e165d1678bf3ccd"
}
INFO [2023-05-04|09:28:47.245] Heimdall services stopped                    module=cmd/heimdalld

查看heimdall文件

# tree /data2/apps/polygon/heimdall/
/data2/apps/polygon/heimdall/
├── config
│   ├── app.toml
│   ├── config.toml
│   ├── genesis.json
│   ├── heimdall-config.toml
│   ├── node_key.json
│   └── priv_validator_key.json
└── data
    └── priv_validator_state.json

2 directories, 7 files

配置config.toml

seeds

# sed -i 's|^seeds =.*|seeds = "2a53a15ffc70ad41b6876ecbe05c50a66af01e20@3.211.248.31:26656,6f829065789e5b156cbbf076f9d133b4d7725847@3.212.183.151:26656,7285a532bad665f051c0aadc31054e2e61ca2b3d@3.93.224.197:26656,0b431127d21c8970f1c353ab212be4f1ba86c3bf@184.73.124.158:26656,f4f605d60b8ffaaf15240564e58a81103510631c@159.203.9.164:26656,31b79cf4a628a4619e8e9ae95b72e4354c5a5d90@44.232.55.71:26656,a385dd467d11c4cdb0be8b51d7bfb0990f49abc3@35.199.4.13:26656,daad548c0a163faae1d8d58425f97207acf923fd@35.230.116.151:26656,81c76e82fcc3dc9a0a1554a3edaa09a632795ea8@35.221.13.28:26656"|g' config.toml 

laddr

laddr = "tcp://0.0.0.0:26657"

配置heimdall-config.toml

# sed -i 's|^eth_rpc_url =.*|eth_rpc_url = "https://eth-mainnet.g.alchemy.com/v2/ydmGjsREDACTED_DONT_USE9t7FSf"|g' heimdall-config.toml
# sed -i 's|^bor_rpc_url =.*|bor_rpc_url = "http://bor:8545"|g' heimdall-config.toml

更新genesis.json

# curl -o /data2/apps/polygon/heimdall/config/genesis.json https://raw.githubusercontent.com/maticnetwork/heimdall/master/builder/files/genesis-mainnet-v1.json
# sha256sum genesis.json
498669113c72864002c101f65cd30b9d6b159ea2ed4de24169f1c6de5bcccf14  genesis.json

docker-compose.yml

version: "3.9"

services:
    heimdalld:
      container_name: heimdalld
      image: 0xpolygon/heimdall:0.3.3
      restart: always
      environment:
        - HEIMDALL_DIR=/var/lib/heimdall
      volumes:
        - ./heimdall:/var/lib/heimdall
      ports:
        - "26656:26656" # P2P (TCP)
        - "26657:26657" # RPC (TCP)
        - "1317:1317"   # rest-server
      entrypoint:
        - /usr/bin/heimdalld
        - start
        - --home
        - "/var/lib/heimdall"
        - --chain=mainnet
        - --rest-server
      networks:
        - polygon


networks:
  polygon:
    driver: bridge

运行heimdall

# docker-compose up -d

查看 heimdall

# docker ps
CONTAINER ID   IMAGE                      COMMAND                  CREATED         STATUS         PORTS                                                          NAMES
f7d0b936e68f   0xpolygon/heimdall:0.3.3   "/usr/bin/heimdalld …"   3 minutes ago   Up 3 minutes   0.0.0.0:1317->1317/tcp, 0.0.0.0:26656-26657->26656-26657/tcp   heimdalld

查看 Heimdall syncing

# curl localhost:26657/status
{
  "jsonrpc": "2.0",
  "id": "",
  "result": {
    "node_info": {
      "protocol_version": {
        "p2p": "7",
        "block": "10",
        "app": "0"
      },
      "id": "c708bba92a12a45ba481f57c4e165d1678bf3ccd",
      "listen_addr": "tcp://0.0.0.0:26656",
      "network": "heimdall-137",
      "version": "0.32.7",
      "channels": "4020212223303800",
      "moniker": "ab2cc2a29553",
      "other": {
        "tx_index": "on",
        "rpc_address": "tcp://0.0.0.0:26657"
      }
    },
    "sync_info": {
      "latest_block_hash": "8C4774C2D31DCB41BEA64770926B38DC87F32596D9EFCA18A9BA0BD435EFB8B2",
      "latest_app_hash": "CF7FC8EE1210E0F20AB2DA9006804ADB90A923742E8C0E58C5076C08E92D2020",
      "latest_block_height": "13840293",
      "latest_block_time": "2023-05-05T05:06:34.613457742Z",
      "catching_up": false
    },
    "validator_info": {
      "address": "EE5938AD3F2847F0BCCF53AA4D1D73CC5F2D1566",
      "pub_key": {
        "type": "tendermint/PubKeySecp256k1",
        "value": "BA3wte+5OscVQVZyJiw0UhX4FlXdrsvH+0SBGrsPnxt4FeD6ZMveIiBUyzFCfyV2G/BERk17+EiSla6WY0sopJg="
      },
      "voting_power": "0"
    }
  }
}

Heimdall rest server

# curl localhost:1317/bor/span/1
{"height":"13840327","result":{"span_id":1,"start_block":256,"end_block":6655,"validator_set":{"validators":[{"ID":6,"startEpoch":0,"endEpoch":0,"nonce":1,"power":10000,"pubKey":"0x0447ed13442b485dd6990efc01d4297d798e90d3fa8467dd9c2f50ffe3238c8bf722f6c774f584b5fe91364b7b430c5a24fe57aca48665cf778030266f2c452bd9","signer":"0x0375b2fc7140977c9c76d45421564e354ed42277","last_updated":"","jailed":false,"accum":-60000},{"ID":7,"startEpoch":0,"endEpoch":0,"nonce":1,"power":10000,"pubKey":"0x043522a004012c9740703f676b95b5121edd7237fb0f182c3c45e7c7a77eaa67a20e6d0ac025d5bd96295bf95e2e875ab2a9da5c0e547b7d00ca7ede33c1b03893","signer":"0x42eefcda06ead475cde3731b8eb138e88cd0bac3","last_updated":"","jailed":false,"accum":10000},{"ID":1,"startEpoch":0,"endEpoch":0,"nonce":1,"power":10000,"pubKey":"0x043c53ea6e1964e0670dc9ac72b3224207885d4c5f08cabe1e1080c662fdec278e7e833798757cb5cf121447dcd02a15f010eb4aa87cceecb23daa4bf904112e77","signer":"0x5973918275c01f50555d44e92c9d9b353cadad54","last_updated":"","jailed":false,"accum":10000},{"ID":5,"startEpoch":0,"endEpoch":0,"nonce":1,"power":10000,"pubKey":"0x0479efe8c50b1f9923f48a467ecac0a64c2d6bcaa9ae67e135df84cac5aed5321f9cbb29c115f26dc84f2ef0e5fea29615848c79d690cb205cc10d688324ae8bce","signer":"0x7fcd58c2d53d980b247f1612fdba93e9a76193e6","last_updated":"","jailed":false,"accum":10000},{"ID":4,"startEpoch":0,"endEpoch":0,"nonce":1,"power":10000,"pubKey":"0x04b4e1d56b3429f7756452426be611e595debcb858d59f47d29ec9dd6e4b547dce1539f9b7144420bc309de496b70d6dc5f13345eee85e6b7fb332cd9f364ef12f","signer":"0xb702f1c9154ac9c08da247a8e30ee6f2f3373f41","last_updated":"","jailed":false,"accum":10000},{"ID":2,"startEpoch":0,"endEpoch":0,"nonce":1,"power":10000,"pubKey":"0x04d6b06c725f5410e4ccbd65906ece180364ebea4902b21232c1fb5892a76be7eec22480397d6bf653e9abe7ac50435ee472b59364fe78b17acb2be2116f92a76f","signer":"0xb8bb158b93c94ed35c1970d610d1e2b34e26652c","last_updated":"","jailed":false,"accum":10000},{"ID":3,"startEpoch":0,"endEpoch":0,"nonce":1,"power":10000,"pubKey":"0x040600efda73e1404b0c596e08c78c5ed51631fc173e5f39d21deeddd5712fcd7d6d440c53d211eb48b03063a05b2c0c0eb084053dfcf1c6540def705c8e028456","signer":"0xf84c74dea96df0ec22e11e7c33996c73fcc2d822","last_updated":"","jailed":false,"accum":10000}],"proposer":{"ID":6,"startEpoch":0,"endEpoch":0,"nonce":1,"power":10000,"pubKey":"0x0447ed13442b485dd6990efc01d4297d798e90d3fa8467dd9c2f50ffe3238c8bf722f6c774f584b5fe91364b7b430c5a24fe57aca48665cf778030266f2c452bd9","signer":"0x0375b2fc7140977c9c76d45421564e354ed42277","last_updated":"","jailed":false,"accum":-60000}},"selected_producers":[{"ID":6,"startEpoch":0,"endEpoch":0,"nonce":1,"power":10000,"pubKey":"0x0447ed13442b485dd6990efc01d4297d798e90d3fa8467dd9c2f50ffe3238c8bf722f6c774f584b5fe91364b7b430c5a24fe57aca48665cf778030266f2c452bd9","signer":"0x0375b2fc7140977c9c76d45421564e354ed42277","last_updated":"","jailed":false,"accum":-60000},{"ID":7,"startEpoch":0,"endEpoch":0,"nonce":1,"power":10000,"pubKey":"0x043522a004012c9740703f676b95b5121edd7237fb0f182c3c45e7c7a77eaa67a20e6d0ac025d5bd96295bf95e2e875ab2a9da5c0e547b7d00ca7ede33c1b03893","signer":"0x42eefcda06ead475cde3731b8eb138e88cd0bac3","last_updated":"","jailed":false,"accum":10000},{"ID":1,"startEpoch":0,"endEpoch":0,"nonce":1,"power":10000,"pubKey":"0x043c53ea6e1964e0670dc9ac72b3224207885d4c5f08cabe1e1080c662fdec278e7e833798757cb5cf121447dcd02a15f010eb4aa87cceecb23daa4bf904112e77","signer":"0x5973918275c01f50555d44e92c9d9b353cadad54","last_updated":"","jailed":false,"accum":10000},{"ID":5,"startEpoch":0,"endEpoch":0,"nonce":1,"power":10000,"pubKey":"0x0479efe8c50b1f9923f48a467ecac0a64c2d6bcaa9ae67e135df84cac5aed5321f9cbb29c115f26dc84f2ef0e5fea29615848c79d690cb205cc10d688324ae8bce","signer":"0x7fcd58c2d53d980b247f1612fdba93e9a76193e6","last_updated":"","jailed":false,"accum":10000},{"ID":4,"startEpoch":0,"endEpoch":0,"nonce":1,"power":10000,"pubKey":"0x04b4e1d56b3429f7756452426be611e595debcb858d59f47d29ec9dd6e4b547dce1539f9b7144420bc309de496b70d6dc5f13345eee85e6b7fb332cd9f364ef12f","signer":"0xb702f1c9154ac9c08da247a8e30ee6f2f3373f41","last_updated":"","jailed":false,"accum":10000},{"ID":2,"startEpoch":0,"endEpoch":0,"nonce":1,"power":10000,"pubKey":"0x04d6b06c725f5410e4ccbd65906ece180364ebea4902b21232c1fb5892a76be7eec22480397d6bf653e9abe7ac50435ee472b59364fe78b17acb2be2116f92a76f","signer":"0xb8bb158b93c94ed35c1970d610d1e2b34e26652c","last_updated":"","jailed":false,"accum":10000},{"ID":3,"startEpoch":0,"endEpoch":0,"nonce":1,"power":10000,"pubKey":"0x040600efda73e1404b0c596e08c78c5ed51631fc173e5f39d21deeddd5712fcd7d6d440c53d211eb48b03063a05b2c0c0eb084053dfcf1c6540def705c8e028456","signer":"0xf84c74dea96df0ec22e11e7c33996c73fcc2d822","last_updated":"","jailed":false,"accum":10000}],"bor_chain_id":"137"}}

bor

创建数据目录

# mkdir -pv /data2/apps/polygon/bor
mkdir: created directory '/data2/apps/polygon/bor'

下载genesis.json

# curl -o /data2/apps/polygon/bor/genesis.json 'https://raw.githubusercontent.com/maticnetwork/bor/master/builder/files/genesis-mainnet-v1.json'
# sha256sum genesis.json
4bacbfbe72f0d966412bb2c19b093f34c0a1bd4bb8506629eba1c9ca8c69c778  genesis.json

生成 config.toml

# docker run -it 0xpolygon/bor:0.3.7 dumpconfig | sudo tee /data2/apps/polygon/bor/config.toml

修改 config.toml

# Similar to moniker, you might want to update this with a name of your own choosing
identity = "docker.example"

# Setting this to the location of a mount that we'll make
datadir = "/var/lib/bor/data"

# We'll want to specify some boot nodes
[p2p]
  [pep.discovery]
    bootnodes = ["enode://0cb82b395094ee4a2915e9714894627de9ed8498fb881cec6db7c65e8b9a5bd7f2f25cc84e71e89d0947e51c76e85d0847de848c7782b13c0255247a6758178c@44.232.55.71:30303", "enode://88116f4295f5a31538ae409e4d44ad40d22e44ee9342869e7d68bdec55b0f83c1530355ce8b41fbec0928a7d75a5745d528450d30aec92066ab6ba1ee351d710@159.203.9.164:30303"]

# Because we're running inside docker, we'll likely need to change the way we connect to heimdall
[heimdall]
  url = "http://heimdalld:1317"

# Assumming you want to access the RPC, you'll need to make a change here as well
[jsonrpc]
  [jsonrpc.http]
    enabled = true
    host = "0.0.0.0"

docker-compose.yml

version: "3.9"

services:
  heimdalld:
    container_name: heimdalld
    image: 0xpolygon/heimdall:0.3.3
    restart: always
    environment:
      - HEIMDALL_DIR=/var/lib/heimdall
    volumes:
      - ./heimdall:/var/lib/heimdall
    ports:
      - "26656:26656" # P2P (TCP)
      - "26657:26657" # RPC (TCP)
      - "1317:1317"   # rest-server
    entrypoint:
      - /usr/bin/heimdalld
      - start
      - --home
      - "/var/lib/heimdall"
      - --chain=mainnet
      - --rest-server
    networks:
      - polygon

  bor:
    container_name: bor
    image: 0xpolygon/bor:0.3.7
    restart: always
    environment:
      - BOR_DIR=/var/lib/bor
    volumes:
      - ./bor:/var/lib/bor
    ports:
      - "30303:30303"
      - "8545:8545"
    networks:
      - polygon
    command:
      - server
      - -config
      - "/var/lib/bor/config.toml"
    depends_on:
      - heimdalld

networks:
  polygon:
    driver: bridge

运行服务

bor

# docker-compose up -d
[+] Running 2/2
 ⠿ Container heimdalld  Running                                                                                                                                                                                                                                                             0.0s
 ⠿ Container bor        Started                         

查看运行服务

# docker ps
CONTAINER ID   IMAGE                      COMMAND                  CREATED         STATUS        PORTS                                                                        NAMES
c426fe25ae62   0xpolygon/bor:0.3.7        "bor server -config …"   2 seconds ago   Up 1 second   0.0.0.0:8545->8545/tcp, 0.0.0.0:30303->30303/tcp, 8546-8547/tcp, 30303/udp   bor
1fa014691d53   0xpolygon/heimdall:0.3.3   "/usr/bin/heimdalld …"   23 hours ago    Up 22 hours   0.0.0.0:1317->1317/tcp, 0.0.0.0:26656-26657->26656-26657/tcp                 heimdalld

查看 bor 同步状态

# curl 'localhost:8545/' --header 'Content-Type: application/json' -d '{ "jsonrpc":"2.0", "method":"eth_syncing", "params":[], "id":1 }'

未同步完成返回结果

{"jsonrpc":"2.0","id":1,"result":{"currentBlock":"0x28495a2","healedBytecodeBytes":"0x0","healedBytecodes":"0x0","healedTrienodeBytes":"0x0","healedTrienodes":"0x0","healingBytecode":"0x0","healingTrienodes":"0x0","highestBlock":"0x28656a3","startingBlock":"0x2849481","syncedAccountBytes":"0x0","syncedAccounts":"0x0","syncedBytecodeBytes":"0x0","syncedBytecodes":"0x0","syncedStorage":"0x0","syncedStorageBytes":"0x0"}}

同步完成后返回结果

{"jsonrpc":"2.0","id":1,"result":false}

Polygon Chains Snapshots

安装依赖

# apt-get  install -y zstd pv aria2

Chains Snapshots 下载

https://snapshots.polygon.technology/

Heimdall Snapshots

# wget -c https://snapshot-download.polygon.technology/heimdall-mainnet-fullnode-2023-05-04.tar.zst -O - | tar -I zstd -xzf - -C /data2/apps/polygon/heimdalld/data/

bor Snapshots

# wget -c https://snapshot-download.polygon.technology/bor-mainnet-fullnode-2023-05-04.tar.zst  -O - | tar -I zstd -xzf - -C /data2/apps/polygon/bor/data/bor/chaindata

 

posted @ 2023-05-06 15:05  小吉猫  阅读(565)  评论(0编辑  收藏  举报