Bitcoin Forum
November 10, 2024, 01:49:22 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Selfish miner implementation  (Read 213 times)
RoeiDimi (OP)
Newbie
*
Offline Offline

Activity: 1
Merit: 0


View Profile
May 22, 2018, 09:11:43 AM
 #1

Hello,
im an exprienced software developer but im new to bitcoin core
as part of my 2nd degree theses i wanna implement a selfish miner such as mentioned in this paper - https://arxiv.org/abs/1311.0243
the general idea is pretty known in the community -
every selfish miner in a selfish miners pool maintains 2 different blockchains, and when a new block is found, the selfish pool miners dont necessarily always tell the rest of the network about it.

i downloaded the bitcoin core code, its a pretty big and not that organized code and seems to me that i only need to make a few changes
1. give the node another blockchain
2. patch the code of receiving a new block so that it updates both blockchains according to the algorithm
3. patch the code that broadcasts a new found block so that it wont always broadcast it to everyone etc...

my question is - can someone point me to the places in the code where these features are found?
would also appreciate any other suggestions or tips regarding the implementation

thanks
DevilOper
Member
**
Offline Offline

Activity: 280
Merit: 26


View Profile
May 23, 2018, 08:45:58 AM
 #2

I am not familiar with bitcoin core code, just an idea: you can maintain the second blockchain the same way as orphan blocks (AFAIK they are kept in blockchain).
For "sefish mining" you have to hack the "consensus algorithm" code part.
QRC
Newbie
*
Offline Offline

Activity: 10
Merit: 2


View Profile
May 24, 2018, 05:30:55 AM
 #3

As blockchain name suggests, it's a chain of blocks.
So if your selfish miner works on its own private chain, you don't have to accept blocks from the main chain.
AcceptBlock function and other functions which are related to accepting blocks are located in validation.cpp
DevilOper
Member
**
Offline Offline

Activity: 280
Merit: 26


View Profile
May 24, 2018, 09:02:11 AM
 #4

So if your selfish miner works on its own private chain, you don't have to accept blocks from the main chain.

AFAIK above some treshold selfish miner may decide to drop his chain (fork) and restart a new one over the new point of main chain.
Another concern is to compare chain lengths in order to decide when to publish his 'private'.
QRC
Newbie
*
Offline Offline

Activity: 10
Merit: 2


View Profile
May 24, 2018, 12:22:11 PM
Last edit: May 24, 2018, 12:39:31 PM by QRC
 #5

So if your selfish miner works on its own private chain, you don't have to accept blocks from the main chain.

AFAIK above some treshold selfish miner may decide to drop his chain (fork) and restart a new one over the new point of main chain.
Another concern is to compare chain lengths in order to decide when to publish his 'private'.
Of course, you're right on that, it can have some elaborated program logic behind it. (when release private blockchain, when to drop it and follow the main chain, ect.)
But I think RoeiDimi can first implement something simple. Something like:
Code:
if (privateChainLen > 4) 
   ReleasePrivateChain();
else (nBlocksBehindMainChain > 2)
   DropPrivateChain();
ranochigo
Legendary
*
Offline Offline

Activity: 3038
Merit: 4420


Crypto Swap Exchange


View Profile
May 24, 2018, 12:40:31 PM
 #6

Of course, you right on that, it can have some elaborated program logic behind it. (when release private blockchain, when to drop it and follow the main chain, ect.)
But I think RoeiDimi can first implement something simple. Something like:
Code:
if (privateChainLen > 4) 
   releasePrivateChain();
else (nBlocksBehindOfMainChain > 2)
   dropPrivateChain();
Agreed, some refinements could be made. Selfish mining works the best if you can at least compete with others when they are at the same block height as you. When you're in this attack, you should be connected to the peers which are the major mining pools. If any of them relay a block, you would also broadcast your own block. As such, there is still a chance for the network to build on your chain.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!