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

Committee query - implement next epoch change #3878

Merged
merged 11 commits into from
Dec 5, 2023

Conversation

teodanciu
Copy link
Contributor

@teodanciu teodanciu commented Nov 17, 2023

Description

Closes: #3810

I'm not convinced about a few things in this implementation:

  1. describing members from both current and next epoch committee as Active (with the only difference between them being that the former has NextEpochChange either ToBeRemoved or NoChangeExpected and the latter ToBeEnacted).
    In the current acceptance of the Query, Active means not expired, so it is technically compatible with the above, but I think it can be confusing.
    What can we do ?
  • Adding another value to this status, say ActiveNextEpoch ? Maybe, but it would kinda mix the categories. Is it possible for a member from the nextCommittee to be already expired? Then which value would this field take, ActiveNextEpoch or Expired?
  • Another option would be to return only the current committee members, and use the nextEpoch committee members to determine if a member will be removed or no change expected. So ToBeEnacted would never appear as a value in this implementation.
  1. members that are Unrecognized (so: they have a hot key in the CommitteeState but no corresponding cold key in either the current committee or the committee in the next epoch), will have the field set to NoChangeExpected. Because what else can it be? ToBeRemoved doesn't really match, since they are not in the committee. ToBeEnacted also no, because they are not in the next committee.
  2. At first I thought that expiration of the committee member should be part of the computation of this field, but I have decided against it, because
    • the expiration dimension is dealt with in another field , namely MemberStatus
    • expired members are not technically removed from the committee (though their vote doesn't count, in the same way as members without a hot key don't count).
      So i thought it would be better to keep the two separate.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated
  • When applicable, versions are updated in .cabal and CHANGELOG.md files according to the
    versioning process.
  • The version bounds in .cabal files for all affected packages are updated. If you change the bounds in a cabal file, that package itself must have a version increase. (See RELEASING.md)
  • All visible changes are prepended to the latest section of a CHANGELOG.md for the affected packages. New section is never added with the code changes. (See RELEASING.md)
  • Code is formatted with fourmolu (use scripts/fourmolize.sh)
  • Cabal files are formatted (use scripts/cabal-format.sh)
  • hie.yaml has been updated (use scripts/gen-hie.sh)
  • Self-reviewed the diff

@teodanciu teodanciu force-pushed the td/committee-query-next-epoch-change branch from 2313c61 to 1d167ee Compare November 17, 2023 04:12
@lehins
Copy link
Collaborator

lehins commented Nov 17, 2023

  1. .... What can we do ?

If you look at the haddock for Unrecognized, it is exactly that, so no new status is needed. In current state it is still an unknown committee member, but it will be enacted in the future. It might be a confusing name, I am definitely opened to renaming it to something better.
https://github.com/input-output-hk/cardano-ledger/blob/1d167ee0c72c2fdb51774d7998b91f237b9bf0cc/libs/cardano-ledger-api/src/Cardano/Ledger/Api/State/Query/CommitteeMembersState.hs#L44-L46

@lehins
Copy link
Collaborator

lehins commented Nov 17, 2023

members that are Unrecognized (so: they have a hot key in the CommitteeState but no corresponding cold key in either the current committee or the committee in the next epoch)

They will be removed at the next epoch, otherwise that Map could grow with garbage CC keys forever

Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

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

Not quite right, but it is really good first attempt. Could you also add a couple of test cases for the new functionality?

@lehins
Copy link
Collaborator

lehins commented Nov 17, 2023

At first I thought that expiration of the committee member should be part of the computation of this field,

That brings me an idea, we could add an extra status: ToBeExpired

@teodanciu
Copy link
Contributor Author

teodanciu commented Nov 17, 2023

Could you also add a couple of test cases for the new functionality

There is a test for it:
c3cdf55#diff-fb722545a2358df077b89f77d538341ddfbb9d6a3e68354459abad096b1bfbc7R267

It's still not clear to me what we want to achieve. I have assumed this, if we look at an example ( not saying it's the right thing ,because I can see quite a few things that are confusing, as i pointed out in the description) :

current:   
c1 -> epoch 
c2 ->  epochExpired
c3 -> epoch
c4 -> epochExpired

committeeState: 
c1 -> h1
c2 -> h2
c80 -> h80
c90 -> h90

next:Committe:
c1 -> epoch
c4 -> epoch
c500 -> epoch
c80 -> epoch

Then a query without any filters, would have the domain all the cold keys: so a union of: current committee, next committee and the keyset of committeeState:

c1 - (Authorized h1, Active, NoChangeExpected)
c2 - (Authorized h2, Expired, ToBeRemoved)
c3 - (NotAuthorized, Active, ToBeRemoved)
c4 - (NotAuthorized, Expired, NoChangeExpected)
c80 - (Authorized h80, Active, ToBeEnacted)
c90 - (Authorized h90, Unrecognized, NoChangeExpected)
c500 - (NotAuthorized, Active, ToBeEnacted)

But if I understand from your comment, you would prefer to not have the nextCommittee in the domain?
so basically the query would return results for:

c1
c2
c3 
c4 
c80
c90

as it does now? In this case, we won't be able to set ToBeEnacted status, unless the hot key is in the committeeState (which sound sensible).

@teodanciu
Copy link
Contributor Author

teodanciu commented Nov 17, 2023

So something like this?

c1 - (Authorized h1, Active, NoChangeExpected)  (it's in current & nextCommittee)
c2 - (Authorized h2, Expired, ToBeRemoved) (it's in current && not in nextCommittee)
c3 -  (NotAuthorized, Active, ToBeRemoved) (it's in current && no the nextCommittee)
c4 - (NotAuthorized, Expired, NoChangeExpected)  (it's in current && the nextCommittee)
c80 - (Authorized h80, ???, ToBeEnacted) (it's in the next committee but not in the current. MemberStatus Active/Expired (depending on the epoch) is a little weird, but what else can it be?  )
c90 - (Authorized h90, Unrecognized,  ToBeRemoved)  (because it's not in nextCommittee)

So the difference between this and the implementation in this PR would be:

  • if cold keys appear in the nextCommitee, but not in the current committe nor in the committeeState, then they won't be returned in the query
  • all results with status Unrecognized will have nextChange to be ToBeRemoved

@teodanciu
Copy link
Contributor Author

As discussed, the result for this would be:

c1 - (Authorized h1, Active, NoChangeExpected)  (it's in current & nextCommittee)
c2 - (Authorized h2, Expired, ToBeRemoved) (it's in current && not in nextCommittee)
c3 -  (NotAuthorized, Active, ToBeRemoved) (it's in current && no the nextCommittee)
c4 - (NotAuthorized, Expired, NoChangeExpected)  (it's in current && the nextCommittee)
c80 - (Authorized h80, Unrecognized, ToBeEnacted)   (Unrecognized, regardless of the epochNo, because it's not in the current committee)
c90 - (Authorized h90, Unrecognized,  ToBeRemoved)  (Unrecognized, because it's not in currentCommitee,  ToBeRemoved, because it's not in the nextCommittee)
c500 -  (NotAuthorized, Unrecognized, ToBeEnacted)  (Unrecognized, because it's not in currentCommittee, ToBeEnacted, because it's in the nextCommittee)

@teodanciu teodanciu force-pushed the td/committee-query-next-epoch-change branch from 1d167ee to d20e6d4 Compare November 21, 2023 13:51
@teodanciu teodanciu mentioned this pull request Nov 21, 2023
9 tasks
@teodanciu teodanciu force-pushed the td/committee-query-next-epoch-change branch 2 times, most recently from 8ad77ee to d191696 Compare November 21, 2023 17:12
Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

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

I've suggested some minor changes.
We can discuss them tomorrow if you have questions about it.

@teodanciu teodanciu force-pushed the td/committee-query-next-epoch-change branch 5 times, most recently from 78d886d to e5b85cd Compare November 24, 2023 01:23
@teodanciu
Copy link
Contributor Author

Updated with the suggested changes, and also reflected them in the ImpTests in the other PR: #3883

@teodanciu teodanciu requested a review from lehins November 24, 2023 12:24
Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

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

There is a test failure on CI due to a faulty tes, otherwise it looks great.

@teodanciu teodanciu force-pushed the td/committee-query-next-epoch-change branch 3 times, most recently from 3d7fec6 to 43b1122 Compare December 5, 2023 11:21
Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

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

Awesome work!

@teodanciu teodanciu force-pushed the td/committee-query-next-epoch-change branch from 43b1122 to e2310f7 Compare December 5, 2023 13:43
with default empty implementation
by looking at the committee that will be enacted at the next epoch
boundary.
and refactor data generation functions to use `Committee` and
`CommitteeState` types instead of the underlying types
@teodanciu teodanciu force-pushed the td/committee-query-next-epoch-change branch from e2310f7 to eaab9e7 Compare December 5, 2023 14:01
@lehins lehins enabled auto-merge December 5, 2023 14:10
@lehins lehins disabled auto-merge December 5, 2023 14:10
@lehins lehins enabled auto-merge December 5, 2023 14:11
@teodanciu teodanciu force-pushed the td/committee-query-next-epoch-change branch from e1adbd7 to 7661330 Compare December 5, 2023 14:35
@lehins lehins merged commit 7afb1c8 into master Dec 5, 2023
8 of 11 checks passed
@iohk-bors iohk-bors bot deleted the td/committee-query-next-epoch-change branch December 5, 2023 16:37
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.

Finish queryCommitteeMembersState
2 participants