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: fix incorrect MinerGetBaseInfo #4617

Merged
merged 1 commit into from
Aug 6, 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 @@ -52,6 +52,9 @@
deserialisation in `Filecoin.EthGetBlockByNumber` and
`Filecoin.EthGetBlockByHash` RPC methods.

- [#4610](https://github.com/ChainSafe/forest/issues/4610) Fixed incorrect
structure in the `Filecoin.MinerGetBaseInfo` RPC method.

## Forest 0.19.2 "Eagle"

Non-mandatory release that includes a fix for the Prometheus-incompatible
Expand Down
1 change: 0 additions & 1 deletion scripts/tests/api_compare/filter-list
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# This list contains potentially broken methods (or tests) that are ignored.
# They should be considered bugged, and not used until the root cause is resolved.
!Filecoin.MinerGetBaseInfo
# Internal Server Error on Lotus: https://github.com/ChainSafe/forest/actions/runs/8619017774/job/23623141130?pr=4170
!Filecoin.MpoolGetNonce
# CustomCheckFailed in Forest: https://github.com/ChainSafe/forest/actions/runs/9593268587/job/26453560366
Expand Down
3 changes: 1 addition & 2 deletions scripts/tests/api_compare/filter-list-offline
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# This list contains potentially broken methods (or tests) that are ignored.
# They should be considered bugged, and not used until the root cause is resolved.
!Filecoin.MinerGetBaseInfo
# Internal Server Error on Lotus: https://github.com/ChainSafe/forest/actions/runs/8619314467/job/23624081698
!Filecoin.MpoolGetNonce
!Filecoin.EthSyncing
Expand All @@ -20,4 +19,4 @@
!Filecoin.StateCirculatingSupply
# The estimation is inaccurate only for offline RPC server, to be investigated: https://github.com/ChainSafe/forest/issues/4555
!Filecoin.EthEstimateGas
!eth_estimateGas
!eth_estimateGas
2 changes: 2 additions & 0 deletions src/fil_cns/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use fil_actors_shared::v10::runtime::DomainSeparationTag;
use futures::stream::FuturesUnordered;
use fvm_ipld_blockstore::Blockstore;
use fvm_ipld_encoding::{bytes_32, to_vec};
use itertools::Itertools;
use nunny::Vec as NonEmpty;

use crate::fil_cns::{metrics, FilecoinConsensusError};
Expand Down Expand Up @@ -391,6 +392,7 @@ fn verify_winning_post_proof<DB: Blockstore>(
&header.miner_address,
Randomness::new(rand.to_vec()),
)
.map(|sectors| sectors.iter().map(Into::into).collect_vec())
.map_err(|e| FilecoinConsensusError::WinningPoStValidation(e.to_string()))?;

verify_winning_post(
Expand Down
70 changes: 70 additions & 0 deletions src/lotus_json/extended_sector_info.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright 2019-2024 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use super::*;
use crate::shim::sector::{ExtendedSectorInfo, RegisteredSealProof};
use ::cid::Cid;

#[derive(Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "PascalCase")]
#[schemars(rename = "ExtendedSectorInfo")]
pub struct ExtendedSectorInfoLotusJson {
#[schemars(with = "LotusJson<RegisteredSealProof>")]
#[serde(with = "crate::lotus_json")]
seal_proof: RegisteredSealProof,
sector_number: u64,
#[schemars(with = "LotusJson<Option<Cid>>")]
#[serde(with = "crate::lotus_json")]
sector_key: Option<Cid>,
#[schemars(with = "LotusJson<Cid>")]
#[serde(with = "crate::lotus_json")]
sealed_c_i_d: Cid,
}

impl HasLotusJson for ExtendedSectorInfo {
type LotusJson = ExtendedSectorInfoLotusJson;

#[cfg(test)]
fn snapshots() -> Vec<(serde_json::Value, Self)> {
vec![(
json!({
"SealProof": 0,
"SectorNumber": 0,
"SectorKey": null,
"SealedCID": {
"/": "baeaaaaa"
}
}),
Self {
proof: fvm_shared3::sector::RegisteredSealProof::StackedDRG2KiBV1.into(),
sector_number: 0,
sector_key: None,
sealed_cid: ::cid::Cid::default(),
},
)]
}

fn into_lotus_json(self) -> Self::LotusJson {
Self::LotusJson {
seal_proof: self.proof,
sector_number: self.sector_number,
sector_key: self.sector_key,
sealed_c_i_d: self.sealed_cid,
}
}

fn from_lotus_json(lotus_json: Self::LotusJson) -> Self {
let Self::LotusJson {
seal_proof,
sector_number,
sector_key,
sealed_c_i_d,
} = lotus_json;
Self {
proof: seal_proof,
sector_number,
sector_key,
sealed_cid: sealed_c_i_d,
}
}
}
1 change: 1 addition & 0 deletions src/lotus_json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ decl_and_test!(
block_header for crate::blocks::CachingBlockHeader,
cid for ::cid::Cid,
election_proof for crate::blocks::ElectionProof,
extended_sector_info for crate::shim::sector::ExtendedSectorInfo,
gossip_block for crate::blocks::GossipBlock,
key_info for crate::key_management::KeyInfo,
message for crate::shim::message::Message,
Expand Down
6 changes: 3 additions & 3 deletions src/rpc/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::shim::{
executor::Receipt,
fvm_shared_latest::MethodNum,
message::Message,
sector::{RegisteredSealProof, SectorInfo, SectorNumber, StoragePower},
sector::{ExtendedSectorInfo, RegisteredSealProof, SectorNumber, StoragePower},
};
use cid::Cid;
use fil_actor_interface::market::AllocationID;
Expand Down Expand Up @@ -503,8 +503,8 @@ pub struct MiningBaseInfo {
#[schemars(with = "LotusJson<StoragePower>")]
pub network_power: StoragePower,
#[serde(with = "crate::lotus_json")]
#[schemars(with = "LotusJson<Vec<SectorInfo>>")]
pub sectors: Vec<SectorInfo>,
#[schemars(with = "LotusJson<Vec<ExtendedSectorInfo>>")]
pub sectors: Vec<ExtendedSectorInfo>,
#[serde(with = "crate::lotus_json")]
#[schemars(with = "LotusJson<Address>")]
pub worker_key: Address,
Expand Down
30 changes: 30 additions & 0 deletions src/shim/sector.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2019-2024 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use cid::Cid;
pub use fvm_shared3::sector::StoragePower;
pub use fvm_shared3::sector::{
RegisteredPoStProof as RegisteredPoStProofV3, RegisteredSealProof as RegisteredSealProofV3,
Expand Down Expand Up @@ -153,6 +154,35 @@ impl From<SectorInfo> for SectorInfoV2 {
}
}

/// Information about a sector necessary for PoSt verification
#[derive(
Eq, PartialEq, Debug, Clone, derive_more::From, derive_more::Into, Serialize, Deserialize,
)]
pub struct ExtendedSectorInfo {
pub proof: RegisteredSealProof,
pub sector_number: SectorNumber,
pub sector_key: Option<Cid>,
pub sealed_cid: Cid,
}

impl From<&ExtendedSectorInfo> for SectorInfo {
fn from(value: &ExtendedSectorInfo) -> SectorInfo {
SectorInfo::new(value.proof.into(), value.sector_number, value.sealed_cid)
}
}

#[cfg(test)]
impl quickcheck::Arbitrary for ExtendedSectorInfo {
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
Self {
proof: RegisteredSealProof::arbitrary(g),
sector_number: u64::arbitrary(g),
sector_key: Option::<cid::Cid>::arbitrary(g),
sealed_cid: cid::Cid::arbitrary(g),
}
}
}

#[derive(
serde::Serialize,
serde::Deserialize,
Expand Down
11 changes: 8 additions & 3 deletions src/state_manager/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::shim::{
actors::{is_account_actor, is_ethaccount_actor, is_placeholder_actor},
address::{Address, Payload},
randomness::Randomness,
sector::{RegisteredPoStProof, RegisteredSealProof, SectorInfo},
sector::{ExtendedSectorInfo, RegisteredPoStProof, RegisteredSealProof},
state_tree::ActorState,
version::NetworkVersion,
};
Expand Down Expand Up @@ -33,7 +33,7 @@ where
nv: NetworkVersion,
miner_address: &Address,
rand: Randomness,
) -> Result<Vec<SectorInfo>, anyhow::Error> {
) -> Result<Vec<ExtendedSectorInfo>, anyhow::Error> {
let store = self.blockstore();

let actor = self
Expand Down Expand Up @@ -102,7 +102,12 @@ where

let out = sectors
.into_iter()
.map(|s_info| SectorInfo::new(*spt, s_info.sector_number, s_info.sealed_cid))
.map(|s_info| ExtendedSectorInfo {
hanabi1224 marked this conversation as resolved.
Show resolved Hide resolved
proof: s_info.seal_proof.into(),
sector_number: s_info.sector_number,
sector_key: s_info.sector_key_cid,
sealed_cid: s_info.sealed_cid,
})
.collect();

Ok(out)
Expand Down
Loading