When updating CI we noticed with the configuration updates, that if an environment variable such as OPERATOR_ID was defined with not value, it would override the values in the .env file. This caused tests to fail when the relay tried to submit a transaction. Ideally, the relay to fail fast, during bootstrap if required environment variables are not set.
Solution
Consolidate environment variable loading to the start of the relay. Fail to start if any required environment variables are not set. Better to fail fast.
All environment variables should be handled in one class that can also validate them, list their usage in a --help option, and exit appropriately if a validation fails.
We should also replace environment variables with a yml settings file.
Needed validations
Make sure that CHAIN_ID, HEDERA_NETWORK, MIRROR_NODE_URL, OPERATOR_ID_MAIN, OPERATOR_KEY_MAIN, SERVER_PORT are non-empty and in the expected format
Make sure that if OPERATOR_KEY_FORMAT is not specified, the provided OPERATOR_KEY_MAIN is in the DER format
Make sure that HBAR_RATE_LIMIT_TINYBAR is more than HBAR_RATE_LIMIT_BASIC, HBAR_RATE_LIMIT_EXTENDED, HBAR_RATE_LIMIT_PRIVILEGED
Implementation Steps
[ ] Consolidate all environment variables into one service class
[ ] Add validations and exit on fail of validation, to the environment service class
Problem
When updating CI we noticed with the configuration updates, that if an environment variable such as
OPERATOR_ID
was defined with not value, it would override the values in the .env file. This caused tests to fail when the relay tried to submit a transaction. Ideally, the relay to fail fast, during bootstrap if required environment variables are not set.Solution
Consolidate environment variable loading to the start of the relay. Fail to start if any required environment variables are not set. Better to fail fast.
All environment variables should be handled in one class that can also validate them, list their usage in a --help option, and exit appropriately if a validation fails.
We should also replace environment variables with a yml settings file.
Needed validations
CHAIN_ID
,HEDERA_NETWORK
,MIRROR_NODE_URL
,OPERATOR_ID_MAIN
,OPERATOR_KEY_MAIN
,SERVER_PORT
are non-empty and in the expected formatOPERATOR_KEY_FORMAT
is not specified, the providedOPERATOR_KEY_MAIN
is in the DER formatHBAR_RATE_LIMIT_TINYBAR
is more thanHBAR_RATE_LIMIT_BASIC
,HBAR_RATE_LIMIT_EXTENDED
,HBAR_RATE_LIMIT_PRIVILEGED
Implementation Steps
Alternatives
No response