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

8722 provisionPool re-register notifiers #9481

Merged
merged 5 commits into from
Jun 12, 2024
Merged

8722 provisionPool re-register notifiers #9481

merged 5 commits into from
Jun 12, 2024

Conversation

Chris-Hibbert
Copy link
Contributor

@Chris-Hibbert Chris-Hibbert commented Jun 10, 2024

fixes: #8722
fixes: #8724
fixes: #8238

Description

Upgrade provisionPool so its notifiers are robust to upgrades.

Security Considerations

This is about soundness of the chain and its services.

Scaling Considerations

N/A

Documentation Considerations

No change to functionality.

Testing Considerations

Includes a test in a3p-integration that demonstrates that provisionPool will survive its own or vat-bank's upgrade.

Upgrade Considerations

See above.

@Chris-Hibbert Chris-Hibbert added bug Something isn't working test Inter-protocol Overarching Inter Protocol contract-upgrade labels Jun 10, 2024
@Chris-Hibbert Chris-Hibbert self-assigned this Jun 10, 2024
@Chris-Hibbert Chris-Hibbert changed the title 8722 provisionPool re-register norifiers 8722 provisionPool re-register notifiers Jun 10, 2024
Copy link

cloudflare-workers-and-pages bot commented Jun 10, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 997d72c
Status: ✅  Deploy successful!
Preview URL: https://14c87d62.agoric-sdk.pages.dev
Branch Preview URL: https://8722-provpoolresub.agoric-sdk.pages.dev

View logs

Comment on lines 393 to 416
if (desc.issuerName.match(FIRST_CAP_ASCII)) {
trace(`Saved Issuer ${desc.issuerName}`);
await zcf.saveIssuer(desc.issuer, desc.issuerName);

// see https://github.com/Agoric/agoric-sdk/issues/8238
} else if (desc.issuerName.match(FIRST_LOWER_ASCII)) {
await saveIssuerWithLegalKeyword(desc, zcf);
} else {
console.error(
`unable to save issuer with illegal keyword: ${desc.issuerName}`,
);
}
Copy link
Member

Choose a reason for hiding this comment

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

both branch save with a legal keyword. This abstraction makes it look like this branch does something different. I think it would be more clear if you made a valid desc and then saved it consistently.

Suggested change
if (desc.issuerName.match(FIRST_CAP_ASCII)) {
trace(`Saved Issuer ${desc.issuerName}`);
await zcf.saveIssuer(desc.issuer, desc.issuerName);
// see https://github.com/Agoric/agoric-sdk/issues/8238
} else if (desc.issuerName.match(FIRST_LOWER_ASCII)) {
await saveIssuerWithLegalKeyword(desc, zcf);
} else {
console.error(
`unable to save issuer with illegal keyword: ${desc.issuerName}`,
);
}
// let this handle the conditions and log about whether repair was necessary
const goodDesc = repair(desc);
if (goodDesc) {
await zcf.saveIssuer(desc.issuer, desc.issuerName);
} else {
console.error(
`unable to save issuer with illegal keyword: ${desc.issuerName}`,
);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's better.

instancePrivateArgsP,
]);
const { adminFacet, instance } = provisionPoolStartResult;
// const privateArgs = await deeplyFulfilled(instancePrivateArgs.get(instance));
Copy link
Member

Choose a reason for hiding this comment

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

stray

@@ -137,3 +137,8 @@ export const bankSend = (addr, wanted) => {

return agd.tx('bank', 'send', VALIDATORADDR, addr, wanted, ...noise);
};

export const getProvisionPoolMetrics = async () => {
Copy link
Member

Choose a reason for hiding this comment

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

not worth the abstraction imo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It hides two things: getQuoteBody() is not exported, and the callers would have to share a definition of the path. I'll make the change if you insist, but you'll have to ask a second time. :-)

Copy link
Member

Choose a reason for hiding this comment

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

ah, I didn't notice the export privacy aspect


/**
* @file
* The problems to be addressed are that provisionPool won't correctly handle
Copy link
Member

Choose a reason for hiding this comment

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

minor: "won't correctly handle" is one problem

Comment on lines 34 to 35
* 2a. if we had been able to null-upgrade provisionPool at this point, we
* wouldn't have been able to productively add USDC, but the null upgrade fails.
Copy link
Member

Choose a reason for hiding this comment

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

IIUC, this would be more clear:

Suggested change
* 2a. if we had been able to null-upgrade provisionPool at this point, we
* wouldn't have been able to productively add USDC, but the null upgrade fails.
* 2a. verify a provisionPool null upgrade fails (if it passed, we wouldn't have been able to productively add USDC)

Though I don't understand why

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I attempted to clarify.

* 3. Do a full upgrade of provisionPool; then deposit USDC, and see IST
* incremented in totalMintedConverted.
*
* 4. Null upgrade vat-bank again, and then see (in logs) that adding a new
Copy link
Member

Choose a reason for hiding this comment

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

why not make a deposit to verify that ability?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We only have assets for currencies that provisionPool already knows about. We can add new currencies, but I haven't found a reasonable way to mint them to be able to deposit them.

Copy link
Member

@turadg turadg Jun 12, 2024

Choose a reason for hiding this comment

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

it is trickier since it's a synthetic-chain test. I think you could do it with core-eval that both adds a new currency and with the available powers mints then deposits. But this comment suffices.

'brands match',
);
if (expectedToGrow) {
// I couldn't import AmountMath. dunno why.
Copy link
Member

Choose a reason for hiding this comment

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

you'd have to add @agoric/ertp as a dependency of this proposal package. Did you try that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did try that. Lemme try again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I do, I get an error at runtime

  ReferenceError: assert is not defined

  › file://node_modules/@endo/eventual-send/src/E.js:3:40

without anything I can recognize as indicating where the problem manifested.

Copy link
Member

Choose a reason for hiding this comment

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

oh yeah, that durn dependency on SES.

You'll also need import "@endo/init/debug.js" before that import.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not familiar with that one (or I've forgotten). Do you have a pointer to an issue or discussion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, it turns out that what we get from vstorage isn't actually an Amount. The brand field contains stringified captp representations. We can compare them for equality, but they're not the brands that AmountMath recognizes.

}
};

test.serial('add assets before', async t => {
Copy link
Member

Choose a reason for hiding this comment

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

are these meant to run in sequence? test.serial just means not in parallel and the order is technically undefined.

if they're in sequence, just put them all into a single test. You can use t.log to show progress

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


export default async (homeP, endowments) => {
const { writeCoreProposal } = await makeHelpers(homeP, endowments);
await writeCoreProposal('add-STARS-collateral', starsVaultProposalBuilder);
Copy link
Member

Choose a reason for hiding this comment

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

doesn't this belong under scripts/inter-protocol like the other add-STARS.js? Please distinguish between them by filename and perhaps a @file comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thinking about moving them there (good idea!) made it clearer that these two are for testing, and shouldn't be confused with the production scripts. Is it enough to put them under a testing directory and add a top-comment?
I also renamed them from STARS since the re-use of an actual currency name is of no value.

// the contract, so it technically can change between incarnations.
// That would be a severe bug.
AmountMath.coerce(poolBrand, params.getPerAccountInitialAmount());
void observeNotifier(E(exchangePurse).getCurrentAmountNotifier(), {
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 part of a commit titled refactor: but it's changing behavior. It's adding a new feature for upgrade durability so it's a feat:. Though it would have made review easier if the refactor changes were separated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed. I'll try to make better separations.

Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/tummychow/git-absorb helps me. E.g. when you had the your review changes, if you ran git add . && git absorb it would make fixups on the previous. That way master doesn't have the iterations of code review.

// the contract, so it technically can change between incarnations.
// That would be a severe bug.
AmountMath.coerce(poolBrand, params.getPerAccountInitialAmount());
void observeNotifier(E(exchangePurse).getCurrentAmountNotifier(), {
Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/tummychow/git-absorb helps me. E.g. when you had the your review changes, if you ran git add . && git absorb it would make fixups on the previous. That way master doesn't have the iterations of code review.


/**
* @file
* *** TESTING ONLY *** NOT FOR PRODUCTION USE ***
Copy link
Member

Choose a reason for hiding this comment

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

+1 to scripts/testing. Perhaps even scripts/a3p. There might be some other scripts that belong here but nbd.

That said, I think this line is too scary. There's practically zero risk that somebody is going to find scripts/testing/add-LEMON.js and shepherd it into production.

Suggested change
* *** TESTING ONLY *** NOT FOR PRODUCTION USE ***

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, okay. I added the scary line before I renamed them. It's unneeded now.

Comment on lines 30 to 31
const FIRST_CAP_ASCII = /^[A-Z][a-zA-Z0-9_$]*$/;
const FIRST_LOWER_ASCII = /^[a-z][a-zA-Z0-9_$]*$/;
Copy link
Member

Choose a reason for hiding this comment

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

these are more restricted than ASCII. consider,

Suggested change
const FIRST_CAP_ASCII = /^[A-Z][a-zA-Z0-9_$]*$/;
const FIRST_LOWER_ASCII = /^[a-z][a-zA-Z0-9_$]*$/;
const FIRST_CAP_KEYWORD = /^[A-Z]/;
const FIRST_LOWER_KEYWORD = /^[a-z]/;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm changing the names to FIRST_UPPER_KEYWORD and FIRST_LOWER_NEAR_KEYWORD, but keeping the patterns the same. If it's not a keyword pattern, I'd rather take the else fallback.

@Chris-Hibbert Chris-Hibbert added the automerge:rebase Automatically rebase updates, then merge label Jun 12, 2024
@mergify mergify bot merged commit 26b0505 into master Jun 12, 2024
63 checks passed
@mergify mergify bot deleted the 8722-provPoolResub branch June 12, 2024 18:47
Copy link
Member

Choose a reason for hiding this comment

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

Why is this test being removed?

mergify bot added a commit that referenced this pull request Jun 22, 2024
closes: #9553

## Description
Restores tests deleted in #9481 and fixes a bug in localchain introduced since

### Security Considerations
None

### Scaling Considerations
None

### Documentation Considerations
None

### Testing Considerations
Restoring integration tests

### Upgrade Considerations
Needed for upgrade 16
mhofman pushed a commit that referenced this pull request Jun 22, 2024
closes: #9553

## Description
Restores tests deleted in #9481 and fixes a bug in localchain introduced since

### Security Considerations
None

### Scaling Considerations
None

### Documentation Considerations
None

### Testing Considerations
Restoring integration tests

### Upgrade Considerations
Needed for upgrade 16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge bug Something isn't working contract-upgrade Inter-protocol Overarching Inter Protocol test
Projects
None yet
3 participants