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

Small improvements to queries #559

Merged
merged 1 commit into from
Jun 25, 2024
Merged

Conversation

smelc
Copy link
Contributor

@smelc smelc commented Jun 19, 2024

Changelog

- description: |
    Small improvements to queries
# uncomment types applicable to the change:
  type:
  # - feature        # introduces a new feature
  - breaking       # the API has changed in a breaking way
  # - compatible     # the API has changed but is non-breaking
  # - optimisation   # measurable performance improvements
  - refactoring    # QoL changes
  # - bugfix         # fixes a defect
  # - test           # fixes/modifies tests
  # - maintenance    # not directly related to the code
  # - release        # related to a new release preparation
  # - documentation  # change in code docs, haddocks...

Context

How to trust this PR

  • The first commit doesn't change the runtime
  • The second commit was carefully done mechanically, but please reread it carefully
  • It's more deletions than additions 🎖️

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • Self-reviewed the diff

@smelc smelc force-pushed the smelc/small-improvements-to-queries branch from 97292c7 to d174341 Compare June 19, 2024 15:12
@smelc smelc marked this pull request as ready for review June 19, 2024 15:14
@smelc smelc force-pushed the smelc/small-improvements-to-queries branch 2 times, most recently from 07c3bcf to 58664b9 Compare June 20, 2024 09:10
@smelc smelc force-pushed the smelc/small-improvements-to-queries branch 4 times, most recently from db0e822 to fe7c6e7 Compare June 24, 2024 09:14
Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

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

LGTM but I disagree with StateForBalancedTx. It's not necessary and IMO it takes away from code readability.

@@ -69,22 +71,26 @@ renderQueryConvenienceError (QceUnsupportedNtcVersion (UnsupportedNtcVersionErro
"This query requires at least " <> textShow minNtcVersion <> " but the node negotiated " <> textShow ntcVersion <> ".\n" <>
"Later node versions support later protocol versions (but development protocol versions are not enabled in the node by default)."

-- | Data returned by 'queryStateForBalancedTx'. Parameterized on the type of 'eraHistory',
-- because sometimes we don't need it.
data StateForBalancedTx history era = StateForBalancedTx
Copy link
Contributor

@Jimbo4350 Jimbo4350 Jun 24, 2024

Choose a reason for hiding this comment

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

I don't think this refactor is necessary. It's better to explicitly have the parameters needed rather than introduce a new data type with an additional type variable is sometimes () or EraHistory. This is also introducing more churn in the cli for not much benefit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The thing is, I'm adding another member to this record in this follow-up PR: #557

If we don't add this record, this follow-up PR will make queryStateForBalancedTx return yet another value, which I think is not really nice.

Copy link
Contributor

@carbolymer carbolymer Jun 25, 2024

Choose a reason for hiding this comment

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

I'm also unsure about this new datatype. But I think my gripe is parameterisation by history. I think having a single type parameter and returning a product (EraHistory, StateForBalancedTx era) where needed instead, would be cleaner.

Copy link
Contributor Author

@smelc smelc Jun 25, 2024

Choose a reason for hiding this comment

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

Alright, let me scratch the new datatype then 👍 (@carbolymer> I think it'd be weird if StateForBalancedTx didn't return all values, so I'm not keen on the product version)

@@ -842,133 +845,123 @@ fromConsensusQueryResultShelleyBased
-> Consensus.BlockQuery (Consensus.ShelleyBlock protocol ledgerera) result'
-> result'
-> result
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@smelc smelc force-pushed the smelc/small-improvements-to-queries branch from fe7c6e7 to 22dbb35 Compare June 25, 2024 10:02
@smelc smelc added this pull request to the merge queue Jun 25, 2024
@smelc smelc removed this pull request from the merge queue due to a manual request Jun 25, 2024
@smelc smelc merged commit 2b5e948 into main Jun 25, 2024
23 checks passed
@smelc smelc deleted the smelc/small-improvements-to-queries branch June 25, 2024 13:25
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.

3 participants