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

Add support for chain spec modifier commands #909

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

Fahrrader
Copy link

In response to #892.

@cla-bot-2021
Copy link

cla-bot-2021 bot commented Apr 8, 2023

User @Fahrrader, please sign the CLA here.

@Fahrrader
Copy link
Author

Fahrrader commented Apr 8, 2023

Tests (and examples and docs, probably) are required, but putting the draft out there for review :)

Comment on lines 27 to 29
for (const key of Object.keys(processes)) {
processes[key].kill();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing prettier formatting.

Copy link
Contributor

@l0r1s l0r1s left a comment

Choose a reason for hiding this comment

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

Some fixes but lgtm

commandArgs: string[],
) {
const chainSpecSubstitutePattern = new RegExp(
RAW_CHAIN_SPEC_IN_CMD_PATTERN.source + "|" + PLAIN_CHAIN_SPEC_IN_CMD_PATTERN.source,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
RAW_CHAIN_SPEC_IN_CMD_PATTERN.source + "|" + PLAIN_CHAIN_SPEC_IN_CMD_PATTERN.source,
RAW_CHAIN_SPEC_IN_CMD_PATTERN?.source + "|" + PLAIN_CHAIN_SPEC_IN_CMD_PATTERN?.source,

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is oks since RAW_CHAIN_SPEC_IN_CMD_PATTERN and PLAIN_CHAIN_SPEC_IN_CMD_PATTERN are defined as constants. (in constanst.ts)

javascript/packages/orchestrator/src/chainSpec.ts Outdated Show resolved Hide resolved
javascript/packages/orchestrator/src/configGenerator.ts Outdated Show resolved Hide resolved
javascript/packages/orchestrator/src/configGenerator.ts Outdated Show resolved Hide resolved
javascript/packages/orchestrator/src/configGenerator.ts Outdated Show resolved Hide resolved
javascript/packages/orchestrator/src/configGenerator.ts Outdated Show resolved Hide resolved
docs/src/network-definition-spec.md Outdated Show resolved Hide resolved
docs/src/network-definition-spec.md Outdated Show resolved Hide resolved
@wirednkod
Copy link
Contributor

@Fahrrader , also, please run lint prior to next push, for the checks to pass

Copy link
Collaborator

@pepoviola pepoviola left a comment

Choose a reason for hiding this comment

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

Hi @Fahrrader, thanks for your contribution. Add this kind of feature is awesome! I think we should have a more concrete docs about how to use it (and also some example). We should give some explanation about how this works with chainql, or any other process that can mutate the spec.

Thanks again for your contribution!

@Fahrrader
Copy link
Author

Docs, examples and tests (hopefully) are up and ready!

for (const cmd of networkSpec.relaychain.chainSpecModifierCommands) {
await runCommandWithChainSpec(specPath, cmd, networkSpec.configBasePath);
}
} catch (err) {
Copy link
Author

@Fahrrader Fahrrader Apr 20, 2023

Choose a reason for hiding this comment

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

Regarding the last commit, I believe we shouldn't let the process go on if a step in chain spec customization has failed. By removing the try-catch structure from customizePlainRelayChain, the error would go into the spawn's try-catch structure where it would print it out, dump the logs and exit the process. This was the way it was done prior to displacement of the relay's plain chain spec customization to chainSpec.ts, too.

@Fahrrader Fahrrader closed this Apr 22, 2023
@Fahrrader Fahrrader deleted the feat/chain-spec-mutator branch April 22, 2023 20:49
@Fahrrader Fahrrader restored the feat/chain-spec-mutator branch April 22, 2023 20:50
@Fahrrader Fahrrader reopened this Apr 22, 2023
@Fahrrader
Copy link
Author

@pepoviola @wirednkod I think this PR is good to go and ready for the final review! I believe all the previous concerns were addressed. Please take another look, if not already.

@pepoviola
Copy link
Collaborator

Hi @Fahrrader, sorry about the delay. First let me say thanks for contribution and your feedback. We had discussed with the team and some security concerns arise from allow users to execute arbitrary 3rd party tools as part of the spawning process. We have a couple of options, we can built-in some kind of customization tool that allow us to have more control of what is executed, we can allow this execution (giving us more flexibility) and add some guards (like don't allow to run with root access) or we can also make the spawning process more flexible and add a command to just produce the chain artifacts so allow others tools to interact with zombienet to their needs.

I will a new discussion in the repo to collect some feedback before go into one of the paths. Agains, sorry about the delay and thanks for your contribution and feedback!!

@Polkadot-Forum
Copy link

This pull request has been mentioned on Polkadot Forum. There might be relevant details there:

https://forum.polkadot.network/t/discover-chainql-unique-networks-advanced-tool-for-substrate-chain-storage/2861/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants