-
Notifications
You must be signed in to change notification settings - Fork 86
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
New GetChainBlockNo and GetChainPoint queries #3346
New GetChainBlockNo and GetChainPoint queries #3346
Conversation
570a33f
to
9614299
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.
So if we're adding GetChainBlockNo
and GetChainPoint
queries then we do not need one for the tip. So we can get rid of the patch that adds GetHeaderStateTip
and we don't need the corresponding tip type that's added there.
I think we can also get rid of the dependency on the serialise
package.
I think we ought to be able to shrink this PR somewhat. Check we really need all the new code we're adding.
I agree that the right way to structure this PR is as two patches, the first that only adds support for another protocol version, and then the second that adds the two new queries.
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.
It looks good to me, though I coincide with Duncan's comments. I just made some minor comments on style and alignment.
9614299
to
99ddea4
Compare
Query.QueryVersion1 -> genTopLevelQuery queryVersion | ||
Query.QueryVersion2 -> genTopLevelQuery queryVersion | ||
where | ||
genTopLevelQuery queryVersion = |
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.
This will change the distribution of what QC generates, won't it? So we'll go from a 15
to 1
to a 15
to 3
block query to "with version" generated data. Is this desired?
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.
What principle should be followed for this kind of decision making?
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.
Ideally, we'd have coverage testing which would safeguard that we still cover a sufficient percentage of the cases we consider important. I'll ping you on slack to discuss this further.
cdac3c6
to
d9c2112
Compare
1a376f6
to
2348947
Compare
, (1, do blockV <- arbitrary | ||
return (WithVersion (queryVersion, blockV) | ||
(SomeSecond GetSystemStart))) | ||
[ queryFrequencyFor Query.TopLevelQueryDisabled 15 $ |
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.
One thing that I'd like to discuss in a call is why not just hardcoding the frequencies as it used to be
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.
So, in particular, I was wondering if it'd be possible to write something like:
case queryVersion of
Query.TopLevelQueryDisabled -> arbitraryBlockQuery queryVersion
Query.QueryVersion1 -> arbitraryBlockVersion1Query
Query.QueryVersion2 -> arbitraryBlockVersion1Query
where
query item = do blockV <- arbitrary
return (WithVersion (queryVersion, blockV)
(SomeSecond item)))
arbitraryBlockVersion1Query =
frequency
[ (15, arbitraryBlockQuery queryVersion)
, (1, query GetSystemStart)))
]
arbitraryBlockVersion2Query =
oneof
[ arbitraryBlockVersion1Query
, frequency [ (1, query GetChainBlockNo)
, (1, query GetChainPoint)
]
]
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.
Or repeating code, but removing one level of indirection for the reader so that it is easier for them to understand what the frequency distributions are:
arbitraryBlockVersion2Query =
frequency
[ (15, arbitraryBlockQuery queryVersion)
, (1, query GetSystemStart)))
, (1, query GetChainBlockNo)
, (1, query GetChainPoint)
]
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.
How does it look now?
5ddd38a
to
db96392
Compare
db96392
to
aa795f4
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.
I shared some minor-to-medium observations, mostly around avoiding code duplication.
52527d5
to
0af53cb
Compare
] | ||
|
||
latestReleasedNodeVersion _prx = (Just NodeToNodeV_7, Just NodeToClientV_9) | ||
latestReleasedNodeVersion _prx = (Just NodeToNodeV_7, Just 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.
I'm thinking out loud here, in case someone sees something objectionable.
It's fine to bump this, since it's inconsequential whether the next release/release candidate tries to negotiate this new version. Esp: if they talk to a node that doesn't support it, they'll simply negotiate the eg previous version. Thus, as long as the cardano-node
dependence on these new queries is well-guarded wrt to the negotiated version, then it's fine to "enable" them here.
ouroboros-consensus-test/src/Test/Util/Serialisation/Roundtrip.hs
Outdated
Show resolved
Hide resolved
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 pointed out enough small-to-medium things that I'm Requesting Changes.
Also: apologies for not grouping all my comments into this review; I made a few before realizing there'd be more than a couple.
ouroboros-network/src/Ouroboros/Network/NodeToClient/Version.hs
Outdated
Show resolved
Hide resolved
@@ -162,16 +228,26 @@ queryDecodeNodeToClient codecConfig queryVersion blockVersion | |||
blockVersion | |||
return (SomeSecond (BlockQuery blockQuery)) | |||
|
|||
instance SerialiseResult blk (BlockQuery blk) => SerialiseResult blk (Query blk) where | |||
instance ( SerialiseResult blk (BlockQuery blk) | |||
, Serialise (HeaderHash blk) |
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 have a general preference for ToCBOR
and FromCBOR
instead of Serialise
. But using Serialise
here is not without precedent (eg BlockQuery ShelleyBlock
uses Serialise
for a Point
's HeaderHash
).
Ultimately, the Serialise
vs ToCBOR
/FromCBOR
vs SerialiseNodeToClient
/SerialiseNodeToNode
vs SerialiseResult
is in a confused and confusing state, in my opinion. The only stark contrast is that many "low-level" Serialise
instances come from 3rd party libraries, and so we shouldn't be using them: changes in our codecs should never be accidental, and so shouldn't run the risk of accidentally depending on 3rd party serializations.
So: if it's not too much trouble, I would prefer at least ToCBOR
and FromCBOR
instead of Serialise
. But really, this is already in the scope of existing tech debt :(
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 it's okay I'd like to do this in a separate PR.
e6a3b5a
to
79ec191
Compare
79ec191
to
943390f
Compare
@dnadales pointed out on Slack that this PR is enriching our interface, and so deserves an entry in https://github.com/input-output-hk/ouroboros-network/blob/master/ouroboros-consensus/docs/interface-CHANGELOG.md 🙌 I'm sorry I didn't realize that sooner. @newhoggy Would you add a section at the top there. I'm guess it'll be similarly formatted to the latest one (ie Circa 2021-08-31). If the top of the |
943390f
to
c58824e
Compare
cd853cc
to
b1cadd4
Compare
This patch adds a supported node to client version `NodeToClientV_10` with new queries: - `GetChainBlockNo`: Get the chain block number - `GetChainPoint`: Get the chain point, which includes the slot number and
b1cadd4
to
d2f66b3
Compare
bors r+ |
Build succeeded: |
No description provided.