diff --git a/CHANGELOG.md b/CHANGELOG.md index 61adc5920fd8..802028eb101b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,8 @@ - [#6821](https://github.com/ChainSafe/forest/pull/6821): Added message receipt size and event size to `forest-tool archive info` output. +- [#6830](https://github.com/ChainSafe/forest/pull/6830): Make base fee FIP-0115 activation configurable via `FOREST_FEES_FIP0115HEIGHT` environment variable. The FIP will NOT be automatically activated on the next network upgrade with this change, for now. + ### Removed ### Fixed diff --git a/docs/docs/users/reference/env_variables.md b/docs/docs/users/reference/env_variables.md index 7847ad7c7350..e30f46ffb4eb 100644 --- a/docs/docs/users/reference/env_variables.md +++ b/docs/docs/users/reference/env_variables.md @@ -64,6 +64,7 @@ process. | `FOREST_GENESIS_NETWORK_VERSION` | non-negative integer | empty | 25 | Override the genesis network version (devnet only) | | `FOREST_TIPSET_CACHE_DISABLED` | 1 or true | empty | 1 | Disable the tipset cache. Used internally by development and tool subcommands | | `FOREST_MAX_CONCURRENT_CHAIN_EXCHANGE_REQUESTS` | positive integer | 3 | 3 | number of max concurrent requests to send over chain exchange protocol | +| `FOREST_FEES_FIP0115HEIGHT` | integer | -1 | 100 | FIP-0115 base fee activation epoch. Set to -1 to disable. **Consensus-breaking, for testing only.** | ### `FOREST_F3_SIDECAR_FFI_BUILD_OPT_OUT` diff --git a/src/chain/store/base_fee.rs b/src/chain/store/base_fee.rs index 96baa448a207..7707eedd4bd4 100644 --- a/src/chain/store/base_fee.rs +++ b/src/chain/store/base_fee.rs @@ -1,15 +1,25 @@ // Copyright 2019-2026 ChainSafe Systems // SPDX-License-Identifier: Apache-2.0, MIT +use std::sync::LazyLock; + use crate::blocks::Tipset; use crate::message::Message; use crate::shim::clock::ChainEpoch; use crate::shim::econ::{BLOCK_GAS_LIMIT, TokenAmount}; +use crate::utils::misc::env::env_or_default; use ahash::{HashSet, HashSetExt}; use fvm_ipld_blockstore::Blockstore; use super::weighted_quick_select::weighted_quick_select; +/// FIP-0115 base fee activation epoch, controlled via `FOREST_FEES_FIP0115HEIGHT`. +/// Defaults to `-1` (disabled). Setting to a non-negative value activates premium-based +/// base fee computation at that epoch. +/// WARNING: This is a consensus-breaking change and should only be used for testing. +static FIP0115_HEIGHT: LazyLock = + LazyLock::new(|| env_or_default("FOREST_FEES_FIP0115HEIGHT", -1)); + pub const BLOCK_GAS_TARGET_INDEX: u64 = BLOCK_GAS_LIMIT * 80 / 100 - 1; /// Used in calculating the base fee change. @@ -54,13 +64,13 @@ pub fn compute_base_fee( db: &DB, ts: &Tipset, smoke_height: ChainEpoch, - xxx_height: ChainEpoch, ) -> Result where DB: Blockstore, { - // FIP-0115: https://github.com/filecoin-project/FIPs/pull/1233 - if ts.epoch() >= xxx_height { + // FIP-0115: https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0115.md + let fip0115_height = *FIP0115_HEIGHT; + if fip0115_height >= 0 && ts.epoch() >= fip0115_height { return compute_next_base_fee_from_premiums(db, ts); } @@ -219,8 +229,7 @@ mod tests { }); let ts = Tipset::from(h0); let smoke_height = ChainConfig::default().epoch(Height::Smoke); - let xxx_height = ChainConfig::default().epoch(Height::Xxx); - assert!(compute_base_fee(&blockstore, &ts, smoke_height, xxx_height).is_err()); + assert!(compute_base_fee(&blockstore, &ts, smoke_height).is_err()); } #[test] diff --git a/src/chain_sync/tipset_syncer.rs b/src/chain_sync/tipset_syncer.rs index 418a8ba64881..86f1e4604389 100644 --- a/src/chain_sync/tipset_syncer.rs +++ b/src/chain_sync/tipset_syncer.rs @@ -232,20 +232,14 @@ async fn validate_block( // Base fee check validations.spawn_blocking({ let smoke_height = state_manager.chain_config().epoch(Height::Smoke); - let xxx_height = state_manager.chain_config().epoch(Height::Xxx); let base_tipset = base_tipset.clone(); let block_store = state_manager.blockstore_owned(); let block = Arc::clone(&block); move || { - let base_fee = crate::chain::compute_base_fee( - &block_store, - &base_tipset, - smoke_height, - xxx_height, - ) - .map_err(|e| { - TipsetSyncerError::Validation(format!("Could not compute base fee: {e}")) - })?; + let base_fee = crate::chain::compute_base_fee(&block_store, &base_tipset, smoke_height) + .map_err(|e| { + TipsetSyncerError::Validation(format!("Could not compute base fee: {e}")) + })?; let parent_base_fee = &block.header.parent_base_fee; if &base_fee != parent_base_fee { return Err(TipsetSyncerError::Validation(format!( diff --git a/src/message_pool/msgpool/provider.rs b/src/message_pool/msgpool/provider.rs index 12ea83c4ec76..0005f2edcc65 100644 --- a/src/message_pool/msgpool/provider.rs +++ b/src/message_pool/msgpool/provider.rs @@ -92,8 +92,7 @@ impl Provider for ChainStore { fn chain_compute_base_fee(&self, ts: &Tipset) -> Result { let smoke_height = self.chain_config().epoch(Height::Smoke); - let xxx_height = self.chain_config().epoch(Height::Xxx); - crate::chain::compute_base_fee(self.blockstore(), ts, smoke_height, xxx_height) + crate::chain::compute_base_fee(self.blockstore(), ts, smoke_height) .map_err(|err| err.into()) } } diff --git a/src/rpc/methods/miner.rs b/src/rpc/methods/miner.rs index fba9d8b41edf..6699daa1013a 100644 --- a/src/rpc/methods/miner.rs +++ b/src/rpc/methods/miner.rs @@ -142,11 +142,6 @@ impl RpcMethod<1> for MinerCreateBlock { .get(&Height::Smoke) .context("Missing Smoke height")? .epoch, - ctx.chain_config() - .height_infos - .get(&Height::Xxx) - .context("Missing Xxx height")? - .epoch, )?; let ExecutedTipset { state_root,