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!: in SmartWallet, if invitation is invalid, don't process offer #9240

Merged
merged 3 commits into from
Apr 17, 2024

Conversation

Chris-Hibbert
Copy link
Contributor

refs: #9239

Description

When SmartWallet gets a request to exercise an invitation, it shouldn't create an offer if the invitation is broken.

Security Considerations

Creating an offer requires withdrawing funds, which have to be returned to the user. Better to check the invitation first and skip the rest.

Scaling Considerations

None

Documentation Considerations

None

Testing Considerations

We added a test and a fix.

Upgrade Considerations

We'd like to get this into the next available upgrade. There are no complex interactions with other updates.

Copy link

cloudflare-workers-and-pages bot commented Apr 16, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8e5a054
Status: ✅  Deploy successful!
Preview URL: https://73c2c595.agoric-sdk.pages.dev
Branch Preview URL: https://9239-badinvitation.agoric-sdk.pages.dev

View logs

@Chris-Hibbert Chris-Hibbert requested a review from dckc April 16, 2024 16:08
Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

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

a couple questions and a suggestion... not critical

Comment on lines +975 to +976
const invitationAmount =
await E(invitationIssuer).getAmountOf(invitation);
Copy link
Member

Choose a reason for hiding this comment

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

Looks like we're reconsidering the design from...

Is there anybody we should check with? The record only shows you, me, and @turadg as party to that issue and its fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I was part of that discussion, I've forgotten it.

Thanks for the off-line discussion. I'm comfortable that given what we know now, this order is better.

Comment on lines +36 to 37
/** @type {import('@agoric/vat-data').Baggage} */
const baggage = makeScalarMapStore('bootstrap');
Copy link
Member

Choose a reason for hiding this comment

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

Does anybody know why the type of baggage isn't inferred from makeScalarMapStore?

Copy link
Member

Choose a reason for hiding this comment

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

Baggage is MapStore<string, any> but makeScaleMapStore returns MapStore<unknown, unknown>.

It can take keyShape and valueShape in options, so it could eventually infer those two type parameters, but that would depend on the work to infer types from shapes.

Copy link
Member

Choose a reason for hiding this comment

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

that would depend on the work to infer types from shapes

adding a link to track motivations:

Comment on lines 158 to 159
// @ts-expect-error It's a promise.
const walletsStorage = E(chainStorage).makeChildNode('wallet');
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// @ts-expect-error It's a promise.
const walletsStorage = E(chainStorage).makeChildNode('wallet');
// @ts-expect-error Test setup ensures that chainStorage resolution is not undefined.
const walletsStorage = E(chainStorage).makeChildNode('wallet');

another approach is something like:

 * @param {BootstrapPowers & NonNullChainStorage} powers
 * @typedef {PromiseSpaceOf<{ chainStorage: StorageNode }>} NonNullChainStorage

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 either of the above is good for this PR. You could also reference,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

const invitationAmount =
await E(invitationIssuer).getAmountOf(invitation);

const paymentKeywordRecord =
Copy link
Member

Choose a reason for hiding this comment

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

This is mutative, so no longer simply "prepare". It belongs under "2. Begin executing offer". Consider also naming the object like withdrawnPayments to it's more clear how it relates to the lifecycle of the request.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@dckc
Copy link
Member

dckc commented Apr 16, 2024

Why the ! breaking change marker?

@Chris-Hibbert
Copy link
Contributor Author

Why the ! breaking change marker?

I think of ! as "incompatible behavior change", but if its really "breaking change", I'll drop it.

@dckc dckc merged commit 6fb8dac into dc-invitation-testing Apr 17, 2024
2 checks passed
@dckc dckc deleted the 9239-badInvitation branch April 17, 2024 20:36
mergify bot added a commit that referenced this pull request Apr 18, 2024
…itation (#9236)

refs: #9239

## Description

test handling payments in case of failure to create invitation;
incorporate fix from ...

 - #9240

### Security / Scaling / Documentation

n/a

### Upgrade Considerations

deployment involves upgrading walletFactory (see #9238) 

### Testing Considerations

swingsetTest (and thus walletDriver) doesn't provide access to balances,
so bootstrap test was removed from this PR
gibson042 pushed a commit that referenced this pull request Apr 19, 2024
…itation (#9236)

refs: #9239

## Description

test handling payments in case of failure to create invitation;
incorporate fix from ...

 - #9240

### Security / Scaling / Documentation

n/a

### Upgrade Considerations

deployment involves upgrading walletFactory (see #9238) 

### Testing Considerations

swingsetTest (and thus walletDriver) doesn't provide access to balances,
so bootstrap test was removed from this PR
gibson042 pushed a commit that referenced this pull request Apr 19, 2024
…itation (#9236)

refs: #9239

## Description

test handling payments in case of failure to create invitation;
incorporate fix from ...

 - #9240

### Security / Scaling / Documentation

n/a

### Upgrade Considerations

deployment involves upgrading walletFactory (see #9238) 

### Testing Considerations

swingsetTest (and thus walletDriver) doesn't provide access to balances,
so bootstrap test was removed from this PR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

enhance smart wallet behavior when invitation creation fails
3 participants