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

ledger-tool: add show-entries option to bigtable block #34536

Merged

Conversation

CriesofCarrots
Copy link
Contributor

Problem

Now that entries are uploaded to bigtable, solana-ledger-tool bigtable block can reconstruct complete blocks comparable to the data returned by solana-ledger-tool slot.
Re: #34266 (review)

Summary of Changes

Add --show-entries flag to build block display struct with entries
Output looks like:

$ solana-ledger-tool bigtable block 2 --show-entries

Slot: 2
Parent Slot: 1
Blockhash: D9aBYGVchmxMprqqGDGhCcYkJXS78S4Xnygj2Lnd9pvu
Previous Blockhash: FP1G5WQBMebHhnBkCXLctcU63rkRCzkYACKsPEyZJPvT
Block Time: 2023-12-14T17:28:49-07:00
Block Height: 2
Rewards:
  Address                                            Type        Amount           New Balance           Percent Change  Commission
  9a25m7QZ2VMkiFETP2UzQxnCnUfEE3LUKbXCnWPb1mGz        fee        ◎0.000005000     ◎499.999995000          0.000001000%      -
Total Rewards: ◎0.000005000
Entry 0 - num_hashes: 1, hash: BVCqk2ssPHxpnaWLCKPvAXhHDmvvXHw2hfT8Uv9QvGoG, transactions: 0, starting_transaction_index: 0
Entry 1 - num_hashes: 1, hash: H6nwjKVKPQQDSZyTgYRXPXsY25ZqQW5yDzyQmicUGuAY, transactions: 1, starting_transaction_index: 0
  Transaction 0:
    Version: legacy
    Recent Blockhash: FP1G5WQBMebHhnBkCXLctcU63rkRCzkYACKsPEyZJPvT
    Signature 0: jva724YHSwd8W8vPNJuueeyLDEdrdqHngRyoNrbSJ1pbqb9hEVC9rBYRaLVxkz9ga1Xer5Hht3YSSUGmsXng8pw
    Signature 1: 59m7yLfF89iHvnwEbo3WjeWHF3Mm48NMQ4Ckvn852pUs3wTYtwiNkvxHkUwhfvhhnrkGqzpM5TpLtuC5TPtS6Fs7
...

This is similar to what solana-ledger-tool slot spits out. The only differences are a lower indent level and metadata (slot prints SlotMeta, bigtable block prints the block meta, like parent info and rewards).

The output still supports json:

$ solana-ledger-tool bigtable block 2 --show-entries --output json

{
  "previousBlockhash": "FP1G5WQBMebHhnBkCXLctcU63rkRCzkYACKsPEyZJPvT",
  "blockhash": "D9aBYGVchmxMprqqGDGhCcYkJXS78S4Xnygj2Lnd9pvu",
  "parentSlot": 1,
  "entries": [
    {
      "numHashes": 1,
      "hash": "BVCqk2ssPHxpnaWLCKPvAXhHDmvvXHw2hfT8Uv9QvGoG",
      "numTransactions": 0,
      "startingTransactionIndex": 0,
      "transactions": []
    },
    {
      "numHashes": 1,
      "hash": "H6nwjKVKPQQDSZyTgYRXPXsY25ZqQW5yDzyQmicUGuAY",
      "numTransactions": 1,
      "startingTransactionIndex": 0,
      "transactions": [
        {
          "transaction": [
            "AiUEBbnLDFFPNO3o2XcNB5YAzF5opjqrrf3g5waeQKmrfJya+7PpBGLETVspvVuan+NBTEA4uegUQU77gtS3JwDPn3U87KByUhG9feL1+aUKT9DG2zg9ZAhmqveFTUZZ/TbyIMlMilNt03ma8a0V+/Jdx9UoE7wxpvJf0oCQf/AKAgABA39S4rf62DlBSnKtIej8CwJ0YYwniIMHlcioNgd6s4pvBVuVE+TlbMBeJem+JRsZfMgybN1tk4+R1QMnYz4R7c4HYUgdNXR0u3xNdiTr072z2DVec9EQQ/wNo1OAAAAAANWmsE8Wa5K57r76aEUBVpRd/fjlFpnCOP04FavM0skcAQICAQE4DAAAAAAAAAAAAAAAAQEBLCW+EHZf1zNDBk/ClQMWqZ+db/ArLKUg+10mBttPS/cBwp17ZQAAAAA=",
            "base64"
          ],
          "meta": {..}
        }
      ]
    }
 ...
}

@CriesofCarrots
Copy link
Contributor Author

I kept all the type and output work in solana-ledger-tool for now. But if we decide to, say, return these blocks with entries from RPC in the future, we can move things upstream

@CriesofCarrots CriesofCarrots force-pushed the slt-bigtable-block-entries branch from 5a9e3ff to 286a16d Compare December 19, 2023 22:26
Copy link

codecov bot commented Dec 19, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4a8582e) 81.8% compared to head (286a16d) 81.8%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #34536   +/-   ##
=======================================
  Coverage    81.8%    81.8%           
=======================================
  Files         822      822           
  Lines      221532   221532           
=======================================
+ Hits       181307   181328   +21     
+ Misses      40225    40204   -21     

Copy link
Contributor

@steviez steviez left a comment

Choose a reason for hiding this comment

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

LGTM!

With the way you wrote writeln_entry(), it seems a follow-up could be to simplify the functions in solana-ledger-tool slot path (ie output_entry())

@CriesofCarrots
Copy link
Contributor Author

With the way you wrote writeln_entry(), it seems a follow-up could be to simplify the functions in solana-ledger-tool slot path (ie output_entry())

Agreed!

@CriesofCarrots CriesofCarrots merged commit cc0e5f7 into solana-labs:master Dec 20, 2023
34 checks passed
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.

2 participants