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

feat: refactored convert command logic to fix issues #921

Merged
merged 1 commit into from
Apr 12, 2023

Conversation

l0r1s
Copy link
Contributor

@l0r1s l0r1s commented Apr 11, 2023

Refactoring of the convert command logic to take into accounts ports and missing values:

Input polkadot launch config:

{
	"relaychain": {
		"bin": "../../polkadot/target/release/polkadot",
		"chain": "rococo-local",
		"nodes": [
			{
				"name": "alice",
				"wsPort": 9944,
				"port": 30444,
				"flags": [
					"--unsafe-ws-external",
					"--unsafe-rpc-external",
					"--rpc-cors=all"
				]
			},
			{
				"name": "bob",
				"wsPort": 9955,
				"port": 30555,
				"flags": [
					"--unsafe-ws-external",
					"--unsafe-rpc-external",
					"--rpc-cors=all"
				]
			},
			{
				"name": "charlie",
				"wsPort": 9966,
				"port": 30666,
				"flags": [
					"--unsafe-ws-external",
					"--unsafe-rpc-external",
					"--rpc-cors=all"
				]
			},
			{
				"name": "dave",
				"wsPort": 9967,
				"port": 30667,
				"flags": [
					"--unsafe-ws-external",
					"--unsafe-rpc-external",
					"--rpc-cors=all"
				]
			},
			{
				"name": "ferdie",
				"wsPort": 9968,
				"port": 30668,
				"flags": [
					"--unsafe-ws-external",
					"--unsafe-rpc-external",
					"--rpc-cors=all"
				]
			},
			{
				"name": "eve",
				"wsPort": 9969,
				"port": 30669,
				"flags": [
					"--unsafe-ws-external",
					"--unsafe-rpc-external",
					"--rpc-cors=all"
				]
			},
			{
				"name": "one",
				"wsPort": 9970,
				"port": 30670,
				"flags": [
					"--unsafe-ws-external",
					"--unsafe-rpc-external",
					"--rpc-cors=all"
				]
			},
			{
				"name": "two",
				"wsPort": 9971,
				"port": 30671,
				"flags": [
					"--unsafe-ws-external",
					"--unsafe-rpc-external",
					"--rpc-cors=all"
				]
			}
		],
		"genesis": {
			"runtime": {
				"runtime_genesis_config": {
					"parachainsConfiguration": {
						"config": {
							"validation_upgrade_frequency": 1,
							"validation_upgrade_delay": 1
						}
					}
				}
			}
		}
	},
	"simpleParachains": [],
	"parachains": [
		{
			"bin": "../../bifrost-node/target/release/bifrost-node",
			"id": "2001",
			"chain":"dev",
			"nodes": [
				{
					"wsPort": 9995,
					"port": 31200,
					"name": "alice",
					"flags": [
						"--unsafe-ws-external",
						"--unsafe-rpc-external",
						"--rpc-cors=all",
						"--",
						"--execution=wasm"
					]
				}
			]
		},
		{
			"bin": "../../Acala/target/release/acala",
			"id": "2000",
			"chain": "karura-dev",
			"nodes": [
				{
					"wsPort": 9999,
					"port": 31300,
					"name": "alice",
					"flags": [
						"--unsafe-ws-external",
						"--unsafe-rpc-external",
						"--rpc-cors=all",
						"--",
						"--execution=wasm"
					]
				}
			]
		},
		{
			"bin": "../../kylin-collator/target/release/kylin-collator",
			"id": "2102",
			"chain": "pichiu-local",
			"nodes": [
				{
					"wsPort": 9991,
					"port": 31400,
					"name": "alice",
					"flags": [
						"--unsafe-ws-external",
						"--unsafe-rpc-external",
						"--rpc-cors=all",
						"--",
						"--execution=wasm"
					]
				}
			]
		}
	],
	"hrmpChannels": [
		{
			"sender": 2000,
			"recipient": 2001,
			"maxCapacity": 8,
			"maxMessageSize": 1024
		},
		{
			"sender": 2001,
			"recipient": 2000,
			"maxCapacity": 8,
			"maxMessageSize": 1024
		},
		{
			"sender": 2000,
			"recipient": 2102,
			"maxCapacity": 8,
			"maxMessageSize": 1024
		},
		{
			"sender": 2102,
			"recipient": 2000,
			"maxCapacity": 8,
			"maxMessageSize": 1024
		},
		{
			"sender": 2001,
			"recipient": 2102,
			"maxCapacity": 8,
			"maxMessageSize": 1024
		},
		{
			"sender": 2102,
			"recipient": 2001,
			"maxCapacity": 8,
			"maxMessageSize": 1024
		}
	],
	"types": {},
	"finalization": false
}

Output zombienet config:

{
  "relaychain": {
    "chain": "rococo-local",
    "default_command": "../../polkadot/target/release/polkadot",
    "genesis": {
      "runtime": {
        "runtime_genesis_config": {
          "parachainsConfiguration": {
            "config": {
              "validation_upgrade_frequency": 1,
              "validation_upgrade_delay": 1
            }
          }
        }
      }
    },
    "nodes": [
      {
        "name": "alice",
        "args": [
          "--unsafe-ws-external",
          "--unsafe-rpc-external",
          "--rpc-cors=all"
        ],
        "ws_port": 9944,
        "p2p_port": 30444,
        "balance": 2000000000000,
        "validator": true,
        "invulnerable": true
      },
      {
        "name": "bob",
        "args": [
          "--unsafe-ws-external",
          "--unsafe-rpc-external",
          "--rpc-cors=all"
        ],
        "ws_port": 9955,
        "p2p_port": 30555,
        "balance": 2000000000000,
        "validator": true,
        "invulnerable": true
      },
      {
        "name": "charlie",
        "args": [
          "--unsafe-ws-external",
          "--unsafe-rpc-external",
          "--rpc-cors=all"
        ],
        "ws_port": 9966,
        "p2p_port": 30666,
        "balance": 2000000000000,
        "validator": true,
        "invulnerable": true
      },
      {
        "name": "dave",
        "args": [
          "--unsafe-ws-external",
          "--unsafe-rpc-external",
          "--rpc-cors=all"
        ],
        "ws_port": 9967,
        "p2p_port": 30667,
        "balance": 2000000000000,
        "validator": true,
        "invulnerable": true
      },
      {
        "name": "ferdie",
        "args": [
          "--unsafe-ws-external",
          "--unsafe-rpc-external",
          "--rpc-cors=all"
        ],
        "ws_port": 9968,
        "p2p_port": 30668,
        "balance": 2000000000000,
        "validator": true,
        "invulnerable": true
      },
      {
        "name": "eve",
        "args": [
          "--unsafe-ws-external",
          "--unsafe-rpc-external",
          "--rpc-cors=all"
        ],
        "ws_port": 9969,
        "p2p_port": 30669,
        "balance": 2000000000000,
        "validator": true,
        "invulnerable": true
      },
      {
        "name": "one",
        "args": [
          "--unsafe-ws-external",
          "--unsafe-rpc-external",
          "--rpc-cors=all"
        ],
        "ws_port": 9970,
        "p2p_port": 30670,
        "balance": 2000000000000,
        "validator": true,
        "invulnerable": true
      },
      {
        "name": "two",
        "args": [
          "--unsafe-ws-external",
          "--unsafe-rpc-external",
          "--rpc-cors=all"
        ],
        "ws_port": 9971,
        "p2p_port": 30671,
        "balance": 2000000000000,
        "validator": true,
        "invulnerable": true
      }
    ]
  },
  "parachains": [
    {
      "id": 2001,
      "chain": "dev",
      "collators": [
        {
          "name": "alice",
          "command": "../../bifrost-node/target/release/bifrost-node",
          "args": [
            "--unsafe-ws-external",
            "--unsafe-rpc-external",
            "--rpc-cors=all",
            "--",
            "--execution=wasm"
          ],
          "ws_port": 9995,
          "p2p_port": 31200,
          "balance": 2000000000000,
          "validator": true,
          "invulnerable": true
        }
      ]
    },
    {
      "id": 2000,
      "chain": "karura-dev",
      "collators": [
        {
          "name": "alice",
          "command": "../../Acala/target/release/acala",
          "args": [
            "--unsafe-ws-external",
            "--unsafe-rpc-external",
            "--rpc-cors=all",
            "--",
            "--execution=wasm"
          ],
          "ws_port": 9999,
          "p2p_port": 31300,
          "balance": 2000000000000,
          "validator": true,
          "invulnerable": true
        }
      ]
    },
    {
      "id": 2102,
      "chain": "pichiu-local",
      "collators": [
        {
          "name": "alice",
          "command": "../../kylin-collator/target/release/kylin-collator",
          "args": [
            "--unsafe-ws-external",
            "--unsafe-rpc-external",
            "--rpc-cors=all",
            "--",
            "--execution=wasm"
          ],
          "ws_port": 9991,
          "p2p_port": 31400,
          "balance": 2000000000000,
          "validator": true,
          "invulnerable": true
        }
      ]
    }
  ],
  "hrmp_channels": [
    {
      "sender": 2000,
      "recipient": 2001,
      "max_capacity": 8,
      "max_message_size": 1024
    },
    {
      "sender": 2001,
      "recipient": 2000,
      "max_capacity": 8,
      "max_message_size": 1024
    },
    {
      "sender": 2000,
      "recipient": 2102,
      "max_capacity": 8,
      "max_message_size": 1024
    },
    {
      "sender": 2102,
      "recipient": 2000,
      "max_capacity": 8,
      "max_message_size": 1024
    },
    {
      "sender": 2001,
      "recipient": 2102,
      "max_capacity": 8,
      "max_message_size": 1024
    },
    {
      "sender": 2102,
      "recipient": 2001,
      "max_capacity": 8,
      "max_message_size": 1024
    }
  ],
  "types": {}
}

@l0r1s l0r1s force-pushed the feat/refacto-convert-command branch from 6d074c1 to 3254cbf Compare April 11, 2023 16:44
Copy link
Contributor

@wirednkod wirednkod left a comment

Choose a reason for hiding this comment

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

Some minor optional comments - lgtm

const baseName = path.basename(filePath, extension);
let config;

console.log(extension);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this log intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, good catch 🎯

const collator = {
name: "alice",
command: bin,
p2p_port: +port,
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
p2p_port: +port,
p2p_port: +port,

nice usage of unary operator!

parachains: ParachainConfig[];
simpleParachains: SimpleParachainConfig[];
hrmpChannels: HrmpChannelsConfig[];
types: any;
Copy link
Contributor

Choose a reason for hiding this comment

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

This eventually will byte us in the ass; Maybe add a normal type if possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I have used the exact type used by the Polkadot Launch repo: https://github.com/paritytech/polkadot-launch/blob/master/src/types.d.ts to have maximum compatibility and minimum issues so I would prefer to keep it to avoid unwanted behavior in the future, wdyt ?

@l0r1s l0r1s force-pushed the feat/refacto-convert-command branch from 3254cbf to 746fc2d Compare April 12, 2023 07:21
@pepoviola pepoviola merged commit 3d5e0b0 into main Apr 12, 2023
@pepoviola pepoviola deleted the feat/refacto-convert-command branch April 12, 2023 13:07
@pepoviola
Copy link
Collaborator

Thanks @l0r1s !

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.

3 participants