Code Monkey home page Code Monkey logo

cblocksim's Introduction

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.

cblocksim's People

Contributors

xuyangm avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.