Skip to content

Commit

Permalink
fix: rename and doc FOREST_IGNROE_DRAND env var (#5366)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 authored Mar 3, 2025
1 parent fc2ef1e commit 8d38412
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/docs/users/reference/env_variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ process.
| `FOREST_STATE_MIGRATION_THREADS` | integer | Depends on the machine. | 3 | The number of threads for state migration thread-pool. Advanced users only. |
| `FOREST_CONFIG_PATH` | string | /$FOREST_HOME/com.ChainSafe.Forest/config.toml | `/path/to/config.toml` | Forest configuration path. Alternatively supplied via `--config` cli parameter. |
| `RUST_LOG` | string | empty | `debug,forest_libp2p::service=info` | Allows for log level customization. |
| `FOREST_IGNORE_DRAND` | 1 or true | empty | 1 | Ignore Drand validation. |
| `FOREST_F3_SIDECAR_RPC_ENDPOINT` | string | 127.0.0.1:23456 | `127.0.0.1:23456` | An RPC endpoint of F3 sidecar. |
| `FOREST_F3_SIDECAR_FFI_ENABLED` | 1 or true | hard-coded per chain | 1 | Whether or not to start the F3 sidecar via FFI |
| `FOREST_F3_CONSENSUS_ENABLED` | 1 or true | hard-coded per chain | 1 | Whether or not to apply the F3 consensus to the node |
Expand Down
2 changes: 1 addition & 1 deletion src/beacon/drand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use url::Url;

/// Environmental Variable to ignore `Drand`. Lotus parallel is
/// `LOTUS_IGNORE_DRAND`
pub const IGNORE_DRAND_VAR: &str = "IGNORE_DRAND";
pub const IGNORE_DRAND_VAR: &str = "FOREST_IGNORE_DRAND";

/// Type of the `drand` network. `mainnet` is chained and `quicknet` is unchained.
/// For the details, see <https://github.com/filecoin-project/FIPs/blob/1bd887028ac1b50b6f2f94913e07ede73583da5b/FIPS/fip-0063.md#specification>
Expand Down
2 changes: 1 addition & 1 deletion src/chain/store/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl<DB: Blockstore> ChainIndex<DB> {
}
}

if std::env::var(IGNORE_DRAND_VAR) == Ok("1".to_owned()) {
if is_env_truthy(IGNORE_DRAND_VAR) {
return Ok(BeaconEntry::new(0, vec![9; 16]));
}

Expand Down
3 changes: 2 additions & 1 deletion src/fil_cns/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use crate::shim::{
};
use crate::state_manager::StateManager;
use crate::utils::encoding::prover_id_from_u64;
use crate::utils::misc::env::is_env_truthy;
use cid::Cid;
use fil_actors_shared::filecoin_proofs_api::{post, PublicReplicaInfo, SectorId};
use fil_actors_shared::v10::runtime::DomainSeparationTag;
Expand Down Expand Up @@ -129,7 +130,7 @@ pub(in crate::fil_cns) async fn validate_block<DB: Blockstore + Sync + Send + 's
}));

// Beacon values check
if std::env::var(IGNORE_DRAND_VAR) != Ok("1".to_owned()) {
if !is_env_truthy(IGNORE_DRAND_VAR) {
validations.push(tokio::task::spawn({
let block = Arc::clone(&block);
let parent_epoch = base_tipset.epoch();
Expand Down
2 changes: 1 addition & 1 deletion src/utils/misc/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn is_env_truthy(env: &str) -> bool {
pub fn is_env_set_and_truthy(env: &str) -> Option<bool> {
std::env::var(env)
.ok()
.map(|var| matches!(var.to_lowercase().as_str(), "1" | "true"))
.map(|var| matches!(var.to_lowercase().as_str(), "1" | "true" | "yes" | "_yes_"))
}

#[cfg(test)]
Expand Down

0 comments on commit 8d38412

Please sign in to comment.