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

feat(release): Add epoch start estimator script #12114

Merged
merged 3 commits into from
Sep 25, 2024

Conversation

VanBarbascu
Copy link
Contributor

@VanBarbascu VanBarbascu commented Sep 19, 2024

Usage:

python3 estimate_epoch_start_time.py --chain_id mainnet --num_future_epochs 10 --num_past_epochs 20
Example output
Epoch -1: 14 hours, 59 minutes                                                                                                                                                                                        
Epoch -2: 14 hours, 58 minutes                                                                                                                                                                                        
Epoch -3: 13 hours, 22 minutes                                                                                                                                                                                        
Epoch -4: 13 hours, 22 minutes                                                                                                                                                                                        
Epoch -5: 13 hours, 42 minutes                                                                                                                                                                                        
Epoch -6: 13 hours, 27 minutes                                                                                                                                                                                        
Epoch -7: 13 hours, 53 minutes                                                                                                                                                                                        
Epoch -8: 13 hours, 22 minutes
Epoch -9: 13 hours, 46 minutes
Epoch -10: 13 hours, 30 minutes
Epoch -11: 13 hours, 20 minutes
Epoch -12: 14 hours, 11 minutes
Epoch -13: 13 hours, 58 minutes
Epoch -14: 13 hours, 58 minutes
Epoch -15: 13 hours, 19 minutes
Epoch -16: 13 hours, 49 minutes
Epoch -17: 13 hours, 32 minutes
Epoch -18: 13 hours, 16 minutes
Epoch -19: 13 hours, 18 minutes
Epoch -20: 13 hours, 18 minutes

Exponential weighted average epoch length: 13 hours, 52 minutes
Predicted start of epoch 1: 2024-09-25 18:18:07 Wednesday
Predicted start of epoch 2: 2024-09-26 08:10:37 Thursday
Predicted start of epoch 3: 2024-09-26 22:03:07 Thursday
Predicted start of epoch 4: 2024-09-27 11:55:37 Friday
Predicted start of epoch 5: 2024-09-28 01:48:07 Saturday
Predicted start of epoch 6: 2024-09-28 15:40:37 Saturday
Predicted start of epoch 7: 2024-09-29 05:33:07 Sunday
Predicted start of epoch 8: 2024-09-29 19:25:37 Sunday
Predicted start of epoch 9: 2024-09-30 09:18:07 Monday
Predicted start of epoch 10: 2024-09-30 23:10:37 Monday

Copy link

codecov bot commented Sep 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.56%. Comparing base (8a18ee7) to head (873fc4a).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12114      +/-   ##
==========================================
- Coverage   71.56%   71.56%   -0.01%     
==========================================
  Files         821      821              
  Lines      165303   165303              
  Branches   165303   165303              
==========================================
- Hits       118300   118295       -5     
+ Misses      41873    41870       -3     
- Partials     5130     5138       +8     
Flag Coverage Δ
backward-compatibility 0.17% <ø> (ø)
db-migration 0.17% <ø> (ø)
genesis-check 1.26% <ø> (ø)
integration-tests 38.69% <ø> (+0.02%) ⬆️
linux 71.35% <ø> (+<0.01%) ⬆️
linux-nightly 71.13% <ø> (-0.03%) ⬇️
macos 54.05% <ø> (-0.01%) ⬇️
pytests 1.52% <ø> (ø)
sanity-checks 1.32% <ø> (ø)
unittests 65.29% <ø> (+<0.01%) ⬆️
upgradability 0.21% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

debug_scripts/estimate_epoch_start_time.py Outdated Show resolved Hide resolved
debug_scripts/estimate_epoch_start_time.py Outdated Show resolved Hide resolved
debug_scripts/estimate_epoch_start_time.py Outdated Show resolved Hide resolved
debug_scripts/estimate_epoch_start_time.py Outdated Show resolved Hide resolved
@tayfunelmas
Copy link
Contributor

Not needed for this PR but it would be nice to have an argument to set a specific timezone.

debug_scripts/estimate_epoch_start_time.py Outdated Show resolved Hide resolved
debug_scripts/estimate_epoch_start_time.py Outdated Show resolved Hide resolved
epoch_length_seconds = epoch_length / 1e9 # Convert to seconds
epoch_lengths.append(epoch_length_seconds)

print(f"Epoch {i+1}: {epoch_length_seconds} seconds")
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to print the actual epoch height instead of 1 2 3 ...? Same for the future epochs.

Also the time in seconds isn't very readable, would be nicer to have something like: 14h 20m

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not straight forward.



# Function to approximate future epoch start dates
def predict_future_epochs(starting_epoch_timestamp, avg_epoch_length,
Copy link
Contributor

Choose a reason for hiding this comment

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

One observation - the tool predicts that the next epoch will start in 11 hours, but debug-ui says it'll happen in 13 hours.
I wonder where the discrepancy comes from 🤔 Maybe debug-ui doesn't use exponential average. /cc @robin-near

help="Number of future epochs to predict.")

args = parser.parse_args()
main(args)
Copy link
Contributor

Choose a reason for hiding this comment

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

Very useful, thank you for making this!

To resolve #12107 I would love to have two more things:

  • If the voting date is X, when will the protocol upgrade happen?
  • Given a day of the voting date find the hour that maximizes the probability that the upgrade happens during working hours

But that can be done in follow up PRs

debug_scripts/estimate_epoch_start_time.py Outdated Show resolved Hide resolved
@VanBarbascu VanBarbascu added this pull request to the merge queue Sep 25, 2024
Merged via the queue into near:master with commit 6b76ee6 Sep 25, 2024
28 of 29 checks passed
@VanBarbascu VanBarbascu deleted the epoch_start_date_script branch September 25, 2024 11:35
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.

3 participants