Last active
May 9, 2023 14:03
-
-
Save michaelneuder/85a3e2bc7f1ec3e61aa90d5e01a6dbdf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
## sed | |
remove spaces | |
sed -e 's/ //g' last4hrs.csv > out.csv; mv out.csv last4hrs.csv | |
remove last line | |
sed -i '' -e '$ d' out.csv | |
remove first line | |
sed '1d' file.txt > tmpfile; mv tmpfile file.txt | |
## awk | |
remove every other line | |
awk 'FNR%2' < missed2.txt > tmp; mv tmp missed2.txt | |
## alchemy | |
curl https://eth-mainnet.g.alchemy.com/v2/cnHeH_ifD-29lrdBoGTMISiDgmrF9ZBz -X POST -H | |
"Content-Type: application/json" -s -d '[{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0xfb86ba",false],"id":0},{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0xfb86bb",false],"id":0}]' | |
| jq -jr '.[] | .result["number"], " ", .result["hash"], "\n"' > feb263.txt | |
## python | |
read ts and round | |
dlvd = pd.read_csv('apr12-payloads.txt', delimiter='|', names=['slot','block_hash','proposer_pubkey','inserted_at']) | |
dlvd['inserted_at'] = pd.to_datetime(dlvd['inserted_at'], format="%Y-%m-%d%H:%M:%S.%f") | |
jnd['boundary'] = pd.to_datetime(1606824023 + jnd['slot'] * 12, unit='s') | |
unix seconds | |
bns['time'] = pd.to_datetime(bns['time'],unit='s') | |
## crypto | |
genesis 1606824023 | |
## percentiles | |
f, ax = plt.subplots(figsize=(8,5)) | |
percs = [(int(i*100), np.quantile(total_plt/int(1e9), i)) for i in [.50, .90, .99]] | |
ax.hist(total_plt/int(1e9), bins=1000, color='g', alpha=0.5, cumulative=1, density=True, label='cdf') | |
linestyle = ['-', '--', ':'] | |
for i, v in enumerate(percs): | |
ax.axvline(v[1], label='p{}={:0.3f}'.format(v[0], v[1]), color='k', linestyle=linestyle[i], linewidth=3, alpha=0.7) | |
ax.set_xlim(0,60) | |
ax.set_xlabel('utility (gwei/$\mu s$)', size=16) | |
ax.set_title('marginal utility of time; $\mu={:0.0f}$ gwei$/\mu s$'.format(total_plt.mean()/int(1e9)), size=18) | |
plt.legend(loc=4) | |
plt.show() | |
## sort index and drop | |
getPayloads = getPayloads.sort_values(['slot', 'reqTime'], ascending=[True, True]) | |
getPayloads = getPayloads.drop_duplicates(['slot']) | |
getPayloads.reset_index(drop=True) | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import json | |
import requests | |
import time | |
import tqdm | |
from datetime import datetime | |
plt.rcParams['axes.grid'] = True | |
plt.rcParams['grid.alpha'] = 0.3 | |
plt.rcParams['axes.titlesize'] = 18 | |
genesis = 1606824023 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment