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

Record delisted pools in a dedicated table. #2277

Conversation

jonathanknowles
Copy link
Contributor

Issue Number

#2249

Overview

This PR records delisted pools in a dedicated table instead of using a field in the pool_registrations table.

In the updated schema, a pool is delisted if (and only if) there is a single row containing that pool's id in the delisted_pools table.

This solution has several advantages:

  1. We only need a single database row to record that a pool is delisted.

  2. We no longer need to carefully to ensure that all registration records for a particular pool have the same delisted status. A pool is either delisted or not delisted: the schema rules out all intermediate states.

  3. Pools automatically remain delisted when rollbacks occur or when new certificates are published, with no special effort.

  4. The putPoolRegistration function no longer needs to read the most-recently-written registration entry before adding a new entry.

  5. Each row in the pool_registrations table is now just an immutable record of a registration certificate.

@jonathanknowles jonathanknowles self-assigned this Oct 28, 2020
Copy link
Contributor

@hasufell hasufell left a comment

Choose a reason for hiding this comment

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

Looks good, just a few remarks

lib/core/src/Cardano/Pool/DB/Model.hs Show resolved Hide resolved
lib/core/src/Cardano/Pool/DB/Model.hs Outdated Show resolved Hide resolved
lib/core/src/Cardano/Pool/DB/Sqlite.hs Outdated Show resolved Hide resolved
lib/core/src/Cardano/Pool/DB/Sqlite/TH.hs Outdated Show resolved Hide resolved
jonathanknowles added a commit that referenced this pull request Oct 28, 2020
jonathanknowles added a commit that referenced this pull request Oct 28, 2020
We must replace the set of delisted pools, rather than augmenting it.

In response to review feedback:

#2277 (comment)
jonathanknowles added a commit that referenced this pull request Oct 28, 2020
This operation completely replaces the set of delisted pools, rather
than augmenting it. Therefore, the name `delistPools` is slightly
misleading, as it gives the impression that the existing set will be
augmented, which is no longer true.

In response to review feedback:

#2277 (comment)
jonathanknowles added a commit that referenced this pull request Oct 28, 2020
In particular, we check that 'putDelistedPools' completely overwrites
the existing set every time.

In response to review feedback:

#2277 (comment)
jonathanknowles added a commit that referenced this pull request Oct 28, 2020
This test no longer makes sense, as delisted pools are no longer stored
in the `pool_registration` table.

In response to review feedback:

#2277 (comment)
lib/core/src/Cardano/Pool/DB/Model.hs Outdated Show resolved Hide resolved
lib/core/src/Cardano/Pool/DB/Sqlite.hs Outdated Show resolved Hide resolved
jonathanknowles added a commit that referenced this pull request Oct 28, 2020
Record delisted pools in a dedicated table instead of using a field in
the `pool_registrations` table.

In the updated schema, a pool is delisted if (and only if) there is a
single row containing that pool's id in the `delisted_pools` table.

This solution has several advantages:

  1.  We only need a single database row to record that a pool is delisted.

  2.  We no longer need to carefully to ensure that all registration records
      for a particular pool have the same delisted status. A pool is either
      delisted or not delisted: the schema rules out all intermediate states.

  3.  Pools automatically remain delisted when rollbacks occur or when new
      certificates are published, with no extra effort.

  4.  The `putPoolRegistration` function no longer needs to read the
      most-recently-written registration entry before adding a new entry.

  5.  Each row in the `pool_registrations` table is now just an immutable
      record of a registration certificate.

  6.  The `PoolFlag` type is no longer necessary.
We must replace the set of delisted pools, rather than augmenting it.

In response to review feedback:

#2277 (comment)
@jonathanknowles jonathanknowles force-pushed the jonathanknowles/simply-delist-pools branch from 12f5426 to b44bbb8 Compare October 29, 2020 04:10
jonathanknowles added a commit that referenced this pull request Oct 29, 2020
This operation completely replaces the set of delisted pools, rather
than augmenting it. Therefore, the name `delistPools` is slightly
misleading, as it gives the impression that the existing set will be
augmented, which is no longer true.

In response to review feedback:

#2277 (comment)
jonathanknowles added a commit that referenced this pull request Oct 29, 2020
In particular, we check that 'putDelistedPools' completely overwrites
the existing set every time.

In response to review feedback:

#2277 (comment)
jonathanknowles added a commit that referenced this pull request Oct 29, 2020
This test no longer makes sense, as delisted pools are no longer stored
in the `pool_registration` table.

In response to review feedback:

#2277 (comment)
jonathanknowles added a commit that referenced this pull request Oct 29, 2020
This operation completely replaces the set of delisted pools, rather
than augmenting it. Therefore, the name `delistPools` is slightly
misleading, as it gives the impression that the existing set will be
augmented, which is no longer true.

In response to review feedback:

#2277 (comment)
In particular, we check that 'putDelistedPools' completely overwrites
the existing set every time.

In response to review feedback:

#2277 (comment)
This test no longer makes sense, as delisted pools are no longer stored
in the `pool_registration` table.

In response to review feedback:

#2277 (comment)
@jonathanknowles jonathanknowles force-pushed the jonathanknowles/simply-delist-pools branch from b44bbb8 to f5681e8 Compare October 29, 2020 06:54
@jonathanknowles jonathanknowles merged commit c95ce6e into jospald/ADP-478/gc-delisted-stake-pools Oct 29, 2020
@jonathanknowles jonathanknowles deleted the jonathanknowles/simply-delist-pools branch October 29, 2020 07:35
jonathanknowles added a commit that referenced this pull request Oct 29, 2020
jonathanknowles added a commit that referenced this pull request Oct 29, 2020
We must replace the set of delisted pools, rather than augmenting it.

In response to review feedback:

#2277 (comment)
jonathanknowles added a commit that referenced this pull request Oct 29, 2020
This operation completely replaces the set of delisted pools, rather
than augmenting it. Therefore, the name `delistPools` is slightly
misleading, as it gives the impression that the existing set will be
augmented, which is no longer true.

In response to review feedback:

#2277 (comment)
jonathanknowles added a commit that referenced this pull request Oct 29, 2020
In particular, we check that 'putDelistedPools' completely overwrites
the existing set every time.

In response to review feedback:

#2277 (comment)
jonathanknowles added a commit that referenced this pull request Oct 29, 2020
This test no longer makes sense, as delisted pools are no longer stored
in the `pool_registration` table.

In response to review feedback:

#2277 (comment)
hasufell pushed a commit that referenced this pull request Oct 30, 2020
hasufell pushed a commit that referenced this pull request Oct 30, 2020
We must replace the set of delisted pools, rather than augmenting it.

In response to review feedback:

#2277 (comment)
hasufell pushed a commit that referenced this pull request Oct 30, 2020
This operation completely replaces the set of delisted pools, rather
than augmenting it. Therefore, the name `delistPools` is slightly
misleading, as it gives the impression that the existing set will be
augmented, which is no longer true.

In response to review feedback:

#2277 (comment)
hasufell pushed a commit that referenced this pull request Oct 30, 2020
In particular, we check that 'putDelistedPools' completely overwrites
the existing set every time.

In response to review feedback:

#2277 (comment)
hasufell pushed a commit that referenced this pull request Oct 30, 2020
This test no longer makes sense, as delisted pools are no longer stored
in the `pool_registration` table.

In response to review feedback:

#2277 (comment)
hasufell pushed a commit that referenced this pull request Oct 30, 2020
KtorZ pushed a commit that referenced this pull request Nov 6, 2020
KtorZ pushed a commit that referenced this pull request Nov 6, 2020
We must replace the set of delisted pools, rather than augmenting it.

In response to review feedback:

#2277 (comment)
KtorZ pushed a commit that referenced this pull request Nov 6, 2020
This operation completely replaces the set of delisted pools, rather
than augmenting it. Therefore, the name `delistPools` is slightly
misleading, as it gives the impression that the existing set will be
augmented, which is no longer true.

In response to review feedback:

#2277 (comment)
KtorZ pushed a commit that referenced this pull request Nov 6, 2020
In particular, we check that 'putDelistedPools' completely overwrites
the existing set every time.

In response to review feedback:

#2277 (comment)
KtorZ pushed a commit that referenced this pull request Nov 6, 2020
This test no longer makes sense, as delisted pools are no longer stored
in the `pool_registration` table.

In response to review feedback:

#2277 (comment)
KtorZ pushed a commit that referenced this pull request Nov 6, 2020
KtorZ pushed a commit that referenced this pull request Nov 10, 2020
KtorZ pushed a commit that referenced this pull request Nov 10, 2020
We must replace the set of delisted pools, rather than augmenting it.

In response to review feedback:

#2277 (comment)
KtorZ pushed a commit that referenced this pull request Nov 10, 2020
This operation completely replaces the set of delisted pools, rather
than augmenting it. Therefore, the name `delistPools` is slightly
misleading, as it gives the impression that the existing set will be
augmented, which is no longer true.

In response to review feedback:

#2277 (comment)
KtorZ pushed a commit that referenced this pull request Nov 10, 2020
In particular, we check that 'putDelistedPools' completely overwrites
the existing set every time.

In response to review feedback:

#2277 (comment)
KtorZ pushed a commit that referenced this pull request Nov 10, 2020
This test no longer makes sense, as delisted pools are no longer stored
in the `pool_registration` table.

In response to review feedback:

#2277 (comment)
KtorZ pushed a commit that referenced this pull request Nov 10, 2020
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.

2 participants