-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Replace RollingSessionWindow
in approval-voting with RuntimeInfo
#7123
Conversation
…unction also tries to initialize `SessionInfoProvider`
While it's ok for dispute-coordinator to only store the past |
I see what you mean but with Am I thinking in the right direction? |
The runtime keeps only 6 sessions in state. In the case of a long finality stall we would need to query session infos from older blocks. See #7127 |
You mean the cache in runtime api subsystem or the actual runtime? If the former - we are good. All get_session_info() calls are made with a corresponding block hash, not the latest seen head. |
That sounds good then! |
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.
Maybe I'm misreading the code, but I think we should make sure #6165 is addressed properly here.
@ordian just to be sure we are on the same page:
Do you agree (especially with 3)? |
In principle yes, I agree. But I'm not sure exactly what is the purpose of |
Okay, what you wrote above is sort of correct. We already agreed it is wrong. But the scenario you described is only valid for the session caching. The actual session fetching in the rest of the code (in this PR) is made via parent hash so it should be fine. I think I understand the concerns of both of you - let me rework the PR and we'll continue discussing the final solution. |
I've removed the check for earliest session and check if the block is finalized instead. Also I removed the pre-caching. I think it won't help much because of the reasons @ordian and @sandreim - in case of a finality lag we won't be able to fill in the cache. During normal operation - the cache will be populated the first time when a session is requested. Any thoughts on this @eskimor? The last two commits are work in progress and need polishing and fixing the tests. Please ignore (for now) things like commented out code blocks in the tests, misleading variable names and broken tests. I want to get some feedback first because adjusting the tests will be time consuming and I want to do it only once :) |
Sounds sensible. |
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.
Looks nice except for the log levels which need double checking.
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.
Looks good! Actual removal of RollingSessionWindow and db migration will be a separate PR?
…se log level to DEBUG
I've fixed all outstanding issues. I'll do a burnin on versi and this can be merged.
My plan was to remove |
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.
Good job!
closes #6144
This is the 2nd change for #6812. It's similar to #6968 but addresses approval-voting.
Please refer to the description in #6968 for some context.
This PR introduces
SessionInfoProvider
which wrapsRuntimeInfo
and some additional fields for book keeping. Unlikedispute-coordinator
,approval-voting
doesn't wait for the first leaf to initialize its session information and directly starts its main loop. For this reasonRollingSessionWindow
was wrapped inOption
. It isNone
on startup and gets initialized on first leaf update. I can't see a reason for this to be honest but it probably handles some edge case so I kept this behaviour. If this is not the case - please leave a comment. Removing this might make the overall code a bit nicer.RollingSessionWindow
was part ofState. However
RuntimeInforequires
&mut selffor each operation which created some complications so I decided to separate them. Furthermore this allowed me to remove some mut borrows of
State` throughout the code.RuntimeInfo
is async which required to convert some of the functions inapproval-voting
toasync
ones but this change is small and self-explanatory.Another change worth mentioning is that
session_info
(renamed toget_session_info
) andcache_session_info_for_head
are now free standing functions, but more or less their behaviour is the same.cache_session_info_for_head
pre-cachesSessionInfo
in a fashion similar to the one used indispute-coordinator
.