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

Introduced IncrementalStake, for all Eras #2538

Merged
merged 1 commit into from
Dec 7, 2021

Conversation

TimSheard
Copy link
Contributor

incrementally maintains the raw stake distribution as well as the UTxO.
Adds InrementalStake field to UTxOState
Utxo rule (Utxos rule in Alonzo) and the Snap rule are modified to use this new state
Added a property test that computes both ways at every Epoch Boundary.

Copy link
Contributor

@JaredCorduan JaredCorduan left a comment

Choose a reason for hiding this comment

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

@TimSheard overall this is really awesome!! I made some minor comments.

@TimSheard TimSheard force-pushed the jc/incremental-stake-distribution branch from e81788c to fc9c609 Compare November 4, 2021 14:25
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 don't know enough about the staking logic to comment on the implementation, but here are my comments with respect to Haskell.

eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Snap.hs Outdated Show resolved Hide resolved
eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Snap.hs Outdated Show resolved Hide resolved
eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Utxo.hs Outdated Show resolved Hide resolved
libs/cardano-ledger-core/src/Cardano/Ledger/TerseTools.hs Outdated Show resolved Hide resolved
libs/cardano-ledger-core/src/Cardano/Ledger/TerseTools.hs Outdated Show resolved Hide resolved
@TimSheard TimSheard force-pushed the jc/incremental-stake-distribution branch from 8b7c7d0 to 81abe93 Compare November 4, 2021 20:16
@TimSheard TimSheard force-pushed the jc/incremental-stake-distribution branch from 81abe93 to 6900bf2 Compare November 5, 2021 18:07
Copy link
Contributor

@nc6 nc6 left a comment

Choose a reason for hiding this comment

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

Just marking this as request changes so we don't accidentally merge - this branch is known to cause problems during benchmark run.

@JaredCorduan JaredCorduan force-pushed the jc/incremental-stake-distribution branch from c3ef302 to c37360d Compare November 18, 2021 21:06
@JaredCorduan JaredCorduan force-pushed the jc/incremental-stake-distribution branch from c37360d to a107301 Compare November 19, 2021 17:43
@nc6 nc6 force-pushed the jc/incremental-stake-distribution branch from a107301 to bb7e7eb Compare November 26, 2021 09:14
@deepfire
Copy link
Contributor

deepfire commented Dec 3, 2021

@nc6, this is green from benchmarking standpoint.

@nc6 nc6 self-requested a review December 6, 2021 08:13
Copy link
Contributor

@nc6 nc6 left a comment

Choose a reason for hiding this comment

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

Left a bunch of comments, which I think it would be good to address. However, since this PR has been open for so long, happy for them to be addressed in a separate PR if that's easier.

-- and combining them with the ordinary stake. Zero out the Ptr indexed stake in the result.
-- This function is meant to only be called at the Epoch boundary in the Snap Rule. It is not meant
-- to be used to transform the IncrementalStake.
resolveIncrementalPtrs :: Map Ptr (Credential 'Staking (Crypto era)) -> IncrementalStake (Crypto era) -> IncrementalStake (Crypto era)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason in this case for returning IncrementalStake rather than simply Map Credential Coin? I assume we zero out the incremental stuff at the epoch boundary anyway?

Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively, just move this function inside of incrementalStakeDistr, which is the only thing to use it anyway.

-- the _utxo. This is aways safe to do, but if the _utxo field is big, this can be very expensive,
-- which defeats the purpose of memoizing the _stakeDistro field. So use of this function should be
-- restricted to tests and initializations, where the invariant should be maintained.
smartUTxOState ::
Copy link
Contributor

Choose a reason for hiding this comment

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

Better name? Not that I have any good ideas...

@TimSheard TimSheard force-pushed the jc/incremental-stake-distribution branch from bb7e7eb to 3e387a3 Compare December 6, 2021 19:44
Incrementally maintains the raw stake distributiona as well as the UTxO
@TimSheard TimSheard force-pushed the jc/incremental-stake-distribution branch from 3e387a3 to 247e7f0 Compare December 7, 2021 00:14
@nc6 nc6 merged commit c655d61 into master Dec 7, 2021
@iohk-bors iohk-bors bot deleted the jc/incremental-stake-distribution branch December 7, 2021 15:53
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