One Step Closer to Coordicide: IOTA Releases Fast Probabilistic Consensus Simulator

In a previous blogpost, the IOTA Research Department, with the collaboration of one of our research grant recipients, Dr. Sebastian Mueller, published simulation results of the FPC protocol, short for FastProbabilisticConsensus, which was proposed by Dr. Serguei Popov and Dr. Bill Buchanan.  

Today, we are excited to share with you the source code of the simulator we use to produce some of the results of FPC. Releasing the FPC simulator to the public allows us to include the community, open up the technology and encourage to get it tested in the wild.

Our simulator is written in Go and you can access the code from the following repository:

https://github.com/iotaledger/fpc-sim

The simulator is optimized to assess how FPC behaves under certain conditions. We streamlined the source code to vote on single transactions. In the simulation, nodes can behave either honest or adverse.

For each transaction, we define the average initial opinion of the honest nodes, a strategy for the adversaries, as well as other parameters. We briefly discuss some of those parameters in the following section.

In the FPC paper, we assume that every node has a complete view of the network, but we are also interested in what happens if we assume a partial view of the network instead. In other words, we want to analyze how the lack of complete knowledge about all other nodes in the network affects the ability to reach consensus.

To study this scenario, we have included a Watts-Strogatz model, which allows simulating the network as a graph with small-world properties. Two parameters are added for the creation of these graphs:  

Firstly a parameterδ, which sets the proportion of the network a node can peer with, and a parameterγwhich is the rewiring probability. The graph is created in the following way: firstly we create a ring graph in which each node neighbors with the closest δN-1 neighbors, where N is the total number of nodes.  

Then for half of these connections, a new peer is selected randomly from the remaining nodes with the rewiring probabilityγ. Note that forγ=0we obtain a ring graph, which maximizes the diameter of the graph for a fixedδ. The latter can be understood as a worst-case scenario given a Watts-Strogatz graph.

Effects of the two parameters in the Watts-Strogatz model.

We include the possibility of reducing the likelihood of receiving a random number. This allows the study of the performance of the protocol in case a random threshold is not provided for every round. This is of particular relevance for understanding how much randomness the FPC protocol requires.

Furthermore, we provide the possibility to include two cautious adversary strategies. In the first, the adversary attempts to attack the integrity of the opinions, i.e. flip the initial opinion by continuously voting the initial minority opinion. In the second, the adversary attempts to attack the network by trying to create an agreement failure and break the consensus between the nodes.

Currently, the simulator supports the following main metrics for which we also provide evaluation scripts:

  • TerminationRate: The rate at which all honest nodes conclude before the maximum allowed round.
  • AgreementRate: The rate at which all honest nodes conclude with the same opinion
  • IntegrityRate: The rate at which all honest nodes conclude with the same opinion and where the final opinion is the same as the original majority.
  • EtaEvolution: A histogram of the honest η-values for each round for nodes that have not yet concluded.

For these, we include three evaluation scripts, written in Python with Matplotlib.  

plot.pyandplot2d.py: These two scripts allow evaluation with 1 and 2 vectors of inputs respectively. We employ the script to extract the data from CSV-output files that are produced by the simulation code.

For example, in the figures below, we apply the plot.py script for displaying the data that has been obtained by assessing the effects of a partial network view. In the first figure, we take a conservative viewpoint and assume the graph takes the form of a ring. It can be seen that a partial network view is sufficient for the nodes to come to an agreement.  

For the second figure, we randomized the topology by considering that some of the connections are rewired with probabilityγ. We show that the agreement rate can be significantly increased whilst keeping the network view small.  

plot_eps.py: This script provides a heatmap of the distribution of theη-values with time. For example, in the next figure, you can see the evolution of the etas if a large proportion of nodes are adverse.  

-values.

In addition, the following metrics can also be extracted and their output is provided as CSV files:

  • MeanTerminationRound: Average round when FPC terminated
  • MedianTerminationRound: Median round when FPC terminated
  • TerminationRound: Number of rounds necessary to complete FPC in histogram form
  • MeanLastRound: Mean last round across all nodes
  • LastRoundHisto: Histogram of nodes’ individual termination rounds
  • OnesProportion: The proportion of 1s after the protocol terminates
  • OnesPropEvolution: Evolution of the proportion of 1s

The IOTA Research team is constantly working on improving the simulation code and adding new features. If you are curious and want to learn more about it, feel free to start experimenting with this code! Also, if you would like to contribute, you could implement new adversary strategies as well as defensive mechanisms. More info on how to build and run the simulator can be found in the README file of the repository.  

Releasing the Fast Probabilistic Consensus Simulator is another step forward in the Coordicide project. It allows us to engage with the community and researchers interested in the technology alike. Through this, individuals around the world have another avenue to contribute to the effort or even to apply for grants here.  

We hope you will enjoy the development of this simulator as much as we do. As always, we welcome your comments and questions either here or in #tanglemath on IOTA’s official Discord server.