Skip to content

xuyangm/CBlockSim

Repository files navigation

A High-Performance Blockchain Simulator

arXiv

Introduction

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.

Configure

Users can configure blockchain via editing Config.h and Config.cpp

Modules

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.

1. Block Policy: BlockPolicy.h, BlockPolicy.cpp

(1) LoadPoW and LoadPoS

Describe how to simulate block generation,corresponding to Block Proposal in paper.
PoW and a simple PoS have been included, both using exponential distribution.

(2) LoadBitcoinPropagation and LoadEthereumPropagation

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.

(3) LoadLongestRule and LoadGHOSTRule

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.

2. Transaction Policy: TransactionPolicy.h, TransactionPolicy.cpp

(1) PropagationTxn

Describe how to propagate transactions.

(2) LoadEthereumTxnSelection and LoadBitcoinTxnSelection

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.

(3) LoadLongestRule and LoadGHOSTRule

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.

3. Topology Generation: TopologyFactory.h, TopologyFactory.cpp

(1) ProduceCompleteTopo

Generate a complete graph topology.

(2) ProduceSmallWorldTopo

Generate a small-world topology. See reference "Simple, distance-dependent formulation of the Watts-Strogatz model for directed and undirected small-world networks".

4. Transaction Generation: TransactionFactory.h, TransactionFactory.cpp

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.

How to use

cd build/
bash start.sh

Result

see build/output.csv

Publication

The CBlockSim paper has been accepted by IEEE International Conference on Blockchain and Cryptocurrency 2022.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published