A blockchain, or distributed ledger, consists in an append-only data structure that stores an ordered list of transactions, replicated in several nodes connected by the Internet. Blockchains typically assume that these nodes, which do not fully trust each other, may behave in a Byzantine manner. At the same time, they need to reach a consensus on the order of transactions, which has to tolerate Byzantine failures. New transactions can be added to the blockchain but it is not possible to modify those already listed, thereby ensuring integrity of transactions.
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.
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 behaviour 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.
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 here.