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

Implement DAA score timestamp estimation #268

Merged

Conversation

coderofstuff
Copy link
Collaborator

@coderofstuff coderofstuff commented Aug 27, 2023

Input = array of daa_scores
Output = array of timestamps, where each index in output matches the index of DAA score in input

Timestamp estimation logic:

  • given a set of pruning points (daily available values) + extra samples from recent chain blocks, find 2 points that contain the current DAA score being estimated.
  • then, given the timestamps of those two points, estimate the timestamp of current DAA by:
fraction_between = (input_daa_score - curr_pp_daa) / (next_daa - curr_pp_daa);
estimate = curr_pp_timestamp + (next_pp_timestamp - curr_pp_timestamp) * fraction_between;

Starts with the pruning point headers as the base, then attempts to include additional headers from recent chain blocks to provide better timestamp estimates for recent days after the last pruning point.

Fixes #257

@coderofstuff coderofstuff force-pushed the coderofstuff/add-daa-estimate branch 4 times, most recently from 6a82ec4 to 874ffff Compare September 2, 2023 03:37
@coderofstuff coderofstuff marked this pull request as ready for review September 2, 2023 03:41
@coderofstuff coderofstuff self-assigned this Sep 3, 2023
@coderofstuff coderofstuff force-pushed the coderofstuff/add-daa-estimate branch 2 times, most recently from 579926e to ac040cc Compare October 6, 2023 03:55
@coderofstuff coderofstuff force-pushed the coderofstuff/add-daa-estimate branch 2 times, most recently from 89a91b6 to 72ff4c7 Compare October 9, 2023 23:23
@coderofstuff coderofstuff force-pushed the coderofstuff/add-daa-estimate branch 2 times, most recently from 83154e2 to 0f2fdb4 Compare October 29, 2023 02:54
@coderofstuff coderofstuff force-pushed the coderofstuff/add-daa-estimate branch 3 times, most recently from 14348f7 to c50cc42 Compare November 9, 2023 07:19
@coderofstuff coderofstuff force-pushed the coderofstuff/add-daa-estimate branch 3 times, most recently from 4dc28b1 to 59ad2eb Compare November 21, 2023 17:10
coderofstuff and others added 8 commits November 23, 2023 12:03
Basic implementation, just return the value back. Commit is focused on
adding the API rather than functionality.
Input = array of daa_scores
Output = array of timestamps, index matched with input
- acquire prune lock
- use tighter indexing logic
- ensure sink is included
- avoid assuming that timestamps are strictly monotonic
michaelsutton
michaelsutton previously approved these changes Nov 23, 2023
@michaelsutton michaelsutton dismissed their stale review November 23, 2023 19:19

still missing one detail -- will add shortly

coderofstuff and others added 2 commits November 23, 2023 13:50
It's the same daa_score as checkpoint genesis, but timestamp is
different to improve accuracy for queries right before and right after
this daa_score
@michaelsutton michaelsutton merged commit f536fe7 into kaspanet:master Nov 23, 2023
6 checks passed
@coderofstuff coderofstuff deleted the coderofstuff/add-daa-estimate branch January 27, 2024 08:31
smartgoo pushed a commit to smartgoo/rusty-kaspa that referenced this pull request Jun 18, 2024
* Add GetDaaEstimateTimestamp RPC API

Basic implementation, just return the value back. Commit is focused on
adding the API rather than functionality.

* Implement DAA score timestamp estimation

Input = array of daa_scores
Output = array of timestamps, index matched with input

* Use info for daa TS estimate as opposed to println

* Factor in BPS in the last header estimation

* - use compact headers
- acquire prune lock
- use tighter indexing logic
- ensure sink is included

* eof new line

* add todos

* - bug fix: use f64, otherwise the fraction is always zero
- avoid assuming that timestamps are strictly monotonic

* renames

* translate score -> miliisecs directly using target time per block

* note

* Add last data point from jupyter notebook

It's the same daa_score as checkpoint genesis, but timestamp is
different to improve accuracy for queries right before and right after
this daa_score

* use an array to avoid prealloc inaccuracies

---------

Co-authored-by: Michael Sutton <[email protected]>
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.

Implement DAA-based timestamp estimation
3 participants