diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..763513e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.ipynb_checkpoints diff --git a/corpetty/committee_sim/committee-simulations.ipynb b/corpetty/committee_sim/committee-simulations.ipynb new file mode 100644 index 0000000..51c5be2 --- /dev/null +++ b/corpetty/committee_sim/committee-simulations.ipynb @@ -0,0 +1,270 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "b01c279a-cd3f-4e6f-a7ba-fca8d1f42804", + "metadata": {}, + "outputs": [], + "source": [ + "import random\n", + "import pandas as pd" + ] + }, + { + "cell_type": "markdown", + "id": "53cc43b6-051f-43fb-8195-6a753ab74cf1", + "metadata": {}, + "source": [ + "LogosBFT works by partitioning the nodes into equally-sized committees, then forming a binary tree structure from those committees. A primary (or leader) then partitions the propposed data to be verified via erasure coding techniques (fountain or raptor codes) and distributes it through the tree.\n", + "\n", + "This notebook is an attempt to simulate various structures and their respective consequences w.r.t. bandwidth, byzantine behavior, latency, etc. \n", + "\n", + "The general process can be described by the following:\n", + "- Get Random Seed (Blackboxed here)\n", + "- Form Overlay\n", + " - Initial Committee Assignment\n", + " - Overlay Tree Structure Formation\n", + " - Parent <--> Child Assignment\n", + "- Leader Selection (Blackboxed here)\n", + "- Leader Forms Block Proposal (Blackboxed here)\n", + "- Proposal Erasure Coding\n", + "- Data Dissemination\n", + "- Each Committee Forms Block Independently\n", + "\n", + "We'd like to track the following metrics:\n", + "- total bandwidth for an individual node\n", + "- total num of messages for an individual node\n", + "- latency of block distribution throughout the network" + ] + }, + { + "cell_type": "markdown", + "id": "2b3761fe-d4dc-438f-8cdb-dbfafeb3b6e5", + "metadata": {}, + "source": [ + "## Globals definitions" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "4da35087-f815-4b88-99f8-04890b839beb", + "metadata": {}, + "outputs": [], + "source": [ + "num_nodes = 1000\n", + "committee_size = 50\n", + "num_committees = num_nodes / committee_size\n", + "byzantine_coeff = 0.15\n", + "max_time_delay = 60 # seconds\n", + "block_size = 1 # MB" + ] + }, + { + "cell_type": "markdown", + "id": "e1238929-cbe8-4f80-90c0-5823c6a5ddf6", + "metadata": {}, + "source": [ + "# Form overlay\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "id": "14c20750-375a-410d-aa2b-1b97e17c2ef8", + "metadata": {}, + "source": [ + "## Initial Committee Assignment" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "0bec3377-a302-4bbd-bcfc-3e9c40af51bb", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "def chunks(l, n):\n", + " \"\"\"Yield successive n-sized chunks from l.\"\"\"\n", + " for i in range(0, len(l), n):\n", + " yield l[i:i + n]\n", + "\n", + "random_node_list = [i for i in range(num_nodes)]\n", + "random.shuffle(random_node_list)\n", + "\n", + "committee_list = list(chunks(random_node_list, committee_size))" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "id": "e5917cca-9c2b-423d-b930-6fddfcdea47e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + " | committee_ind | \n", + "committee_members | \n", + "
---|---|---|
0 | \n", + "0 | \n", + "[506, 929, 199, 437, 427, 686, 861, 597, 81, 5... | \n", + "
1 | \n", + "1 | \n", + "[677, 491, 334, 209, 41, 121, 697, 943, 504, 6... | \n", + "
2 | \n", + "2 | \n", + "[439, 996, 238, 574, 388, 12, 956, 330, 386, 3... | \n", + "
3 | \n", + "3 | \n", + "[817, 370, 626, 151, 562, 539, 797, 270, 791, ... | \n", + "
4 | \n", + "4 | \n", + "[288, 693, 282, 348, 777, 671, 545, 222, 477, ... | \n", + "