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

Wire between Orchestrator - Provider #101

Merged
merged 100 commits into from
Sep 29, 2023
Merged

Conversation

pepoviola
Copy link
Collaborator

NOTE: The base branch is a merge of refactor/provider-trait and feat/network-spec.

This pr is still very WIP but is a good step forward and now we can spawn networks (relaychain only at the moment), some parts of the code still have some values hardcoded that we need to replace from config/spec.

A brief walkthrough

The orchestrator can be created by passing a filesystem (FS: Filesystem) and a provider (P: Provider) and have a public method spawn (that receive a NetworkConfig) that in the future will return the Network instance.
So, basically you can use it like this

    let fs = LocalFileSystem;
    let provider = NativeProvider::new(fs.clone());
    let orchestrator = Orchestrator::new(fs, provider);
    let _network = orchestrator.spawn(config).await?;

Inside the provider we compute the NwtworkSpec from the provided NetworkConfig, for this we have a few generators that acts as helper methods to create stuffs like chain-spec, node-identities, keystore, compute the command to run the node and other stuffs :)

Ones we have the network spec computed, we start building the needed artifacts (at this point only the chain-spec for the relaychain is implemented but in the future in this step we need to create the state/wasm and chain-spec for each parachain (and if is required register the para in the genesis of the relaychain).

Then we calculate the bootnodes (to spawn first and get the addr to use in others) and continue with the process of spawning the nodes (at the moment I using a simple try_join_all in the future tasks but we should have a method to control the concurrency as we have in the current version)

For each node at the moment we are creating a NetworkNode instance with the DynNode stored as inner and the spec of the node also stored in the same instance. Is not ideal to hold all that info for each node but I think is something to improve ones we have a complete working version.

And that all for now, there is much work to do until we have a real working version and the code is full of //TODO: ... to think through/implement. But to mention some things I'm sure we need to rethink:

  • IP/Ports, we should implement a view_point as we have in the current version. Since is not the same to require the ip/port from an external runner (like our test-runner running from our laptops) than from a local one (like our CI).
  • I had implemented a scoped filesystem to encapsulate all the fs operations inside of the isolated (a.k.a fake root) directory of the ns, this is not ideal and would be good to implement some erasure technique to just add the logic as blanket impl. inside the trait. (Note: the fs trait is not object-safe)
  • The config shared types and support are all over the places, we should just consolidate a common crate (or move all to support` to easily re-use them.
  • Logger, I will add the env_logger as part of a follow-up commit.
  • Naming, we should agree on some convention. I briefly talk this with @l0r1s today. I personally don't have some predilection but I do think we should follow a pattern. In example TransferedFile vs TransferFile vs FileToTransfer.

As I said at the begging, this is very much wip but will be good to have your insights :)

Thanks!

To run the example:

cargo run --package examples --example small_network_with_default

pepoviola and others added 30 commits August 8, 2023 12:13
…d mirror implementation of tokio::fs with tests
…ider struct threadsafe using RwLock and Arc, added implementation logic of resume/restart/pause, destroy and helpers for logs
…om_node in NativeProvider, removed unused comments
@pepoviola
Copy link
Collaborator Author

pepoviola commented Sep 27, 2023 via email

pepoviola and others added 5 commits September 27, 2023 19:38
Co-authored-by: Loris Moulin <45130584+l0r1s@users.noreply.github.com>
Co-authored-by: Loris Moulin <45130584+l0r1s@users.noreply.github.com>
@github-actions
Copy link

Coverage after merging feat/glue/network-spec_provider into main

77.96%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
crates/configuration/src
   global_settings.rs99.12%100%96.43%99.50%
   hrmp_channel.rs95.88%100%89.47%97.44%
   network.rs99.34%100%97.78%99.49%111, 116, 124, 80
   parachain.rs98.82%100%97.06%99.02%51–53, 67–70
   relaychain.rs98.99%100%95.38%99.44%
   utils.rs100%100%100%100%
crates/configuration/src/shared
   errors.rs50%100%50%50%
   helpers.rs100%100%100%100%
   node.rs98.32%100%92.68%98.93%124, 130
   resources.rs96.09%100%94.52%96.43%102, 114, 126–128, 147–150
   types.rs91.20%100%86.14%92.69%279–281, 350–352, 375–376, 378–380, 60–62
crates/orchestrator/src
   errors.rs0%100%0%0%8
   lib.rs0%100%0%0%100–102, 106–109, 111–117, 119, 123, 125–140, 143–168, 172–181, 184–192, 194, 196–200, 203–220, 222–227, 229–238, 241–247, 250, 253–262, 265–269, 272, 274–287, 289–291, 294–298, 300, 302–315, 317–320, 322–324, 335–336, 343, 350–352, 354–363, 365–366, 368–376, 378–385, 387–394, 396–399, 40, 400–407, 41, 410, 42–45, 47–52, 54–60, 62–67, 70, 72–86, 92–97, 99
   network.rs0%100%0%0%100–108, 111–117, 119–127, 130–154, 156, 158–167, 170, 172–176, 185–189, 191, 193, 195–199, 201, 203, 205–213, 215, 217, 220–225, 227–229, 231–233, 235–237, 239–241, 243–245, 247–249, 251–253, 32–40, 43, 56–70, 77–82, 85–94, 96, 98–99
   network_spec.rs96.25%100%91.67%97.06%37
   spawner.rs0%100%0%0%100–106, 108, 112–114, 117–119, 121, 127–147, 149, 151–167, 17, 37–50, 52–53, 55, 57–63, 67–68, 70, 73–93, 95–99
crates/orchestrator/src/generators
   bootnode_addr.rs0%100%0%0%10–28, 30, 33–34, 5–9
   chain_spec.rs3.90%100%8.33%3.48%100–111, 113–128, 130, 135–146, 149–155, 157–159, 162–190, 192–195, 197–199, 201–214, 216–218, 221–223, 225, 227–239, 241, 244–249, 251–252, 254–267, 269, 272–277, 279–280, 283–296, 298–303, 305–307, 309–311, 315–344, 347, 350–353, 356, 358–359, 361–376, 378, 38, 380–381, 386–427, 438–446, 456–464, 466–478, 480–488, 491–493, 497–500, 502–503, 508–519, 523–539, 541, 544–545, 548, 550–556, 558–563, 569–574, 576, 578, 580–587, 589–592, 595–596, 599–601, 603–604, 606–608, 610–612, 614–616, 619–621, 624–628, 630, 632–640, 642–643, 648–655, 657–667, 671–674, 676, 678, 680–685, 687–697, 699–715, 717–724, 726, 730–749, 75, 750–751, 753, 76, 762–769, 77, 770–772, 774, 776–794, 796–800, 802, 804, 84–87, 95–99
   command.rs0%100%0%0%100–111, 113–119, 121, 124–129, 131–132, 135–147, 149, 15, 152–154, 156–157, 16, 160–169, 17, 170–179, 18, 180–189, 19, 190–196, 198, 20, 200, 202–209, 21, 210–219, 22, 220–223, 225–228, 23, 230–232, 234–239, 24, 240–242, 245–249, 251–255, 257, 260–268, 270, 273–289, 292–297, 299, 302–304, 306–307, 310–332, 334, 336, 43–61, 63–65, 67–75, 78–96, 99
   errors.rs0%100%0%0%4
   identity.rs82.35%100%60%86.21%11
   key.rs84.48%100%50%90%31
   keystore.rs0%100%0%0%19–26, 28–31, 34–46, 48–55, 57–64, 66, 68–86
   para_artifact.rs24.64%100%40%22.03%44–46, 48–64, 66–69, 72–81, 83–88, 92–93
   port.rs84.62%100%50%90.91%
crates/orchestrator/src/network
   node.rs0%100%0%0%17–29, 33–41, 5
   parachain.rs0%100%0%0%15–23, 25–37, 5
   relaychain.rs0%100%0%0%14–21, 5
crates/orchestrator/src/network_spec
   node.rs40.83%100%33.33%41.23%108, 146–150, 152–153, 155, 158, 160–163, 165–168, 173–178, 180, 183, 185–215, 217, 90–91, 93–96
   parachain.rs73.91%100%75%73.86%104, 122, 127–130, 133, 144–147, 150, 68–70, 73, 75–77, 83, 92, 97
   relaychain.rs91.80%100%83.33%92.73%67, 90, 97
crates/orchestrator/src/shared
   types.rs47.37%100%38.46%52%43–47, 50
crates/provider/src
   lib.rs25%100%0%50%
   native.rs90.42%100%81.88%91.54%1020, 1024, 1057, 1066, 1087, 1094, 1125, 1152, 1176, 1181, 1209, 1235, 1245, 1252, 1269, 1319, 132, 1376–1378, 1423, 1499–1500, 1524, 155, 1565, 190–194, 262, 281, 294, 296, 303, 305–306, 319, 341, 355–357, 359–361, 363–365, 387–389, 391–393, 41, 434, 454, 49, 503, 552, 581–582, 587–589, 707, 799, 806, 811, 816, 821, 828, 841, 90, 912, 936, 941, 945, 974, 990
crates/provider/src/shared
   types.rs84.47%100%74.29%86.41%123, 140–146, 15–18, 230, 249–256, 79
crates/support/src
   fs.rs75%100%66.67%80%
   net.rs0%100%0%0%10, 4–9
crates/support/src/fs
   in_memory.rs95.55%100%96.48%95.37%149, 271, 321, 372, 424, 432, 440, 448, 470, 478, 593, 615, 643, 660, 678, 685, 704, 731, 748, 79–82, 84, 86–89, 91, 96
   local.rs98.25%100%96.30%98.75%51, 8
crates/test-runner/src
   lib.rs100%100%100%100%

@github-actions
Copy link

Coverage after merging feat/glue/network-spec_provider into main

78.42%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
crates/configuration/src
   global_settings.rs99.12%100%96.43%99.50%
   hrmp_channel.rs95.88%100%89.47%97.44%
   network.rs99.34%100%97.78%99.49%111, 116, 124, 80
   parachain.rs98.82%100%97.06%99.02%51–53, 67–70
   relaychain.rs98.99%100%95.38%99.44%
   utils.rs100%100%100%100%
crates/configuration/src/shared
   errors.rs50%100%50%50%
   helpers.rs100%100%100%100%
   node.rs98.32%100%92.68%98.93%124, 130
   resources.rs96.09%100%94.52%96.43%102, 114, 126–128, 147–150
   types.rs91.20%100%86.14%92.69%279–281, 350–352, 375–376, 378–380, 60–62
crates/orchestrator/src
   errors.rs0%100%0%0%8
   lib.rs0%100%0%0%100–102, 106–109, 111–117, 119, 123, 125–140, 143–168, 172–181, 184–192, 194, 196–200, 203–220, 222–227, 229–238, 241–247, 250, 253–262, 265–269, 272, 274–287, 289–291, 294–298, 300, 302–315, 317–320, 322–324, 335–336, 343, 350–352, 354–363, 365–366, 368–376, 378–385, 387–394, 396–399, 40, 400–407, 41, 410, 42–45, 47–52, 54–60, 62–67, 70, 72–86, 92–97, 99
   network.rs0%100%0%0%100–108, 111–117, 119–127, 130–154, 156, 158–167, 170, 172–176, 185–189, 191, 193, 195–199, 201, 203, 205–213, 215, 217, 220–225, 227–229, 231–233, 235–237, 239–241, 243–245, 247–249, 251–253, 32–40, 43, 56–70, 77–82, 85–94, 96, 98–99
   network_spec.rs96.25%100%91.67%97.06%37
   spawner.rs0%100%0%0%100–103, 105, 109–111, 114–116, 118, 124–144, 146, 148–164, 17, 37–50, 52–53, 55, 57–60, 64–65, 67, 70–90, 92–99
crates/orchestrator/src/generators
   bootnode_addr.rs96.63%100%100%96.25%
   chain_spec.rs3.90%100%8.33%3.48%100–111, 113–128, 130, 135–146, 149–155, 157–159, 162–190, 192–195, 197–199, 201–214, 216–218, 221–223, 225, 227–239, 241, 244–249, 251–252, 254–267, 269, 272–277, 279–280, 283–296, 298–303, 305–307, 309–311, 315–344, 347, 350–353, 356, 358–359, 361–376, 378, 38, 380–381, 386–427, 438–446, 456–464, 466–478, 480–488, 491–493, 497–500, 502–503, 508–519, 523–539, 541, 544–545, 548, 550–556, 558–563, 569–574, 576, 578, 580–587, 589–592, 595–596, 599–601, 603–604, 606–608, 610–612, 614–616, 619–621, 624–628, 630, 632–640, 642–643, 648–655, 657–667, 671–674, 676, 678, 680–685, 687–697, 699–715, 717–724, 726, 730–749, 75, 750–751, 753, 76, 762–769, 77, 770–772, 774, 776–794, 796–800, 802, 804, 84–87, 95–99
   command.rs0%100%0%0%100–112, 114–120, 122, 125–130, 132–133, 136–148, 15, 150, 153–155, 157–158, 16, 161–169, 17, 170–179, 18, 180–189, 19, 190–197, 199, 20, 201, 203–209, 21, 210–219, 22, 220–224, 226–229, 23, 231–233, 235–239, 24, 240–243, 246–250, 252–256, 258, 261–269, 271, 274–290, 293–298, 300, 303–305, 307–308, 311–333, 335, 337, 44–62, 64–66, 68–76, 79–97
   errors.rs0%100%0%0%4
   identity.rs82.35%100%60%86.21%13
   key.rs84.48%100%50%90%31
   keystore.rs0%100%0%0%19–26, 28–31, 34–46, 48–55, 57–64, 66, 68–86
   para_artifact.rs24.64%100%40%22.03%44–46, 48–64, 66–69, 72–81, 83–88, 92–93
   port.rs93.75%100%83.33%96.15%
crates/orchestrator/src/network
   node.rs0%100%0%0%17–29, 33–41, 5
   parachain.rs0%100%0%0%15–23, 25–37, 5
   relaychain.rs0%100%0%0%14–21, 5
crates/orchestrator/src/network_spec
   node.rs40.83%100%33.33%41.23%108, 146–150, 152–153, 155, 158, 160–163, 165–168, 173–178, 180, 183, 185–215, 217, 90–91, 93–96
   parachain.rs73.91%100%75%73.86%104, 122, 127–130, 133, 144–147, 150, 68–70, 73, 75–77, 83, 92, 97
   relaychain.rs91.80%100%83.33%92.73%67, 90, 97
crates/orchestrator/src/shared
   types.rs47.37%100%38.46%52%43–47, 50
crates/provider/src
   lib.rs25%100%0%50%
   native.rs90.42%100%81.88%91.54%1020, 1024, 1057, 1066, 1087, 1094, 1125, 1152, 1176, 1181, 1209, 1235, 1245, 1252, 1269, 1319, 132, 1376–1378, 1423, 1499–1500, 1524, 155, 1565, 190–194, 262, 281, 294, 296, 303, 305–306, 319, 341, 355–357, 359–361, 363–365, 387–389, 391–393, 41, 434, 454, 49, 503, 552, 581–582, 587–589, 707, 799, 806, 811, 816, 821, 828, 841, 90, 912, 936, 941, 945, 974, 990
crates/provider/src/shared
   types.rs84.47%100%74.29%86.41%123, 140–146, 15–18, 230, 249–256, 79
crates/support/src
   fs.rs75%100%66.67%80%
   net.rs0%100%0%0%10, 4–9
crates/support/src/fs
   in_memory.rs95.55%100%96.48%95.37%149, 271, 321, 372, 424, 432, 440, 448, 470, 478, 593, 615, 643, 660, 678, 685, 704, 731, 748, 79–82, 84, 86–89, 91, 96
   local.rs98.25%100%96.30%98.75%51, 8
crates/test-runner/src
   lib.rs100%100%100%100%

@github-actions
Copy link

Coverage after merging feat/glue/network-spec_provider into main

78.56%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
crates/configuration/src
   global_settings.rs99.12%100%96.43%99.50%
   hrmp_channel.rs95.88%100%89.47%97.44%
   network.rs99.34%100%97.78%99.49%111, 116, 124, 80
   parachain.rs98.82%100%97.06%99.02%51–53, 67–70
   relaychain.rs98.99%100%95.38%99.44%
   utils.rs100%100%100%100%
crates/configuration/src/shared
   errors.rs50%100%50%50%
   helpers.rs100%100%100%100%
   node.rs98.32%100%92.68%98.93%124, 130
   resources.rs96.09%100%94.52%96.43%102, 114, 126–128, 147–150
   types.rs91.20%100%86.14%92.69%279–281, 350–352, 375–376, 378–380, 60–62
crates/orchestrator/src
   errors.rs0%100%0%0%8
   lib.rs0%100%0%0%100–102, 106–109, 111–117, 119, 123, 125–140, 143–168, 172–181, 184–192, 194, 196–200, 203–220, 222–227, 229–238, 241–247, 250, 253–262, 265–269, 272, 274–287, 289–291, 294–298, 300, 302–315, 317–320, 322–324, 335–336, 343, 350–352, 354–363, 365–366, 368–376, 378–385, 387–394, 396–399, 40, 400–407, 41, 410, 42–45, 47–52, 54–60, 62–67, 70, 72–86, 92–97, 99
   network.rs0%100%0%0%100–108, 111–117, 119–127, 130–154, 156, 158–167, 170, 172–176, 185–189, 191, 193, 195–199, 201, 203, 205–213, 215, 217, 220–225, 227–229, 231–233, 235–237, 239–241, 243–245, 247–249, 251–253, 32–40, 43, 56–70, 77–82, 85–94, 96, 98–99
   network_spec.rs96.25%100%91.67%97.06%37
   spawner.rs0%100%0%0%100–103, 105, 109–111, 114–116, 118, 124–144, 146, 148–164, 17, 37–50, 52–53, 55, 57–60, 64–65, 67, 70–90, 92–99
crates/orchestrator/src/generators
   bootnode_addr.rs97.20%100%100%96.84%
   chain_spec.rs3.90%100%8.33%3.48%100–111, 113–128, 130, 135–146, 149–155, 157–159, 162–190, 192–195, 197–199, 201–214, 216–218, 221–223, 225, 227–239, 241, 244–249, 251–252, 254–267, 269, 272–277, 279–280, 283–296, 298–303, 305–307, 309–311, 315–344, 347, 350–353, 356, 358–359, 361–376, 378, 38, 380–381, 386–427, 438–446, 456–464, 466–478, 480–488, 491–493, 497–500, 502–503, 508–519, 523–539, 541, 544–545, 548, 550–556, 558–563, 569–574, 576, 578, 580–587, 589–592, 595–596, 599–601, 603–604, 606–608, 610–612, 614–616, 619–621, 624–628, 630, 632–640, 642–643, 648–655, 657–667, 671–674, 676, 678, 680–685, 687–697, 699–715, 717–724, 726, 730–749, 75, 750–751, 753, 76, 762–769, 77, 770–772, 774, 776–794, 796–800, 802, 804, 84–87, 95–99
   command.rs0%100%0%0%100–112, 114–120, 122, 125–130, 132–133, 136–148, 15, 150, 153–155, 157–158, 16, 161–169, 17, 170–179, 18, 180–189, 19, 190–197, 199, 20, 201, 203–209, 21, 210–219, 22, 220–224, 226–229, 23, 231–233, 235–239, 24, 240–243, 246–250, 252–256, 258, 261–269, 271, 274–290, 293–298, 300, 303–305, 307–308, 311–333, 335, 337, 44–62, 64–66, 68–76, 79–97
   errors.rs0%100%0%0%4
   identity.rs82.35%100%60%86.21%13
   key.rs95.05%100%84.62%96.59%31
   keystore.rs0%100%0%0%19–26, 28–31, 34–46, 48–55, 57–64, 66, 68–86
   para_artifact.rs24.64%100%40%22.03%44–46, 48–64, 66–69, 72–81, 83–88, 92–93
   port.rs93.75%100%83.33%96.15%
crates/orchestrator/src/network
   node.rs0%100%0%0%17–29, 33–41, 5
   parachain.rs0%100%0%0%15–23, 25–37, 5
   relaychain.rs0%100%0%0%14–21, 5
crates/orchestrator/src/network_spec
   node.rs40.83%100%33.33%41.23%108, 146–150, 152–153, 155, 158, 160–163, 165–168, 173–178, 180, 183, 185–215, 217, 90–91, 93–96
   parachain.rs73.91%100%75%73.86%104, 122, 127–130, 133, 144–147, 150, 68–70, 73, 75–77, 83, 92, 97
   relaychain.rs91.80%100%83.33%92.73%67, 90, 97
crates/orchestrator/src/shared
   types.rs47.37%100%38.46%52%43–47, 50
crates/provider/src
   lib.rs25%100%0%50%
   native.rs90.42%100%81.88%91.54%1020, 1024, 1057, 1066, 1087, 1094, 1125, 1152, 1176, 1181, 1209, 1235, 1245, 1252, 1269, 1319, 132, 1376–1378, 1423, 1499–1500, 1524, 155, 1565, 190–194, 262, 281, 294, 296, 303, 305–306, 319, 341, 355–357, 359–361, 363–365, 387–389, 391–393, 41, 434, 454, 49, 503, 552, 581–582, 587–589, 707, 799, 806, 811, 816, 821, 828, 841, 90, 912, 936, 941, 945, 974, 990
crates/provider/src/shared
   types.rs84.47%100%74.29%86.41%123, 140–146, 15–18, 230, 249–256, 79
crates/support/src
   fs.rs75%100%66.67%80%
   net.rs0%100%0%0%10, 4–9
crates/support/src/fs
   in_memory.rs95.55%100%96.48%95.37%149, 271, 321, 372, 424, 432, 440, 448, 470, 478, 593, 615, 643, 660, 678, 685, 704, 731, 748, 79–82, 84, 86–89, 91, 96
   local.rs98.25%100%96.30%98.75%51, 8
crates/test-runner/src
   lib.rs100%100%100%100%

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.

Awesome work ! Asked many questions to understand more about how everything works and some todos we will tackle later 👏

Comment on lines 30 to 39
let mut errs = vec![];
let relaychain = RelaychainSpec::from_config(network_config.relaychain())?;
let mut parachains = vec![];

for para_config in network_config.parachains() {
match ParachainSpec::from_config(para_config) {
Ok(para) => parachains.push(para),
Err(err) => errs.push(err),
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: map + fold

Suggested change
let mut errs = vec![];
let relaychain = RelaychainSpec::from_config(network_config.relaychain())?;
let mut parachains = vec![];
for para_config in network_config.parachains() {
match ParachainSpec::from_config(para_config) {
Ok(para) => parachains.push(para),
Err(err) => errs.push(err),
}
}
let (parachains, errs) = network_config
.parachains()
.iter()
.map(|para_config| ParachainSpec::from_config(para_config))
.fold((vec![], vec![]), |(mut parachains, mut errs), result| {
match result {
Ok(para) => parachains.push(para),
Err(err) => errs.push(err),
}
(parachains, errs)
});

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I think we can use fold directly too :)

Err(err) => errs.push(err),
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

We don't use errors here, maybe do something like in network_spec::node ? A bit hacky but we will revisit later:

Suggested change
if !errs.is_empty() {
// TODO: merge errs
return Err(errs.swap_remove(0));
}

crates/orchestrator/src/lib.rs Show resolved Hide resolved
crates/orchestrator/src/lib.rs Show resolved Hide resolved
Comment on lines +66 to +78
let main_cmd = if let Some(cmd) = config.default_command() {
cmd
} else if let Some(first_node) = config.collators().first() {
let Some(cmd) = first_node.command() else {
return Err(OrchestratorError::InvalidConfig("Parachain, either default_command or command in the first node needs to be set.".to_string()));
};

cmd
} else {
return Err(OrchestratorError::InvalidConfig(
"Parachain without nodes and default_command isn't set.".to_string(),
));
};
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: same refacto as relaychain

Suggested change
let main_cmd = if let Some(cmd) = config.default_command() {
cmd
} else if let Some(first_node) = config.collators().first() {
let Some(cmd) = first_node.command() else {
return Err(OrchestratorError::InvalidConfig("Parachain, either default_command or command in the first node needs to be set.".to_string()));
};
cmd
} else {
return Err(OrchestratorError::InvalidConfig(
"Parachain without nodes and default_command isn't set.".to_string(),
));
};
let main_cmd = config
.default_command()
.or(config.collators().first().and_then(|node| node.command()))
.ok_or(OrchestratorError::InvalidConfig(
"Parachain, either default_command or first node with command needs to be set."
.to_string(),
));

Copy link
Contributor

Choose a reason for hiding this comment

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

TODO: extract errors to constants or variant with more details

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, in general Errors needs to be revamped as followup pr.

Comment on lines +146 to +149
.filter(|para| match &para.registration_strategy {
RegistrationStrategy::InGenesis => true,
RegistrationStrategy::UsingExtrinsic => false,
})
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO: add helper on RegistrationStrategy to do something like this:

registration_strategy.is_in_genesis();
registration_strategy.is_using_extrinsic();

Comment on lines +202 to +212
// TODO: we want to still supporting spawn a dedicated bootnode??
let mut ctx = SpawnNodeCtx {
chain_id: &relay_chain_id,
parachain_id: None,
chain: relay_chain_name,
role: ZombieRole::Node,
ns: &ns,
scoped_fs: &scoped_fs,
parachain: None,
bootnodes_addr: &vec![],
};
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you mean ? If there is no bootnodes, do we want to bootstrap a node ourselves ?

crates/orchestrator/src/lib.rs Show resolved Hide resolved
@pepoviola pepoviola changed the title [Draft] wire between Orchestrator - Provider Wire between Orchestrator - Provider Sep 29, 2023
@github-actions
Copy link

Coverage after merging feat/glue/network-spec_provider into main

78.56%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
crates/configuration/src
   global_settings.rs99.12%100%96.43%99.50%
   hrmp_channel.rs95.88%100%89.47%97.44%
   network.rs99.34%100%97.78%99.49%111, 116, 124, 80
   parachain.rs98.82%100%97.06%99.02%51–53, 67–70
   relaychain.rs98.99%100%95.38%99.44%
   utils.rs100%100%100%100%
crates/configuration/src/shared
   errors.rs50%100%50%50%
   helpers.rs100%100%100%100%
   node.rs98.32%100%92.68%98.93%124, 130
   resources.rs96.09%100%94.52%96.43%102, 114, 126–128, 147–150
   types.rs91.20%100%86.14%92.69%279–281, 350–352, 375–376, 378–380, 60–62
crates/orchestrator/src
   errors.rs0%100%0%0%8
   lib.rs0%100%0%0%100–102, 106–109, 111–117, 119, 123, 125–140, 143–168, 172–181, 184–192, 194, 196–200, 203–220, 222–227, 229–238, 241–247, 250, 253–262, 265–269, 272, 274–287, 289–291, 294–298, 300, 302–315, 317–320, 322–324, 335–336, 346, 353–355, 357–366, 368–369, 371–379, 381–388, 390–397, 399, 40, 400–409, 41, 410, 413, 42–45, 47–52, 54–60, 62–67, 70, 72–86, 92–97, 99
   network.rs0%100%0%0%100–108, 111–117, 119–127, 130–154, 156, 158–167, 170, 172–176, 185–189, 191, 193, 195–199, 201, 203, 205–213, 215, 217, 220–225, 227–229, 231–233, 235–237, 239–241, 243–245, 247–249, 251–253, 32–40, 43, 56–70, 77–82, 85–94, 96, 98–99
   network_spec.rs96.25%100%91.67%97.06%38
   spawner.rs0%100%0%0%100–103, 105, 109–111, 114–116, 118, 124–144, 146, 148–164, 17, 37–50, 52–53, 55, 57–60, 64–65, 67, 70–90, 92–99
crates/orchestrator/src/generators
   bootnode_addr.rs97.20%100%100%96.84%
   chain_spec.rs3.90%100%8.33%3.48%100–111, 113–128, 130, 135–146, 149–155, 157–159, 162–190, 192–195, 197–199, 201–214, 216–218, 221–223, 225, 227–239, 241, 244–249, 251–252, 254–267, 269, 272–277, 279–280, 283–296, 298–303, 305–307, 309–311, 315–344, 347, 350–353, 356, 358–359, 361–376, 378, 38, 380–381, 386–427, 438–446, 456–464, 466–478, 480–488, 491–493, 497–500, 502–503, 508–519, 523–539, 541, 544–545, 548, 550–556, 558–563, 569–574, 576, 578, 580–587, 589–592, 595–596, 599–601, 603–604, 606–608, 610–612, 614–616, 619–621, 624–628, 630, 632–640, 642–643, 648–655, 657–667, 671–674, 676, 678, 680–685, 687–697, 699–715, 717–724, 726, 730–749, 75, 750–751, 753, 76, 762–769, 77, 770–772, 774, 776–794, 796–800, 802, 804, 84–87, 95–99
   command.rs0%100%0%0%100–112, 114–120, 122, 125–130, 132–133, 136–148, 15, 150, 153–155, 157–158, 16, 161–169, 17, 170–179, 18, 180–189, 19, 190–197, 199, 20, 201, 203–209, 21, 210–219, 22, 220–224, 226–229, 23, 231–233, 235–239, 24, 240–243, 246–250, 252–256, 258, 261–269, 271, 274–290, 293–298, 300, 303–305, 307–308, 311–333, 335, 337, 44–62, 64–66, 68–76, 79–97
   errors.rs0%100%0%0%4
   identity.rs82.35%100%60%86.21%13
   key.rs95.05%100%84.62%96.59%31
   keystore.rs0%100%0%0%19–26, 28–31, 34–46, 48–55, 57–64, 66, 68–86
   para_artifact.rs24.64%100%40%22.03%44–46, 48–64, 66–69, 72–81, 83–88, 92–93
   port.rs93.75%100%83.33%96.15%
crates/orchestrator/src/network
   node.rs0%100%0%0%17–29, 33–41, 5
   parachain.rs0%100%0%0%15–23, 25–37, 5
   relaychain.rs0%100%0%0%14–21, 5
crates/orchestrator/src/network_spec
   node.rs40.83%100%33.33%41.23%108, 146–150, 152–153, 155, 158, 160–163, 165–168, 173–178, 180, 183, 185–215, 217, 90–91, 93–96
   parachain.rs73.91%100%75%73.86%104, 122, 127–130, 133, 144–147, 150, 68–70, 73, 75–77, 83, 92, 97
   relaychain.rs91.80%100%83.33%92.73%67, 90, 97
crates/orchestrator/src/shared
   types.rs47.37%100%38.46%52%43–47, 50
crates/provider/src
   lib.rs25%100%0%50%
   native.rs90.42%100%81.88%91.54%1020, 1024, 1057, 1066, 1087, 1094, 1125, 1152, 1176, 1181, 1209, 1235, 1245, 1252, 1269, 1319, 132, 1376–1378, 1423, 1499–1500, 1524, 155, 1565, 190–194, 262, 281, 294, 296, 303, 305–306, 319, 341, 355–357, 359–361, 363–365, 387–389, 391–393, 41, 434, 454, 49, 503, 552, 581–582, 587–589, 707, 799, 806, 811, 816, 821, 828, 841, 90, 912, 936, 941, 945, 974, 990
crates/provider/src/shared
   types.rs84.47%100%74.29%86.41%123, 140–146, 15–18, 230, 249–256, 79
crates/support/src
   fs.rs75%100%66.67%80%
   net.rs0%100%0%0%10, 4–9
crates/support/src/fs
   in_memory.rs95.55%100%96.48%95.37%149, 271, 321, 372, 424, 432, 440, 448, 470, 478, 593, 615, 643, 660, 678, 685, 704, 731, 748, 79–82, 84, 86–89, 91, 96
   local.rs98.25%100%96.30%98.75%51, 8
crates/test-runner/src
   lib.rs100%100%100%100%

@pepoviola
Copy link
Collaborator Author

Merging now @wirednkod / @l0r1s, thanks!

@pepoviola pepoviola merged commit 8f8b03f into main Sep 29, 2023
5 checks passed
@pepoviola pepoviola deleted the feat/glue/network-spec_provider branch September 29, 2023 12:12
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