Granola-Team / mina-indexer

The Mina Indexer is a re-imagined version of the software collectively called the "Mina archive node."
Apache License 2.0
19 stars 9 forks source link

feat(web)!: return full block in blocks REST endpoint #1660

Closed jhult closed 1 month ago

jhult commented 1 month ago

If you step through at the commit level, it will be much easier to follow.

Describe your changes

Return the full block (see example below) Make height a query variable Remove query by slot (unnecessary)

Link issue(s) fixed

Checklist before requesting a review

Example

[
    {
      "canonical": true,
      "epoch_num_blocks": 166,
      "epoch_num_canonical_blocks": 100,
      "epoch_num_supercharged_blocks": 20,
      "total_num_blocks": 166,
      "total_num_canonical_blocks": 100,
      "total_num_supercharged_blocks": 20,
      "block_num_snarks": 0,
      "block_num_user_commands": 3,
      "block_num_internal_commands": 2,
      "epoch_num_slots_produced": 100,
      "num_unique_block_producers_last_n_blocks": null,
      "block": {
        "state_hash": "3NKGnZMYQiKAZDZfAnyHgVPhSrMWRHaR3aHMnAc28oatHJiifVFz",
        "block_height": 95,
        "global_slot_since_genesis": 136,
        "winner_account": {
          "public_key": "B62qrafvvcSTkGMpFiprxzDN8JXqoiyHSUQwUsKbRqrvTK1khb1HJyC"
        },
        "date_time": "2021-03-17T06:48:00.000Z",
        "received_time": "2021-03-17T06:48:34.898Z",
        "creator_account": {
          "public_key": "B62qrafvvcSTkGMpFiprxzDN8JXqoiyHSUQwUsKbRqrvTK1khb1HJyC"
        },
        "coinbase_receiver": {
          "public_key": "B62qrafvvcSTkGMpFiprxzDN8JXqoiyHSUQwUsKbRqrvTK1khb1HJyC"
        },
        "creator": "B62qrafvvcSTkGMpFiprxzDN8JXqoiyHSUQwUsKbRqrvTK1khb1HJyC",
        "protocol_state": {
          "previous_state_hash": "3NK7n6j2Bx9yCVjv2AKnfxwvwvCL9uww9mQaefkm3zyabdrcczjA",
          "blockchain_state": {
            "utc_date": "1615963680000",
            "date": "1615963680000",
            "snarked_ledger_hash": "jx7buQVWFLsXTtzRgSxbYcT8EYLS8KCZbLrfDcJxMtyy4thw2Ee",
            "staged_ledger_hash": "jx1mMFf433UeHdb6c4pPHcMvyRGsdmzEaYh7p66m49Cz7RJmPXR"
          },
          "consensus_state": {
            "total_currency": 805385692840039233,
            "blockchain_length": 95,
            "block_height": 95,
            "epoch_count": 0,
            "epoch": 0,
            "has_ancestor_in_same_checkpoint_window": true,
            "last_vrf_output": "lR1013dg7Yms68xJLBArsQcYdPbZdE6ldbJBmNd4DgA=",
            "min_window_density": 77,
            "slot": 136,
            "slot_since_genesis": 136,
            "next_epoch_data": {
              "seed": "2vb3d6UdrpXTrLxjxjbwHPZJLpJzQZNBYV2xrZYJRWJs3KaX7LGY",
              "epoch_length": 96,
              "start_checkpoint": "3NK2tkzqqK5spR2sZ7tujjqPksL45M3UUrcA4WhCkeiPtnugyE2x",
              "lock_checkpoint": "3NK7n6j2Bx9yCVjv2AKnfxwvwvCL9uww9mQaefkm3zyabdrcczjA",
              "ledger": {
                "hash": "jx7buQVWFLsXTtzRgSxbYcT8EYLS8KCZbLrfDcJxMtyy4thw2Ee",
                "total_currency": 805385692840039233
              }
            },
            "staking_epoch_data": {
              "seed": "2va9BGv9JrLTtrzZttiEMDYw1Zj6a6EHzXjmP9evHDTG3oEquURA",
              "epoch_length": 96,
              "start_checkpoint": "3NK2tkzqqK5spR2sZ7tujjqPksL45M3UUrcA4WhCkeiPtnugyE2x",
              "lock_checkpoint": "3NK2tkzqqK5spR2sZ7tujjqPksL45M3UUrcA4WhCkeiPtnugyE2x",
              "ledger": {
                "hash": "jx7buQVWFLsXTtzRgSxbYcT8EYLS8KCZbLrfDcJxMtyy4thw2Ee",
                "total_currency": 805385692840039233
              }
            }
          }
        },
        "tx_fees": "30000000",
        "snark_fees": "0",
        "transactions": {
          "coinbase": "720000000000",
          "coinbase_receiver_account": {
            "public_key": "B62qrafvvcSTkGMpFiprxzDN8JXqoiyHSUQwUsKbRqrvTK1khb1HJyC"
          },
          "fee_transfer": [
            {
              "fee": "30000000",
              "recipient": "B62qrafvvcSTkGMpFiprxzDN8JXqoiyHSUQwUsKbRqrvTK1khb1HJyC",
              "feetransfer_kind": "Fee_transfer"
            }
          ],
          "user_commands": [
            {
              "amount": 1000,
              "block_height": 95,
              "global_slot": 136,
              "canonical": true,
              "failure_reason": null,
              "is_applied": true,
              "fee": 10000000,
              "from": "B62qre3erTHfzQckNuibViWQGyyKwZseztqrjPZBv6SQF384Rg6ESAy",
              "hash": "CkpZzZtaDCDsXCF23bUcytwKxEMM5i9xcKMRTVSUzqjjo2ZM3mqwq",
              "kind": "PAYMENT",
              "memo": "",
              "nonce": 138,
              "receiver": {
                "public_key": "B62qjYanmV7y9njVeH5UHkz3GYBm7xKir1rAnoY4KsEYUGLMiU45FSM"
              },
              "to": "B62qjYanmV7y9njVeH5UHkz3GYBm7xKir1rAnoY4KsEYUGLMiU45FSM",
              "token": 1,
              "epoch_num_user_commands": 247,
              "total_num_user_commands": 247
            },
            {
              "amount": 1000,
              "block_height": 95,
              "global_slot": 136,
              "canonical": true,
              "failure_reason": null,
              "is_applied": true,
              "fee": 10000000,
              "from": "B62qre3erTHfzQckNuibViWQGyyKwZseztqrjPZBv6SQF384Rg6ESAy",
              "hash": "CkpZDke3de25Peph3L7WShQqXF9hfoZ4bwUq1n3SHiWSENF2f539v",
              "kind": "PAYMENT",
              "memo": "",
              "nonce": 139,
              "receiver": {
                "public_key": "B62qjYanmV7y9njVeH5UHkz3GYBm7xKir1rAnoY4KsEYUGLMiU45FSM"
              },
              "to": "B62qjYanmV7y9njVeH5UHkz3GYBm7xKir1rAnoY4KsEYUGLMiU45FSM",
              "token": 1,
              "epoch_num_user_commands": 247,
              "total_num_user_commands": 247
            },
            {
              "amount": 1000,
              "block_height": 95,
              "global_slot": 136,
              "canonical": true,
              "failure_reason": null,
              "is_applied": true,
              "fee": 10000000,
              "from": "B62qre3erTHfzQckNuibViWQGyyKwZseztqrjPZBv6SQF384Rg6ESAy",
              "hash": "CkpYTBgcbGKGfpKdVEu8L8xfr646VBtYbiYJLjkHwEvPJKKNWPdTe",
              "kind": "PAYMENT",
              "memo": "",
              "nonce": 140,
              "receiver": {
                "public_key": "B62qjYanmV7y9njVeH5UHkz3GYBm7xKir1rAnoY4KsEYUGLMiU45FSM"
              },
              "to": "B62qjYanmV7y9njVeH5UHkz3GYBm7xKir1rAnoY4KsEYUGLMiU45FSM",
              "token": 1,
              "epoch_num_user_commands": 247,
              "total_num_user_commands": 247
            }
          ]
        },
        "snark_jobs": []
      }
    }
]
n1tranquilla commented 1 month ago

Remove query by slot (unnecessary)

If you are sure about this, i'm fine with the PR