luckydonald / pbft

Implementation of the Practical Byzantine Fault Tolerant Algorithm (pbft)
https://github.com/luckydonald/pbft
GNU General Public License v3.0
135 stars 45 forks source link

how to use #9

Open livc opened 6 years ago

livc commented 6 years ago

I run as README but get a blank web page:

image

So how to add nodes or commits? Could you demonstrate or add it to README? Thanks.

luckydonald commented 6 years ago

I updated the readme. Please execute

docker-compose down

follow the set up steps once again, and afterwards post the output of

docker-compose ps
livc commented 6 years ago
$ docker-compose ps
WARNING: The API_HOST variable is not set. Defaulting to a blank string.
         Name                        Command               State              Ports
----------------------------------------------------------------------------------------------
pbft_api_1                /entrypoint.sh python main ...   Up      443/tcp, 0.0.0.0:80->80/tcp
pbft_node_1               /usr/lib/jvm/java-8-openjd ...   Up      4458/tcp
pbft_postgres_1           docker-entrypoint.sh postgres    Up      5432/tcp
pbft_postgres_browser_1   bash start.sh                    Up      0.0.0.0:8080->80/tcp
pbft_web_1                /entrypoint.sh                   Up      0.0.0.0:8000->8000/tcp

another problem is that the db seems outdate.

image
WuZifan commented 6 years ago

I may successfully run the program, it looks like this: image but I don't know how to send a request, since all we can do is get the value from the db...

and when I try to access the db ,it told me like this: image

need you help~

luckydonald commented 6 years ago

Please make sure you successfully cloned the submodule of the java node, so the folder code/java_node/ is filled. Either with git clone --recursive https://github.com/luckydonald/pbft.git when doing the initial code checkout, or google how to pull submodules afterwards.

@WuZifan The nodes them self send the data to the api container, which writes it to database. The database interface is accessed via it's own container, and on localhost that means a different port. Check out the table at the readme (permalink) for those.

This can be found here:

If you plan to use the python nodes, I don't really remember how far we developed those prototypes. We later switched to the java nodes, as java was a project requirement.

However, contributions and improvements to the code are always welcome!

luckydonald commented 6 years ago

@livc The PostgresMyAdmin config is also checked out via submodule. It will be found under /extras/phppgadmin-docker/Dockerfile. Git is here: luckydonald-forks/phppgadmin-docker @luckydonald-patch-1 (permalink)

You might have to look into editing that Dockerfile, to install a newer phppgadmin.


Another approach would be to just use an older postgres. In the file luckydonald/pbft @1a524b /api.docker-compose.yml:15 https://github.com/luckydonald/pbft/blob/1a524b9b3f270e98dc3d252108ffbcd223941ec0/api.docker-compose.yml#L15 Change it to one older version of postgres: https://hub.docker.com/_/postgres/

    image: postgres:X.X.X

Please report back what worked for you.

WuZifan commented 6 years ago

@luckydonald Thanks for your help and right now I am able to run the project~

But I still can not see the pictures down below: image image

can you show me how to get this two pictures?

luodidege commented 6 years ago

hello, I'm sorry to bother that how to get the image when I click the Web GUI "http://localhost:8000/src/". There is no picture shown when it's running. Sincerely need your help!

bajarang commented 5 years ago

Hello @luckydonald I am also not able to get the project running properly. Can you please give me the hints to make it run. Here is the output of docker-compose ps command :

$ docker-compose ps
WARNING: The API_HOST variable is not set. Defaulting to a blank string.
         Name                        Command               State           Ports         
-----------------------------------------------------------------------------------------
pbft_api_1                /entrypoint.sh python main ...   Up      0.0.0.0:80->80/tcp    
pbft_node_1               /usr/lib/jvm/java-8-openjd ...   Up      4458/tcp              
pbft_postgres_1           docker-entrypoint.sh postgres    Up      5432/tcp              
pbft_postgres_browser_1   bash start.sh                    Up      0.0.0.0:8080->80/tcp  
pbft_web_1                /entrypoint.sh                   Up      0.0.0.0:8000->8000/tcp

I have been going through the codes since past one week, I am beginning to understand the structure of the project but some running example which can be traced back to the code again, will help immensely. I will appreciate your help. Thanks.

luckydonald commented 5 years ago

You can inspect error logs via

docker-compose logs

Or for specific services like the following:

docker-compose logs api node web

Maybe that'll show some error?

This was a university project, finished quite some time ago, and thus I don't run it locally any longer. I'll try to help, but am not in the topic any longer. However, please share your progress/solution.

bajarang commented 5 years ago

Hi @luckydonald , thanks for your prompt reply.

I went through each of the logs separately as you suggested. I do not see any errors there. The only problem I had was to initiate the service postgres_browser. I made the subsequent changes in the Dockerfile for updating debian 8.6 as done here.

For the localhost:8000 all I see is this : Screenshot from 2019-04-04 19-26-56 and it stays like this, I do not see any nodes or the message passing either.

For the database I see this : Screenshot from 2019-04-04 19-13-35

Can you please give me a hint for where exactly to look to make the animations run properly? Let me know if you need some more information.

luckydonald commented 5 years ago

You should be able to click on the postgres link until you reach the table, to check if there are events getting inserted.

Also you can have a look at the node and the api containers, they should log if something is happening.

The GUI is only a visualisation of what's happening, so if there is no display, maybe nothing is happening.

bajarang commented 5 years ago

Thanks for the hints. When I click the postgres link, I see this : Screenshot from 2019-04-04 19-41-03

Should I try to use an older version of postgres as you have suggested before to livc above?

Also the api container shows this : Screenshot from 2019-04-04 19-44-13 Sorry but I do not understand what to make out of it. Can you please explain briefly?

And on the localhost, I see this : Screenshot from 2019-04-04 19-44-01

This is the log of the node container : Screenshot from 2019-04-04 19-48-44 but I guess it is reading one of the pre-stored file for this.

bajarang commented 5 years ago

Hello @luckydonald I upgraded the postgres version you had suggested here with : image: postgres:9.5.16

and I get this for phppgadmin now. Screenshot from 2019-04-05 16-27-03

How do the events get filled in those tables now? The logs are not getting updated and the web GUI is still the same as earlier. -> Sorry, the node log is getting updated with new sequence numbers. Need your help.

Thanks and regards, Bajarang

bajarang commented 5 years ago

Hello @luckydonald The logs are getting filled now successfully. And I can see the updating log for node with this : $ docker-compose logs -f node

Can you please explain in brief how to interpret the messages database defined here. The only thing which I find changing with time in the messages database is the processes entry as shown in the image below : Screenshot from 2019-04-08 17-50-56

Do I have to define any other database other than the messages? The web gui is also not showing any nodes.

I will really appreciate your help. Thanks and regards, Bajrang

luckydonald commented 5 years ago

Hey, could you post a full screenshot of some more output of the node logs, please? So we can confirm that that you have indeed multiple nodes running (the scale command) Or better let it run for a minute and post the output in a gist. Or can store the output in a text file and upload it to this issue as attachment. To get the log into a text file you can run

docker-compose logs node > /tmp/node-log.txt

and simply upload the resulting file at /tmp/node-log.txt

Also if you did something different to get it work please describe what you did and share it with everyone else.

The db "messages" you linked above is just the database the API writes to. If you look closer the postgres container has the same value for its database environment variable so that will be created on first launch automatically.

bajarang commented 5 years ago

Hi @luckydonald , thanks for your reply. I get this as output after I run : docker-compose logs -f node you can see in this log that multiple nodes are running properly with the scale command.

Also for the things to work, I made this change to the extras/phppgadmin-docker/Dockerfile file to update the debian 8.6 properly and changed the postgres version to 9.5.16 (the default was 9.4.21). And then :

docker-compose up -d --build
docker-compose scale node=4

starts the various docker services :

$ docker container ls
CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                    NAMES
adeb1cb4cdc1        pbft_node               "/usr/lib/jvm/java-8…"   43 minutes ago      Up 43 minutes       4458/tcp                 pbft_node_4
a27abe0e1f01        pbft_node               "/usr/lib/jvm/java-8…"   43 minutes ago      Up 43 minutes       4458/tcp                 pbft_node_2
46434002bc4b        pbft_node               "/usr/lib/jvm/java-8…"   43 minutes ago      Up 43 minutes       4458/tcp                 pbft_node_3
484cb029af16        pbft_node               "/usr/lib/jvm/java-8…"   44 minutes ago      Up 44 minutes       4458/tcp                 pbft_node_1
8b53bedd02b2        pbft_api                "/entrypoint.sh pyth…"   44 minutes ago      Up 44 minutes       0.0.0.0:80->80/tcp       pbft_api_1
0637759f03f5        postgres:9.5.16         "docker-entrypoint.s…"   22 hours ago        Up 44 minutes       5432/tcp                 pbft_postgres_1
895098f09289        pbft_web                "/entrypoint.sh"         22 hours ago        Up 44 minutes       0.0.0.0:8000->8000/tcp   pbft_web_1
46f8e2f5c8ac        pbft_postgres_browser   "bash start.sh"          22 hours ago        Up 44 minutes       0.0.0.0:8080->80/tcp     pbft_postgres_browser_1

with these processes :

$ docker-compose ps
WARNING: The API_HOST variable is not set. Defaulting to a blank string.
         Name                        Command               State           Ports         
-----------------------------------------------------------------------------------------
pbft_api_1                /entrypoint.sh python main ...   Up      0.0.0.0:80->80/tcp    
pbft_node_1               /usr/lib/jvm/java-8-openjd ...   Up      4458/tcp              
pbft_node_2               /usr/lib/jvm/java-8-openjd ...   Up      4458/tcp              
pbft_node_3               /usr/lib/jvm/java-8-openjd ...   Up      4458/tcp              
pbft_node_4               /usr/lib/jvm/java-8-openjd ...   Up      4458/tcp              
pbft_postgres_1           docker-entrypoint.sh postgres    Up      5432/tcp              
pbft_postgres_browser_1   bash start.sh                    Up      0.0.0.0:8080->80/tcp  
pbft_web_1                /entrypoint.sh                   Up      0.0.0.0:8000->8000/tcp

The db "messages" seems to be empty in my case. Can you possibly help me debug that please or few pointers would also help?

bajarang commented 5 years ago

Hello @luckydonald , one quick question.

In this code here, when the host_to_post variable is empty, the code returns nothing and hence the api is unable to pass different values to the database. And that is what is exactly happening in my case.

Ideally, I guess this host_to_post variable must be the API_HOST value passed in the docker-compose.yml file, but its empty in my case.

For a quick debugging, I tried to pass different string values like "api", "0" etc. to host_to_post, but with no luck, I get this error in the logs of the node. node_1 | Sending message to API failed: java.net.MalformedURLException: no protocol: 0/dump/

also with host_to_post set to "http://localhost:8080/api" I get this error message in the node log. node_3 | Sending message to API failed: java.net.ConnectException: Connection refused (Connection refused)

Can you please tell me what should be this host_to_post value so that, it will start filling-in the database? I will appreciate your help.

Thanks, Bajrang

Mac24 commented 5 years ago

when run the $ docker-compose up -d postgres postgres_browser have a error

@luckydonald 1

luckydonald commented 5 years ago

@bajarang host_to_post will contain the hostname of the api container. Most likely http://api/. To retrieve it, the docker deamon (/var/run/docker.sock, in the volumes section of the compose file, see also this stackoverflow question) will get queried.

luckydonald commented 5 years ago

@Mac24 your error is the postgres_browser failing to build. Maybe you can gather in the #7 issue for finding a solution.

has12zen commented 2 years ago

I was having trouble building but this worked for me Thanks!