diff --git a/CHANGELOG.md b/CHANGELOG.md index f3c992878e81..b5bd97dbc09b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/scripts/tests/api_compare/filter-list b/scripts/tests/api_compare/filter-list index 22c0d94ad0ae..0649721eea2c 100644 --- a/scripts/tests/api_compare/filter-list +++ b/scripts/tests/api_compare/filter-list @@ -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 diff --git a/scripts/tests/api_compare/filter-list-offline b/scripts/tests/api_compare/filter-list-offline index 122a001aeb72..95f9f19a5062 100644 --- a/scripts/tests/api_compare/filter-list-offline +++ b/scripts/tests/api_compare/filter-list-offline @@ -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 @@ -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 \ No newline at end of file +!eth_estimateGas diff --git a/src/fil_cns/validation.rs b/src/fil_cns/validation.rs index 24a6f878e4c9..7b659f886f57 100644 --- a/src/fil_cns/validation.rs +++ b/src/fil_cns/validation.rs @@ -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}; @@ -391,6 +392,7 @@ fn verify_winning_post_proof( &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( diff --git a/src/lotus_json/extended_sector_info.rs b/src/lotus_json/extended_sector_info.rs new file mode 100644 index 000000000000..45466578af9c --- /dev/null +++ b/src/lotus_json/extended_sector_info.rs @@ -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")] + #[serde(with = "crate::lotus_json")] + seal_proof: RegisteredSealProof, + sector_number: u64, + #[schemars(with = "LotusJson>")] + #[serde(with = "crate::lotus_json")] + sector_key: Option, + #[schemars(with = "LotusJson")] + #[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, + } + } +} diff --git a/src/lotus_json/mod.rs b/src/lotus_json/mod.rs index 0107ee666d56..373be63e8a25 100644 --- a/src/lotus_json/mod.rs +++ b/src/lotus_json/mod.rs @@ -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, diff --git a/src/rpc/types/mod.rs b/src/rpc/types/mod.rs index 1a080f6a305c..123fac4ecb73 100644 --- a/src/rpc/types/mod.rs +++ b/src/rpc/types/mod.rs @@ -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; @@ -503,8 +503,8 @@ pub struct MiningBaseInfo { #[schemars(with = "LotusJson")] pub network_power: StoragePower, #[serde(with = "crate::lotus_json")] - #[schemars(with = "LotusJson>")] - pub sectors: Vec, + #[schemars(with = "LotusJson>")] + pub sectors: Vec, #[serde(with = "crate::lotus_json")] #[schemars(with = "LotusJson
")] pub worker_key: Address, diff --git a/src/shim/sector.rs b/src/shim/sector.rs index 794c99f17c16..b3a333fcb7b8 100644 --- a/src/shim/sector.rs +++ b/src/shim/sector.rs @@ -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, @@ -153,6 +154,35 @@ impl From 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, + 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::::arbitrary(g), + sealed_cid: cid::Cid::arbitrary(g), + } + } +} + #[derive( serde::Serialize, serde::Deserialize, diff --git a/src/state_manager/utils.rs b/src/state_manager/utils.rs index bc9a6b1024a0..6e82cfcd96cb 100644 --- a/src/state_manager/utils.rs +++ b/src/state_manager/utils.rs @@ -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, }; @@ -33,7 +33,7 @@ where nv: NetworkVersion, miner_address: &Address, rand: Randomness, - ) -> Result, anyhow::Error> { + ) -> Result, anyhow::Error> { let store = self.blockstore(); let actor = self @@ -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 { + 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)