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 exception when executing drep queries #221

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions cardano-api/internal/Cardano/Api/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -675,17 +675,16 @@ toConsensusQueryShelleyBased erainmode (QueryStakeDelegDeposits creds) =
creds' = Set.map toShelleyStakeCredential creds

toConsensusQueryShelleyBased erainmode QueryGovState =
Some (consensusQueryInEraInMode erainmode (Consensus.GetCBOR Consensus.GetGovState))
Some (consensusQueryInEraInMode erainmode Consensus.GetGovState)
Copy link
Contributor Author

@carbolymer carbolymer Aug 30, 2023

Choose a reason for hiding this comment

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

Why sometimes do we need GetCBOR?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't know the answer to this unfortunately.

Copy link
Contributor

Choose a reason for hiding this comment

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

The issue (for example) is here:

...
fromConsensusQueryResultShelleyBased _ QueryStakeSnapshot{} q' r' =
  case q' of
    Consensus.GetCBOR Consensus.GetStakeSnapshots {} -> SerialisedStakeSnapshots r'
    _                                                -> fromConsensusQueryResultMismatch

fromConsensusQueryResultShelleyBased _ QueryStakeDelegDeposits{} q' stakeCreds' =
    case q' of
      Consensus.GetStakeDelegDeposits{} -> Map.map fromShelleyLovelace
                                         . Map.mapKeysMonotonic fromShelleyStakeCredential
                                         $ stakeCreds'
      _                                 -> fromConsensusQueryResultMismatch

fromConsensusQueryResultShelleyBased _ QueryGovState{} q' govState' =
  case q' of
    Consensus.GetGovState{} -> govState'
    _                       -> fromConsensusQueryResultMismatch
...

You need to pattern match on Consensus.GetCBOR Consensus.GetGovState{}

Copy link
Contributor

@Jimbo4350 Jimbo4350 Aug 30, 2023

Choose a reason for hiding this comment

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

#221 (comment): Ignore this as Sam says its not useful. Make sure the queries work in the cli however before merging this.


toConsensusQueryShelleyBased erainmode (QueryDRepState creds) =
Some (consensusQueryInEraInMode erainmode (Consensus.GetCBOR (Consensus.GetDRepState creds)))

Some (consensusQueryInEraInMode erainmode (Consensus.GetDRepState creds))

toConsensusQueryShelleyBased erainmode (QueryDRepStakeDistr dreps) =
Some (consensusQueryInEraInMode erainmode (Consensus.GetCBOR $ Consensus.GetDRepStakeDistr dreps))
Some (consensusQueryInEraInMode erainmode (Consensus.GetDRepStakeDistr dreps))

toConsensusQueryShelleyBased erainmode QueryCommitteeState =
Some (consensusQueryInEraInMode erainmode (Consensus.GetCBOR Consensus.GetCommitteeState))
Some (consensusQueryInEraInMode erainmode Consensus.GetCommitteeState)

consensusQueryInEraInMode
:: forall era mode erablock modeblock result result' xs.
Expand Down Expand Up @@ -859,7 +858,7 @@ fromConsensusQueryResultShelleyBased _ QueryEpoch q' epoch =
fromConsensusQueryResultShelleyBased _ QueryConstitution q' mConstitution =
case q' of
Consensus.GetConstitution -> mConstitution
_ -> fromConsensusQueryResultMismatch
_ -> fromConsensusQueryResultMismatch

fromConsensusQueryResultShelleyBased _ QueryGenesisParameters q' r' =
case q' of
Expand Down