Blockchain is being applied in critical sectors of society, such as: financial, health care, energy and logistics, among others. However, it lacks on proper tools to evaluate or simulate certain events or conditions.

While there is a broad interest in developing blockchain systems for specific use cases, there is a lack of tools to perform their evaluation. Current evaluation methods use emulation, to deploy large number of nodes in a controlled environment and then its used tools like Hyperledger Caliper, BLOCKBENCH, or even hammer - that I developed to work with Ethereum clients. These tools can be used to stress test nodes to obtain insights about the overall performance of the network. This approach, however, incurs in large overhead and lacks scalability to real world deployments. Besides, power consumption of a large-scale system must be taken into account.

Simulation

Another valid alternative is simulation. Network and distributed system simulators are important tools to evaluate the performance of protocols and systems in a large set of conditions. These simulators provide an environment that simplifies the implementation and deployment of protocols. Simulators like The ONE, PeerSim, and CloudSim are important tools in the development of protocols and systems for opportunistic networks, peer-to-peer networks, and cloud computing, respectively. With simulation it is possible to study a large-scale system with thousands of nodes in a single machine and gather results in reasonable time.

What is Simulation?

Simulation can be defined as an imitation of the operation of a real-world process or system over time. Whether done by hand or on a computer, simulation involves the generation of an artificial history of a system and the observation of that artificial history to draw inferences concerning the operating characteristics of the real system.

Banks, Jerry. Discrete event system simulation. Pearson Education India, 2005.

A simulation attempts to reproduce the behavior of a system and its progress over time. To do so, simulations run a model. A model is a set of assumptions about the operation of the system. These assumptions can be expressed in algorithmic (a sequence of steps), mathematical and logical relationships between entities of the system.

Simulation can be used to study a wide variety of questions about the real-world system. It can also be used to predict the effect of changes to existing systems, and assist in the design of new systems, by predicting the performance under a set of variables.

Real world simulation

To conclude, the simulation models can be classified according to several independent pairs of attributes, stochastic or deterministic, static or dynamic and discrete-event or continuous.

BlockSim: A Blockchain Simulator

With help of Prof. Miguel Pupo Correia from INESC-ID and IST, I developed BlockSim as my Master thesis in Computer Science. BlockSim consists in a simulation framework that assists in the design, implementation, and evaluation of existing or new blockchains.

The followed approach provides a framework with pre-existing simulations models, commonly present across all blockchain implementations (blocks, transactions, ledger, network, etc.). Developers can extend these simulation models to evaluate their own design and implementation decisions. The framework will then take the created models and execute them in the simulator, according to a set of events defined by users. This approach provides a very versatile solution without the burden of implementing a simulator from scratch, and can be extended to simulate any kind of blockchain implementation.

BlockSim provides fast and useful insights as to how a certain blockchain system operates, thorough examination of certain assumptions on the simulation models without the overhead of deployment and implementation of a real network.

This simulator follows a stochastic simulation model, being able to represent random phenomena by introducing probability distributions for certain events. Our solution consists in the introduction of random phenomena in terms of probabilities of events. Our models are considered dynamic; they can represent the system over a certain interval determined by the user interacting with BlockSim.

A discrete-event simulation (DES) model is suitable to model a blockchain system, since an event-based system collects and changes states at a discrete point in time. This way, the change of state variables only needs to be tracked at discrete points in time, as opposed to continuously over time (as in continuous simulation model). Therefore, the simulator can keep track of thousands of nodes and events that only change states.

Where can I start using it?

The best place to start using BlockSim is looking to our Github repository.

BlockSim was presented at 2019 IEEE International Conference on Blockchain, you can check the slides here. In addition you can find the full paper and also the published paper.