|
1 | 1 | // Copyright 2019-2026 ChainSafe Systems |
2 | 2 | // SPDX-License-Identifier: Apache-2.0, MIT |
3 | 3 |
|
4 | | -use std::sync::LazyLock; |
5 | | - |
6 | 4 | use crate::blocks::Tipset; |
7 | 5 | use crate::message::MessageReadWrite; |
8 | 6 | use crate::shim::clock::ChainEpoch; |
9 | 7 | use crate::shim::econ::{BLOCK_GAS_LIMIT, TokenAmount}; |
10 | | -use crate::utils::misc::env::env_or_default; |
11 | 8 | use ahash::{HashSet, HashSetExt}; |
12 | 9 | use fvm_ipld_blockstore::Blockstore; |
13 | 10 |
|
14 | 11 | use super::weighted_quick_select::weighted_quick_select; |
15 | 12 |
|
16 | | -/// FIP-0115 base fee activation epoch, controlled via `FOREST_FEES_FIP0115HEIGHT`. |
17 | | -/// Defaults to `-1` (disabled). Setting to a non-negative value activates premium-based |
18 | | -/// base fee computation at that epoch. |
19 | | -/// WARNING: This is a consensus-breaking change and should only be used for testing. |
20 | | -static FIP0115_HEIGHT: LazyLock<ChainEpoch> = |
21 | | - LazyLock::new(|| env_or_default("FOREST_FEES_FIP0115HEIGHT", -1)); |
22 | | - |
23 | 13 | pub const BLOCK_GAS_TARGET_INDEX: u64 = BLOCK_GAS_LIMIT * 80 / 100 - 1; |
24 | 14 |
|
25 | 15 | /// Used in calculating the base fee change. |
@@ -64,17 +54,15 @@ pub fn compute_base_fee<DB>( |
64 | 54 | db: &DB, |
65 | 55 | ts: &Tipset, |
66 | 56 | smoke_height: ChainEpoch, |
| 57 | + firehorse_height: ChainEpoch, |
67 | 58 | ) -> Result<TokenAmount, crate::chain::Error> |
68 | 59 | where |
69 | 60 | DB: Blockstore, |
70 | 61 | { |
71 | | - // FIP-0115: https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0115.md |
72 | | - let fip0115_height = *FIP0115_HEIGHT; |
73 | | - if fip0115_height >= 0 && ts.epoch() >= fip0115_height { |
74 | | - return compute_next_base_fee_from_premiums(db, ts); |
| 62 | + if ts.epoch() < firehorse_height { |
| 63 | + return compute_next_base_fee_from_utlilization(db, ts, smoke_height); |
75 | 64 | } |
76 | | - |
77 | | - compute_next_base_fee_from_utlilization(db, ts, smoke_height) |
| 65 | + compute_next_base_fee_from_premiums(db, ts) |
78 | 66 | } |
79 | 67 |
|
80 | 68 | fn compute_next_base_fee_from_premiums<DB>( |
@@ -229,7 +217,8 @@ mod tests { |
229 | 217 | }); |
230 | 218 | let ts = Tipset::from(h0); |
231 | 219 | let smoke_height = ChainConfig::default().epoch(Height::Smoke); |
232 | | - assert!(compute_base_fee(&blockstore, &ts, smoke_height).is_err()); |
| 220 | + let firehorse_height = ChainConfig::default().epoch(Height::FireHorse); |
| 221 | + assert!(compute_base_fee(&blockstore, &ts, smoke_height, firehorse_height).is_err()); |
233 | 222 | } |
234 | 223 |
|
235 | 224 | #[test] |
|
0 commit comments