Skip to content
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

fix: watch ERTP purse balances across zoe upgrades (release branch) #8557

Closed
wants to merge 4 commits into from

Conversation

dckc
Copy link
Member

@dckc dckc commented Nov 21, 2023

refs: #8293

Description

observeNotifier(...) would handle upgrade disconnects if the notifiers were durable. But in the @agoric/ertp implementation, they're ephemeral. So we open-code the loop.

  • the failure case now throws. It used to log and return undefined. Is this a good API change?

Security / Scaling / Documentation Considerations

I don't see any.

Upgrade Considerations

This change is not intended to ship on its own. Fixes for #8286 and #8292 are intended for the same upgrade.

This PR targets the release-mainnet1B branch. A separate PR targeting master is in progress.

Testing Considerations

The first commit reproduces #8293 by upgrading zoe and noting the balance update failure.
The 2nd commit fixes it.

@dckc dckc changed the base branch from master to release-mainnet1B November 21, 2023 17:23
@dckc dckc changed the title test: 8293 upgrade watch balance fix(smart-wallet): watch ERTP purse balances across zoe upgrades Nov 28, 2023
@dckc dckc marked this pull request as ready for review November 28, 2023 00:43
@dckc dckc requested a review from turadg November 28, 2023 00:44
Copy link
Member

@turadg turadg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code reviewed together. Pushed some commits, LGTM.

the failure case now throws. It used to log and return undefined. Is this a good API change?

Yes good. We confirmed the only consumers use void instead of awaiting the promise, so the change is basically to log as an UnhandledPromiseRejection instead of a simple console message.

Should it target master and then get back-ported to the release branch?

Both. Currently, it needs to be on the release branch to be released. We also need it on master going forward.

console.error(address, `failed updateState observer`, reason);
},
});
// This would seem to fit the observeNotifier() pattern,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

valuable comment

@dckc dckc changed the title fix(smart-wallet): watch ERTP purse balances across zoe upgrades fix: watch ERTP purse balances across zoe upgrades (release branch) Nov 28, 2023
@dckc dckc added the automerge:rebase Automatically rebase updates, then merge label Nov 28, 2023
dckc and others added 4 commits November 28, 2023 14:24
  - provision a smartWallet for an oracle operator
  - upgrade zoe; reproduce smartWallet bug
  - check for new invitation
observeNotifier() would handle upgrade disconnects if the notifiers
were durable. But in @agoric/ertp, they're ephemeral, so we open-code
the loop.
@dckc dckc requested a review from mhofman November 28, 2023 20:36
@dckc dckc removed the automerge:rebase Automatically rebase updates, then merge label Nov 28, 2023
@mhofman mhofman added the force:integration Force integration tests to run on PR label Nov 28, 2023
Copy link
Member

@mhofman mhofman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides the surprising tail recursion, I'm a little confused as to how this new subscription will apply to existing purses, since this was and remains an active / heap subscription, and I don't see any iteration over existing purses during upgrade.

I understand this is a separate issue (durability of the subscriber), but I'm surprised to not see a mention of it in Upgrade Considerations given that this code requires an upgrade of the smart wallet vat.

}
} catch (err) {
if (isUpgradeDisconnection(err)) {
helper.watchPurse(purse); // retry
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No return? Not sure who is the initial caller but this looks like a tail recursion, and it feels weird without a return.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually thinking about this more, this seem too simplistic, and doesn't handle the same disconnection error being replayed, which is why tools like reconnectAsNeeded exist which check the incarnation in the disconnect error.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't handle the same disconnection error being replayed

What am I missing? The way I understand things, the test is compelling evidence that it does.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the problem is in case of a proxy between the notifier in the upgraded vat, and the subscriber. It's possible that this is not the case here, but you could get in an infinite loop if the subscription request somehow rejects with the same disconnect error. The increasing incarnation number is there to help differentiate the case of replayed disconnect error, and should be checked when re-attempting subscription.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No return? Not sure who is the initial caller but this looks like a tail recursion, and it feels weird without a return.

Agreed. #8573 has a return.

@dckc which PR should be reviewed? I support this one first and the port be in draft until this lands, so that it can match whatever changes are made here

@mhofman
Copy link
Member

mhofman commented Nov 28, 2023

Besides that, the code only changes the smart wallet vat, so is safe from the point of view of targeting the release-mainnet1B branch,

Copy link
Member

@mhofman mhofman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paging @gibson042 who is likely more familiar with the disconnect errors than me.

}
} catch (err) {
if (isUpgradeDisconnection(err)) {
helper.watchPurse(purse); // retry
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually thinking about this more, this seem too simplistic, and doesn't handle the same disconnection error being replayed, which is why tools like reconnectAsNeeded exist which check the incarnation in the disconnect error.

@dckc
Copy link
Member Author

dckc commented Nov 28, 2023

... I'm a little confused as to how this new subscription will apply to existing purses, since this was and remains an active / heap subscription, and I don't see any iteration over existing purses during upgrade.

That's a problem with upgrading the walletFactory; for that, see #8286.

This PR is about a problem when upgrading zoe.

Perhaps they're not entirely orthogonal. I suppose this could depend on a fix for #8286. But I would prefer to land this independently.

@dckc
Copy link
Member Author

dckc commented Nov 28, 2023

I understand this is a separate issue (durability of the subscriber), but I'm surprised to not see a mention of it in Upgrade Considerations given that this code requires an upgrade of the smart wallet vat.

Good point. I added something in Upgrade Considerations.

@mhofman
Copy link
Member

mhofman commented Nov 28, 2023

I suppose this could depend on a fix for #8286. But I would prefer to land this independently.

That issue mentions problems with offer notifications, but here it seems to be an upgrade problem with purse balances. Is that issue too narrowly described?

These fixes are indeed not entirely orthogonal as this new code won't take effect on upgrade for existing purses, which to me seems like an upgrade concern for the issues of "purse balances stopping to update", albeit not when the issuer/zoe is upgraded, but when the smart wallet vat is. (Also, how was this not a concern in the 11wf upgrade?)

@dckc dckc requested a review from mhofman November 28, 2023 22:29
@dckc
Copy link
Member Author

dckc commented Nov 28, 2023

... Also, how was this not a concern in the 11wf upgrade?

The only purses were vbank purses and the zoe invitation purse. walletFactory doesn't subscribe to vbank purse updates (we don't provide them: #5896). The smartWallet finish method calls helper.watchPurse(invitationPurse).

@dckc dckc closed this Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
force:integration Force integration tests to run on PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants