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: Component TOMLs #14

Open
refcell opened this issue Oct 2, 2023 · 5 comments
Open

feat: Component TOMLs #14

refcell opened this issue Oct 2, 2023 · 5 comments
Assignees
Labels
A-config Area: configuration file crate C-feature Category: Features

Comments

@refcell
Copy link
Collaborator

refcell commented Oct 2, 2023

Description

The op_config crate offers a Config TOML that allows you to configure the OP Stack.

While this is useful for stack-wide configuration, op-up needs component-level TOML configs.

TOML is the config of choice to enable for configuration parsing into native rust so configs can be used as a library. This is a backwards-compatible alternative to defining custom dockerfiles for each component, and will allow for #3.

To make the TOMLs backwards-compatible, a field should allow for component TOMLs to reference base docker images or local Dockerfiles.

The TOML could look like the following

[metadata]
name = "challenger-go"
version = "1.1.2"

[command]
git = "[email protected]:ethereum-optimism/optimism.git"
# Default test hardhat deploy key - not safe for production environments
deployer = "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"

[docker]
# The remote docker url will be tried first to fetch the container.
remote = "<remote dockerhub container url>"
# If the remote field is not set, or the fetch fails, the local dockerfile will be referenced.
local = "./Dockerfile.challenger-go"

# Below are inlined docker-file specific fields that are only used if the above remote or local fields are not specified.

[docker.build]
base = "golang:1.19.0-alpine3.15"
dependencies = [
    "make",
    "gcc",
    "musl-dev",
    "linux-headers",
    "git",
    "jq",
    "bash"
]
run = "make op-challenger GOOS=$TARGETOS GOARCH=$TARGETARCH"

[docker.exec]
base = "alpine:3.15"
command = ["/bin/sh", "/op-challenger-go-entrypoint.sh"]

[flags]
l1-eth-rpc = "http://l1:8545"
rollup-rpc = "http://rollup-client:8545"
l2oo-address = "$L2OO_ADDRESS"
dgf-address = "$DGF_ADDRESS"
@refcell refcell added C-feature Category: Features A-config Area: configuration file crate labels Oct 2, 2023
@refcell
Copy link
Collaborator Author

refcell commented Oct 2, 2023

LMK what y'all think @clabby @merklefruit. I'm not sure I like the inlined docker fields, but not sure as of yet how to do better.

@merklefruit
Copy link
Collaborator

Looks good already! Just a few thoughts:

  1. [ports] section: ideally opup will find non-colluding ports in a smart way, but in a first version it's fine to have them manually in the toml files imo
  2. [volumes] section: most clients are also gonna need to store some stuff on disk somehow
  3. how to resolve variables: e.g. $L2OO_ADDRESS? We need to make sure these vars are exported when we run the docker compose setup

@merklefruit
Copy link
Collaborator

merklefruit commented Oct 7, 2023

It might also be a good idea to check out the Bollard container Config struct to see what are the pieces needed to start a container, since we'll probably have to parse the TOML into one of these.

More context in #39

@roninjin10
Copy link

What do you think about putting the components in the same toml config but different keys? One key per op component

[challenger]
[[metadata]]
name = "challenger-go"
version = "1.1.2"

[[command]]
git = "[email protected]:ethereum-optimism/optimism.git"
# Default test hardhat deploy key - not safe for production environments
deployer = "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"

[[docker]]
# The remote docker url will be tried first to fetch the container.
remote = "<remote dockerhub container url>"
# If the remote field is not set, or the fetch fails, the local dockerfile will be referenced.
local = "./Dockerfile.challenger-go"

# Below are inlined docker-file specific fields that are only used if the above remote or local fields are not specified.

[[docker.build]]
base = "golang:1.19.0-alpine3.15"
dependencies = [
    "make",
    "gcc",
    "musl-dev",
    "linux-headers",
    "git",
    "jq",
    "bash"
]
run = "make op-challenger GOOS=$TARGETOS GOARCH=$TARGETARCH"

[[docker.exec]]
base = "alpine:3.15"
command = ["/bin/sh", "/op-challenger-go-entrypoint.sh"]

[[flags]]
l1-eth-rpc = "http://l1:8545"
rollup-rpc = "http://rollup-client:8545"
l2oo-address = "$L2OO_ADDRESS"
dgf-address = "$DGF_ADDRESS"

@merklefruit
Copy link
Collaborator

hmm I guess it would become quite long with a lot of containers, not sure which way is best

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-config Area: configuration file crate C-feature Category: Features
Projects
None yet
Development

No branches or pull requests

3 participants