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

fix: not to throw error when no txs in block #982

Merged
merged 2 commits into from
Apr 19, 2023

Conversation

loin3
Copy link
Contributor

@loin3 loin3 commented Apr 18, 2023

Description

I followd this cosmos-sdk/issues/12040 and cosmos-sdk/pull/12108

our version 0.45.x does not have GetBlockWithTxs in x/auth/tx/service, so we create x/auth/tx2.
It's hard to cherr-pick because the directories are different. So I reflected the changes directly into tx2.

Motivation and context

When query through GetBlockWithTxs, invalid request error occurred when no txs are included in block.
The correct behavior is to return the block with empty list of txs.

How has this been tested?

tested no error occured and return 0 length of tx list

Screenshots (if appropriate):

before thsi PR, when tx does not exist in block

{
  "code": 3,
  "message": "out of range: cannot paginate 0 txs with offset 0 and limit 100: invalid request: invalid request",
  "details": []
}

when tx does not exist in block

{
  "txs": [],
  "block_id": {
    "hash": "tMvoEOdixC8Kt9YNwb6vGDsYJO/euSW3TRuDfzLijPk=",
    "part_set_header": {
      "total": 1,
      "hash": "ykh4pBbXq5ehsj2zyFRv0UdOFnf/8rVwjVl5MXN+pFM="
    }
  },
  "block": {
    "header": {
      "version": {
        "block": "11",
        "app": "0"
      },
      "chain_id": "simd-testing",
      "height": "115",
      "time": "2023-04-18T08:51:57.136998Z",
      "last_block_id": {
        "hash": "2mVthS8/78uoXxmNaQaO43UivRU142JD42xE/d3ps4I=",
        "part_set_header": {
          "total": 1,
          "hash": "ucOMMUTAhQtMR8sREYbbyG6RKKIDb3bOxjh5D/j1s0M="
        }
      },
      "last_commit_hash": "sUmrUkJM+xlOfckEN7yXVJX9zFySepZa2Gnl670tzwQ=",
      "data_hash": "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=",
      "validators_hash": "wUFwitwdiD2JQIkDe4MofWg7YqGlxwofCZBWzI7H5Mk=",
      "next_validators_hash": "wUFwitwdiD2JQIkDe4MofWg7YqGlxwofCZBWzI7H5Mk=",
      "consensus_hash": "BICRvH3cKD93v7+R1zxE2ljD34qcvIZ0Bdi389qtoi8=",
      "app_hash": "39H866EPWyvnODRPEYFHFVXqdH+EJj03QpKADY12BGI=",
      "last_results_hash": "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=",
      "evidence_hash": "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=",
      "proposer_address": "VwWa2x8sslGSe+6MjgugQo0iGBA="
    },
    "data": {
      "txs": []
    },
    "evidence": {
      "evidence": []
    },
    "last_commit": {
      "height": "114",
      "round": 0,
      "block_id": {
        "hash": "2mVthS8/78uoXxmNaQaO43UivRU142JD42xE/d3ps4I=",
        "part_set_header": {
          "total": 1,
          "hash": "ucOMMUTAhQtMR8sREYbbyG6RKKIDb3bOxjh5D/j1s0M="
        }
      },
      "signatures": [
        {
          "block_id_flag": "BLOCK_ID_FLAG_COMMIT",
          "validator_address": "VwWa2x8sslGSe+6MjgugQo0iGBA=",
          "timestamp": "2023-04-18T08:51:57.136998Z",
          "signature": "lsvVrOiJqC8HzBR98fExYb32m4a+Hx2BtpeS8xu98EArSt7xM9Fni55jNujet85uWczriUFhUdPOf2zDEGyRBQ=="
        }
      ]
    },
    "entropy": {
      "round": 0,
      "proof": "A1AeRTirM3lC5QXH0DaCevHadrGw5WTRwOkOMytT5rDqUG19978T9wGAoR94pYQBYQ2DIHCI5QzyYAwTB6P8hqfULXBvsb8FAxvCKfjO6yQK"
    }
  },
  "pagination": {
    "next_key": null,
    "total": "0"
  }
}

Checklist:

  • I followed the contributing guidelines and code of conduct.
  • I have added a relevant changelog to CHANGELOG.md
  • I have added tests to cover my changes.
  • I have updated the documentation accordingly.
  • I have updated API documentation client/docs/swagger-ui/swagger.yaml

@loin3 loin3 force-pushed the fix/getBlockWithTxs branch from f46aa5a to 3775766 Compare April 18, 2023 11:33
@loin3 loin3 self-assigned this Apr 18, 2023
CHANGELOG.md Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

Codecov Report

Merging #982 (ea6b6d8) into rc/v0.47.0-alpha1 (1c841d9) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files

Impacted file tree graph

@@                  Coverage Diff                  @@
##           rc/v0.47.0-alpha1     #982      +/-   ##
=====================================================
- Coverage              62.08%   62.08%   -0.01%     
=====================================================
  Files                    655      655              
  Lines                  79041    79041              
=====================================================
- Hits                   49076    49075       -1     
- Misses                 27283    27284       +1     
  Partials                2682     2682              
Impacted Files Coverage Δ
x/auth/tx2/service.go 69.44% <100.00%> (ø)

... and 1 file with indirect coverage changes

@loin3 loin3 requested a review from jaeseung-bae April 19, 2023 03:15
@loin3 loin3 merged commit 3a7a409 into Finschia:rc/v0.47.0-alpha1 Apr 19, 2023
@loin3 loin3 deleted the fix/getBlockWithTxs branch April 19, 2023 04:47
zemyblue added a commit to zemyblue/finschia-sdk that referenced this pull request Apr 21, 2023
* rc/v0.47.0-alpha1: (34 commits)
  ci: update docker action (Finschia#983)
  fix: revert Finschia#952 (Finschia#984)
  refactor: refactor x/token,collection query errors (Finschia#980)
  fix: not to throw error when no txs in block (Finschia#982)
  chore: change import path to `github.com/Finschia/finschia-sdk` (Finschia#970)
  fix: remove legacy events on x/collection and x/token (Finschia#966)
  chore: provide specific error messages on x/collection queries (Finschia#965)
  fix: check event determinism on original modules (Finschia#963)
  fix: refactor queries of x/collection and x/token (Finschia#957)
  chore: address generation of the empty coins in x/foundation (Finschia#952)
  fix: do not loop enum in x/collection (Finschia#961)
  fix: fix default next class ids of x/collection (Finschia#960)
  fix: revert Finschia#955 and add Query/HasParent into x/collection (Finschia#959)
  fix: replace query errors on the original modules into gRPC ones (Finschia#956)
  fix: return nil where the parent not exists in x/collection Query/Parent (Finschia#955)
  fix: remove duplicated events in x/collection Msg/Modify (Finschia#954)
  fix: allow zero amount of coin in x/collection Query/Balance (Finschia#953)
  fix: unpack proposals in x/foundation import-genesis (Finschia#947)
  fix: fix broken x/foundation invariant on treasury (Finschia#946)
  docs: update comments in the x/token,collection events proto (Finschia#944)
  ...
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.

5 participants