从EOS 主网同步数据

从EOS 主网同步数据

最近想建立一个EOS 节点来同步EOS 主网的block 数据, 搜索了很久才找到正确的方法,本文记录这个过程,方便和我有类似需求的人。

编译源代码

如果你已经编译了EOS 源代码, 请忽略这个章节。当前时间(2018-11-06)主网的tag 编号最大的是 mainnet-1.1.0

同步源代码

git clone https://github.com/EOS-Mainnet/eos -b mainnet-1.1.0
cd eos
git submodule update --init --recursive

编译源代码

./eosio_build.sh -s EOS
cd build
make install

编辑 config.ini

Ctrl + C 退出 nodeos, 用vim 或者 nano 编辑 config.ini, 修改 p2p-peer-address 所指向的地址。

vim ~/.local/share/eosio/nodeos/config/config.ini

当前的网络的 p2p-peer-address 地址可以从下面地址获得

https://eosnodes.privex.io/?config=1

当前从上诉地址获取到的 p2p-pper-address 的列表为:

p2p-peer-address = 106.10.42.238:9876
p2p-peer-address = 178.49.174.48:9876
p2p-peer-address = 18.188.38.175:9876
p2p-peer-address = 18.188.4.97:9876
p2p-peer-address = 18.221.255.38:9876
p2p-peer-address = 185.253.188.1:19876
p2p-peer-address = 807534da.eosnodeone.io:19872
p2p-peer-address = api-full1.eoseoul.io:9876
p2p-peer-address = api-full2.eoseoul.io:9876
p2p-peer-address = api.eosuk.io:12000
p2p-peer-address = boot.eostitan.com:9876
p2p-peer-address = bp.antpool.com:443
p2p-peer-address = bp.cryptolions.io:9876
p2p-peer-address = bp.eosbeijing.one:8080
p2p-peer-address = bp.libertyblock.io:9800
p2p-peer-address = br.eosrio.io:9876
p2p-peer-address = eos-seed-de.privex.io:9876
p2p-peer-address = eos.nodepacific.com:9876
p2p-peer-address = eos.staked.us:9870
p2p-peer-address = eosapi.blockmatrix.network:13546
p2p-peer-address = eosnode.fi:9888
p2p-peer-address = eu-west-nl.eosamsterdam.net:9876
p2p-peer-address = eu1.eosdac.io:49876
p2p-peer-address = fn001.eossv.org:443
p2p-peer-address = fullnode.eoslaomao.com:443
p2p-peer-address = m.eosvibes.io:9876
p2p-peer-address = mainnet-eos.wancloud.cloud:55576
p2p-peer-address = mainnet.eoscalgary.io:5222
p2p-peer-address = mainnet.eospay.host:19876
p2p-peer-address = mars.fnp2p.eosbixin.com:443
p2p-peer-address = node.eosflare.io:1883
p2p-peer-address = node.eosmeso.io:9876
p2p-peer-address = node1.eoscannon.io:59876
p2p-peer-address = node1.eosnewyork.io:6987
p2p-peer-address = node2.eosnewyork.io:6987
p2p-peer-address = p.jeda.one:3322
p2p-peer-address = p2p.eos.bitspace.no:9876
p2p-peer-address = p2p.eosio.cr:1976
p2p-peer-address = p2p.genereos.io:9876
p2p-peer-address = p2p.mainnet.eospace.io:88
p2p-peer-address = p2p.meet.one:9876
p2p-peer-address = p2p.one.eosdublin.io:9876
p2p-peer-address = p2p.two.eosdublin.io:9876
p2p-peer-address = p2p.unlimitedeos.com:15555
p2p-peer-address = peer.eosjrr.io:9876
p2p-peer-address = peer.eosn.io:9876
p2p-peer-address = peer.main.alohaeos.com:9876
p2p-peer-address = peer1.mainnet.helloeos.com.cn:80
p2p-peer-address = peer2.mainnet.helloeos.com.cn:80
p2p-peer-address = peering.dutcheos.io:9876
p2p-peer-address = peering.mainnet.eoscanada.com:9876
p2p-peer-address = peering1.mainnet.eosasia.one:80
p2p-peer-address = peering2.mainnet.eosasia.one:80
p2p-peer-address = pub0.eosys.io:6637
p2p-peer-address = pub1.eosys.io:6637
p2p-peer-address = publicnode.cypherglass.com:9876
p2p-peer-address = seed1.greymass.com:9876
p2p-peer-address = seed2.greymass.com:9876

在config 中可以考虑加入如下的plugin

plugin = eosio::chain_plugin
plugin = eosio::chain_api_plugin
plugin = eosio::net_plugin
plugin = eosio::net_api_plugin
plugin = eosio::history_plugin
plugin = eosio::history_api_plugin
plugin = eosio::http_plugin
plugin = eosio::http_client_plugin

其中 eosio::chain_api_plugin 是和 cleos 通讯所必须的plugin, 因此这个plugin 一定要配置加载。

运行和加载 genesis.json

cd ~
wget https://eosnodes.privex.io/static/genesis.json
nodeos --genesis-json genesis.json

如果提示 “failed to initialize” ,那么可以删除原先生成的block 数据

rm  -rf ~/.local/share/eosio/nodeos/data/blocks/*
rm  -rf ~/.local/share/eosio/nodeos/data/state/* 

nodeos --genesis-json genesis.json

genesis.jon 的内容:

{
“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
}
}

核实是否已经开始了从主网同步数据block

方法一

运行命令

cleos get info

会输出当前区块的信息。 例如:

{
“server_version”: “8f0f54cf”,
“chain_id”: “aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906”,
“head_block_num”: 3140,
“last_irreversible_block_num”: 3139,
“last_irreversible_block_id”: “00000c4365a125dd1959b9a87c770dea5294edd9fb725fe3bdacd957b809d98c”,
“head_block_id”: “00000c4495d341f4334a7d8c10f4ecbac496ddf2bdcf41b5db499d9bb84bd490”,
“head_block_time”: “2018-06-09T12:24:23.500”,
“head_block_producer”: “eosio”,
“virtual_block_cpu_limit”: 1509483694,
“virtual_block_net_limit”: 24229034,
“block_cpu_limit”: 100000000,
“block_net_limit”: 1048576,
“server_version_string”: “v1.3.1-dirty”
}

请核实 chain id 是 “aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906”, 如果 chain id 不是这个,那么说明不是从主网同步数据。

方法二

运行命令

cleos get block 191

会输出第191 区块的信息。 例如:

{
“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”: “eac01b5bbd00421775ad000000000100a6823403ea3055000000572d3ccdcd010000000000ea305500000000a8ed3232ba010000000000ea30550000000000004038a08601000000000004454f530000000098014e6576657220646f7562742074686174206120736d616c6c2067726f7570206f662074686f75676874
66756c2c20636f6d6d697474656420636974697a656e732063616e206368616e67652074686520776f726c643b20696e646565642c206974277320746865206f6e6c79207468696e672074686174206576657220686173202d20656f7361636b6e6f776c6564676d656e74732e696f00”,
“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”: “0000000000ea30550000000000004038a08601000000000004454f530000000098014e6576657220646f7562742074686174206120736d616c6c2067726f7570206f662074686f7567687466756c2c20636f6d6d697474656420636974697a656e732063616e206368616e67652074686520776f726c643b20696e
646565642c206974277320746865206f6e6c79207468696e672074686174206576657220686173202d20656f7361636b6e6f776c6564676d656e74732e696f”
}
],
“transaction_extensions”: []
}
}
}
],
“block_extensions”: [],
“id”: “000000bf87a9db45034a46671514a225cb1a5c30e9b8dc172bc75ef30a812970”,
“block_num”: 191,
“ref_block_prefix”: 1732659715
}

其中交易数据中的memo 是成为了一个EOS 中很著名的一个符号: “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
如果你获取的区块信息的第 191 个块,没有这些信息数据, 说明获取的区块不是来自于主网。

如果你觉得本文有帮助, 请打赏博主!

link.打赏博主

相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页