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

fix: align StateMinerProvingDeadline with Lotus #4635

Merged
merged 3 commits into from
Aug 9, 2024
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
- [#4610](https://github.com/ChainSafe/forest/issues/4610) Fixed incorrect
structure in the `Filecoin.MinerGetBaseInfo` RPC method.

- [#4635](https://github.com/ChainSafe/forest/pull/4635) Fixed bug in
`StateMinerProvingDeadline`.

## Forest 0.19.2 "Eagle"

Non-mandatory release that includes a fix for the Prometheus-incompatible
Expand Down
2 changes: 0 additions & 2 deletions scripts/tests/api_compare/filter-list
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@
!Filecoin.StateCall
# CustomCheckFailed in Forest: https://github.com/ChainSafe/forest/issues/4446
!Filecoin.StateCirculatingSupply
# CustomCheckFailed in Forest: https://github.com/ChainSafe/forest/issues/4630
!Filecoin.StateMinerProvingDeadline
2 changes: 0 additions & 2 deletions scripts/tests/api_compare/filter-list-offline
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,3 @@
# Offline server won't provide correct results for finality-related methods
!Filecoin.EthGetBlockByNumber
!eth_getBlockByNumber
# CustomCheckFailed in Forest: https://github.com/ChainSafe/forest/issues/4630
!Filecoin.StateMinerProvingDeadline
6 changes: 5 additions & 1 deletion src/rpc/methods/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,11 @@ impl RpcMethod<2> for StateMinerProvingDeadline {
let state: miner::State = ctx
.state_manager
.get_actor_state_from_address(&ts, &address)?;
Ok(ApiDeadlineInfo(state.deadline_info(policy, ts.epoch())))
Ok(ApiDeadlineInfo(
state
.recorded_deadline_info(policy, ts.epoch())
.next_not_elapsed(),
))
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/shim/actors/miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ mod partition;
mod state;

use cid::Cid;
use fil_actor_interface::miner::State;
use fil_actor_interface::{
miner::{DeadlineInfo, State},
Policy,
};
use fil_actors_shared::fvm_ipld_bitfield::BitField;
use fvm_ipld_blockstore::Blockstore;

use crate::rpc::types::{SectorOnChainInfo, SectorPreCommitOnChainInfo};
use crate::shim::clock::ChainEpoch;
use crate::utils::db::CborStoreExt as _;

pub trait MinerStateExt {
Expand All @@ -31,6 +35,8 @@ pub trait MinerStateExt {
store: &BS,
sector_number: u64,
) -> anyhow::Result<Option<SectorPreCommitOnChainInfo>>;

fn recorded_deadline_info(&self, policy: &Policy, current_epoch: ChainEpoch) -> DeadlineInfo;
}

pub trait PartitionExt {
Expand Down
29 changes: 29 additions & 0 deletions src/shim/actors/miner/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// SPDX-License-Identifier: Apache-2.0, MIT

use anyhow::Context as _;
use fil_actor_interface::{convert::*, Policy};

use crate::shim::clock::ChainEpoch;

use super::*;

Expand Down Expand Up @@ -180,4 +183,30 @@ impl MinerStateExt for State {
.map(SectorPreCommitOnChainInfo::from),
})
}

/// Returns deadline calculations for the state recorded proving period and deadline.
/// This is out of date if the a miner does not have an active miner cron
fn recorded_deadline_info(&self, policy: &Policy, current_epoch: ChainEpoch) -> DeadlineInfo {
match self {
State::V8(st) => st
.recorded_deadline_info(&from_policy_v13_to_v9(policy), current_epoch)
.into(),
State::V9(st) => st
.recorded_deadline_info(&from_policy_v13_to_v9(policy), current_epoch)
.into(),
State::V10(st) => st
.recorded_deadline_info(&from_policy_v13_to_v10(policy), current_epoch)
.into(),
State::V11(st) => st
.recorded_deadline_info(&from_policy_v13_to_v11(policy), current_epoch)
.into(),
State::V12(st) => st
.recorded_deadline_info(&from_policy_v13_to_v12(policy), current_epoch)
.into(),
State::V13(st) => st.recorded_deadline_info(policy, current_epoch).into(),
State::V14(st) => st
.recorded_deadline_info(&from_policy_v13_to_v14(policy), current_epoch)
.into(),
}
}
}
Loading