From a2f85719d2e511d70b1cb40842f90fe3e054454d Mon Sep 17 00:00:00 2001 From: PavitraAgarwal <85789615+PavitraAgarwal21@users.noreply.github.com> Date: Tue, 22 Oct 2024 14:34:17 +0530 Subject: [PATCH] hardcoded mainnet timestamp data for first 10 blocks (#281) --- scripts/data/generate_timestamp_data.py | 121 ++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/scripts/data/generate_timestamp_data.py b/scripts/data/generate_timestamp_data.py index 84303394..44ecc6b3 100644 --- a/scripts/data/generate_timestamp_data.py +++ b/scripts/data/generate_timestamp_data.py @@ -87,11 +87,132 @@ def load_index(file_name): def get_timestamp_data(block_number): """Get the timestamp data for a given block number.""" + if block_number <= 10: + return hardcoded_timestamp_data(block_number) file_name = index_file_name(int(block_number) // INDEX_SIZE) index = load_index(file_name) return index +def hardcoded_timestamp_data(block_number): + def hardcoded_timestamp_data(block_number): + hardcoded_data = { + 0: { + "block_number": "0", + "epoch_start_time": "1231006505", + "previous_timestamps": [], + }, + 1: { + "block_number": "1", + "epoch_start_time": "1231469665", + "previous_timestamps": ["1231006505"], + }, + 2: { + "block_number": "2", + "epoch_start_time": "1231469744", + "previous_timestamps": ["1231006505", "1231469665"], + }, + 3: { + "block_number": "3", + "epoch_start_time": "1231470173", + "previous_timestamps": ["1231006505", "1231469665", "1231469744"], + }, + 4: { + "block_number": "4", + "epoch_start_time": "1231470988", + "previous_timestamps": [ + "1231006505", + "1231469665", + "1231469744", + "1231470173", + ], + }, + 5: { + "block_number": "5", + "epoch_start_time": "1231471428", + "previous_timestamps": [ + "1231006505", + "1231469665", + "1231469744", + "1231470173", + "1231470988", + ], + }, + 6: { + "block_number": "6", + "epoch_start_time": "1231471789", + "previous_timestamps": [ + "1231006505", + "1231469665", + "1231469744", + "1231470173", + "1231470988", + "1231471428", + ], + }, + 7: { + "block_number": "7", + "epoch_start_time": "1231472369", + "previous_timestamps": [ + "1231006505", + "1231469665", + "1231469744", + "1231470173", + "1231470988", + "1231471428", + "1231471789", + ], + }, + 8: { + "block_number": "8", + "epoch_start_time": "1231472743", + "previous_timestamps": [ + "1231006505", + "1231469665", + "1231469744", + "1231470173", + "1231470988", + "1231471428", + "1231471789", + "1231472369", + ], + }, + 9: { + "block_number": "9", + "epoch_start_time": "1231473279", + "previous_timestamps": [ + "1231006505", + "1231469665", + "1231469744", + "1231470173", + "1231470988", + "1231471428", + "1231471789", + "1231472369", + "1231472743", + ], + }, + 10: { + "block_number": "10", + "epoch_start_time": "1231473952", + "previous_timestamps": [ + "1231006505", + "1231469665", + "1231469744", + "1231470173", + "1231470988", + "1231471428", + "1231471789", + "1231472369", + "1231472743", + "1231473279", + ], + }, + } + + return hardcoded_data.get(block_number, {}) + + if __name__ == "__main__": file_names = list_files_in_gcs() for file_name in tqdm(file_names, "Downloading files"):