Last active
December 26, 2023 22:45
-
-
Save metachris/c455d93312853905e1d4110bd3ebea16 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
""" | |
Quick and dirty script to download the delivered payloads from relay data API and write into CSV file. | |
Relays: | |
https://boost-relay.flashbots.net | |
https://bloxroute.max-profit.blxrbdn.com | |
https://bloxroute.ethical.blxrbdn.com | |
https://bloxroute.regulated.blxrbdn.com | |
https://builder-relay-mainnet.blocknative.com | |
https://relay.edennetwork.io | |
https://mainnet-relay.securerpc.com | |
See also: | |
- https://github.com/dvush/check-relay-value | |
""" | |
import requests | |
import csv | |
import time | |
# timeout between calls to the relay (i.e. to avoid hitting rate limits) | |
timeout_sec = 0.5 | |
# define relay and csv filename | |
relay = "https://relay.edennetwork.io" | |
outfile = "eden.csv" | |
# csv writer setup | |
csvfile = open(outfile, 'w', newline='') | |
fieldnames = ["slot", "parent_hash", "block_hash", "builder_pubkey", | |
"proposer_pubkey", "proposer_fee_recipient", "gas_limit", "gas_used", "value"] | |
csvwriter = csv.DictWriter(csvfile, fieldnames) | |
csvwriter.writeheader() | |
# keeping track of already written slots | |
slots = {} | |
def get_delivered_payloads(cursor=None): | |
url = relay + "/relay/v1/data/bidtraces/proposer_payload_delivered" | |
if cursor: | |
url += "?cursor=" + str(cursor) | |
print(url) | |
response = requests.get(url) | |
entries = response.json() | |
slot_min = 0 | |
entries_new = 0 | |
for e in entries: | |
slot = e["slot"] | |
if slot not in slots: | |
slots[slot] = 1 | |
csvwriter.writerow(e) | |
entries_new += 1 | |
if slot_min == 0 or int(slot) < slot_min: | |
slot_min = int(slot) | |
return slot_min, entries_new | |
cursor = None | |
while True: | |
slot_min, entries_new = get_delivered_payloads(cursor) | |
print("lowest slot:", slot_min, "\t new entries:", entries_new) | |
cursor = slot_min | |
if entries_new == 0: | |
break | |
if timeout_sec > 0: | |
time.sleep(timeout_sec) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment