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

odd {x, y, z} >= {z} failure in AmountMath.isGTE with AssetKind.SET #10292

Closed
dckc opened this issue Oct 17, 2024 · 2 comments
Closed

odd {x, y, z} >= {z} failure in AmountMath.isGTE with AssetKind.SET #10292

dckc opened this issue Oct 17, 2024 · 2 comments
Assignees
Labels
bug Something isn't working ERTP package: ERTP

Comments

@dckc
Copy link
Member

dckc commented Oct 17, 2024

Describe the bug

AmountMath.isGTE with AssetKind.SET fails in a case involving invitations with common descriptions but distinct instance handles.

To Reproduce

Add this to packages/ERTP/test/unitTests/mathHelpers/copySetMathHelpers.test.js and run it:

test('balance {x, y, z} >= {z}', t => {
  const x = { instance: mockHandle('Foo'), description: 'fraz' };
  const y = { instance: mockHandle('Foo'), description: 'fraz' };
  const z = { instance: mockHandle('Foo'), description: 'alan' };

  const balance = harden({ brand: mockBrand, value: makeCopySet([x, y, z]) });
  const withdraw = harden({ brand: mockBrand, value: makeCopySet([z]) });

  t.true(m.isGTE(balance, withdraw));
});

Expected behavior

test above passes

Platform Environment

375dc25

Additional context

@frazarshad discovered this while working on

He made a test PR, #10281

a ci log of that a3p test shows the original context where the problem was found

more diagnosis an an endo issue to follow

Screenshots / Logs

since ci logs expire:

2024-10-16T13:03:13.026Z SwingSet: ls: v9: Error#1: Withdrawal of { brand: Object [Alleged: Zoe Invitation brand] {}, value: [ { description: 'charter member invitation', handle: Object [Alleged: InvitationHandle] {}, installation: Object [Alleged: BundleIDInstallation] {}, instance: Object [Alleged: InstanceHandle] {} } ] } failed because the purse only contained { brand: Object [Alleged: Zoe Invitation brand] {}, value: [ { description: 'charter member invitation', handle: Object [Alleged: InvitationHandle] {}, installation: Object [Alleged: BundleIDInstallation] {}, instance: Object [Alleged: InstanceHandle] {} }, { description: 'oracle invitation', handle: Object [Alleged: InvitationHandle] {}, installation: Object [Alleged: BundleIDInstallation] {}, instance: Object [Alleged: InstanceHandle] {} }, { description: 'oracle invitation', handle: Object [Alleged: InvitationHandle] {}, installation: Object [Alleged: BundleIDInstallation] {}, instance: Object [Alleged: InstanceHandle] {} }, { description: 'Voter0', handle: Object [Alleged: InvitationHandle] {}, installation: Object [Alleged: BundleIDInstallation] {}, instance: Object [Alleged: InstanceHandle] {} } ] }
@dckc dckc added bug Something isn't working ERTP package: ERTP labels Oct 17, 2024
@dckc
Copy link
Member Author

dckc commented Oct 17, 2024

The original failure was observed in a withdraw:

return E(invitationsPurse).withdraw(toWithDraw);

We can see that the amount withdrawn is derived from the balance by filtering:

const purseAmount = await E(invitationsPurse).getCurrentAmount();
const invitations = AmountMath.getValue(invitationBrand, purseAmount);
const matches = invitations.filter(
details =>
description === details.description && instance === details.instance,
);
if (matches.length === 0) {
// look up diagnostic info
const dCount = invitations.filter(
details => description === details.description,
).length;
const iCount = invitations.filter(
details => instance === details.instance,
).length;
assert.fail(
`no invitation match (${dCount} description and ${iCount} instance)`,
);
} else if (matches.length > 1) {
// TODO? allow further disambiguation
console.warn('multiple invitation matches, picking the first');
}
const match = matches[0];
const toWithDraw = AmountMath.make(invitationBrand, harden([match]));
console.log('.... ', { toWithDraw });
return E(invitationsPurse).withdraw(toWithDraw);

interleaving is theoretically possible, but that would have shown in logs, and it doesn't.

@dckc dckc changed the title odd {x, y, z} >= {y} failure in AmountMath.isGTE with AssetKind.SET odd {x, y, z} >= {z} failure in AmountMath.isGTE with AssetKind.SET Oct 22, 2024
@dckc
Copy link
Member Author

dckc commented Oct 23, 2024

fixed in #10316

for upgrade of the zoe invitation issuer, see #10279

@dckc dckc closed this as completed Oct 23, 2024
mergify bot added a commit that referenced this issue Oct 25, 2024
closes: #9370

## Description

The priceFeed proposal has been tested as an independent coreEval, but the current plan calls for it to be included in Upgrade 18. This adds it to `upgrade.go` and moves the tests to `n:upgrade-next`.

### Security Considerations

No additional security implications.

### Scaling Considerations

Addresses pre-existing scaling concerns (see #8400), and adds no new scaling issues.

### Documentation Considerations

None

### Testing Considerations

An existing test is moved to a new location.

The current version seems to tickle #10292, so tests may not pass at this point.

### Upgrade Considerations

Targeted for upgrade 18.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ERTP package: ERTP
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants