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 @@ -45,6 +45,8 @@

- [#6817](https://github.com/ChainSafe/forest/pull/6817): Fixed `StateSearchMsg` to return null instead of error when not found to match Lotus behaviour.

- [#6849](https://github.com/ChainSafe/forest/pull/6849): Included strict bound in blocks included for calculating gas premium `GasEstimateGasPremium`.

## Forest v0.32.4 "Mild Inconvenience"

This is a non-mandatory release for all node operators. It enables F3 finality resolution on ETH v1 RPC methods.
Expand Down
10 changes: 5 additions & 5 deletions src/rpc/methods/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ use rand_distr::{Distribution, Normal};
use std::ops::Add;

const MIN_GAS_PREMIUM: f64 = 100000.0;
// constant taken from here <https://github.com/filecoin-project/lotus/blob/v1.35.1/node/impl/gasutils/gasutils.go#L33>
const MAX_GAS_HISTORY: u64 = 128;

/// Estimate the fee cap
pub enum GasEstimateFeeCap {}
Expand Down Expand Up @@ -106,12 +108,10 @@ struct GasMeta {

pub async fn estimate_gas_premium<DB: Blockstore>(
ctx: &Ctx<DB>,
mut nblocksincl: u64,
nblocksincl: u64,
ApiTipsetKey(ts_key): &ApiTipsetKey,
) -> Result<TokenAmount, ServerError> {
if nblocksincl == 0 {
nblocksincl = 1;
}
let nblocksincl = nblocksincl.clamp(1, MAX_GAS_HISTORY);

let mut prices: Vec<GasMeta> = Vec::new();
let mut blocks = 0;
Expand Down Expand Up @@ -163,7 +163,7 @@ pub async fn estimate_gas_premium<DB: Blockstore>(
Ok(premium)
}

// logic taken from here <https://github.com/filecoin-project/lotus/blob/v1.34.3/node/impl/gasutils/gasutils.go#L302>
// logic taken from here <https://github.com/filecoin-project/lotus/blob/v1.35.1/node/impl/gasutils/gasutils.go#L309>
fn compute_gas_premium(mut prices: Vec<GasMeta>, blocks: u64) -> TokenAmount {
prices.sort_by(|a, b| b.price.cmp(&a.price));

Expand Down
Loading