-
Notifications
You must be signed in to change notification settings - Fork 11
/
stat_Block.py
178 lines (154 loc) · 6 KB
/
stat_Block.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
import zipfile
fileDir = "./"
files = [
"0to999999_Block",
"1000000to1999999_Block",
"2000000to2999999_Block",
"3000000to3999999_Block",
"4000000to4999999_Block",
"5000000to5999999_Block",
"6000000to6999999_Block",
"7000000to7999999_Block",
"8000000to8999999_Block",
"9000000to9999999_Block",
"10000000to10999999_Block",
"11000000to11999999_Block",
"12000000to12999999_Block",
"13000000to13249999_Block",
"13250000to13499999_Block",
"13500000to13749999_Block",
"13750000to13999999_Block",
"14000000to14249999_Block",
"14250000to14499999_Block",
"14500000to14749999_Block",
"14750000to14999999_Block",
"15000000to15249999_Block",
"15250000to15499999_Block",
"15500000to15749999_Block",
"15750000to15999999_Block",
"16000000to16249999_Block",
"16250000to16499999_Block",
"16500000to16749999_Block",
"16750000to16999999_Block",
"17000000to17249999_Block",
"17250000to17499999_Block",
"17500000to17749999_Block",
"17750000to17999999_Block",
"18000000to18249999_Block",
"18250000to18499999_Block",
"18500000to18749999_Block",
"18750000to18999999_Block",
"19000000to19249999_Block",
"19250000to19499999_Block",
"19500000to19749999_Block",
"19750000to19999999_Block",
"20000000to20249999_Block",
"20250000to20499999_Block",
"20500000to20749999_Block",
"20750000to20999999_Block",
"21000000to21249999_Block"
]
def ToInt(str):
return None if str=="None" else int(str)
def ToFloat(str):
return None if str=="None" else float(str)
line_count1 = 0
tx_count = 0
total_burnt = 0
total_tips = 0
total_blobs = 0
line_count2 = 0
total_reward = 0
line_count3 = 0
total_withdrawal = 0
for file in files:
print(file)
theZIP = zipfile.ZipFile(fileDir+file+".zip", 'r')
# Info
theCSV = theZIP.open(file+"_Info.csv")
head = theCSV.readline()
oneLine = theCSV.readline().decode("utf-8").strip()
while (oneLine!=""):
oneArray = oneLine.split(",")
# blockNumber,timestamp,size,difficulty,transactionCount,internalTxCntSimple,internalTxCntAdvanced,erc20TxCnt,erc721TxCnt,minerAddress,minerExtra,gasLimit,gasUsed,minGasPrice,maxGasPrice,avgGasPrice,txFees,baseFeePerGas,burntFees,tipsFees,blobGasUsed,excessBlobGas,blobBaseFeePerGas,blobTxCnt,blobCnt
blockNumber = int(oneArray[0])
timestamp = int(oneArray[1])
size = int(oneArray[2])
difficulty = int(oneArray[3])
transactionCount = int(oneArray[4])
internalTxCntSimple = int(oneArray[5])
internalTxCntAdvanced = int(oneArray[6])
erc20TxCnt = int(oneArray[7])
erc721TxCnt = int(oneArray[8])
minerAddress = oneArray[9]
minerExtra = oneArray[10]
gasLimit = int(oneArray[11])
gasUsed = int(oneArray[12])
minGasPrice = ToInt(oneArray[13])
maxGasPrice = ToInt(oneArray[14])
avgGasPrice = ToFloat(oneArray[15])
txFees = ToInt(oneArray[16])
baseFeePerGas = ToInt(oneArray[17])
burntFees = ToInt(oneArray[18])
tipsFees = ToInt(oneArray[19])
if blockNumber >= 19426587:
blobGasUsed = int(oneArray[20])
excessBlobGas = int(oneArray[21])
blobBaseFeePerGas = int(oneArray[22])
blobTxCnt = int(oneArray[23])
blobCnt = int(oneArray[24])
tx_count += transactionCount
if blockNumber >= 12965000:
total_burnt += burntFees
total_tips += tipsFees
if blockNumber >= 19426587:
total_blobs += blobCnt
line_count1 += 1
oneLine = theCSV.readline().decode("utf-8").strip()
if line_count1 % 100000 == 0 :
print("Info", line_count1, tx_count)
theCSV.close()
# MinerReward
if blockNumber < 17000000:
theCSV = theZIP.open(file+"_MinerReward.csv")
head = theCSV.readline()
oneLine = theCSV.readline().decode("utf-8").strip()
while (oneLine!=""):
oneArray = oneLine.split(",")
# blockNumber,timestamp,miner,reward
blockNumber = int(oneArray[0])
timestamp = int(oneArray[1])
miner = oneArray[2]
reward = int(oneArray[3])
total_reward += reward
line_count2 += 1
oneLine = theCSV.readline().decode("utf-8").strip()
if line_count2 % 100000 == 0:
print("MinerReward", line_count2, total_reward/1e+18)
# Withdrawal
else:
theCSV = theZIP.open(file+"_Withdrawal.csv")
head = theCSV.readline()
oneLine = theCSV.readline().decode("utf-8").strip()
while (oneLine!=""):
oneArray = oneLine.split(",")
# blockNumber,timestamp,index,validatorIndex,recipient,value
blockNumber = int(oneArray[0])
timestamp = int(oneArray[1])
index = int(oneArray[2])
validatorIndex = int(oneArray[3])
recipient = oneArray[4]
value = int(oneArray[5])
total_withdrawal += value
line_count3 += 1
oneLine = theCSV.readline().decode("utf-8").strip()
if line_count3 % 100000 == 0:
print("Withdrawal", line_count3, total_withdrawal/1e+18)
print(oneLine, value/1e+18)
theCSV.close()
theZIP.close()
print("Info", line_count1, tx_count) # 21250000 2590496925
print("MinerReward", line_count2, total_reward/1e+18) # 16844112 50363872.71875
print("EIP1559", total_burnt/1e+18, total_tips/1e+18) # 4472365.948022883 890835.6210974426
print("Withdrawal", line_count3, total_withdrawal/1e+18) # 67440619 21354274.58305941
print("EIP4844", total_blobs) # 4072810