diff --git a/src/scrap_script.py b/src/scrap_script.py index d042926d5..a3cd705fa 100644 --- a/src/scrap_script.py +++ b/src/scrap_script.py @@ -9,11 +9,9 @@ ETHERSCAN_API_KEY = "9NF7PAGYH2AM8XHSXM96S1TJ7ZKVPP59YB" -SUBMIT_REPORT_DATA_SELECTOR = "0xfc7377cd" - # 🔹 Fetch the last 20 transactions of a contract -def get_transactions(contract_address): +def get_transactions(contract_address, selector): url = f"https://api.etherscan.io/api?module=account&action=txlist&address={contract_address}&sort=desc&apikey={ETHERSCAN_API_KEY}" response = requests.get(url) @@ -28,25 +26,27 @@ def get_transactions(contract_address): # 🔹 Filter only successful transactions successful_transactions = [tx for tx in transactions if tx.get("txreceipt_status") == "1"] - submit_report_calls = [tx for tx in successful_transactions if tx["input"].startswith(SUBMIT_REPORT_DATA_SELECTOR)][:30] + submit_report_calls = [tx for tx in successful_transactions if tx["input"].startswith(selector)][:30] return submit_report_calls -def extract_ref_slot(tx_data): +def extract_ref_slot(tx_data, type): # Remove function selector (first 10 characters "0x12345678") raw_data = tx_data[10:] raw_bytes = binascii.unhexlify(raw_data) - format = [ - "(uint256,uint256,uint256,uint256,uint256[],uint256[],uint256,uint256,uint256,uint256[],uint256,bool,uint256,bytes32,uint256)", - "uint256"] - - decoded_static_values = decode(format, raw_bytes) - - ref_slot = decoded_static_values[0][1] - return ref_slot + f = [] + if type == 'accounting': + f = [ + "(uint256,uint256,uint256,uint256,uint256[],uint256[],uint256,uint256,uint256,uint256[],uint256,bool,uint256,bytes32,uint256)", + "uint256"] + elif type == 'ejector': + f = ["(uint256,uint256,uint256,uint256,bytes)", "uint256"] + else: + f = ["(uint256,uint256,bytes32,string,string,uint256)", "uint256"] + return decode(f, raw_bytes) if __name__ == "__main__": @@ -63,7 +63,7 @@ def extract_ref_slot(tx_data): for tx in transactions: tx_hash = tx["hash"] - refslot = extract_ref_slot(tx["input"]) + refslot = extract_ref_slot(tx["input"], 'accounting') print(f"🔹 Tx: {tx_hash} → X: {refslot}") os.environ["ORACLE_REFSLOT"] = str(refslot) os.environ["DEAMON"] = str(False) @@ -71,19 +71,36 @@ def extract_ref_slot(tx_data): print(f"---ValidatorExitBusOracle---") ejector_address = "0x0De4Ea0184c2ad0BacA7183356Aea5B8d5Bf5c6e" + transactions = get_transactions(ejector_address, "0x294492c8") + if not transactions: + print("No submitReportData transactions found!") + sys.exit(0) - transactions = get_transactions(ejector_address) + print(f"✅ Found {len(transactions)} submitReportData calls") + for tx in transactions: + tx_hash = tx["hash"] + decoded_static_values = extract_ref_slot(tx["input"], 'ejector') + refslot = decoded_static_values[0][1] + print(f"🔹 Tx: {tx_hash} → X: {refslot}") + os.environ["ORACLE_REFSLOT"] = str(refslot) + os.environ["DEAMON"] = str(False) + print(decoded_static_values) + run_oracle('ejector') + print(f"---CSFeeOracle---") + csm_oracle_address = "0x4D4074628678Bd302921c20573EEa1ed38DdF7FB" + transactions = get_transactions(csm_oracle_address, "0xade4e312") if not transactions: print("No submitReportData transactions found!") sys.exit(0) print(f"✅ Found {len(transactions)} submitReportData calls") - for tx in transactions: tx_hash = tx["hash"] - refslot = extract_ref_slot(tx["input"]) + decoded_static_values = extract_ref_slot(tx["input"], 'csm') + refslot = decoded_static_values[0][1] print(f"🔹 Tx: {tx_hash} → X: {refslot}") os.environ["ORACLE_REFSLOT"] = str(refslot) os.environ["DEAMON"] = str(False) - run_oracle('ejector') + print(decoded_static_values) + run_oracle('csm')