-
Notifications
You must be signed in to change notification settings - Fork 168
Introduce Stake Slices #1086
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
Introduce Stake Slices #1086
Conversation
What is |
cardano-db/src/Cardano/Db/Schema.hs
Outdated
| epochNo Word64 Maybe sqltype=word31type | ||
| slotNo Word64 Maybe sqltype=word63type | ||
| epochSlotNo Word64 Maybe sqltype=word31type | ||
| epochHeight Word64 Maybe sqltype=word31type |
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 we are to add this, we will need a documentation entry down below in this file.
This is the height of the block in its epoch. |
2a81508 to
1d852b4
Compare
|
Added comments and fixed hlint. I have synced mainnet up to epoch 247 without issues. The epoch_stake is same as the released snapshots and the epoch_height seems correct. |
c157e8a to
632020b
Compare
We already have something like this, its |
b74ef0e to
26ced03
Compare
|
Also need to ask, what do we need this |
|
This |
|
If its not actually needed, I wonder if its worth adding to the |
| applyToEpochHeight _ _ EBBHeight = Height 0 | ||
|
|
||
| stakeSliceSize :: Word64 | ||
| stakeSliceSize = 2000 |
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.
Sorry for dropping in, but is there potential for this value to be configurable by users - via config or startup arg?
Would be good to be able to tune stake chunks from consumer pov to be larger/smaller depending on instance performance and actual amount of stake inserts by end user (maybe as advanced option)
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.
Not sure making this configurable is such a good idea. Its too easy for a user the configure it to a value that causes problems, but the problems will not be easily related to this value. There is also no advantage for to either making it slower or faster.
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.
Values less than 100 on mainnet could cause issues, since with ~21000 blocks per epoch, this gives us max 2100000 delegations. Maybe it's even worth having a sanity check that this value is bigger than size_of_delegations / expected_blocks or it could be adjusted per epoch to a big enough value if that's not the case.
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.
Right, my primary concern is that other than mainnet and testnet, there are also small networks run by community (guild network is a small one with 3600 slots/~180 blocks per epoch, and some run short-lived networks destroyed later for their own tests too) that have very low amount of blocks per epoch, but can have:
- very low amount of stake initially , as network isn't used by many
- very high amount of stakes as part of burst tests
If we think value of 2000 is safe enough even for small networks, we might be OK.
I understand that it could be misused, but if above becomes a concern - maybe it only be exposed as an advanced option , that not every dbsync user should touch?
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 might make sense to parameterize this value on expected blocks per epoch, but it does not make sense to expose this to users.
@kderme It would be good to think about the issue @rdlrt raises and also think about some of the testnets we run which have a very low quality factor (ie large numbers of missing blocks).
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.
Ok changed this. The slice size is now max 2000 defaultEpochSliceSize. defaultEpochSliceSize is a value big enough to cover everything even if only 20% of the expected blocks are produced in the epoch.
So we could even make 2000 configurable, since if the user provides a very small value it will be orewriten. But I'd leave this for another pr.
Don't really have a strong opinion on this. Other tables are much more populated than |
|
Yes, please remove it. Also worthwhile seeing if the current hard coded number works correctly on some of the QA test nets (there are 2 from memory, both with pretty sparse block production). Also is it possible to have a test for this, both with sparse and dense block production? |
26ced03 to
fb212bf
Compare
d07b9ef to
07e6463
Compare
07e6463 to
af9c70e
Compare
|
This was merged in PR #1094 . |
This removes the stake distribution from the volatile data and introduces a new way to extract slices of the stake distribution from the ledger state. The size of slices is 2000 and the start index is computed by 2000 * (height of block in epoch).
In the same way that consensus extends the ledger state and maintains the
ExtLedgerStatewe extend it even more, in order to maintain the epoch height. The ext^2 state is stored to disk, which means there are no volatile data. I think the idea to extend the ledger state/snapshot with additional information can be useful in other places. We must be careful though, since it breaks compatibility with previous db-sync versions (it needs a resync from genesis).Additionally, this gives us the opportunity to add a new fields
epoch_heightto theblocktable. db-sync doesn't really depend on this field, but it can be good to have.This also implements IntersectMBO/cardano-ledger#2657 or a slight variation
Marking this as draft since I'm still syncing from genesis to test it.