-
Notifications
You must be signed in to change notification settings - Fork 720
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
Use new GetChainBlockNo and GetChainPoint queries in query tip #3179
Conversation
1f1531b
to
0579b3d
Compare
Output against updated
Fall back when using earlier alonzo era node:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the suggestion below about reusing the existing API type for the tip.
And presumably you'll want to rename the PR since you're using |
0579b3d
to
d2b1c98
Compare
|
||
mLocalState <- hushM (first ShelleyQueryCmdAcquireFailure eLocalState) $ \e -> | ||
liftIO . T.hPutStrLn IO.stderr $ "Warning: Local state unavailable: " <> renderShelleyQueryCmdError e | ||
|
||
chainTip <- case mLocalState >>= O.mHeaderStateTip of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not mistaken chainTip
and the long code block needed to compute it is only needed to calculate tipSlotNo
. I'd rather have this code block abstracted away to avoid obscuring the logic of runQueryTip
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The chain tip is actually used later on as well.
8d714ba
to
33d8ffe
Compare
33d8ffe
to
e6a36f4
Compare
c15d310
to
60c051b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. A few comments.
eLocalState <- liftIO $ executeLocalStateQueryExpr localNodeConnInfo Nothing $ \ntcVersion -> do | ||
era <- queryExpr (QueryCurrentEra CardanoModeIsMultiEra) | ||
eraHistory <- queryExpr (QueryEraHistory CardanoModeIsMultiEra) | ||
mChainBlockNo <- if ntcVersion >= NodeToClientV_10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We really need to come up with a better way of handling which queries are available for a particular version. Is this information available in the consensus library?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment, it's documented in the code here: https://github.com/input-output-hk/ouroboros-network/blob/c25d36e62549d5bec9876cb57d1c52ee41bdec3a/ouroboros-network/src/Ouroboros/Network/NodeToClient/Version.hs#L45
b36ffdc
to
8c25e4e
Compare
8c25e4e
to
a4633d9
Compare
Just chainTip -> return chainTip | ||
|
||
-- The chain tip is unavailable via local state query because we are connecting with an older | ||
-- node to client protocol so we use chain sync instead which necessitates another connection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to encode this information in the data type. This is ok for now but (like I said above) we need to improve how we handle query availability in a given node version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Can you clean up the commits?
then Just <$> queryExpr QueryChainBlockNo | ||
else return Nothing | ||
mChainPoint <- if ntcVersion >= NodeToClientV_10 | ||
then Just <$> queryExpr (QueryChainPoint CardanoMode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious if there is a way to not pass in CardanoMode
the constructor argument like this.
-> r' | ||
_ -> fromConsensusQueryResultMismatch | ||
|
||
fromConsensusQueryResult (QueryChainPoint mode) q' r' = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I need the mode
is because below, fromConsensusPointInMode
requires mode
.
Retain chain sync query support for older node to client versions.
a4633d9
to
e82842e
Compare
bors merge |
Build succeeded: |
3355: Delete obsolete function executeLocalStateQueryExprWithChainSync r=newhoggy a=newhoggy The function was necessary previously because it was not possible to query for chain tip from local state queries. This changed with this PR: #3179 which provided `QueryChainBlockNo` and `QueryChainPoint`. This means `executeLocalStateQueryExprWithChainSync` is no longer used nor needed. Co-authored-by: John Ky <john.ky@iohk.io>
No description provided.