Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Cli: add cluster-date subcommand, and make block-time slot optional #9878

Merged
merged 4 commits into from
May 5, 2020

Conversation

CriesofCarrots
Copy link
Contributor

@CriesofCarrots CriesofCarrots commented May 5, 2020

Problem

The cluster calculates the date as a function of slots from genesis, and it uses that date to determine if a stake account is locked. If we want to set an unlock for something like "one day from now", there's no RPC endpoint to ask the cluster what it thinks "now" is.

Summary of Changes

  • Add solana cluster-date command to return sysvar::Clock.unix_timestamp from the most recent cluster-confirmed root
  • Make solana block-time slot param optional, and return getBlockTime from the most recent cluster-confirmed root if None
  • --output json available for both commands
$ solana cluster-date --url http://api.mainnet-beta.solana.com

Block: 9198022
Date: 2020-04-28T04:29:09Z (UnixTimestamp: 1588048149)
$ solana block-time --url http://api.mainnet-beta.solana.com

Block: 9198023
Date: 2020-05-05T00:22:27Z (UnixTimestamp: 1588638147)

Oof, almost a week difference (cc #9874 )

Fixes #9847

@CriesofCarrots CriesofCarrots added the noCI Suppress CI on this Pull Request label May 5, 2020
@CriesofCarrots CriesofCarrots removed the noCI Suppress CI on this Pull Request label May 5, 2020
@CriesofCarrots CriesofCarrots marked this pull request as ready for review May 5, 2020 01:41
@CriesofCarrots CriesofCarrots requested review from mvines and garious May 5, 2020 01:41
@garious
Copy link
Contributor

garious commented May 5, 2020

I don't understand the difference between solana block-time with no slot and solana cluster-date? Also, strange format with Block: on one line and nothing like Date: on the other. And where tests?

@CriesofCarrots
Copy link
Contributor Author

CriesofCarrots commented May 5, 2020

I don't understand the difference between solana block-time with no slot and solana cluster-date?

Well, solana block-time calls the getBlockTime rpc, which queries the validator timestamp oracle.
solana cluster-date queries a Bank for its sysvar::Clock.unix_timestamp

I am not clear on why the validator timestamp oracle was not appropriate for lockup timestamp needs, but we do have 2 sources of timestamps, and @mvines suggested the solana block-time with no slot to exemplify this fact as well as demonstrate the drift between them. Ref: #9847 (comment)

@garious
Copy link
Contributor

garious commented May 5, 2020

Got it, thanks. LGTM

@mvines mvines added the v1.1 label May 5, 2020
@codecov
Copy link

codecov bot commented May 5, 2020

Codecov Report

Merging #9878 into master will decrease coverage by 0.0%.
The diff coverage is 27.4%.

@@           Coverage Diff            @@
##           master   #9878     +/-   ##
========================================
- Coverage    80.4%   80.4%   -0.1%     
========================================
  Files         283     283             
  Lines       64936   64977     +41     
========================================
- Hits        52245   52242      -3     
- Misses      12691   12735     +44     

@CriesofCarrots CriesofCarrots merged commit b2672fd into solana-labs:master May 5, 2020
mergify bot pushed a commit that referenced this pull request May 5, 2020
…9878)

* Add CliBlockTime struct

* Add cli cluster-date subcommand

* Make slot param optional; also jsonify

* Make prints prettier

(cherry picked from commit b2672fd)
@CriesofCarrots CriesofCarrots deleted the cli-cluster-date branch May 7, 2020 20:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't tell what day the cluster thinks it is
3 participants