CBlockSim is an open source blockchain simulator extended from BlockSim: Alharby. We migrate BlockSim from Python to C++. Using bitwise operation supported by C++, we speed up the simulation process a lot. Moreover, we add a module to simulate the real network so that the simulator can be used to do experiments related to the overlay network of blockchain, for example testing gossip protocols of Bitcoin or Ethereum.
Users can configure blockchain via editing Config.h and Config.cpp
Users can modify some components of blockchain easily. Modules can be found in Policy folder and Factories folder.
The Policy folder contains two types of policies now, one for block and another one for transaction.
The Factories folder contains topology generation and transaction generation.
Describe how to simulate block generation,corresponding to Block Proposal in paper.
PoW and a simple PoS have been included, both using exponential distribution.
Describe block propagation protocol, corresponding to Information Propagation in paper.
The protocols of Bitcoin, i.e. CBR, and Ethereum, i.e. Eth Wire Protocol have been simulated. Users can add new function to implement different propagation protocols.
Describe how to finalize blockchain, corresponding to Block Finalization in paper.
The longest rule and GHOST rule have been included. Users can add new function to create new finalization rule.
Describe how to propagate transactions.
Describe how each miner selects transactions to include in the new block.
Miners select transaction based on gas price in Ethereum and based on transaction fee in Bitcoin.
Describe how to finalize blockchain, corresponding to Block Finalization in paper.
The longest rule and GHOST rule have been included. Users can add new function to create new finalization rule.
Generate a complete graph topology.
Generate a small-world topology. See reference "Simple, distance-dependent formulation of the Watts-Strogatz model for directed and undirected small-world networks".
Generate transactions based on average values, i.e. gas limit, used gas and so on, observed in blockchain. Users can modify this part to add more randomness or build transaction based on real transaction data.
cd build/
bash start.sh
see build/output.csv
The CBlockSim paper has been accepted by IEEE International Conference on Blockchain and Cryptocurrency 2022.