vacp2p / wakurtosis

4 stars 3 forks source link

Added node configuration in gennet.py #99

Closed AlbertoSoutullo closed 1 year ago

AlbertoSoutullo commented 1 year ago

Added node configuration in config.json.

I am still not sure about this:

0xFugue commented 1 year ago

this idea is to allow user to declare the basic traits in config.json (either as full config string, or as a trait + corresponding json). Gennet will then read/locate the properties for each of these traits and populate set of basic traits maps. Gennet will have a predefined trait library/dict for all known traits/ protocols/implementations: probably as a json /toml file per trait.

for instance with nwaku with store will have a "node type" nwaku:store and the toml will be the union of nwaku + store-node traits (+ topics). the node types will read like gowaku:filter, nwaku:config1:store, gowaku:config2:lightpush etc. Here the config1 and config2 are user defined traits and user must supply the json/toml file for each of these traits.

The node type distribution will read like "node_type_distribution": { "nwaku:config1:store":50, "gowaku:config2:lightpush":50 }. This is basically trait distribution (and will include arbit user defined traits too).

To summarise, if a user wants a particular set of configs and node distributions, he/she ought to provide them explicitly in config.json. He/she is free to skip specifying any new configs, but they must specify a trait distribution that uses Gennet's trait library. Or he/she is stuck with {"nwaku":100} as the default trait distribution.

AlbertoSoutullo commented 1 year ago

So if I understood you correctly:

"node_type_distribution": { "nwaku:config1:store":50, "gowaku:config2:lightpush":50 }

What do you think about:

"node_type_distribution": { 
    "config_1" : {
        "image": "nwaku",
        "traits": ["store", "config1.toml"],
        "percentage": 50
    },
    "config_2" : {
        "image": "gowaku",
        "traits": ["lightpush", "config2.toml"],
        "percentage": 50
    }
}

Those traits ("store" and "lightpush") will be also in Gennet (we can add them to the documentation). And then the others are provided by the user with their toml.

0xFugue commented 1 year ago

More or less. I am thinking of adding the image name as a trait as well. traits are like "nwaku", "gowaku", "store" etc. The trait string/list/stack is a spec to a compose a stack: "nwaku:filter:discv5", "gowaku:store:dnsdisc" are trait string/lists/stack; the base layer is the image name. I do like the idea of combining def and use in one go under "node_type_distribution". neat.

What I plan to do is this.

"node_type_distribution": { 
       "nwaku:store:config1" : 50,         <<-- Gennet will simply look for  config1.toml under the config.json dir
      "gowaku:lightpush:config2" : 50    <<-- every trait must have its own toml
}

The nodeTypeToToml will basically be traitToToml : this trait dict could be either hard-coded into the code, or could be populated from config.json dir. The later will make everything in Gennet configurable, and all base configs will be in one dir, the config dir.

I need to be tad smart about "image" and "node_config" inside Gennet, but it is otherwise concise and clean.

AlbertoSoutullo commented 1 year ago

For me there is something weird about keeping that information together into the key field but as you want.

Do we keep it like this PR and you do the changes in your branch? Or do I modify it in this PR? Because you told me you were doing tests and refactor so if you want to add it feel free.

0xFugue commented 1 year ago

Fair enough, let me think on it.

If you need to add anything quick to Gennet, pls do add to this PR. Lets merge ur big pending PR97, PR100 (the kurtosis/k8s PR), and this PR (PR 99). Let me then add the traits as PR ~101 (this week), and tests as PR ~102 (next). The tests/gennet are each in one fat file currently and It would be better if we keep the same dir struct between WLS and Gennet: that means splitting Gennet thousand ways; that needs couple of days.

AlbertoSoutullo commented 1 year ago

Then feel free to change/approve this, it is reviewable now