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 timing issue when re-using proposal in bootstrap tests #8449

Merged
merged 1 commit into from
Oct 30, 2023

Conversation

iomekam
Copy link
Contributor

@iomekam iomekam commented Oct 11, 2023

refs: #8270

Description

I added some test to validate that concurrent liquidation of multiple asset works as intended. In doing so, each test needs to re-use the add-STARS proposal to setup a new token for the test to leverage. The test introduced a timing bug where the proposal can be generated simutaneously by multiple running tests. This introduced a race condition where one test could delete the generated files before the other test was able to use them.

To fix this problem, anytime we try to run a proposal, we do so within a unique directory. This allows each test to control the lifespan of the files generated.

Testing Considerations

Updating the way that we create and delete proposals to ensure that they are idempotent and don't affect other test runs

Upgrade Considerations

Touches the bootstrap tests that requires running a proposal to succeed. This change shouldn't affect the upgrade directly.

@iomekam iomekam changed the title Fix timing issue when re-using proposal Fix timing issue when re-using proposal in bootstrap tests Oct 11, 2023
@iomekam iomekam marked this pull request as ready for review October 12, 2023 00:31
Copy link
Contributor

@Chris-Hibbert Chris-Hibbert left a comment

Choose a reason for hiding this comment

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

LGTM.

I get twitchy when all the sections of the template are ignored. This PR updated some tests, and they passed. That's worth mentioning.

The changes here impact at least ZCF's upgrade, and I lump all the bootstrap tests as part of upgrade. Please say something about how this is relevant to upgrade.

const pkgPath = getPkgPath(pkg);
return childProcess.execFileSync('yarn', ['run', name], {
cwd: pkgPath,
const runPackageScript = async (outputDir, pkg, location, env) => {
Copy link
Member

Choose a reason for hiding this comment

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

A "package script" is a line in "scripts" in package.json. This PR removes those so this function name is no longer accurate.

The location can have the package in it so there's no longer need for a separate pkg param.

Suggested change
const runPackageScript = async (outputDir, pkg, location, env) => {
const runProposalBuilder = async (outputDir, builderPath, env) => {

Then the call in liquidation.js would be like,

  const proposal = await buildProposal({
    builderScript: '@agoric/builders/scripts/inter-protocol/add-STARS.js',
  });

You can get a pathname for that with something like this:

const importSpec = spec =>
importMetaResolve(spec, import.meta.url).then(u => new URL(u).pathname);

@@ -7,9 +7,6 @@
"repository": "https://github.com/Agoric/agoric-sdk",
"scripts": {
"build": "exit 0",
"build:add-STARS-proposal": "agoric run scripts/inter-protocol/add-STARS.js",
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 a nice simplification to the code. Note that it changes the CLI of this package and someone may be surprised when it no longer works. Consider a deprecation message.

Suggested change
"build:add-STARS-proposal": "agoric run scripts/inter-protocol/add-STARS.js",
"build:add-STARS-proposal": "echo instead: agoric run scripts/inter-protocol/add-STARS.js",

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 can also just leave this here in that case. We just won't have any callers within the tests

Copy link
Member

Choose a reason for hiding this comment

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

I'd rank options this way:

  1. counsel the user in what to do instead
  2. take it out
  3. leave it (last because it doesn't get us closer to not needing these. the next script to be added someone will think they need to include it here)

@iomekam iomekam force-pushed the agoric-run-temp-dir branch 2 times, most recently from de8969c to eb6f038 Compare October 27, 2023 18:55
@iomekam iomekam marked this pull request as draft October 27, 2023 19:56
@iomekam iomekam force-pushed the agoric-run-temp-dir branch from eb6f038 to 55ae099 Compare October 27, 2023 19:58
@iomekam iomekam marked this pull request as ready for review October 27, 2023 23:05
@iomekam iomekam requested a review from turadg October 27, 2023 23:05
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.

Some comments, none blocking

packages/boot/test/bootstrapTests/supports.ts Outdated Show resolved Hide resolved

const runPackageScript = async (outputDir, scriptPath, env) => {
console.warn('running package script:', scriptPath);
const out = await childProcess.execFileSync('yarn', ['bin', 'agoric'], {
Copy link
Member

Choose a reason for hiding this comment

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

not a blocker but we shouldn't need to shell out here. yarn bin agoric is running https://github.com/Agoric/agoric-sdk/blob/master/packages/agoric-cli/src/entrypoint.js#L53 which is just a wrapper around the JS module https://github.com/Agoric/agoric-sdk/blob/master/packages/agoric-cli/src/main.js that could be called here as a function

Comment on lines 352 to 354
const proposal = await buildProposal({
package: 'builders',
packageScriptName: 'build:add-STARS-proposal',
builderPath: '@agoric/builders/scripts/inter-protocol/add-STARS.js',
});
Copy link
Member

Choose a reason for hiding this comment

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

now that it's one param it could be,

const proposal = await buildProposal('@agoric/builders/scripts/inter-protocol/add-STARS.js');

but there's another named param it still takes env and I'm not sure what that's for. Not a blocker but it would be good to document what it's for or at least have some code that uses it.

@iomekam iomekam force-pushed the agoric-run-temp-dir branch 4 times, most recently from 6fea296 to 440ec33 Compare October 30, 2023 18:01
@iomekam iomekam added automerge:rebase Automatically rebase updates, then merge and removed automerge:rebase Automatically rebase updates, then merge labels Oct 30, 2023
@iomekam iomekam force-pushed the agoric-run-temp-dir branch from 440ec33 to 2904bf3 Compare October 30, 2023 18:44
@iomekam iomekam force-pushed the agoric-run-temp-dir branch from 2904bf3 to 69bcc0e Compare October 30, 2023 19:02
@iomekam iomekam added the automerge:rebase Automatically rebase updates, then merge label Oct 30, 2023
@mergify mergify bot merged commit 5263feb into master Oct 30, 2023
80 checks passed
@mergify mergify bot deleted the agoric-run-temp-dir branch October 30, 2023 21:22
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants