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(web)!: return full block in blocks REST endpoint #1660

Merged
merged 5 commits into from
Oct 29, 2024

Conversation

jhult
Copy link
Member

@jhult jhult commented Oct 29, 2024

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

  • I have performed a self-review of my code.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have verified new and existing tests pass locally with my changes.
  • I verified whether it was necessary to increment the database version.

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": []
      }
    }
]

@jhult jhult requested a review from n1tranquilla October 29, 2024 15:16
@jhult jhult marked this pull request as ready for review October 29, 2024 15:30
@jhult jhult requested a review from robinbb as a code owner October 29, 2024 15:30
@n1tranquilla n1tranquilla self-assigned this Oct 29, 2024
@n1tranquilla
Copy link
Collaborator

Remove query by slot (unnecessary)

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

Copy link
Collaborator

@n1tranquilla n1tranquilla left a comment

Choose a reason for hiding this comment

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

If slot height is not needed as query input on REST endpoint, than i'm ok with this.

@n1tranquilla n1tranquilla merged commit b6c431d into Granola-Team:main Oct 29, 2024
2 checks passed
@jhult jhult deleted the feat/web-rest-blocks branch October 30, 2024 00:28
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