Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug-Fix for the forking problem #29

Merged
merged 29 commits into from
Feb 2, 2019

Conversation

febe19
Copy link
Collaborator

@febe19 febe19 commented Jan 21, 2019

Hello All

This PR fixes issue #27 and does also write the output to a file as questioned in #23.
The exact problem is described in the added PDF-Document.

What I've done:

  • The logger.Printf(...) statements are now printed to a .log file and saved in the project directory directly. This file will be created if not existent at the beginning.
  • Some changes in the logger statements to ease the logs.
  • Created a stash, where all received blocks are stored. --> During a rollback, we first check this stash and if the block is in there, we do not have to do a block request to the network.
  • Changed the block request form random to broadcast --> Higher probability to get blocks (e.g. when never received or not in stash)
  • Added a Stash for all initially invalid transactions --> Now invalid transactions are not deleted immediately. This helps to lower the network requests.
  • Changed the Transaction request from random to broadcast --> Higher probability to get transactions which are not received until now.
  • Rised the MIN_MINERS number to 5. Now the miners actively searches other miners until 5 are in the list. --> Better connected.
  • With multiple miners it can be that the pogram crashes with panic: send on closed channel. This because in the broacastService() function, the range gets updated only before each iteration. Meaning when we are inside one iteration and there is a removal & closure from the peers.minerConns or peers.clientConns, the function may try to send on a closed channel. Therefore I inserted an IF-check, to check if the miner/client is still in the list.

I know that this broadcast requests do rise the network traffic. But it is the most secure way to get a valid response for a request.

Forking Problem.pdf

febe19 and others added 29 commits November 24, 2018 11:41
This Branch is used to test the Performance of the BAZO-Network.
Therefore, certain additions are made:
- Logger creates a logfile 'PerformanceLogger.log' and prints all
statements to the console and the log file.
- Logger includes microseconds
- Logger prints the Mempool size
- Logger does not print "Sent Message... " and "Received Message..."
statemens.
- Logger prints the total transaction number in each block.
-BLOCK_REQ & TX_REQ as Broadcast and not as a random selection of one
miner. With this we can probably prevent timeouts when randomly choosing
a wrong miner.
- after rollback write block back to received stash. so it will be
deleted after 50 blocks but possible to grap for an other rollback.
- logical reorganisation
Now only one Requested TX will go to the fetch method. And MIN_MINER is
set to 5 so that the network does establish more connections.
This should fix the issue of a forking BAZO-Blockchain.
Implemented a stash for all received blocks. After a rollback now the
miner first checks those blocks before requesting one from the network.
the Block request to the network is now done with a broadcast request,
such that the possibility of a valid answer is maximised.
When a fork occurs, the state of the fork-brnaches can quickly diverge.
This results in transactions listed as invalid, despite they are valid
after a rollback to the correct chain. Now we do not discard them
automatically but write them in a special stash, from where they can be
fetched after the rollback. This results in less network requests and a
higher possibility to get a valid answer. Also here the Tx request is
now a broadcast. This also ensures for the case when a transaction is
not received before. With only one random selected miner the miner may
has bad luck and does not get the transaction. Then the block is invalid
and this should be prevented.
@mchetelat mchetelat self-requested a review February 2, 2019 10:02
@mchetelat mchetelat merged commit 70aeba0 into bazo-blockchain:master Feb 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants