Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use new magic value for FIL_RESERVED on calibnet after nv25 is enabled #5378

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
19 changes: 16 additions & 3 deletions src/state_manager/circulating_supply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::sync::Arc;

use crate::chain::*;
use crate::networks::{ChainConfig, Height};
use crate::networks::{ChainConfig, Height, NetworkChain};
use crate::rpc::types::CirculatingSupply;
use crate::shim::actors::{
is_account_actor, is_ethaccount_actor, is_evm_actor, is_miner_actor, is_multisig_actor,
Expand Down Expand Up @@ -96,7 +96,7 @@ impl GenesisInfo {
let network_version = self.chain_config.network_version(height);
let fil_locked = get_fil_locked(&state_tree, network_version)?;
let fil_reserve_disbursed = if height > self.chain_config.epoch(Height::Assembly) {
get_fil_reserve_disbursed(&state_tree)?
get_fil_reserve_disbursed(&self.chain_config, height, &state_tree)?
} else {
TokenAmount::default()
};
Expand Down Expand Up @@ -294,9 +294,22 @@ fn get_fil_power_locked<DB: Blockstore>(
}

fn get_fil_reserve_disbursed<DB: Blockstore>(
chain_config: &ChainConfig,
height: ChainEpoch,
state_tree: &StateTree<DB>,
) -> Result<TokenAmount, anyhow::Error> {
let fil_reserved: TokenAmount = TokenAmount::from_whole(300_000_000);
// FIP-0100 introduced a different hard-coded reserve amount for calibnet.
// On calibnet, after NV25, the reserve amount is 900M. See
// https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0100.md#special-handling-for-calibration-network
// for details.
let is_calibnet = matches!(chain_config.network, NetworkChain::Calibnet);
let is_nv25_or_later = chain_config.network_version(height) >= NetworkVersion::V25;
let use_fip100_reserve = is_calibnet && is_nv25_or_later;
let fil_reserved: TokenAmount = if use_fip100_reserve {
TokenAmount::from_whole(900_000_000)
} else {
TokenAmount::from_whole(300_000_000)
};
let reserve_actor = get_actor_state(state_tree, &Address::RESERVE_ACTOR)?;

// If money enters the reserve actor, this could lead to a negative term
Expand Down
Loading