You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repo provides code for directly simulating a selfish mining attack on a real, simplified blockchain. Blocks are actually mined using their hashes, and mining order is determined by the relative hash power of each miner. This code supports an unlimited number of honest and adversarial miners (given that their fractional hash power sums to 1).
To run the mining backend, first install the python libraries in mining/requirements.txt.
Next, run python mining/server.py
Endpoints
GET/start(Start Mining with defaults)POST/start(Start Mining with Custom Params)
GET/stop(Stop Mining)GET/restart(Restart Mining - Call /start afterwards)GET/blockchain(Get String representation of the Blockchain)GET/chain-quality(Get chain quality as a decimal)GET/longest-chain(Get block hashes of the longest chain)
Visualization
Setup
Install packages with npm install
Start the development server with npm run dev
Usage
Set the mining difficulty (higher leads to longer mining time)
Add some number of miners, set their hash powers as fractions which sum to 1, and choose which should be adversarial
Start mining, and stop mining to change simulation parameters again
The gray block is the genesis block
White blocks are blocks mined by honest nodes
Red blocks are published blocks mined by adversarial nodes
Yellow blocks are unpublished blocks mined by adversarial nodes
Block numbers are effectively the miner address, referring to the nth honest or adversarial miner