Blockchain Geth专用网络问题生成以太 简短描述
我有三个以太坊节点连接在一个专用网络中,我正在使用交互式Javascript控制台和geth 问题是,我找不到任何一个账户上的乙醚。余额始终为0 细节 对于所有三个节点,配置和输出都是相似的,只是它们的地址和帐号不同 运行前的文件树Blockchain Geth专用网络问题生成以太 简短描述,blockchain,ethereum,mining,Blockchain,Ethereum,Mining,我有三个以太坊节点连接在一个专用网络中,我正在使用交互式Javascript控制台和geth 问题是,我找不到任何一个账户上的乙醚。余额始终为0 细节 对于所有三个节点,配置和输出都是相似的,只是它们的地址和帐号不同 运行前的文件树geth: ~/eth/ database/ keystore/ genesis/ CustomGenesis.json CustomGenesis.json的内容: { "config": { "chai
geth
:
~/eth/
database/
keystore/
genesis/
CustomGenesis.json
CustomGenesis.json的内容
:
{
"config": {
"chainId": 15,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"nonce": "0x0000000000000042",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x00",
"gasLimit": "0x08000000",
"difficulty": "0x0400",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0xd77821c8b92e3e29bc63c8f2a94a6c6a64b28b53",
"alloc": {
"0x862e90e6b6ebfe0535081d07be8e0f38e422932c": {"balance": "100"},
"0x47e4cf0cc71e7257663f3d2f95e3f8982ece3ad8": {"balance": "200"},
"0x1df2f4f40c03367a9bf42b28a090fed1cccb3068": {"balance": "300"},
"0xd77821c8b92e3e29bc63c8f2a94a6c6a64b28b53": {"balance": "4444444444444444444"},
"0x28685a4b9418c1cb85725318756aa815e8e34497": {"balance": "5555555555555555555"},
"0x86f0526280fea57255c6391a4c7dbdbe8e1181ab": {"balance": "6666666666666666666"}
}
}
在目录~/eth/
中,我开始geth
时使用了:
sudo geth --networkid 15 --datadir ./database --nodiscover --maxpeers 2 --rpc --rpcport 8080 --rpccorsdomain * --rpcapi "db,eth,net,web3" --port 30303 --identity TestNet init ./genesis/CustomGenesis.json
。。。产生了以下输出:
INFO [07-12|13:12:46] Starting peer-to-peer node instance=Geth/v1.6.6-stable-10a45cb5/linux-amd64/go1.8.1
INFO [07-12|13:12:46] Allocated cache and file handles database=/home/ethereum6/eth/database/geth/chaindata cache=128 handles=1024
INFO [07-12|13:12:46] Writing default main-net genesis block
INFO [07-12|13:12:47] Initialised chain configuration config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Metropolis: 9223372036854775807 Engine: ethash}"
INFO [07-12|13:12:47] Disk storage enabled for ethash caches dir=/home/ethereum6/eth/database/geth/ethash count=3
INFO [07-12|13:12:47] Disk storage enabled for ethash DAGs dir=/home/ethereum6/.ethash count=2
WARN [07-12|13:12:47] Upgrading db log bloom bins
INFO [07-12|13:12:47] Bloom-bin upgrade completed elapsed=222.754µs
INFO [07-12|13:12:47] Initialising Ethereum protocol versions="[63 62]" network=15
INFO [07-12|13:12:47] Loaded most recent local header number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [07-12|13:12:47] Loaded most recent local full block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [07-12|13:12:47] Loaded most recent local fast block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [07-12|13:12:47] Starting P2P networking
INFO [07-12|13:12:47] HTTP endpoint opened: http://127.0.0.1:8080
INFO [07-12|13:12:47] RLPx listener up self="enode://5ded12c388e755791590cfe848635c7bb47d3b007d21787993e0f6259933c78033fd6fa17cbb884ed772f1c90aebaccc64c5c88cddc1260e875ac8f6f07067bf@[::]:30303?discport=0"
INFO [07-12|13:12:47] IPC endpoint opened: /home/ethereum6/eth/database/geth.ipc
交互式Javascript控制台在另一个终端中启动,具有:
sudo geth attach ipc:$HOME/eth/database/geth.ipc
。。。其中:
Welcome to the Geth JavaScript console!
instance: Geth/v1.6.6-stable-10a45cb5/linux-amd64/go1.8.1
coinbase: 0x1fb9fb0502cb57fb654b88dd2d24e19a0eb91540
at block: 0 (Thu, 01 Jan 1970 03:00:00 MSK)
datadir: /home/ethereum6/eth/database
modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
>
在所有节点上使用miner.setEtherbase(personal.listAccounts[0])
设置Etherbase。每个节点只有一个帐户。(3个节点,3个帐户)
调用admin.nodeInfo
将给出:
> admin.nodeInfo
{
enode: "enode://5ded12c388e755791590cfe848635c7bb47d3b007d21787993e0f6259933c78033fd6fa17cbb884ed772f1c90aebaccc64c5c88cddc1260e875ac8f6f07067bf@[::]:30303?discport=0",
id: "5ded12c388e755791590cfe848635c7bb47d3b007d21787993e0f6259933c78033fd6fa17cbb884ed772f1c90aebaccc64c5c88cddc1260e875ac8f6f07067bf",
ip: "::",
listenAddr: "[::]:30303",
name: "Geth/v1.6.6-stable-10a45cb5/linux-amd64/go1.8.1",
ports: {
discovery: 0,
listener: 30303
},
protocols: {
eth: {
difficulty: 17179869184,
genesis: "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
head: "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
network: 15
}
}
}
>
节点与admin.addPeer(..)
相连,这样每个节点在调用admin.peers
时都会显示两个对等节点
当我使用miner.start()
开始挖掘时,这是我在交互式js控制台中收到的输出:
> miner.start()
null
>
。。。在运行该节点的另一终端中:
INFO [07-12|13:16:34] Updated mining threads threads=0
INFO [07-12|13:16:34] Transaction pool price threshold updated price=18000000000
INFO [07-12|13:16:34] Starting mining operation
INFO [07-12|13:16:34] Commit new mining work number=1 txs=0 uncles=0 elapsed=749.279µs
在这之后,什么也没有发生,当使用eth.getBalance(eth.accounts[0])检查时,所有帐户上的余额仍然为0
我必须尝试哪些选项才能让专用网络上的节点开始挖掘以太
为什么乙醚的预分配在CustomGenesis.json
中不起作用
是否忽略了CustomGenesis.json
中提供的困难admin.nodeInfo
显示了不同的数字
欢迎大家提出意见和建议,谢谢 您可能将genesis难度设置得太高,以至于您的CPU挖掘人员没有机会找到块。您可能希望将难度设置为更合理的值,例如100万(
0x100000
十六进制)。好的,我将提供我的输入(请记住,我也是新来的,所以我们在同一条船上!)
我有信心的部分是整个平衡部分,因此:
1.创建一个新帐户(在任何节点上):personal.newAccount(“密码”)
2.将新帐户设置为此节点的coinbase:miner.setEtherbase(eth.accounts[0])
3.开始挖掘:miner.Start()
然后,您可以在挖掘时检查余额。尝试:
web3.fromWei(eth.getBalance(eth.coinbase),“ether”)问题显然在于genesis块的初始化方式 走错路 通过使用
init
和其他命令行参数调用geth
:
geth --networkid 15 --datadir ./database --nodiscover --maxpeers 2 --rpc --rpcport 8080 --rpccorsdomain * --rpcapi "db,eth,net,web3" --port 30303 --identity TestNet init ./genesis/CustomGenesis.json
该节点由mainnet genesis块启动:
...
INFO [07-12|13:12:46] Writing default main-net genesis block
...
在那之后,其他一切都无法按预期的方式运行
解决方案
仅使用init
和--datadir
参数调用geth
:
geth --datadir /path/to/database init /path/to/CustomGenesis.json
给出一个短输出,初始化完成后,geth
立即退出:
INFO [07-13|10:30:49] Allocated cache and file handles database=/path/to/database/geth/chaindata cache=16 handles=16
INFO [07-13|10:30:49] Writing custom genesis block
INFO [07-13|10:30:49] Successfully wrote genesis state database=chaindata hash=ed4e11…f40ac3
INFO [07-13|10:30:49] Allocated cache and file handles database=/path/to/database/geth/lightchaindata cache=16 handles=16
INFO [07-13|10:30:49] Writing custom genesis block
INFO [07-13|10:30:49] Successfully wrote genesis state database=lightchaindata hash=ed4e11…f40ac3
在这之后,其他一切都按预期进行
非常感谢你帮我解决这个问题 我编辑了这篇文章以添加细节。此外,
miner.start()
之后的输出也已更改。这是正确的,是的,但问题目前在其他地方。无论如何谢谢你!
INFO [07-13|10:30:49] Allocated cache and file handles database=/path/to/database/geth/chaindata cache=16 handles=16
INFO [07-13|10:30:49] Writing custom genesis block
INFO [07-13|10:30:49] Successfully wrote genesis state database=chaindata hash=ed4e11…f40ac3
INFO [07-13|10:30:49] Allocated cache and file handles database=/path/to/database/geth/lightchaindata cache=16 handles=16
INFO [07-13|10:30:49] Writing custom genesis block
INFO [07-13|10:30:49] Successfully wrote genesis state database=lightchaindata hash=ed4e11…f40ac3