diff --git a/src/rpc/state_api.rs b/src/rpc/state_api.rs index 96c877732572..b5f3580ae676 100644 --- a/src/rpc/state_api.rs +++ b/src/rpc/state_api.rs @@ -13,7 +13,7 @@ use crate::shim::{ state_tree::ActorState, version::NetworkVersion, }; use crate::state_manager::chain_rand::ChainRand; -use crate::state_manager::vm_circ_supply::GenesisInfo; +use crate::state_manager::circulating_supply::GenesisInfo; use crate::state_manager::{InvocResult, MarketBalance}; use crate::utils::db::car_stream::{CarBlock, CarWriter}; use ahash::{HashMap, HashMapExt}; @@ -864,8 +864,11 @@ pub async fn state_circulating_supply( let genesis_info = GenesisInfo::from_chain_config(state_manager.chain_config()); - let supply = - genesis_info.get_circulating_supply(height, &state_manager.blockstore_owned(), root)?; + let supply = genesis_info.get_state_circulating_supply( + height, + &state_manager.blockstore_owned(), + root, + )?; Ok(LotusJson(supply)) } diff --git a/src/state_manager/vm_circ_supply.rs b/src/state_manager/circulating_supply.rs similarity index 94% rename from src/state_manager/vm_circ_supply.rs rename to src/state_manager/circulating_supply.rs index c7cb4784480c..47f9d3be003e 100644 --- a/src/state_manager/vm_circ_supply.rs +++ b/src/state_manager/circulating_supply.rs @@ -69,7 +69,11 @@ impl GenesisInfo { } } - // Allows generation of the current circulating supply + /// Calculate total FIL circulating supply based on Genesis configuration and state of particular + /// actors at a given height and state root. + /// + /// IMPORTANT: Easy to mistake for [`GenesisInfo::get_state_circulating_supply`], that's being + /// calculated differently. pub fn get_vm_circulating_supply( &self, height: ChainEpoch, @@ -81,6 +85,8 @@ impl GenesisInfo { Ok(detailed.fil_circulating) } + /// Calculate total FIL circulating supply based on Genesis configuration and state of particular + /// actors at a given height and state root. pub fn get_vm_circulating_supply_detailed( &self, height: ChainEpoch, @@ -112,8 +118,12 @@ impl GenesisInfo { }) } - // This can be a lengthy operation - pub fn get_circulating_supply( + /// Calculate total FIL circulating supply based on state, traversing the state tree and + /// checking Actor types. This can be a lengthy operation. + /// + /// IMPORTANT: Easy to mistake for [`GenesisInfo::get_vm_circulating_supply`], that's being + /// calculated differently. + pub fn get_state_circulating_supply( &self, height: ChainEpoch, db: &Arc, diff --git a/src/state_manager/mod.rs b/src/state_manager/mod.rs index b0bd1ddd6a08..c05fd8aaf3e7 100644 --- a/src/state_manager/mod.rs +++ b/src/state_manager/mod.rs @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0, MIT pub mod chain_rand; +pub mod circulating_supply; mod errors; mod metrics; pub mod utils; -pub mod vm_circ_supply; pub use self::errors::*; use self::utils::structured; @@ -42,6 +42,7 @@ use anyhow::{bail, Context as _}; use bls_signatures::{PublicKey as BlsPublicKey, Serialize as _}; use chain_rand::ChainRand; use cid::Cid; +pub use circulating_supply::GenesisInfo; use fil_actor_interface::init::{self, State}; use fil_actor_interface::miner::SectorOnChainInfo; use fil_actor_interface::miner::{MinerInfo, MinerPower, Partition}; @@ -67,7 +68,6 @@ use std::{num::NonZeroUsize, sync::Arc}; use tokio::sync::{broadcast::error::RecvError, Mutex as TokioMutex, RwLock}; use tracing::{debug, error, info, instrument, warn}; pub use utils::is_valid_for_sending; -pub use vm_circ_supply::GenesisInfo; const DEFAULT_TIPSET_CACHE_SIZE: NonZeroUsize = nonzero!(1024usize);