From 9350c2eb0579277153b220d41f0991f541186f7f Mon Sep 17 00:00:00 2001 From: Michael Zaikin Date: Wed, 30 Oct 2024 13:11:10 +0000 Subject: [PATCH] Fix script: next chain state --- scripts/data/generate_data.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/data/generate_data.py b/scripts/data/generate_data.py index 45e307d9..81ceadbc 100755 --- a/scripts/data/generate_data.py +++ b/scripts/data/generate_data.py @@ -295,10 +295,10 @@ def next_chain_state(current_state: dict, new_block: dict) -> dict: """Computes the next chain state given the current state and a new block.""" next_state = new_block.copy() - # Update prev_timestamps - next_state["prev_timestamps"] = current_state["prev_timestamps"][1:] + [ - new_block["time"] - ] + # We need to recalculate the prev_timestamps field given the previous chain state + # and all the blocks we applied to it + prev_timestamps = current_state['prev_timestamps'] + [new_block["time"]] + next_state["prev_timestamps"] = prev_timestamps[-11:] # Update epoch start time if new_block["height"] % 2016 == 0: