EOS主网连接与数据同步

目前,EOS主网已经成功启动,在投票率达到15%之后,主网功能被激活,下面教大家如何连接EOS主网。

一、从GitHub上克隆主网代码仓库:(注意EOS-Mainnet/eos 与 EOSIO/eos 的版本是一致的。若以前在本地已经安装编译过EOSIO/eos的1.0.2版本及以上,则可以直接跳到步骤三)

git clone https://github.com/EOS-Mainnet/eos 
cd eos
git submodule update --init --recursive 
git tag
git checkout mainnet-1.0.2.2

二、编译eos代码

./eosio_build.sh  

三、替换config.ini 和 genesis.json 文件

(1)运行nodeos节点后会生成默认的config.ini/genesis.json文件,现在对其进行替换

(2)在不同系统中找到其文件地址:

  • linux-ubuntu: ~/.local/share/eosio/nodeos/config/
  • mac-osx: ~/Library/Application\ Support/eosio/nodeos/config/

(3)新的config.ini文件设置如下:

# fullnode sample config

blocks-dir = "blocks"

chain-state-db-size-mb = 1024

reversible-blocks-db-size-mb = 340

contracts-console = false

https-client-validate-peers = 1

http-server-address = 0.0.0.0:8888

access-control-allow-credentials = false

p2p-listen-endpoint = 0.0.0.0:9876

p2p-server-address = 0.0.0.0:9876


# List of peers

p2p-peer-address = p2p.one.eosdublin.io:9876

p2p-peer-address = eu-west-nl.eosamsterdam.net:9876

p2p-peer-address = p2p.mainnet.eosgermany.online:9876

p2p-peer-address = 35.197.190.234:19878

p2p-peer-address = p2p.genereos.io:9876

p2p-peer-address = fullnode.eoslaomao.com:443

p2p-peer-address = new.eoshenzhen.io:10034

p2p-peer-address = node1.eosphere.io:9876

p2p-peer-address = p2p.meet.one:9876

p2p-peer-address = bp.eosbeijing.one:8080

p2p-peer-address = peer1.mainnet.helloeos.com.cn:80

p2p-peer-address = p2p-public.hkeos.com:19875

p2p-peer-address = pub1.eostheworld.io:9876

p2p-peer-address = eu1.eosdac.io:49876

p2p-peer-address = peer.eosio.sg:9876


p2p-max-nodes-per-host = 10


agent-name = "eosmainnet"

# allowed-connection can be set to "specified" to use whitelisting with the "peer-key" option

allowed-connection = any


# peer-private-key is needed if you are whitelisting specific peers with the "peer-key" option

peer-private-key = ["EOS6qTvpRYx35aLonqUkWAMwAf3mFVugYfQCbjV67zw2aoe7Vx7qd", "5JroNC1B4pz9gJzNZeU7tkU6YMtoeWRCr4CJJwKsVXnJhRbKXSC"]


max-clients = 250

connection-cleanup-period = 30

network-version-match = 1

sync-fetch-span = 100

max-implicit-request = 1500

enable-stale-production = false

pause-on-startup = false

max-transaction-time = 10000

max-irreversible-block-age = -1

txn-reference-block-lag = 0


# Plugins used for full nodes

plugin = eosio::chain_api_plugin

plugin = eosio::history_api_plugin

plugin = eosio::chain_plugin

plugin = eosio::history_plugin

plugin = eosio::net_plugin

plugin = eosio::net_api_plugin

其中p2p-peer-address的配置来源于:

https://docs.google.com/spreadsheets/d/1K_un5Vak3eDh_b4Wdh43sOersuhs0A76HMCfeQplDOY/edit#gid=0

WX20180619-163221@2x.png

(4)genesis.json文件内容如下:

{
  "initial_timestamp": "2018-06-08T08:08:08.888",
  "initial_key": "EOS7EarnUhcyYqmdnPon8rm7mBCTnBoot6o7fE2WzjvEX2TdggbL3",
  "initial_configuration": {
    "max_block_net_usage": 1048576,
    "target_block_net_usage_pct": 1000,
    "max_transaction_net_usage": 524288,
    "base_per_transaction_net_usage": 12,
    "net_usage_leeway": 500,
    "context_free_discount_net_usage_num": 20,
    "context_free_discount_net_usage_den": 100,
    "max_block_cpu_usage": 200000,
    "target_block_cpu_usage_pct": 1000,
    "max_transaction_cpu_usage": 150000,
    "min_transaction_cpu_usage": 100,
    "max_transaction_lifetime": 3600,
    "deferred_trx_expiration_window": 600,
    "max_transaction_delay": 3888000,
    "max_inline_action_size": 4096,
    "max_inline_action_depth": 4,
    "max_authority_depth": 6
  }
}

此文件称为创世json文件,来自以下链接:

https://github.com/EOS-Mainnet/eos/blob/launch-rc-1.0.2/mainnet-genesis.json

四、将以上的创世json文件,复制拷贝到~/eos/build/program/nodeos目录下,并启动nodeos节点:

./nodeos --genesis-json genesis.json  

可以看到node已经连上主网,on_incoming_block就代表正在同步区块内容了。不过有的节点地址会出现连接不上的error。可以尝试在上述的google链接地址中的表格选择稳定的peer节点进行设置。

3546494ms thread-0   producer_plugin.cpp:290       on_incoming_block    ] Received block ccf596b268aea49a... #479000 @ 2018-06-13T05:29:49.000 signed by genesisblock [trxs: 0, lib: 478999, conf: 0, latency: 527357494 ms]
3552228ms thread-0   producer_plugin.cpp:290       on_incoming_block    ] Received block 3adbcf84f3dea90c... #480000 @ 2018-06-13T05:38:09.000 signed by genesisblock [trxs: 0, lib: 479999, conf: 0, latency: 526863228 ms]
3557963ms thread-0   producer_plugin.cpp:290       on_incoming_block    ] Received block ec80ea02b2d795cb... #481000 @ 2018-06-13T05:46:29.000 signed by genesisblock [trxs: 0, lib: 480999, conf: 0, latency: 526368963 ms]
3563672ms thread-0   producer_plugin.cpp:290       on_incoming_block    ] Received block 580cf0926b807c85... #482000 @ 2018-06-13T05:54:49.000 signed by genesisblock [trxs: 0, lib: 481999, conf: 0, latency: 525874672 ms]
3569426ms thread-0   producer_plugin.cpp:290       on_incoming_block    ] Received block cce03eebb64b3c80... #483000 @ 2018-06-13T06:03:09.000 signed by genesisblock [trxs: 0, lib: 482999, conf: 0, latency: 525380427 ms]
3571971ms thread-0   net_plugin.cpp:1915           connect              ] host: node1.eosphere.io port: 9876
3571971ms thread-0   net_plugin.cpp:1915           connect              ] host: eu1.eosdac.io port: 49876
3571971ms thread-0   net_plugin.cpp:1915           connect              ] host: peer.eosio.sg port: 9876
3571971ms thread-0   net_plugin.cpp:1915           connect              ] host: p2p.mainnet.eosgermany.online port: 9876

五、查看链信息:

比对chain_id是否为:aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906

运行cleos命令:

cleos get info  

返回信息为:

{
  "server_version": "26ec83de",
  "chain_id": "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906",
  "head_block_num": 493299,
  "last_irreversible_block_num": 493298,
  "last_irreversible_block_id": "000786f240401f6fcc24de5240ddd9fead88cbbbbec740c181258dc3e682fb96",
  "head_block_id": "000786f36fafd9e98d703a004a302e86958de991dedbbc27f33c393c2adb2c6f",
  "head_block_time": "2018-06-13T07:28:58",
  "head_block_producer": "genesisblock",
  "virtual_block_cpu_limit": 200000000,
  "virtual_block_net_limit": 1048576000,
  "block_cpu_limit": 199900,
  "block_net_limit": 1048576
}

六、查看区块数据

在数据正常同步后,使用cleos命令可以查看一些区块信息:譬如查看区块191的数据

cleos get block 191  

返回信息如下,可以看到transaction内容

{
  "timestamp": "2018-06-09T11:58:04.500",
  "producer": "eosio",
  "confirmed": 0,
  "previous": "000000be7ec418241839c376b35a4ae88b305e045a4f0e779215c5f5f4508e5d",
  "transaction_mroot": "1f09d60c3b791e1fa29e7fe980807ec36fab1c9fbc130f72f492e3b4c965184b",
  "action_mroot": "1ca50b0889e5c6b884e621ff113b17868dfbbc7cd2d4549784c8e50a5114e75c",
  "schedule_version": 0,
  "new_producers": null,
  "header_extensions": [],
  "producer_signature": "SIG_K1_K87sojWELjnYSUvpS1Xy1L1P5Etr7xrcnuauqM5zoUYZRTL6eLXA9fZASdvH1ynUq1ZXSceNqWGrcAxj6cZt3ERvgk2aD9",
  "transactions": [{
      "status": "executed",
      "cpu_usage_us": 1593,
      "net_usage_words": 35,
      "trx": {
        "id": "ad77575a8b4f52e477682e712b1cbd884299468db6a94d909f90c6961cea9b02",
        "signatures": [
          "SIG_K1_KfUNC7KHjSGKBrk8FHjq9tqZA12q1aD9pspfBbLW9iw58B6DqoyebmLaEP2VUuJZa2nDZ11YdgEi2VwuqY5sSogh7MaG8p"
        ],
        "compression": "none",
        "packed_context_free_data": "",
        "context_free_data": [],
        "packed_trx": "eac01b5bbd00421775ad000000000100a6823403ea3055000000572d3ccdcd010000000000ea305500000000a8ed3232ba010000000000ea30550000000000004038a08601000000000004454f530000000098014e6576657220646f7562742074686174206120736d616c6c2067726f7570206f662074686f7567687466756c2c20636f6d6d697474656420636974697a656e732063616e206368616e67652074686520776f726c643b20696e646565642c206974277320746865206f6e6c79207468696e672074686174206576657220686173202d20656f7361636b6e6f776c6564676d656e74732e696f00",
        "transaction": {
          "expiration": "2018-06-09T11:58:34",
          "ref_block_num": 189,
          "ref_block_prefix": 2910132034,
          "max_net_usage_words": 0,
          "max_cpu_usage_ms": 0,
          "delay_sec": 0,
          "context_free_actions": [],
          "actions": [{
              "account": "eosio.token",
              "name": "transfer",
              "authorization": [{
                  "actor": "eosio",
                  "permission": "active"
                }
              ],
              "data": {
                "from": "eosio",
                "to": "b1",
                "quantity": "10.0000 EOS",
                "memo": "Never doubt that a small group of thoughtful, committed citizens can change the world; indeed, it's the only thing that ever has - eosacknowledgments.io"
              },
              "hex_data": "0000000000ea30550000000000004038a08601000000000004454f530000000098014e6576657220646f7562742074686174206120736d616c6c2067726f7570206f662074686f7567687466756c2c20636f6d6d697474656420636974697a656e732063616e206368616e67652074686520776f726c643b20696e646565642c206974277320746865206f6e6c79207468696e672074686174206576657220686173202d20656f7361636b6e6f776c6564676d656e74732e696f"
            }
          ],
          "transaction_extensions": []
        }
      }
    }
  ],
  "block_extensions": [],
  "id": "000000bf87a9db45034a46671514a225cb1a5c30e9b8dc172bc75ef30a812970",
  "block_num": 191,
  "ref_block_prefix": 1732659715
}
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 201,924评论 5 474
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 84,781评论 2 378
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 148,813评论 0 335
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,264评论 1 272
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,273评论 5 363
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,383评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,800评论 3 393
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,482评论 0 256
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,673评论 1 295
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,497评论 2 318
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,545评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,240评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,802评论 3 304
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,866评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,101评论 1 258
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,673评论 2 348
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,245评论 2 341

推荐阅读更多精彩内容