-
Notifications
You must be signed in to change notification settings - Fork 138
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
Order of EndBlock() #51
Comments
Test scenario 1:
Test scenario 2:
|
It should be pretty easy to make everything work by moving Possible solutions:
@AdityaSripal would like to get your opinion on this because I'm sure it has been an issue for other modules. |
Looks like we already do
I don't think atm there's a better solution than to document this clearly. Plenty of ways to shoot yourself in the foot by wiring app.go incorrectly. I think so far, we've relied on clear documentation and code examples people can copy/paste from |
Add comment in provider/app.go addressing the order of |
Update: see #51 (comment)
The
EndBlock()
of the provider CCV module gets validator updates from the staking module. Therefore, thestaking.EndBlock()
must be executed beforeccv.EndBlock()
.Let
h
be the height at which the provider creates a client for a new consumer chain, i.e.,interchain-security/x/ccv/parent/keeper/proposal.go
Line 29 in 196012a
Then, the initial validator set on the consumer chain is the next validator set (i.e., the validator set that validates at height
h+1
). This validator set was updated by executingstaking.EndBlock()
at heighth-1
. Thus, theLastValidatorPower
index contains this validator set until executingstaking.EndBlock()
at heighth
. SinceMakeChildGenesis()
(called fromCreateChildClient()
) needsLastValidatorPower
to contain this initial validator set, it must be called beforestaking.EndBlock()
.Moreover, since
staking.EndBlock()
at heighth
may update the validator set of heighth+1
(i.e., the initial val set), these updates must be sent to the consumer chain. Thus, the consumer chain must be registered (i.e., have a client created) beforeccv.EndBlock()
is called. Consequently, CCV requires the following order:CreateChildClient()
,staking.EndBlock()
,ccv.EndBlock()
.CreateChildClient()
is called from two places, i.e.,interchain-security/x/ccv/parent/keeper/proposal.go
Line 25 in 9b134d7
interchain-security/x/ccv/parent/keeper/proposal.go
Line 174 in 9b134d7
The former is called from
gov.EndBlock()
, which would entail the following order of executing theEndBlock()
:gov.EndBlock()
,staking.EndBlock()
,ccv.EndBlock()
.The issue is with the latter which is called from
ccv.EndBlock()
and, thus, would entail the following order:ccv.EndBlock()
,staking.EndBlock()
,ccv.EndBlock()
, which is not possible. As a solution, we should callCreateChildClient()
for pending clients fromccv.BeginBlock()
.The text was updated successfully, but these errors were encountered: