Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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 @@ -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`

Expand Down
19 changes: 14 additions & 5 deletions src/chain/store/base_fee.rs
Original file line number Diff line number Diff line change
@@ -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<ChainEpoch> =
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.
Expand Down Expand Up @@ -54,13 +64,13 @@ pub fn compute_base_fee<DB>(
db: &DB,
ts: &Tipset,
smoke_height: ChainEpoch,
xxx_height: ChainEpoch,
) -> Result<TokenAmount, crate::chain::Error>
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);
}

Expand Down Expand Up @@ -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]
Expand Down
14 changes: 4 additions & 10 deletions src/chain_sync/tipset_syncer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,20 +232,14 @@ async fn validate_block<DB: Blockstore + Sync + Send + 'static>(
// 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!(
Expand Down
3 changes: 1 addition & 2 deletions src/message_pool/msgpool/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ impl<DB: Blockstore> Provider for ChainStore<DB> {

fn chain_compute_base_fee(&self, ts: &Tipset) -> Result<TokenAmount, Error> {
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())
}
}
5 changes: 0 additions & 5 deletions src/rpc/methods/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading