基板创世块不匹配

Substrate genesis blocks not matching

我目前正在做 this tutorial. When I am following it as described and execute the alice and bob nodes both on the same machine it works as expected: the nodes are connecting and are creating and finalizing blocks. Now I want to get the same done but over the internet and on different machines. So I execute the bootnode on my PC and the other node on my Laptop. I compiled both from the same code 并且还在我的路由器中转发了端口。所以现在我期望与我在本地计算机上 运行ning 时相同的行为。因此,当我执行它们时,我看到两个控制台都打印了网络流量,但 bob 节点打印了一条警告:Bootnode with peer id '12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp' is on a different chain (our genesis: 0xbfbd…3144 theirs: 0x8859…14c4) 并且它们未连接 (Idle 0 peers)。

因此,根据警告,我得出结论,它们没有相同的创世块,这显然是 运行 作为区块链所必需的。但是根据我的理解,加入节点应该从引导节点复制链的当前状态。如何更改 bobs 部分以使用链的 alices 状态?

两台机器都是运行ning rust version 1.50.0

感谢您的帮助!

Rust 编译不是确定性的,因此不幸的是,在两台计算机上为完全相同的区块链编译的完全相同的代码将不会具有相同的创世哈希。 (特别是因为该链的部分起源是 Wasm Runtime blob,它是用 Rust 非确定性编译的)。

你需要create a chainspec file to use for all other nodes. Note that you want to generate this on one computer, and pass the file to other nodes (don't re-generate it, as the genesis code will differ, as you ran into) before you then start other nodes using the correct chainspec and manually specifying boot nodes.