Lilypad-Tech / lilypad

run AI workloads easily in a decentralized GPU network. https://www.youtube.com/watch?v=zeG2F-JANjI
https://lilypad.tech
Apache License 2.0
42 stars 10 forks source link

[core] Update cli tool for incentivenet #131

Closed AquiGorka closed 2 months ago

AquiGorka commented 2 months ago
bgins commented 2 months ago

Our Goal

Our goal is to make it as simple as possible to switch networks when using the CLI.

The run command would use testnet by default (until mainnet):

lilypad run cowsay:v0.0.4 -i Message="moo"

An additional network option would set the network to devnet or dev:

lilypad run cowsay:v0.0.4 -i Message="moo" --network devnet

Proposal: Embed per network configs into the binary

We could embed configs with contract addresses for each network. The configs would be embedded directly into the binary as an embed.FS.

The network would be selected with a network option:

We may add other values to the config like rpc_url. The configs would be in a standard format so we could extend for custom configs read from file. I propose TOML below.

Precendence

The configs would be used last after command line options and environment variables. The precedence would go:

Benefits

Embedding would give us an easy way to switch networks, but it would have a few additional benefits:

Tradeoffs

We would need to be disciplined about updating the config files every time we change the contracts. We might be able to automate.

Impact on other services

The solver, resource-provider, job-creator, and mediator all use the same mechanism for loading contract addresses. The run command instantiates a job-creator to run a job.

We probably want all services to use the embedded configs. That way we can version the services alongside the CLI. But we could use the embedded configs only for the run command with some refactoring.

Again, none of this will have an immediate impact because the environment variables we use today will override the embedded configs.

Alternatives

We could provide environment files or config files with the contract addresses per network:

We could inject contract addresses into user environments using Doppler:

Proposal: TOML

TOML would be a good choice for the configuration format. With an acknowledgement that there may be bikeshedding, here is how I would compare with the other popular formats:

Also, TOML is configs are mostly flat which makes it quite readable in my opinion. Here's a more thorough comparison if folks are interested: https://www.anbowell.com/blog/an-in-depth-comparison-of-json-yaml-and-toml

Private keys

We obviously can't use this approach for private keys or any other sensitive material. TBD what to do here. Open to ideas.

Migration from GCP

Once we shut down our GCP testnet, we may have users with environments that point to the old contracts.

We could embed a config with the GCP contracts and warn the user that they need remove the environment they were using, which will move them to the new testnet without configuring anything.

Probably the CLI should do nothing until they have cleared out their environment?

We can eventually drop this check from our code base.

richardbremner commented 2 months ago

LGTM.

I've also like to see a command to output the config actually being used.