Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use median-time-past for input sequence checks rather than block… #239

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

fishonamos
Copy link
Contributor

@fishonamos fishonamos commented Oct 3, 2024

… time

Copy link

vercel bot commented Oct 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
raito ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 7, 2024 3:15pm

@fishonamos
Copy link
Contributor Author

fishonamos commented Oct 6, 2024

@m-kus. Kindly review so i can proceed with the scripts.
Screenshot 2024-10-06 at 5 56 56 AM

scripts/data/generate_data.py Outdated Show resolved Hide resolved
@@ -173,37 +185,41 @@ def fetch_block(block_hash: str, fast: bool):
)

block["data"] = {
tx["txid"]: resolve_transaction(tx, previous_outputs)
tx["txid"]: resolve_transaction(
tx, previous_outputs, block["mediantime"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so you need to do some more changes, because here you should provide current_chain_state["median_time_past"]

You need to implement an "apply" function for chain state that would produce next_chain_state from the current_chain_state. Then you provide chain_state to the fetch_block function to get MTP.

As a bonus you'll be able to get rid of fetch_chain_state function because now you are computing it from the previous ones.

@@ -71,6 +77,7 @@ def fetch_chain_state_fast(block_height: int):
head["epoch_start_time"] = 1231006505
else:
head["epoch_start_time"] = int(data["epoch_start_time"])
head["median_time_past"] = compute_median_time_past(head["prev_timestamps"])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

median_time is already in the data (check if it is correct)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug] Use median-time-past for input sequence checks rather than block time
3 participants