Closed AquiGorka closed 2 months ago
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
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:
testnet
. Contract addresses for testnet
. (default)devnet
. Contract addresses for devnet
.dev
. Contract addresses for local development.mainnet
which would become the default)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.
The configs would be used last after command line options and environment variables. The precedence would go:
Embedding would give us an easy way to switch networks, but it would have a few additional benefits:
We would need to be disciplined about updating the config files every time we change the contracts. We might be able to automate.
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.
We could provide environment files or config files with the contract addresses per network:
We could inject contract addresses into user environments using Doppler:
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
We obviously can't use this approach for private keys or any other sensitive material. TBD what to do here. Open to ideas.
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.
LGTM.
I've also like to see a command to output the config actually being used.
--devnet
flag that points to devnet (aws)