Last active
August 31, 2020 17:41
-
-
Save pawanjay176/c493bc9ad270edabc8bd837b1f660e57 to your computer and use it in GitHub Desktop.
Missed attestation analysis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 84, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import pandas as pd\n", | |
"import numpy as np" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 85, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>Validator index</th>\n", | |
" <th>Skip</th>\n", | |
" <th>Orphan</th>\n", | |
" <th>Missed gossip</th>\n", | |
" <th>Propagation</th>\n", | |
" <th>Got in time but vc voted for previous</th>\n", | |
" <th>Double vote</th>\n", | |
" <th>Invalid local signature</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>6686</td>\n", | |
" <td>157088;152864;153248;165025;165376;</td>\n", | |
" <td></td>\n", | |
" <td>156992;153408;169600;166432;168320;</td>\n", | |
" <td>152896;154321;168384;165988;166094;166623;</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>6687</td>\n", | |
" <td>157921;165890;166144;</td>\n", | |
" <td></td>\n", | |
" <td>157888;156992;156928;168320;169313;</td>\n", | |
" <td>165770;</td>\n", | |
" <td>166880;</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>6690</td>\n", | |
" <td>158016;154304;169312;169952;171296;166368;1685...</td>\n", | |
" <td>154336;</td>\n", | |
" <td>153376;153792;166176;166240;168736;</td>\n", | |
" <td>166615;166749;</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>6717</td>\n", | |
" <td>153185;169216;</td>\n", | |
" <td>154323;</td>\n", | |
" <td>158176;158080;156832;156161;152608;</td>\n", | |
" <td>166886;</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>6718</td>\n", | |
" <td>169952;172416;168641;</td>\n", | |
" <td>154323;</td>\n", | |
" <td>158080;157888;156576;168320;170176;167040;</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td>154365;</td>\n", | |
" <td></td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>5</th>\n", | |
" <td>6719</td>\n", | |
" <td>157696;154336;170208;171744;172642;</td>\n", | |
" <td>154321;</td>\n", | |
" <td>157600;153728;154720;172352;</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>6</th>\n", | |
" <td>6720</td>\n", | |
" <td>157088;156609;153345;153600;154309;167582;1719...</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td>154339;</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>7</th>\n", | |
" <td>6721</td>\n", | |
" <td>156704;</td>\n", | |
" <td>154301;154333;</td>\n", | |
" <td>157984;155712;</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td>154343;</td>\n", | |
" <td></td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" Validator index Skip \\\n", | |
"0 6686 157088;152864;153248;165025;165376; \n", | |
"1 6687 157921;165890;166144; \n", | |
"2 6690 158016;154304;169312;169952;171296;166368;1685... \n", | |
"3 6717 153185;169216; \n", | |
"4 6718 169952;172416;168641; \n", | |
"5 6719 157696;154336;170208;171744;172642; \n", | |
"6 6720 157088;156609;153345;153600;154309;167582;1719... \n", | |
"7 6721 156704; \n", | |
"\n", | |
" Orphan Missed gossip \\\n", | |
"0 156992;153408;169600;166432;168320; \n", | |
"1 157888;156992;156928;168320;169313; \n", | |
"2 154336; 153376;153792;166176;166240;168736; \n", | |
"3 154323; 158176;158080;156832;156161;152608; \n", | |
"4 154323; 158080;157888;156576;168320;170176;167040; \n", | |
"5 154321; 157600;153728;154720;172352; \n", | |
"6 \n", | |
"7 154301;154333; 157984;155712; \n", | |
"\n", | |
" Propagation \\\n", | |
"0 152896;154321;168384;165988;166094;166623; \n", | |
"1 165770; \n", | |
"2 166615;166749; \n", | |
"3 166886; \n", | |
"4 \n", | |
"5 \n", | |
"6 \n", | |
"7 \n", | |
"\n", | |
" Got in time but vc voted for previous Double vote Invalid local signature \n", | |
"0 \n", | |
"1 166880; \n", | |
"2 \n", | |
"3 \n", | |
"4 154365; \n", | |
"5 \n", | |
"6 154339; \n", | |
"7 154343; " | |
] | |
}, | |
"execution_count": 85, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"df = pd.read_csv(\"attestation_data.csv\")\n", | |
"df = df.fillna('')\n", | |
"df" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 86, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style scoped>\n", | |
" .dataframe tbody tr th:only-of-type {\n", | |
" vertical-align: middle;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>Validator index</th>\n", | |
" <th>Skip</th>\n", | |
" <th>Orphan</th>\n", | |
" <th>Missed gossip</th>\n", | |
" <th>Propagation</th>\n", | |
" <th>Got in time but vc voted for previous</th>\n", | |
" <th>Double vote</th>\n", | |
" <th>Invalid local signature</th>\n", | |
" <th>all</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>6686</td>\n", | |
" <td>[157088, 152864, 153248, 165025, 165376]</td>\n", | |
" <td></td>\n", | |
" <td>[156992, 153408, 169600, 166432, 168320]</td>\n", | |
" <td>[152896, 154321, 168384, 165988, 166094, 166623]</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td>[157088, 152864, 153248, 165025, 165376, 15699...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>6687</td>\n", | |
" <td>[157921, 165890, 166144]</td>\n", | |
" <td></td>\n", | |
" <td>[157888, 156992, 156928, 168320, 169313]</td>\n", | |
" <td>[165770]</td>\n", | |
" <td>[166880]</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td>[157921, 165890, 166144, 157888, 156992, 15692...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>6690</td>\n", | |
" <td>[158016, 154304, 169312, 169952, 171296, 16636...</td>\n", | |
" <td>[154336]</td>\n", | |
" <td>[153376, 153792, 166176, 166240, 168736]</td>\n", | |
" <td>[166615, 166749]</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td>[158016, 154304, 169312, 169952, 171296, 16636...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>6717</td>\n", | |
" <td>[153185, 169216]</td>\n", | |
" <td>[154323]</td>\n", | |
" <td>[158176, 158080, 156832, 156161, 152608]</td>\n", | |
" <td>[166886]</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td>[153185, 169216, 154323, 158176, 158080, 15683...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>6718</td>\n", | |
" <td>[169952, 172416, 168641]</td>\n", | |
" <td>[154323]</td>\n", | |
" <td>[158080, 157888, 156576, 168320, 170176, 167040]</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td>[154365]</td>\n", | |
" <td></td>\n", | |
" <td>[169952, 172416, 168641, 154323, 158080, 15788...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>5</th>\n", | |
" <td>6719</td>\n", | |
" <td>[157696, 154336, 170208, 171744, 172642]</td>\n", | |
" <td>[154321]</td>\n", | |
" <td>[157600, 153728, 154720, 172352]</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td>[157696, 154336, 170208, 171744, 172642, 15432...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>6</th>\n", | |
" <td>6720</td>\n", | |
" <td>[157088, 156609, 153345, 153600, 154309, 16758...</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td>[154339]</td>\n", | |
" <td>[157088, 156609, 153345, 153600, 154309, 16758...</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>7</th>\n", | |
" <td>6721</td>\n", | |
" <td>[156704]</td>\n", | |
" <td>[154301, 154333]</td>\n", | |
" <td>[157984, 155712]</td>\n", | |
" <td></td>\n", | |
" <td></td>\n", | |
" <td>[154343]</td>\n", | |
" <td></td>\n", | |
" <td>[156704, 154301, 154333, 157984, 155712, 154343]</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" Validator index Skip \\\n", | |
"0 6686 [157088, 152864, 153248, 165025, 165376] \n", | |
"1 6687 [157921, 165890, 166144] \n", | |
"2 6690 [158016, 154304, 169312, 169952, 171296, 16636... \n", | |
"3 6717 [153185, 169216] \n", | |
"4 6718 [169952, 172416, 168641] \n", | |
"5 6719 [157696, 154336, 170208, 171744, 172642] \n", | |
"6 6720 [157088, 156609, 153345, 153600, 154309, 16758... \n", | |
"7 6721 [156704] \n", | |
"\n", | |
" Orphan Missed gossip \\\n", | |
"0 [156992, 153408, 169600, 166432, 168320] \n", | |
"1 [157888, 156992, 156928, 168320, 169313] \n", | |
"2 [154336] [153376, 153792, 166176, 166240, 168736] \n", | |
"3 [154323] [158176, 158080, 156832, 156161, 152608] \n", | |
"4 [154323] [158080, 157888, 156576, 168320, 170176, 167040] \n", | |
"5 [154321] [157600, 153728, 154720, 172352] \n", | |
"6 \n", | |
"7 [154301, 154333] [157984, 155712] \n", | |
"\n", | |
" Propagation \\\n", | |
"0 [152896, 154321, 168384, 165988, 166094, 166623] \n", | |
"1 [165770] \n", | |
"2 [166615, 166749] \n", | |
"3 [166886] \n", | |
"4 \n", | |
"5 \n", | |
"6 \n", | |
"7 \n", | |
"\n", | |
" Got in time but vc voted for previous Double vote Invalid local signature \\\n", | |
"0 \n", | |
"1 [166880] \n", | |
"2 \n", | |
"3 \n", | |
"4 [154365] \n", | |
"5 \n", | |
"6 [154339] \n", | |
"7 [154343] \n", | |
"\n", | |
" all \n", | |
"0 [157088, 152864, 153248, 165025, 165376, 15699... \n", | |
"1 [157921, 165890, 166144, 157888, 156992, 15692... \n", | |
"2 [158016, 154304, 169312, 169952, 171296, 16636... \n", | |
"3 [153185, 169216, 154323, 158176, 158080, 15683... \n", | |
"4 [169952, 172416, 168641, 154323, 158080, 15788... \n", | |
"5 [157696, 154336, 170208, 171744, 172642, 15432... \n", | |
"6 [157088, 156609, 153345, 153600, 154309, 16758... \n", | |
"7 [156704, 154301, 154333, 157984, 155712, 154343] " | |
] | |
}, | |
"execution_count": 86, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"def to_list(x):\n", | |
" try:\n", | |
" return list(map(int, x[:-1].split(';')))\n", | |
" except:\n", | |
" return x\n", | |
"\n", | |
"df['all'] = df.iloc[:,1:].sum(axis=1)\n", | |
"df['all'] = df['all'].apply(lambda x: list(map(int, str(x).split(';')[:-1])))\n", | |
"\n", | |
"# The slot to be attested at was a skip slot. We voted for the previous non skip slot block\n", | |
"df['Skip'] = df['Skip'].apply(to_list)\n", | |
"# The block we voted for was orphaned.\n", | |
"df['Orphan'] = df['Orphan'].apply(to_list)\n", | |
"# We got the block for the slot after 1/4th of the slot had passed.\n", | |
"df['Missed gossip'] = df['Missed gossip'].apply(to_list)\n", | |
"# Voted for the right block still missed the attestation. Probably bad gossip peers.\n", | |
"df['Propagation'] = df['Propagation'].apply(to_list)\n", | |
"# Got the block before 1/4th of a slot passed, still voted for previous block.\n", | |
"df['Got in time but vc voted for previous'] = df['Got in time but vc voted for previous'].apply(to_list)\n", | |
"# Slashable attestation. Didn't vote\n", | |
"df['Double vote'] = df['Double vote'].apply(to_list)\n", | |
"# BN failed with invalid local signature\n", | |
"df['Invalid local signature'] = df['Invalid local signature'].apply(to_list)\n", | |
"df['all'] = df['all'].apply(to_list)\n", | |
"df" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 90, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Min slot 152608\n", | |
"Max slot 172642\n", | |
"Range 20034\n" | |
] | |
} | |
], | |
"source": [ | |
"all_slots = list()\n", | |
"for slots in df['all']:\n", | |
" all_slots.extend(slots)\n", | |
"\n", | |
"print(\"Min slot\", min(all_slots))\n", | |
"print(\"Max slot\", max(all_slots))\n", | |
"print(\"Range\", max(all_slots) - min(all_slots))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 91, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Miss type: Skip\n", | |
"Distribution {0: 25, 1: 6, 2: 2, 5: 1, 30: 1}\n", | |
"Number of unique missed slots 33\n", | |
"Number of missed slots 35\n", | |
"\n", | |
"\n", | |
"Miss type: Orphan\n", | |
"Distribution {0: 1, 19: 2, 17: 1, 29: 2}\n", | |
"Number of unique missed slots 5\n", | |
"Number of missed slots 6\n", | |
"\n", | |
"\n", | |
"Miss type: Missed gossip\n", | |
"Distribution {0: 30, 1: 2}\n", | |
"Number of unique missed slots 27\n", | |
"Number of missed slots 32\n", | |
"\n", | |
"\n", | |
"Miss type: Propagation\n", | |
"Distribution {0: 2, 17: 1, 4: 1, 14: 1, 31: 1, 10: 1, 23: 1, 29: 1, 6: 1}\n", | |
"Number of unique missed slots 10\n", | |
"Number of missed slots 10\n", | |
"\n", | |
"\n", | |
"Miss type: all\n", | |
"Distribution {0: 59, 1: 8, 17: 2, 4: 1, 14: 1, 31: 1, 2: 2, 10: 1, 23: 1, 29: 4, 19: 2, 6: 1, 5: 1, 30: 1, 3: 1, 7: 1}\n", | |
"Number of unique missed slots 77\n", | |
"Number of missed slots 87\n", | |
"\n", | |
"\n" | |
] | |
} | |
], | |
"source": [ | |
"# Get distribution of missed attestations over slot number in epoch.\n", | |
"# e.g. {0: 10} indicates that there are 10 missed attestations for the given key type at slot 0 in an epoch \n", | |
"def distribution(key): \n", | |
" all_slots = list()\n", | |
" for slots in df[key]:\n", | |
" all_slots.extend(slots)\n", | |
" d = dict()\n", | |
" for slot in all_slots:\n", | |
" try:\n", | |
" d[slot % 32] +=1\n", | |
" except:\n", | |
" d[slot % 32] = 1\n", | |
" print(\"Miss type: \", key)\n", | |
" print(\"Distribution\", d)\n", | |
" print(\"Number of unique missed slots\",len(set(all_slots)))\n", | |
" print(\"Number of missed slots\", len(all_slots))\n", | |
" print('\\n')\n", | |
"\n", | |
"distribution('Skip')\n", | |
"distribution('Orphan')\n", | |
"distribution('Missed gossip')\n", | |
"distribution('Propagation')\n", | |
"distribution('all')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "projectname", | |
"language": "python", | |
"name": "projectname" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.9" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validator index | Skip | Orphan | Missed gossip | Propagation | Got in time but vc voted for previous | Double vote | Invalid local signature | |
---|---|---|---|---|---|---|---|---|
6686 | 157088;152864;153248;165025;165376; | 156992;153408;169600;166432;168320; | 152896;154321;168384;165988;166094;166623; | |||||
6687 | 157921;165890;166144; | 157888;156992;156928;168320;169313; | 165770; | 166880; | ||||
6690 | 158016;154304;169312;169952;171296;166368;168576;168640; | 154336; | 153376;153792;166176;166240;168736; | 166615;166749; | ||||
6717 | 153185;169216; | 154323; | 158176;158080;156832;156161;152608; | 166886; | ||||
6718 | 169952;172416;168641; | 154323; | 158080;157888;156576;168320;170176;167040; | 154365; | ||||
6719 | 157696;154336;170208;171744;172642; | 154321; | 157600;153728;154720;172352; | |||||
6720 | 157088;156609;153345;153600;154309;167582;171936;172544; | 154339; | ||||||
6721 | 156704; | 154301;154333; | 157984;155712; | 154343; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment