-
Notifications
You must be signed in to change notification settings - Fork 63
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: capture env variables into sigleton and reusable constants #3047
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: nikolay <n.atanasow94@gmail.com>
# Conflicts: # packages/relay/src/lib/services/hbarLimitService/index.ts # packages/relay/tests/lib/services/hbarLimitService/hbarLimitService.spec.ts
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: nikolay <n.atanasow94@gmail.com>
# Conflicts: # packages/relay/src/lib/constants.ts # packages/relay/src/lib/eth.ts # packages/relay/tests/lib/eth/eth_call.spec.ts # packages/relay/tests/lib/ethGetBlockBy.spec.ts # packages/relay/tests/lib/repositories/hbarLimiter/ethAddressHbarSpendingPlanRepository.spec.ts # packages/relay/tests/lib/repositories/hbarLimiter/hbarSpendingPlanRepository.spec.ts # packages/relay/tests/lib/services/cacheService/cacheService.spec.ts
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: nikolay <n.atanasow94@gmail.com>
# Conflicts: # packages/relay/src/lib/services/hbarLimitService/index.ts
# Conflicts: # packages/relay/src/lib/clients/sdkClient.ts # packages/relay/tests/lib/hbarLimiter.spec.ts # packages/relay/tests/lib/sdkClient.spec.ts # packages/server/tests/acceptance/hbarLimiter.spec.ts
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Signed-off-by: nikolay <n.atanasow94@gmail.com>
# Conflicts: # packages/relay/src/lib/services/hapiService/hapiService.ts # packages/server/tests/acceptance/hbarLimiter.spec.ts # packages/server/tests/acceptance/index.spec.ts # packages/server/tests/acceptance/rpc_batch3.spec.ts # packages/ws-server/tests/acceptance/index.spec.ts
Signed-off-by: nikolay <n.atanasow94@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: nikolay <n.atanasow94@gmail.com>
Quality Gate passedIssues Measures |
🚨 Memory Leak Detected 🚨A potential memory leak has been detected in the test titled Details📊 Memory Leak Detection Report 📊 GC Type: MarkSweepCompact Heap Statistics (before vs after executing the test):
Heap Space Statistics (before vs after executing the test):
RecommendationsPlease investigate the memory allocations in this test, focusing on objects that are not being properly deallocated. |
🚨 Memory Leak Detected 🚨A potential memory leak has been detected in the test titled Details📊 Memory Leak Detection Report 📊 GC Type: MarkSweepCompact Heap Statistics (before vs after executing the test):
Heap Space Statistics (before vs after executing the test):
RecommendationsPlease investigate the memory allocations in this test, focusing on objects that are not being properly deallocated. |
🚨 Memory Leak Detected 🚨A potential memory leak has been detected in the test titled Details📊 Memory Leak Detection Report 📊 GC Type: MarkSweepCompact Heap Statistics (before vs after executing the test):
Heap Space Statistics (before vs after executing the test):
RecommendationsPlease investigate the memory allocations in this test, focusing on objects that are not being properly deallocated. |
🚨 Memory Leak Detected 🚨A potential memory leak has been detected in the test titled Details📊 Memory Leak Detection Report 📊 GC Type: MarkSweepCompact Heap Statistics (before vs after executing the test):
Heap Space Statistics (before vs after executing the test):
RecommendationsPlease investigate the memory allocations in this test, focusing on objects that are not being properly deallocated. |
🚨 Memory Leak Detected 🚨A potential memory leak has been detected in the test titled Details📊 Memory Leak Detection Report 📊 GC Type: MarkSweepCompact Heap Statistics (before vs after executing the test):
Heap Space Statistics (before vs after executing the test):
RecommendationsPlease investigate the memory allocations in this test, focusing on objects that are not being properly deallocated. |
🚨 Memory Leak Detected 🚨A potential memory leak has been detected in the test titled Details📊 Memory Leak Detection Report 📊 GC Type: MarkSweepCompact Heap Statistics (before vs after executing the test):
Heap Space Statistics (before vs after executing the test):
RecommendationsPlease investigate the memory allocations in this test, focusing on objects that are not being properly deallocated. |
Description:
Currently, we are dynamically getting the environment variables and parsing/casting them every time. This is inefficient and also, more importantly, allows env configurations to be dynamically changed, which can modify the behavior of the relay based on the current values of the env vars, which can be a potential exploit.
Also, 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.
Notes for reviews:
config-service
singletonconfig-service
package is added as a dependency torelay
,server
, andws-server
config-service
must be immutable and should not provide an interface for overriding or extending once-loaded environment variables but there are many tests where we dynamically override envs in order to test specific cases so we shouldConfigServiceTestHelper
as wellconfig-service
packageprocess.env.<VAR_NAME>
toConfigService.get(<VAR_NAME>)
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
cc: @ebadiere
Related issue(s):
Fixes #3023 #2686
Notes for reviewer:
Checklist