-
Notifications
You must be signed in to change notification settings - Fork 13
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
[Off-Chain] ModuleParamsClient & Historical Params #543
[Off-Chain] ModuleParamsClient & Historical Params #543
Comments
Current StatusTL;DR, parking this work as-is for now to shift focus. Cold-start edge case IS critical-path; therefore, The current state of this work implements off-chain historical and non-historical, in-memory caching with event-driven cache warming (via comet RPC tx event query subscription). Given the options at this juncture (see the mindmap below), my view is that it would be too wasteful (and create unnecessary uncertainty) to try to postpone event-driven cache warming. Additionally, that branch of the decision tree is independent from that of how to test the cold-start edge case, which I am going to argue IS critical-path, especially in the alpha/beta regimes where there's a very non-zero possibility that binaries may getting bounced more than otherwise expected. Options From Here
My view is that 1. requires extra work prior to merging and may introduce bugs. As the client caching architecture is fairly thoroughly described by class diagrams, collectively across the individual PRs, and since there's no currently planned work that should significantly overlap with these changes (because it's a foundational optimization), there's no good reason to try to rush a merge right now. Related PRs:
Decision Treemindmap
(event-driven cache warming)
(POSTPONE event-driven cache warming<br>⏳⏳⏳⏳)
(MUST SetVersion on cache miss)
(how to know latest height?<br>❓❓❓)
(add BlockQueryClient dependency)
(what query frequency?<br>❓❓❓)
(block time - consensus param)
might as well use BlockClient subscription?<br>🤔
(BlockQueryClient depends on BlockQueryClient)
(BlockClient would waste more bandwidth)
(IMPLEMENTATION OPTIONS<br>🏗️🚧)
(subscribe to CONTAINS MsgUpdateParam<br>✅ ⭐⭐⭐⭐⭐)
(TESTING)
(depends on E2E app testutil - websocket server)
(subscribe to new block events)
(OVERFETCHING)
(MOST blocks WON'T contain param update messages but WILL contain other irrelevant messages and events<br>❌ 💣💣💣💣💣)
(cold-start edge case)
("query ABCI RPC (cometbft)")
(TESTING)
(depends on E2E app testutil)
(gRPC gateway<br>❓❓❓)
(combetbft RPC server<br>❓❓❓)
(OR depends on configurable cache)
(requires many additional generic parameters)
|
Objective
Enable support for off-chain processes to cache on-chain parameters and react to parameter updates asynchronously.
Origin Document
Off-chain actors currently query the network much too frequently.
Observations made while working on [Protocol] Add a
NumBlocksPerSession
governance parameter #517. In order for off-chain processes to use the correct governance params in the appropriate places in the protocol, they MUST be aware of the most recent param values. In some cases, off-chain processes MUST also know the historical values of some params.Assumptions
Example
A param update message is committed in the middle of a session, modifying
num_blocks_per_session
&min_relay_difficulty_bits
by the time a proof is submitted & validated on-chain. Thenum_blocks_per_session
andmin_relay_difficulty_bits
at the time of the session to which the proof corresponds (i.e. will not be the current session) MUST be used. There may also be off-chain use cases (presently or in the future) which require previous values for params.Goals
ModuleParamsClient
(see: notion -ModuleParamsClient
)Design Choices
On-chain persistence of historical params
When a param update message is committed:
The corresponding on-chain params value(s) are updated on commit.
The previous param value(s), the current session number, & the height at which the param update message is committed are stored in the on-chain state. There are a couple of options for how to persist historical params that effect what their usage would look like:
History: map[updateHeight]Params{}
i. When an off-chain client queries for params, the response includes the current param values, as well as previous values, the last session number that each previous was set, and the height at which each previous value was updated (no longer valid after). An additional parameter would be introduced to determine the "retention block count" for (each or all?) param(s).
Pros
Cons
ii. An off-chain client could query would make distinct queries whether querying for current params or historical params. Historical param queries would take a height argument & MAY return an error if the requested height is older than the "retention block count"
Pros
params
module) to consolidate common behavior across modules.Cons
Another degree of freedom is open regarding whether or not to add methods for querying param values a specific height, and if so, whether those methods should be on-chain, off-chain, or both.
Keeper#Params()
&QueryParamsRequest
)Params
go protobuf struct itself)ModuleParamsClient
Use the respective module's
QueryClient
to query for the params initially, followed by subscribing to block events via aBlockClient
(or itsEventsReplayClient
deconstruction used withblock.UnmarshalNewBlockEvent()
) such that updated params may be emitted by an observable & a cache is accumulated over time. Params at height which are not in this cache MUST be queried for on-chain.Pros:
Cons:
block.CometNewBlockEvent
s (see: session_steps_test.go:131).Use a
BlockClient
& the respective module'sQueryClient
to query for the params at the start height of each session.Pros:
Cons:
Deliverables
Non-goals / Non-deliverables
General deliverables
Creator: @bryanchriswhite
The text was updated successfully, but these errors were encountered: