Skip to content

[Colossus] CLI command for updating multiple bags#4812

Merged
mnaamani merged 3 commits intoJoystream:masterfrom
zeeshanakram3:colossus-leader-update-bags
Jul 31, 2023
Merged

[Colossus] CLI command for updating multiple bags#4812
mnaamani merged 3 commits intoJoystream:masterfrom
zeeshanakram3:colossus-leader-update-bags

Conversation

@zeeshanakram3
Copy link
Copy Markdown
Contributor

addresses #4591

based on #4796

@mnaamani mnaamani self-requested a review July 26, 2023 08:10
@mnaamani mnaamani added the origo Origo Release label Jul 26, 2023
Copy link
Copy Markdown
Member

@mnaamani mnaamani left a comment

Choose a reason for hiding this comment

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

Looks good, tested and works. Left a minor comment.
The integration test is failing in the flows/clis/initStorageBucket.ts where the command is used and it has not been renamed.

this.exit(ExitCodes.InvalidParameters)
}

if (_.isEmpty(uniqueBagIds)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this check necessary? Since flag is required?

api,
uniqueBagIds,
account,
flags.add,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I realize that this does work, and runtime handles it safely if there are repeated buckets, but we might as well use the "unique" add and remove arrays instead. It would reduce size of extrinsic if there were duplicates.

@mnaamani
Copy link
Copy Markdown
Member

To test this I played around with the integrations tests tests/network-tests/src/flow/clis/initStorageBucket.ts
with steps like below:

  const { stderr: output1 } = await cli.run('leader:update-bags', [
    '--add',
    bucketId,
    '--bagIds',
    'static:council',
    'static:council',
    'static:council',
    '--bagIds',
    'static:wg:app',
    '-s',
    'atomic',
  ])
  debug(output1)
  const { stderr: output2 } = await cli.run('leader:update-bags', [
    '--remove',
    bucketId,
    '--bagIds',
    'static:council',
    'static:wg:storage',
    'static:wg:storage',
    '--updateStrategy',
    'force',
  ])
  debug(output2)
  await cli.run('leader:update-bags', [
    '--remove',
    bucketId,
    '--bagIds',
    'static:wg:app',
    '--updateStrategy',
    'force'
])

I found it very useful to run a single flow repeatedly after starting the local dev playground. So I added a simple "scenario" for running a single flow, (with a small change to run-test-scenario.sh to pass along additional argument) that looks like this:

import { scenario } from '../Scenario'
import path from 'path'

// eslint-disable-next-line @typescript-eslint/no-floating-promises
scenario('Single Flow', async ({ job }) => {
  const pathToFlow = path.join('../flows', process.argv[2])

  // eslint-disable-next-line @typescript-eslint/no-var-requires
  const flows = require(pathToFlow)

  const flow = flows.default || flows

  job('single-flow', flow)
})
REUSE_KEYS=true DEBUG=* ./run-test-scenario.sh flow clis/initStorageBucket
yarn workspace v1.22.19
yarn run v1.22.19
$ node -r ts-node/register --unhandled-rejections=strict src/scenarios/flow.ts clis/initStorageBucket
  integration-tests:api-factory Connecting to chain, attempt 1.. +0ms
Runtime Version: 12.2001.0
  integration-tests:scenario Single Flow +0ms
  integration-tests:job:single-flow Running +0ms
  integration-tests:flow:initStorageBucketViaCLI Started +0ms
  integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:13:1913 info: Initializing runtime connection to: ws://localhost:9944
  integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:13:1913 info: Waiting for chain to be synced before proceeding.
  integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:13:1913 info: Updating the bag...
  integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:13:1913 debug: Sending utility.batchAll extrinsic...
  integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:14:1914 debug: Extrinsic successful!
  integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:14:1914 info: All extrinsic calls in the batch Tx succeeded!
  integration-tests:flow:initStorageBucketViaCLI  +14s
  integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:15:1915 info: Initializing runtime connection to: ws://localhost:9944
  integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:15:1915 info: Waiting for chain to be synced before proceeding.
  integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:15:1915 info: Updating the bag...
  integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:15:1915 debug: Sending utility.forceBatch extrinsic...
  integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:16:1916 debug: Extrinsic successful!
  integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:16:1916 error: Following extrinsic calls in the batch Tx failed:
  integration-tests:flow:initStorageBucketViaCLI  [
  integration-tests:flow:initStorageBucketViaCLI   {
  integration-tests:flow:initStorageBucketViaCLI     "args": "{\"static\":{\"workingGroup\":\"Storage\"}},[],[19]",
  integration-tests:flow:initStorageBucketViaCLI     "error": "StorageBucketIsNotBoundToBag (The requested storage bucket is not bound to a bag.)"
  integration-tests:flow:initStorageBucketViaCLI   }
  integration-tests:flow:initStorageBucketViaCLI ]}
  integration-tests:flow:initStorageBucketViaCLI  +2s
  integration-tests:flow:initStorageBucketViaCLI Done +9s
  integration-tests:job:single-flow [Succeeded] +25s
Job Results:
single-flow: Succeeded
Writing generated account to output.json
✨  Done in 35.33s.
✨  Done in 35.52s.

Maybe I'll open a PR with this simple addition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

origo Origo Release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants