Skip to content

Have BaseServiceV2 add spaces to environment variable names #2301

@smartcontracts

Description

@smartcontracts

Currently, BaseServiceV2 automatically generates environment variables based on the following piece of code:

program.addOption(
new Option(`--${optionName.toLowerCase()}`, `${optionSpec.desc}`).env(
`${params.name
.replace(/-/g, '_')
.toUpperCase()}__${optionName.toUpperCase()}`
)
)

Notice that the name of the variable ends with optionName.toUpperCase(). This creates a situation where environment variables look like:

MY_SERVICE_NAME__MYVARIABLENAME

However, we prefer to have variables like:

MY_SERVICE_NAME__MY_VARIABLE_NAME

I think the correct way to handle this is to turn the variable name into snake case, then make it upper case. There might be some issues later with the piece of code where we actually load these environment variables. If that does end up being a problem, we'll figure it out when we run into it:

config.load({
env: true,
argv: true,
})

Once this is done, you will also have to update some places where the old variable style is used, for instance:

MESSAGE_RELAYER__L1RPCPROVIDER: http://l1_chain:8545
MESSAGE_RELAYER__L2RPCPROVIDER: http://l2geth:8545
MESSAGE_RELAYER__L1WALLET: '0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97'

And:

https://github.com/ethereum-optimism/optimism/blob/779709f275e8f69bba9941042d91affce4c71d4c/packages/message-relayer/.env.example#L1-L12

The only two services that use BaseServiceV2 are the message-relayer and the replica-healthcheck. You should be able to find all places where the old environment variable style is used by searching for MESSAGE_RELAYER and REPLICA_HEALTHCHECK in the codebase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions