-
Notifications
You must be signed in to change notification settings - Fork 215
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
feat: Cosmos upgrade handler calls swingset #7994
Conversation
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.
I believe in our discussions we wanted to avoid a bridge message sent during the upgrade handler. This may indeed work, but I'd like to think more about the design (hence the request for changes)
The upgrade plan cannot be too large as it must be assayable.
Could you clarify what you mean?
The Swingset upgrade handler runs with significant authority, so it must be written carefully.
Could you details how this authority is different from other swingset invocations from golang?
golang/cosmos/app/app.go
Outdated
func swingsetUpgrade(ctx sdk.Context, plan upgradetypes.Plan, callToController func(ctx sdk.Context, str string) (string, error)) error { | ||
action := swingsetUpgradeAction{ | ||
Type: enactUpgradePlanType, | ||
Plan: plan, |
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.
Should the whole plan be sent over? The info may contain information unrelated to swingset, maybe it'd be better to reserve a specific field for the swingset module?
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.
The conventional Cosmos use of the Info field is pretty small, just containing a reference to the exact commit. See the "Plan" section of https://bigdipper.live/agoric/proposals/34
If upgrade proposal plans become larger in the future I'd be happy to restrict the information sent to swingset, but for now I don't think there's a need.
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.
Exposing the entire plan is the best choice, IMO.
By "assayable", I mean that a human voter must be able to look at the raw plan and decide whether it implements the actions described in the prose of the upgrade proposal. For example: https://bigdipper.live/agoric/proposals/34 |
The security caution only means to say that we cannot really tell ahead of time what sort of authority an upgrade handler might not need, so they need to be written just as carefully as |
I think that this is okay, as long as it can be handled before initializing the kernel. If that's the case, I think it is the best and most flexible design. |
Here is the stack trace from the failed CI:
|
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.
I like the design, but something is wrong with the implementation causing a crash.
golang/cosmos/app/app.go
Outdated
func swingsetUpgrade(ctx sdk.Context, plan upgradetypes.Plan, callToController func(ctx sdk.Context, str string) (string, error)) error { | ||
action := swingsetUpgradeAction{ | ||
Type: enactUpgradePlanType, | ||
Plan: plan, |
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.
Exposing the entire plan is the best choice, IMO.
golang/cosmos/app/app.go
Outdated
// business. | ||
stdlog.Println("Rebooting SwingSet") | ||
return mvm, swingset.BootSwingset(ctx, app.SwingSetKeeper) | ||
// Lastly, let Swingset reaction to the upgrade |
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.
// Lastly, let Swingset reaction to the upgrade | |
// Lastly, let SwingSet react to the upgrade |
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.
Done.
@@ -853,6 +836,7 @@ func (app *GaiaApp) MustInitController(ctx sdk.Context) { | |||
VibcPort: app.vibcPort, | |||
VbankPort: app.vbankPort, | |||
LienPort: app.lienPort, | |||
UpgradePlan: app.upgradePlan, |
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.
Interesting, placing the upgradePlan in the init message actually makes sense. I have plans to refactor the toSwingSet
in chain-main.js
which would make this a lot easier and straightforward to handle too!
As we discussed offline, the ability to handle before initializing the kernel was the sticking point if we were going to take the blocking send approach. The PR now allows us to do this, in a clever way by adding the upgrade plan to the init message. Note for future self: the JS side of cosmic-swingset will need to be careful about hangover inconsistency. It's possible for JS to perform its upgrade steps, commit the swing-store, then for the cosmos side to fail and not commit the cosmos DB. On restart it would result in the init message containing the upgrade plan again. cosmic-swingset needs to detect this case and skip the upgrade work (similarly to how chain sends are simply replayed for normal block processing), at least until we have a better story about swing-store rollbacks (#7963). @JimLarson, to clarify, the upgrade plan includes the upgrade name, so the cosmic-swingset JS side can use that info if needed? |
Correct - the plan contains the upgrade name. Note that the upgrade |
feat: Cosmos upgrade handler calls swingset
feat: Cosmos upgrade handler calls swingset
feat: Cosmos upgrade handler calls swingset
feat: Cosmos upgrade handler calls swingset
refs: #7992
closes: #7151
Description
Allow Swingset to perform upgrade-time actions by making a new bridge action that contains the upgrade plan that is called by the Cosmos upgrade handler. The upgrade plan's
Info
field is a string that by convention contains a JSON-serialized object. We can add additional fields to that object for swingset to use.Security Considerations
The Swingset upgrade handler runs with significant authority, so it must be written carefully.
Scaling Considerations
The upgrade plan cannot be too large as it must be assayable.
Documentation Considerations
N/A
Testing Considerations
Swingset upgrade handlers must be tested in a full upgrade test.