Verifying computation analysis

Code available here.


In [1]:
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
from statistics import mean, stdev, variance, median
import csv

mpl.rcParams['figure.dpi'] = 300
mpl.rcParams['savefig.dpi'] = 300
mpl.rcParams['axes.titlesize'] = "small"
mpl.rcParams['axes.labelsize'] = "large"

Load data


In [2]:
# 30 percent cheaters
w, h = 1000, 6
time30 = [[0 for x in range(100)] for y in range(h)]
status30 = [[0 for x in range(w)] for y in range(h)]
solver30 = [[0 for x in range(w)] for y in range(h)]
gasUsed30 = [[0 for x in range(w)] for y in range(h)]

with open('../data/30_percent_cheaters_1000.csv', 'rb') as csvfile:
    experiment30 = csv.DictReader(csvfile)
    for row in experiment30:
        status30[int(row['Verifiers'])-1][int(row['Run'])] = int(row['Status'])
        solver30[int(row['Verifiers'])-1][int(row['Run'])] = (row['Solver'])
        gasUsed30[int(row['Verifiers'])-1][int(row['Run'])] = int(row['Gas'])

with open('../data/30_percent_cheaters.csv', 'rb') as csvfile:
    experiment30 = csv.DictReader(csvfile)
    for row in experiment30:
        time30[int(row['Verifiers'])-1][int(row['Run'])] = float(row['Time'])
        
# 50 percent cheaters
time50 = [[0 for x in range(100)] for y in range(h)]
status50 = [[0 for x in range(w)] for y in range(h)]
solver50 = [[0 for x in range(w)] for y in range(h)]
gasUsed50 = [[0 for x in range(w)] for y in range(h)]

with open('../data/50_percent_cheaters_1000.csv', 'rb') as csvfile:
    experiment50 = csv.DictReader(csvfile)
    for row in experiment50:
        status50[int(row['Verifiers'])-1][int(row['Run'])] = int(row['Status'])
        solver50[int(row['Verifiers'])-1][int(row['Run'])] = (row['Solver'])
        gasUsed50[int(row['Verifiers'])-1][int(row['Run'])] = int(row['Gas'])

with open('../data/50_percent_cheaters.csv', 'rb') as csvfile:
    experiment50 = csv.DictReader(csvfile)
    for row in experiment50:
        time50[int(row['Verifiers'])-1][int(row['Run'])] = float(row['Time'])
        
# 70 percent cheaters
time70 = [[0 for x in range(100)] for y in range(h)]
status70 = [[0 for x in range(w)] for y in range(h)]
solver70 = [[0 for x in range(w)] for y in range(h)]
gasUsed70 = [[0 for x in range(w)] for y in range(h)]

with open('../data/70_percent_cheaters_1000.csv', 'rb') as csvfile:
    experiment70 = csv.DictReader(csvfile)
    for row in experiment70:
        status70[int(row['Verifiers'])-1][int(row['Run'])] = int(row['Status'])
        solver70[int(row['Verifiers'])-1][int(row['Run'])] = (row['Solver'])
        gasUsed70[int(row['Verifiers'])-1][int(row['Run'])] = int(row['Gas'])
        
with open('../data/70_percent_cheaters.csv', 'rb') as csvfile:
    experiment70 = csv.DictReader(csvfile)
    for row in experiment70:
        time70[int(row['Verifiers'])-1][int(row['Run'])] = float(row['Time'])

Time in relation to number of verifiers


In [3]:
# 30 percent cheaters
fig, axes = plt.subplots()

axes.boxplot(time30)

xlabels = ['1', '2', '3', '4', '5', '6']

axes.yaxis.grid(True)
axes.set_xticks([y for y in range(len(time30))])
axes.set_xlabel('Number of verifiers')
axes.set_ylabel('Time to complete computation in ms')
plt.setp(axes, xticks=[y+1 for y in range(len(time30))],
         xticklabels=xlabels)
plt.xticks()
# plt.ylim(0, 5000)
plt.show()


# 50 percent cheaters
fig, axes = plt.subplots()

axes.boxplot(time50)

xlabels = ['1', '2', '3', '4', '5', '6']

axes.yaxis.grid(True)
axes.set_xticks([y for y in range(len(time50))])
axes.set_xlabel('Number of verifiers')
axes.set_ylabel('Time to complete computation in ms')
plt.setp(axes, xticks=[y+1 for y in range(len(time50))],
         xticklabels=xlabels)
plt.xticks()
# plt.ylim(0, 5000)
plt.show()

# 70 percent cheaters
fig, axes = plt.subplots()

axes.boxplot(time70)

xlabels = ['1', '2', '3', '4', '5', '6']

axes.yaxis.grid(True)
axes.set_xticks([y for y in range(len(time70))])
axes.set_xlabel('Number of verifiers')
axes.set_ylabel('Time to complete computation in ms')
plt.setp(axes, xticks=[y+1 for y in range(len(time70))],
         xticklabels=xlabels)
plt.xticks()
# plt.ylim(0, 5000)
plt.show()



In [4]:
# 30 percent cheaters
i = 0
for item in time30:
    print xlabels[i]
    print "Mean: {}".format(mean(item))
    print "Median: {}".format(median(item))
    print "Min: {}".format(min(item))
    print "Max: {}".format(max(item))
    print "Standard deviation: {}".format(stdev(item))
    print "Variance: {}".format(variance(item))
    print "Outer 90 percentile: {}".format(np.percentile(item,90))
    print "Outer 95 percentile: {}".format(np.percentile(item,95))
    print "Outer 99 percentile: {}".format(np.percentile(item,99))
    print "-------------"
    i += 1
    
# 50 percent cheaters
i = 0
for item in time50:
    print xlabels[i]
    print "Mean: {}".format(mean(item))
    print "Median: {}".format(median(item))
    print "Min: {}".format(min(item))
    print "Max: {}".format(max(item))
    print "Standard deviation: {}".format(stdev(item))
    print "Variance: {}".format(variance(item))
    print "Outer 90 percentile: {}".format(np.percentile(item,90))
    print "Outer 95 percentile: {}".format(np.percentile(item,95))
    print "Outer 99 percentile: {}".format(np.percentile(item,99))
    print "-------------"
    i += 1
    
# 70 percent cheaters
i = 0
for item in time70:
    print xlabels[i]
    print "Mean: {}".format(mean(item))
    print "Median: {}".format(median(item))
    print "Min: {}".format(min(item))
    print "Max: {}".format(max(item))
    print "Standard deviation: {}".format(stdev(item))
    print "Variance: {}".format(variance(item))
    print "Outer 90 percentile: {}".format(np.percentile(item,90))
    print "Outer 95 percentile: {}".format(np.percentile(item,95))
    print "Outer 99 percentile: {}".format(np.percentile(item,99))
    print "-------------"
    i += 1


1
Mean: 1071.32197798
Median: 1024.2570695
Min: 850.550013959
Max: 2032.68578303
Standard deviation: 212.363788658
Variance: 45098.3787333
Outer 90 percentile: 1375.93305767
Outer 95 percentile: 1486.12594191
Outer 99 percentile: 1811.01902417
-------------
2
Mean: 1403.753044
Median: 1344.97342604
Min: 1089.63497096
Max: 2310.163697
Standard deviation: 221.423214753
Variance: 49028.2400318
Outer 90 percentile: 1705.51038409
Outer 95 percentile: 1906.45367065
Outer 99 percentile: 2009.25142788
-------------
3
Mean: 1723.88329272
Median: 1685.6609675
Min: 1323.27491999
Max: 2443.53679299
Standard deviation: 246.87382731
Variance: 60946.6866106
Outer 90 percentile: 2099.31586381
Outer 95 percentile: 2251.68027916
Outer 99 percentile: 2393.99742765
-------------
4
Mean: 2068.95754443
Median: 1999.30307901
Min: 1611.52153897
Max: 2875.42082
Standard deviation: 261.949950364
Variance: 68617.7764958
Outer 90 percentile: 2401.01814113
Outer 95 percentile: 2599.95841455
Outer 99 percentile: 2720.51685752
-------------
5
Mean: 2302.96195298
Median: 2236.81763452
Min: 1828.17157596
Max: 3177.448497
Standard deviation: 297.344583262
Variance: 88413.8011955
Outer 90 percentile: 2749.39190699
Outer 95 percentile: 2897.33141818
Outer 99 percentile: 3120.50349904
-------------
6
Mean: 2617.68528184
Median: 2544.91258204
Min: 2203.39230597
Max: 3494.16062701
Standard deviation: 280.046831918
Variance: 78426.2280672
Outer 90 percentile: 2957.56852586
Outer 95 percentile: 3206.08284589
Outer 99 percentile: 3463.56825585
-------------
1
Mean: 1211.23976405
Median: 1169.664386
Min: 0
Max: 2184.44194502
Standard deviation: 283.295190732
Variance: 80256.1650917
Outer 90 percentile: 1474.0594228
Outer 95 percentile: 1944.89773836
Outer 99 percentile: 2149.92011535
-------------
2
Mean: 1630.07847818
Median: 1532.18026599
Min: 1193.68460602
Max: 3133.64589798
Standard deviation: 339.92722696
Variance: 115550.519629
Outer 90 percentile: 2228.19901393
Outer 95 percentile: 2325.17244614
Outer 99 percentile: 2824.34371542
-------------
3
Mean: 1956.15604395
Median: 1889.53628397
Min: 1607.523974
Max: 2964.18066299
Standard deviation: 261.131984069
Variance: 68189.9131039
Outer 90 percentile: 2351.1725699
Outer 95 percentile: 2606.59083903
Outer 99 percentile: 2756.36836712
-------------
4
Mean: 2311.82761494
Median: 2234.21496701
Min: 1933.894234
Max: 3442.39376098
Standard deviation: 283.747337781
Variance: 80512.5516979
Outer 90 percentile: 2667.65329478
Outer 95 percentile: 3024.88391546
Outer 99 percentile: 3201.81057716
-------------
5
Mean: 2684.92339916
Median: 2598.40059
Min: 2301.849262
Max: 4006.55215901
Standard deviation: 309.403972831
Variance: 95730.8184037
Outer 90 percentile: 3180.0040512
Outer 95 percentile: 3367.54872037
Outer 99 percentile: 3510.32170287
-------------
6
Mean: 3135.66009782
Median: 2979.33417353
Min: 2699.74543804
Max: 4576.53912896
Standard deviation: 386.54409336
Variance: 149416.336111
Outer 90 percentile: 3680.36661359
Outer 95 percentile: 3835.10519271
Outer 99 percentile: 4459.35674937
-------------
1
Mean: 994.14568629
Median: 971.117536008
Min: 725.622087002
Max: 1423.96622795
Standard deviation: 149.091159059
Variance: 22228.1737095
Outer 90 percentile: 1196.96374258
Outer 95 percentile: 1283.81589977
Outer 99 percentile: 1330.06108479
-------------
2
Mean: 1299.0236632
Median: 1277.24406102
Min: 1020.962345
Max: 1848.36488098
Standard deviation: 156.203438742
Variance: 24399.5142748
Outer 90 percentile: 1505.67262527
Outer 95 percentile: 1590.1146369
Outer 99 percentile: 1753.38577
-------------
3
Mean: 1553.78685054
Median: 1541.29627851
Min: 1259.83259201
Max: 2015.43742198
Standard deviation: 142.735627206
Variance: 20373.4592739
Outer 90 percentile: 1738.2965448
Outer 95 percentile: 1839.94030765
Outer 99 percentile: 1931.04436609
-------------
4
Mean: 1878.13317852
Median: 1834.237198
Min: 1485.86119998
Max: 2744.73144197
Standard deviation: 195.240352372
Variance: 38118.7951944
Outer 90 percentile: 2101.33671948
Outer 95 percentile: 2222.17991796
Outer 99 percentile: 2419.94686137
-------------
5
Mean: 2134.08163601
Median: 2107.17438403
Min: 1695.85065699
Max: 3099.620812
Standard deviation: 197.024762854
Variance: 38818.7571775
Outer 90 percentile: 2353.95977763
Outer 95 percentile: 2483.57371312
Outer 99 percentile: 2748.42202848
-------------
6
Mean: 2445.2386591
Median: 2394.05132201
Min: 2076.99915898
Max: 3063.30215597
Standard deviation: 214.435087494
Variance: 45982.4067485
Outer 90 percentile: 2733.32229816
Outer 95 percentile: 2822.13177539
Outer 99 percentile: 2980.93905747
-------------

Gas used in relation to number of verifiers


In [5]:
# 30 percent cheaters
fig, axes = plt.subplots()

axes.boxplot(gasUsed30)

xlabels = ['1', '2', '3', '4', '5', '6']

axes.yaxis.grid(True)
axes.set_xticks([y for y in range(len(gasUsed30))])
axes.set_xlabel('Number of verifiers')
axes.set_ylabel('Total gas consumed')
plt.setp(axes, xticks=[y+1 for y in range(len(gasUsed30))],
         xticklabels=xlabels)
plt.xticks()
plt.ylim(0, 1600000)
plt.show()

# 50 percent cheaters
fig, axes = plt.subplots()

axes.boxplot(gasUsed50)

xlabels = ['1', '2', '3', '4', '5', '6']

axes.yaxis.grid(True)
axes.set_xticks([y for y in range(len(gasUsed50))])
axes.set_xlabel('Number of verifiers')
axes.set_ylabel('Total gas consumed')
plt.setp(axes, xticks=[y+1 for y in range(len(gasUsed50))],
         xticklabels=xlabels)
plt.xticks()
plt.ylim(0, 1600000)
plt.show()

# 70 percent cheaters
fig, axes = plt.subplots()

axes.boxplot(gasUsed70)

xlabels = ['1', '2', '3', '4', '5', '6']

axes.yaxis.grid(True)
axes.set_xticks([y for y in range(len(gasUsed70))])
axes.set_xlabel('Number of verifiers')
axes.set_ylabel('Total gas consumed')
plt.setp(axes, xticks=[y+1 for y in range(len(gasUsed70))],
         xticklabels=xlabels)
plt.xticks()
plt.ylim(0, 1600000)
plt.show()



In [6]:
# 30 percent cheaters
i = 0
for item in gasUsed30:
    print xlabels[i]
    print "Mean: {}".format(mean(item))
    print "Median: {}".format(median(item))
    print "Min: {}".format(min(item))
    print "Max: {}".format(max(item))
    print "Standard deviation: {}".format(stdev(item))
    print "Variance: {}".format(variance(item))
    print "Outer 90 percentile: {}".format(np.percentile(item,90))
    print "Outer 95 percentile: {}".format(np.percentile(item,95))
    print "Outer 99 percentile: {}".format(np.percentile(item,99))
    print "-------------"
    i += 1
    
# 50 percent cheaters
i = 0
for item in gasUsed50:
    print xlabels[i]
    print "Mean: {}".format(mean(item))
    print "Median: {}".format(median(item))
    print "Min: {}".format(min(item))
    print "Max: {}".format(max(item))
    print "Standard deviation: {}".format(stdev(item))
    print "Variance: {}".format(variance(item))
    print "Outer 90 percentile: {}".format(np.percentile(item,90))
    print "Outer 95 percentile: {}".format(np.percentile(item,95))
    print "Outer 99 percentile: {}".format(np.percentile(item,99))
    print "-------------"
    i += 1
    
# 70 percent cheaters
i = 0
for item in gasUsed70:
    print xlabels[i]
    print "Mean: {}".format(mean(item))
    print "Median: {}".format(median(item))
    print "Min: {}".format(min(item))
    print "Max: {}".format(max(item))
    print "Standard deviation: {}".format(stdev(item))
    print "Variance: {}".format(variance(item))
    print "Outer 90 percentile: {}".format(np.percentile(item,90))
    print "Outer 95 percentile: {}".format(np.percentile(item,95))
    print "Outer 99 percentile: {}".format(np.percentile(item,99))
    print "-------------"
    i += 1


1
Mean: 542832.746
Median: 524737.0
Min: 521945
Max: 572014
Standard deviation: 23024.7976581
Variance: 530141307.199
Outer 90 percentile: 571472.0
Outer 95 percentile: 571707.0
Outer 99 percentile: 572014.0
-------------
2
Mean: 732708.41
Median: 750206.0
Min: 701992
Max: 761369
Standard deviation: 24899.6532488
Variance: 619992731.91
Outer 90 percentile: 759869.9
Outer 95 percentile: 760456.0
Outer 99 percentile: 760917.0
-------------
3
Mean: 920032.209
Median: 931337.0
Min: 881696
Max: 950940
Standard deviation: 25320.5672973
Variance: 641131128.26
Outer 90 percentile: 949132.0
Outer 95 percentile: 949801.0
Outer 99 percentile: 950488.0
-------------
4
Mean: 1109917.793
Median: 1112791.0
Min: 1062214
Max: 1141090
Standard deviation: 23997.8943023
Variance: 575898930.943
Outer 90 percentile: 1138830.0
Outer 95 percentile: 1139517.0
Outer 99 percentile: 1140638.09
-------------
5
Mean: 1297271.118
Median: 1295548.0
Min: 1243093
Max: 1331845
Standard deviation: 22333.6577427
Variance: 498792268.17
Outer 90 percentile: 1321094.0
Outer 95 percentile: 1330037.0
Outer 99 percentile: 1331158.0
-------------
6
Mean: 1483051.0
Median: 1482536.0
Min: 1424785
Max: 1522500
Standard deviation: 20640.144429
Variance: 426015562.05
Outer 90 percentile: 1511080.0
Outer 95 percentile: 1513416.55
Outer 99 percentile: 1521598.26
-------------
1
Mean: 549851.541
Median: 570342.0
Min: 522171
Max: 587213
Standard deviation: 23907.8489037
Variance: 571585239.204
Outer 90 percentile: 572448.0
Outer 95 percentile: 572900.0
Outer 99 percentile: 573135.0
-------------
2
Mean: 745528.115
Median: 751388.0
Min: 701284
Max: 762793
Standard deviation: 19813.6695918
Variance: 392581502.692
Outer 90 percentile: 760926.0
Outer 95 percentile: 761640.0
Outer 99 percentile: 762115.0
-------------
3
Mean: 935310.039
Median: 939764.0
Min: 881210
Max: 952360
Standard deviation: 13976.5115424
Variance: 195342874.894
Outer 90 percentile: 948467.6
Outer 95 percentile: 950045.05
Outer 99 percentile: 951455.0
-------------
4
Mean: 1122736.624
Median: 1121922.0
Min: 1062420
Max: 1141614
Standard deviation: 9637.09334399
Variance: 92873568.1207
Outer 90 percentile: 1131745.0
Outer 95 percentile: 1132667.65
Outer 99 percentile: 1140239.44
-------------
5
Mean: 1309629.405
Median: 1311076.0
Min: 1291148
Max: 1331205
Standard deviation: 6966.43828562
Variance: 48531262.3874
Outer 90 percentile: 1320471.9
Outer 95 percentile: 1321601.0
Outer 99 percentile: 1322974.0
-------------
6
Mean: 1496435.886
Median: 1494199.0
Min: 1481557
Max: 1513852
Standard deviation: 6452.97739732
Variance: 41640917.2903
Outer 90 percentile: 1503572.0
Outer 95 percentile: 1504474.1
Outer 99 percentile: 1512704.0
-------------
1
Mean: 548077.946
Median: 571020.0
Min: 521945
Max: 587195
Standard deviation: 24355.4729282
Variance: 593189061.557
Outer 90 percentile: 572448.0
Outer 95 percentile: 572647.0
Outer 99 percentile: 572918.0
-------------
2
Mean: 741494.666
Median: 751356.5
Min: 700606
Max: 762309
Standard deviation: 23251.4787196
Variance: 540631262.649
Outer 90 percentile: 761211.0
Outer 95 percentile: 761613.45
Outer 99 percentile: 762083.0
-------------
3
Mean: 931208.062
Median: 933510.0
Min: 879854
Max: 952332
Standard deviation: 19643.0619753
Variance: 385849883.764
Outer 90 percentile: 949639.0
Outer 95 percentile: 950335.0
Outer 99 percentile: 951629.53
-------------
4
Mean: 1119448.835
Median: 1121658.0
Min: 1059916
Max: 1140707
Standard deviation: 15821.7376069
Variance: 250327380.903
Outer 90 percentile: 1132221.3
Outer 95 percentile: 1139342.0
Outer 99 percentile: 1140472.09
-------------
5
Mean: 1306079.761
Median: 1303036.0
Min: 1240113
Max: 1331440
Standard deviation: 15581.0962591
Variance: 242770560.637
Outer 90 percentile: 1321855.1
Outer 95 percentile: 1322769.0
Outer 99 percentile: 1330093.0
-------------
6
Mean: 1492794.866
Median: 1493438.0
Min: 1470609
Max: 1521865
Standard deviation: 12613.266321
Variance: 159094487.285
Outer 90 percentile: 1511818.0
Outer 95 percentile: 1512722.0
Outer 99 percentile: 1519831.0
-------------

Percentage of accepted wrong results


In [7]:
# 30 percent cheaters
failedJudgeSolutionAccepted30 = [0 for y in range(6)]
failedJudgeSolutionDeclined30 = [0 for y in range(6)]
noSolution30 = [0 for y in range(6)]
wrongAnswerAccepted30 = [0 for y in range(6)]
correct30 = [0 for y in range(6)]


for x in range(h):
    for y in range(w):
        if (status30[x][y] == 901) and (solver30[x][y] == "false"):
            failedJudgeSolutionAccepted30[x] += 1
        elif (status30[x][y] == 902) and (solver30[x][y] == "true"):
            failedJudgeSolutionDeclined30[x] += 1
        elif (status30[x][y] == 902) and (solver30[x][y] == "false"):
            noSolution30[x] += 1
        elif (status30[x][y] == 500) and (solver30[x][y] == "false"):
            wrongAnswerAccepted30[x] += 1
        else:
            correct30[x] += 1

# 50 percent cheaters
failedJudgeSolutionAccepted50 = [0 for y in range(6)]
failedJudgeSolutionDeclined50 = [0 for y in range(6)]
noSolution50 = [0 for y in range(6)]
wrongAnswerAccepted50 = [0 for y in range(6)]
correct50 = [0 for y in range(6)]


for x in range(h):
    for y in range(w):
        if (status50[x][y] == 901) and (solver50[x][y] == "false"):
            failedJudgeSolutionAccepted50[x] += 1
        elif (status50[x][y] == 902) and (solver50[x][y] == "true"):
            failedJudgeSolutionDeclined50[x] += 1
        elif (status50[x][y] == 902) and (solver50[x][y] == "false"):
            noSolution50[x] += 1
        elif (status50[x][y] == 500) and (solver50[x][y] == "false"):
            wrongAnswerAccepted50[x] += 1
        else:
            correct50[x] += 1
            
# 70 percent cheaters
failedJudgeSolutionAccepted70 = [0 for y in range(6)]
failedJudgeSolutionDeclined70 = [0 for y in range(6)]
noSolution70 = [0 for y in range(6)]
wrongAnswerAccepted70 = [0 for y in range(6)]
correct70 = [0 for y in range(6)]


for x in range(h):
    for y in range(w):
        if (status70[x][y] == 901) and (solver70[x][y] == "false"):
            failedJudgeSolutionAccepted70[x] += 1
        elif (status70[x][y] == 902) and (solver70[x][y] == "true"):
            failedJudgeSolutionDeclined70[x] += 1
        elif (status70[x][y] == 902) and (solver70[x][y] == "false"):
            noSolution70[x] += 1
        elif (status70[x][y] == 500) and (solver70[x][y] == "false"):
            wrongAnswerAccepted70[x] += 1
        else:
            correct70[x] += 1

In [23]:
xlabels = ['1', '2', '3', '4', '5', '6']


indexes = np.arange(len(xlabels))
width = 0.8

# 30 percent cheaters
bottom1, bottom2, bottom3 = [], [], []
for i in range(6):
    bottom1.append(correct30[i] + wrongAnswerAccepted30[i])
for i in range(6):
    bottom2.append(bottom1[i] + noSolution30[i])
for i in range(6):
    bottom3.append(bottom2[i] +failedJudgeSolutionAccepted30[i])  

# the barchart of the data
# plt.figure(figsize=(10,7))
plt.bar(indexes, correct30, width, color='#81c784', label='Accepted correct solution')
plt.bar(indexes, wrongAnswerAccepted30, width, color='#c62828', bottom=correct30, label='Resolve dispute not triggered and accepted wrong solution')
plt.bar(indexes, noSolution30, width, color='#bdbdbd', bottom=bottom1, label='Resolve dispute triggered and denied wrong solution')
plt.bar(indexes, failedJudgeSolutionAccepted30, width, color='#7e57c2', bottom=bottom2, label='Resolve dispute triggered, but accepted wrong solution')
plt.bar(indexes, failedJudgeSolutionDeclined30, width, color='#42a5f5', bottom=bottom3, label='Resolve dispute triggered, but denied correct solution')


plt.xlabel('Number of verifiers')
plt.ylabel('Number of computations')
plt.xticks(indexes, xlabels)
# plt.legend(loc='upper center', bbox_to_anchor=(0.7, 0.2), fancybox=True, shadow=True)
plt.legend(loc='center left', bbox_to_anchor=(1.0, 0.83), fancybox=True, shadow=False)

plt.show()

# 50 percent cheaters
bottom1, bottom2, bottom3 = [], [], []
for i in range(6):
    bottom1.append(correct50[i] + wrongAnswerAccepted50[i])
for i in range(6):
    bottom2.append(bottom1[i] + noSolution50[i])
for i in range(6):
    bottom3.append(bottom2[i] +failedJudgeSolutionAccepted50[i])  

# the barchart of the data
# plt.figure(figsize=(10,7))
plt.bar(indexes, correct50, width, color='#81c784', label='Accepted correct solution')    
plt.bar(indexes, wrongAnswerAccepted50, width, color='#c62828', bottom=correct50, label='Resolve dispute not triggered and accepted wrong solution')
plt.bar(indexes, noSolution50, width, color='#bdbdbd', bottom=bottom1, label='Resolve dispute triggered and denied wrong solution')
plt.bar(indexes, failedJudgeSolutionAccepted50, width, color='#7e57c2', bottom=bottom2,label='Resolve dispute triggered, but accepted wrong solution')
plt.bar(indexes, failedJudgeSolutionDeclined50, width, color='#42a5f5', bottom=bottom3, label='Resolve dispute triggered, but denied correct solution')


plt.xlabel('Number of verifiers')
plt.ylabel('Number of computations')
plt.xticks(indexes, xlabels)
# plt.legend(loc='upper center', bbox_to_anchor=(0.7, 0.2), fancybox=True, shadow=True)
plt.legend(loc='center left', bbox_to_anchor=(1.0, 0.83), fancybox=True, shadow=False)

plt.show()

# 70 percent cheaters
bottom1, bottom2, bottom3 = [], [], []
for i in range(6):
    bottom1.append(correct70[i] + wrongAnswerAccepted70[i])
for i in range(6):
    bottom2.append(bottom1[i] + noSolution70[i])
for i in range(6):
    bottom3.append(bottom2[i] +failedJudgeSolutionAccepted70[i])  

# the barchart of the data
# plt.figure(figsize=(10,7))
plt.bar(indexes, correct70, width, color='#81c784', label='Accepted correct solution')
plt.bar(indexes, wrongAnswerAccepted70, width, color='#c62828', bottom=correct70, label='Resolve dispute not triggered and accepted wrong solution')
plt.bar(indexes, noSolution70, width, color='#bdbdbd', bottom=bottom1, label='Resolve dispute triggered and denied wrong solution')
plt.bar(indexes, failedJudgeSolutionAccepted70, width, color='#7e57c2', bottom=bottom2,label='Resolve dispute triggered, but accepted wrong solution')
plt.bar(indexes, failedJudgeSolutionDeclined70, width, color='#42a5f5', bottom=bottom3, label='Resolve dispute triggered, but denied correct solution')


plt.xlabel('Number of verifiers')
plt.ylabel('Number of computations')
plt.xticks(indexes, xlabels)
# plt.legend(loc='upper center', bbox_to_anchor=(0.7, 0.2), fancybox=True, shadow=True)
plt.legend(loc='center left', bbox_to_anchor=(1.0, 0.83), fancybox=True, shadow=False)

plt.show()