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

New GetChainBlockNo and GetChainPoint queries #3346

Merged
merged 1 commit into from
Sep 24, 2021

Conversation

newhoggy
Copy link
Contributor

No description provided.

@newhoggy newhoggy changed the title New get chain block no and get chain point queries New GetChainBlockNo and GetChainPoint queries Sep 13, 2021
@newhoggy newhoggy force-pushed the new-GetChainBlockNo-and-GetChainPoint-queries branch 2 times, most recently from 570a33f to 9614299 Compare September 13, 2021 14:47
Copy link
Contributor

@dcoutts dcoutts left a 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.

ouroboros-consensus/src/Ouroboros/Consensus/Node.hs Outdated Show resolved Hide resolved
ouroboros-network/src/Ouroboros/Network/Block.hs Outdated Show resolved Hide resolved
ouroboros-network/src/Ouroboros/Network/Point.hs Outdated Show resolved Hide resolved
@EncodePanda EncodePanda self-requested a review September 13, 2021 15:07
Copy link
Contributor

@jasagredo jasagredo left a 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.

@newhoggy newhoggy force-pushed the new-GetChainBlockNo-and-GetChainPoint-queries branch from 9614299 to 99ddea4 Compare September 14, 2021 09:29
Query.QueryVersion1 -> genTopLevelQuery queryVersion
Query.QueryVersion2 -> genTopLevelQuery queryVersion
where
genTopLevelQuery queryVersion =
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

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.

@newhoggy newhoggy force-pushed the new-GetChainBlockNo-and-GetChainPoint-queries branch 3 times, most recently from cdac3c6 to d9c2112 Compare September 14, 2021 12:20
@newhoggy newhoggy dismissed dcoutts’s stale review September 14, 2021 12:24

Addressed concerns.

@newhoggy newhoggy force-pushed the new-GetChainBlockNo-and-GetChainPoint-queries branch 4 times, most recently from 1a376f6 to 2348947 Compare September 14, 2021 21:12
, (1, do blockV <- arbitrary
return (WithVersion (queryVersion, blockV)
(SomeSecond GetSystemStart)))
[ queryFrequencyFor Query.TopLevelQueryDisabled 15 $
Copy link
Member

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

Copy link
Member

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)
                    ]
        ]

Copy link
Member

@dnadales dnadales Sep 15, 2021

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)
        ]

Copy link
Contributor Author

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?

@newhoggy newhoggy force-pushed the new-GetChainBlockNo-and-GetChainPoint-queries branch 2 times, most recently from 5ddd38a to db96392 Compare September 15, 2021 23:42
@newhoggy newhoggy force-pushed the new-GetChainBlockNo-and-GetChainPoint-queries branch from db96392 to aa795f4 Compare September 15, 2021 23:43
Copy link
Contributor

@nfrisby nfrisby left a 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.

ouroboros-network/src/Ouroboros/Network/Block.hs Outdated Show resolved Hide resolved
@newhoggy newhoggy force-pushed the new-GetChainBlockNo-and-GetChainPoint-queries branch 2 times, most recently from 52527d5 to 0af53cb Compare September 17, 2021 10:31
]

latestReleasedNodeVersion _prx = (Just NodeToNodeV_7, Just NodeToClientV_9)
latestReleasedNodeVersion _prx = (Just NodeToNodeV_7, Just NodeToClientV_10)
Copy link
Contributor

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.

Copy link
Contributor

@nfrisby nfrisby left a 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.

@@ -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)
Copy link
Contributor

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 :(

Copy link
Contributor Author

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.

@newhoggy newhoggy force-pushed the new-GetChainBlockNo-and-GetChainPoint-queries branch 3 times, most recently from e6a3b5a to 79ec191 Compare September 20, 2021 10:05
@newhoggy newhoggy force-pushed the new-GetChainBlockNo-and-GetChainPoint-queries branch from 79ec191 to 943390f Compare September 20, 2021 10:27
@newhoggy newhoggy dismissed nfrisby’s stale review September 20, 2021 10:29

Review comments addressed.

@nfrisby
Copy link
Contributor

nfrisby commented Sep 20, 2021

@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 interface-CHANGELOG.md file doesn't give you enough guidance, please let me know 👍

@newhoggy newhoggy force-pushed the new-GetChainBlockNo-and-GetChainPoint-queries branch from 943390f to c58824e Compare September 21, 2021 10:36
@coot coot removed request for coot and karknu September 21, 2021 20:42
@newhoggy newhoggy force-pushed the new-GetChainBlockNo-and-GetChainPoint-queries branch from cd853cc to b1cadd4 Compare September 22, 2021 10:56
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
@dnadales dnadales force-pushed the new-GetChainBlockNo-and-GetChainPoint-queries branch from b1cadd4 to d2f66b3 Compare September 24, 2021 07:16
@dnadales
Copy link
Member

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Sep 24, 2021

@iohk-bors iohk-bors bot merged commit c25d36e into master Sep 24, 2021
@iohk-bors iohk-bors bot deleted the new-GetChainBlockNo-and-GetChainPoint-queries branch September 24, 2021 07:47
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