Skip to content

Conversation

@Kayanski
Copy link
Contributor

This PR aims at separating env variables in their respective crates.
Closes ORC-120

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Apr 17, 2024

Deploying cw-orchestrator with  Cloudflare Pages  Cloudflare Pages

Latest commit: dea2334
Status: ✅  Deploy successful!
Preview URL: https://751a97c5.cw-orchestrator.pages.dev
Branch Preview URL: https://update-separate-env-variable.cw-orchestrator.pages.dev

View logs

@codecov
Copy link

codecov bot commented Apr 17, 2024

Codecov Report

Attention: Patch coverage is 47.82609% with 60 lines in your changes are missing coverage. Please review.

Project coverage is 64.2%. Comparing base (31c160c) to head (dea2334).

Additional details and impacted files
Files Coverage Δ
cw-orch-daemon/src/log.rs 100.0% <100.0%> (ø)
cw-orch-daemon/src/state.rs 88.9% <100.0%> (+<0.1%) ⬆️
...ges/cw-orch-core/src/contract/contract_instance.rs 84.0% <100.0%> (ø)
packages/cw-orch-core/src/contract/deploy.rs 0.0% <0.0%> (ø)
packages/cw-orch-core/src/contract/paths.rs 85.4% <0.0%> (+1.2%) ⬆️
packages/cw-orch-networks/src/chain_info.rs 61.2% <33.3%> (-0.8%) ⬇️
cw-orch-daemon/src/queriers/node.rs 44.2% <40.0%> (-0.5%) ⬇️
packages/cw-orch-networks/src/env.rs 33.3% <33.3%> (ø)
cw-orch-daemon/src/env.rs 78.4% <78.4%> (ø)
cw-orch-daemon/src/sender.rs 58.8% <12.5%> (ø)
... and 1 more

Copy link
Contributor

@Buckram123 Buckram123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separating them is nice

Comment on lines 96 to 99
impl DaemonEnvVars {
pub fn load() -> Result<Self, CwEnvError> {
let mut env_values = DaemonEnvVars::default();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really sure why we load all of the env variables every time we use only one of them.
Options I see:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, would be nice to use cell here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using OnceCell or lazy_static here means it's not possible to change those env variables in code, once it's initialized.
Because this is hidden from the user, unexpected behavior can happen which would be hard to debug for the user.
I would prefer the second solution !

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't lazy static it but initialize it with the daemon state instead. That way the user can still execute code (and set envs) before this is loaded.

@Kayanski Kayanski added the breaking This change prompts a major version bump. label Apr 23, 2024
Copy link
Contributor

@Buckram123 Buckram123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 🚀

pub const MIN_GAS_ENV_NAME: &str = "CW_ORCH_MIN_GAS";
pub const MAX_TX_QUERIES_RETRY_ENV_NAME: &str = "CW_ORCH_MAX_TX_QUERY_RETRIES";
pub const MIN_BLOCK_SPEED_ENV_NAME: &str = "CW_ORCH_MIN_BLOCK_SPEED";
pub const DISABLE_WALLET_BALANCE_ASSERTION_ENV_NAME: &str =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a nit but are we defaulting to having the env-var named as disable and basically defaulting to setting env-vars to true if they want to enable something (so default all our bool env vars to false) or do we change it to the env-vars always indicating the feature and having the env var toggle them. I.e. rename these "disable" env vars to "wallet_balance_assertion", "log_activation", etc. and having them set to a default value.

@Kayanski Kayanski merged commit 4f272cb into main Apr 24, 2024
@Kayanski Kayanski deleted the update/separate-env-variables branch April 24, 2024 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking This change prompts a major version bump.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants