ethresearch / sharding-p2p-poc

Proof of Concept of Ethereum Serenity Peer-to-Peer Layer on libp2p PubSub System
40 stars 19 forks source link

[Demo] try go mod #91

Closed ChihChengLiang closed 5 years ago

ChihChengLiang commented 5 years ago

What was wrong?

This is an attempt to fix #85 by using the Go mod approach.

How was it fixed?

By introducing go.mod and go.sum, the go mod download step in the dev.Dockerfile can cache the dependencies download, so no need to go get every time on codebase changes.

But there's an issue. The containers spun from the newly built images fails randomly when executing add_peer commands in Ansible scripts. The error message is:

dial attempt failed: connected to wrong peer. 

To reproduce this PR, one needs to

Cute Animal Picture

image

jrhea commented 5 years ago

@ChihChengLiang I am running go 1.11.1 and the repo is in my $GOPATH and I get this error occasionally when running from the CLI and no docker container:

Steps to reproduce:

Open a new terminal sesh and run

$ ./sharding-p2p-poc -seed=0 -port=10000 -rpcport=13000 &
[1] 27462
2018/11/16 16:18:17 Initializing logging reporter
16:18:17.752  INFO sharding-p: Node is listening: seed=0, addr=127.0.0.1:10000, peerID=QmS5QmciTXXnCUCyxud5eWFenUMAmvAWSDa1c7dvdXRMZ7 main.go:189
16:18:17.753  INFO sharding-p: RPC server listening to address: 127.0.0.1:13000 rpcserver.go:423

$ ./sharding-p2p-poc -seed=1 -port=10001 -rpcport=13001 &
[2] 27463
$ 2018/11/16 16:18:26 Initializing logging reporter
16:18:26.341  INFO sharding-p: Node is listening: seed=1, addr=127.0.0.1:10001, peerID=QmexAnfpHrhMmAC5UNQVS8iBuUUgDrMbMY17Cck2gKrqeX main.go:189
16:18:26.341  INFO sharding-p: RPC server listening to address: 127.0.0.1:13001 rpcserver.go:423

$ ./sharding-p2p-poc -seed=2 -port=10002 -rpcport=13002 &
[3] 27464
$ 2018/11/16 16:18:33 Initializing logging reporter
16:18:33.960  INFO sharding-p: Node is listening: seed=2, addr=127.0.0.1:10002, peerID=Qmd3wzD2HWA95ZAs214VxnckwkwM4GHJyC6whKUCNQhNvW main.go:189
16:18:33.960  INFO sharding-p: RPC server listening to address: 127.0.0.1:13002 rpcserver.go:423

Open another terminal sesh and run:

$ ./sharding-p2p-poc -port=10001 -rpcport=13001 -client addpeer 127.0.0.1 10000 0
16:20:28.108 CRITI sharding-p: Failed to add peer at 127.0.0.1:10000, err: rpc error: code = Unknown desc = Failed to connect to peer <peer.ID Qm*KoDARa>, err: dial attempt failed: <peer.ID Qm*gKrqeX> --> <peer.ID Qm*KoDARa> dial attempt failed: connected to wrong peer cli.go:136

You can see that we get an error, but if i run it again:

jonny@jonnys-MBP:$ ./sharding-p2p-poc -port=10001 -rpcport=13001 -client addpeer 127.0.0.1 10000 0
$ ./sharding-p2p-poc -port=10001 -rpcport=13001 -client listpeer
["QmS5QmciTXXnCUCyxud5eWFenUMAmvAWSDa1c7dvdXRMZ7"]

You can see that it worked.

I am thinking that it has something to go with the code running on go1.11.1.

I will trace through the code and investigate. If either @ChihChengLiang or @mhchia can confirm that it works on a previous version of Go...that might be a good lead.

ChihChengLiang commented 5 years ago

It works for me on the first try. I'm using go1.11.1.

Note that I've updated my environment with

go get -v ...
make deps # get latest gx
make partial-gx-rw
go build
NIC619 commented 5 years ago

@jrhea I believe it's related to #100 and I'm currently working on the fix right now. Sorry for the trouble.

jrhea commented 5 years ago

@nic619 ahhh... interesting. Let me know if you have a fix and I will test it. @ChihChengLiang I'll try your suggestion as well

jrhea commented 5 years ago

@NIC619 your fix seemed to work.

ChihChengLiang commented 5 years ago

Closed in favor of #121