polygon主网RPC

下载快照:

https://docs.polygon.technology/pos/how-to/snapshots/#downloading-and-using-client-snapshots

注意最好等待heimdall同步完成再启动bor。

安装go和依赖

apt-get install build-essential -y

编译heimdalld

# git clone https://github.com/maticnetwork/heimdall
# cd heimdall/
 git checkout v1.0.7
 make install
 ```

 # 初始化heimdalld
 ```
heimdalld init --chain=mainnet --home /mnt/polygon_heimdall/
sed -i 's|^seeds =.*|seeds = "1500161dd491b67fb1ac81868952be49e2509c9f@52.78.36.216:26656,dd4a3f1750af5765266231b9d8ac764599921736@3.36.224.80:26656,8ea4f592ad6cc38d7532aff418d1fb97052463af@34.240.245.39:26656,e772e1fb8c3492a9570a377a5eafdb1dc53cd778@54.194.245.5:26656,6726b826df45ac8e9afb4bdb2469c7771bd797f1@52.209.21.164:26656"|g' /mnt/polygon_heimdall/config/config.toml

下载heimdall快照(此下载方式疑似失效,可以用https://publicnode.com/snapshots#polygon 的)

cd  /mnt/polygon_heimdall/

curl -L https://snapshot-download.polygon.technology/snapdown.sh | bash -s -- --network mainnet --client heimdall --extract-dir ./data --validate-checksum true

目录结构

heimdalld service文件

vim /etc/systemd/system/heimdalld.service

[Unit]
  Description=heimdalld
  StartLimitIntervalSec=500
  StartLimitBurst=5
[Service]
  Restart=on-failure
  RestartSec=5s
  WorkingDirectory=/mnt/polygon_heimdall
  ExecStart=/usr/local/bin/heimdalld start --home "/mnt/polygon_heimdall" --chain=mainnet --rest-server
  Type=simple
  LimitNOFILE=65536
  #User=heimdall
[Install]
  WantedBy=multi-user.target

启动heimdalld

systemctl daemon-reload
systemctl start heimdalld

下载bor快照

cd /mnt/polygon_bor/

 aria2c -s16 -x16 -k1024M  https://snapshots.publicnode.com/polygon-bor-base-0-59369564.tar.lz4

下载bor第二部分快照

https://publicnode.com/snapshots#polygon

编译bor

~# git clone https://github.com/maticnetwork/bor
~# cd bor
~# git checkout v1.3.4
~# make bor
~# cp bor/build/bin/bor /usr/local/bin/

bor目录结构

bor service


`vim /lib/systemd/system/bor.service `
[Unit]
  Description=bor
  StartLimitIntervalSec=500
  StartLimitBurst=5

[Service]
  Restart=on-failure
  RestartSec=5s
  ExecStart=/usr/local/bin/bor server -config "/mnt/polygon_bor/config.toml"   -state.scheme="path"
  Type=simple
  KillSignal=SIGINT
  User=root
  TimeoutStopSec=120

[Install]
  WantedBy=multi-user.target
/mnt/polygon_bor/config.toml

# NOTE: Uncomment and configure the following 8 fields in case you run a validator:
# `mine`, `etherbase`, `nodiscover`, `maxpeers`, `keystore`, `allow-insecure-unlock`, `password`, `unlock`

chain = "mainnet"
# chain = "mumbai"
# identity = "Annon-Identity"
# verbosity = 3
# vmdebug = false
datadir = "/mnt/polygon_bor/data"
# ancient = ""
# "db.engine" = "leveldb"
"db.engine" = "pebble"
StateScheme = "path"
# keystore = "/var/lib/bor/keystore"
# "rpc.batchlimit" = 100
# "rpc.returndatalimit" = 100000
syncmode = "full"
gcmode = "full"
# snapshot = true
# "bor.logs" = false
# ethstats = ""
# devfakeauthor = false
# ["eth.requiredblocks"]

# [log]
  # vmodule = ""
  # json = false
  # backtrace = ""
  # debug = true
  # enable-block-tracking = false

[p2p]
  maxpeers = 200
  # nodiscover = true
  # maxpendpeers = 50
  # bind = "0.0.0.0"
  port = 20303
  # nat = "any"
  # netrestrict = ""
  # nodekey = ""
  # nodekeyhex = ""
  [p2p.discovery]
    # v4disc = true
    # v5disc = false
    bootnodes = ["enode://a7f59b918fe19b5448b6dfbb35d5096eaffcdf20050f41f442c4a72377f7634da10fe23b1a405f72f6146b3c78738160c98c2c47d60a81e489fa47a50fe8700c@77.172.185.210:30303","enode://dcafedac347b24aea85a4b396511dc7ba4da37cd2ce13de9511aba50879fe04e6e259ce6314ae3376c1e3cc2f1909273781a74e9c386bcec29f5b42d1db0fe14@47.76.152.221:30303"]
    # Uncomment below `bootnodes` field for Mumbai bootnode
    # bootnodesv4 = []
    # bootnodesv5 = []
    # static-nodes = []
    # trusted-nodes = []
    # dns = []

# [heimdall]
  # url = "http://localhost:1317"
  # "bor.without" = false
  # grpc-address = ""

[txpool]
  nolocals = true
  pricelimit = 30000000000
  accountslots = 16
  globalslots = 32768
  accountqueue = 16
  globalqueue = 32768
  lifetime = "1h30m0s"
  # locals = []
  # journal = ""
  # rejournal = "1h0m0s"
  # pricebump = 10

[miner]
  gaslimit = 30000000
  gasprice = "30000000000"
  # mine = true
  # etherbase = "VALIDATOR ADDRESS"
  # extradata = ""
  # recommit = "2m5s"
  # commitinterrupt = true

[jsonrpc]
#   ipcdisable = false
#   ipcpath = ""
#   gascap = 50000000
#   evmtimeout = "5s"
#   txfeecap = 5.0
#   allow-unprotected-txs = false
#   enabledeprecatedpersonal = false
   [jsonrpc.http]
     enabled = true
     port = 28545
     prefix = ""
     host = "localhost"
     api = ["eth", "net", "web3", "txpool", "bor", "debug", "personal"]
     vhosts = ["*"]
     corsdomain = ["*"]
     ep-size = 40
     ep-requesttimeout = "0s"
   [jsonrpc.ws]
     enabled = true
     port = 28546
     prefix = ""
     host = "localhost"
     api = ["eth", "net", "web3", "txpool", "bor", "debug", "personal"]
     origins = ["*"]
     ep-size = 40
     ep-requesttimeout = "0s"
   [jsonrpc.graphql]
     enabled = false
     port = 0
     prefix = ""
     host = ""
     vhosts = ["*"]
     corsdomain = ["*"]
#   [jsonrpc.auth]
#     jwtsecret = ""
#     addr = "localhost"
#     port = 8551
#     vhosts = ["localhost"]
#   [jsonrpc.timeouts]
#     read = "10s"
#     write = "30s"
#     idle = "2m0s"

[gpo]
  # blocks = 20
  # percentile = 60
  # maxheaderhistory = 1024
  # maxblockhistory = 1024
  # maxprice = "5000000000000"
  ignoreprice = "30000000000"

[telemetry]
  metrics = true
  # expensive = false
  # prometheus-addr = "127.0.0.1:7071"
  # opencollector-endpoint = ""
  # [telemetry.influx]
    # influxdb = false
    # endpoint = ""
    # database = ""
    # username = ""
    # password = ""
    # influxdbv2 = false
    # token = ""
    # bucket = ""
    # organization = ""
  # [telemetry.influx.tags]

# [cache]
  cache = 2048
  # gc = 25
  # snapshot = 10
  # database = 50
  # trie = 15
  # noprefetch = false
  # preimages = false
  # txlookuplimit = 2350000
  # triesinmemory = 128
  # blocklogs = 32
  # timeout = "1h0m0s"
  # fdlimit = 0

[accounts]
  # allow-insecure-unlock = true
  # password = "/var/lib/bor/password.txt"
  # unlock = ["VALIDATOR ADDRESS"]
  # lightkdf = false
  # disable-bor-wallet = false

# [grpc]
  # addr = ":3131"

# [developer]
  # dev = false
  # period = 0
  # gaslimit = 11500000

# [parallelevm]
  # enable = true
  # procs = 8

# [pprof]
#   pprof = false
#   port = 6060
#   addr = "127.0.0.1"
#   memprofilerate = 524288
#   blockprofilerate = 0
服务器技术交流群请加微信 YJZyjz