Skip to content

Commit

Permalink
chore(test): bump lotus version in CI tests (#4286)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 authored May 10, 2024
1 parent 8dd64d3 commit 74e23e6
Show file tree
Hide file tree
Showing 10 changed files with 326 additions and 55 deletions.
2 changes: 1 addition & 1 deletion scripts/tests/api_compare/.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Note: this should be a `fat` image so that it contains the pre-downloaded filecoin proof parameters
FOREST_IMAGE=ghcr.io/chainsafe/forest:edge-fat
LOTUS_IMAGE=filecoin/lotus-all-in-one:v1.26.3-calibnet
LOTUS_IMAGE=filecoin/lotus-all-in-one:v1.27.0-rc2-calibnet
FIL_PROOFS_PARAMETER_CACHE=/var/tmp/filecoin-proof-parameters
LOTUS_RPC_PORT=1234
FOREST_RPC_PORT=2345
Expand Down
10 changes: 5 additions & 5 deletions src/rpc/methods/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,9 @@ pub struct Block {
}

impl Block {
pub fn new(has_transactions: bool) -> Self {
pub fn new(has_transactions: bool, tipset_len: usize) -> Self {
Self {
gas_limit: Uint64(BLOCK_GAS_LIMIT),
gas_limit: Uint64(BLOCK_GAS_LIMIT.saturating_mul(tipset_len as _)),
logs_bloom: Bloom(ethereum_types::Bloom(FULL_BLOOM)),
sha3_uncles: Hash::empty_uncles(),
transactions_root: if has_transactions {
Expand Down Expand Up @@ -1258,7 +1258,7 @@ pub async fn block_from_filecoin_tipset<DB: Blockstore + Send + Sync + 'static>(
} else {
Transactions::Hash(hash_transactions)
},
..Block::new(!msgs_and_receipts.is_empty())
..Block::new(!msgs_and_receipts.is_empty(), tipset.len())
})
}

Expand Down Expand Up @@ -1504,10 +1504,10 @@ mod test {

#[test]
fn test_block_constructor() {
let block = Block::new(false);
let block = Block::new(false, 1);
assert_eq!(block.transactions_root, Hash::empty_root());

let block = Block::new(true);
let block = Block::new(true, 1);
assert_eq!(block.transactions_root, Hash::default());
}

Expand Down
16 changes: 4 additions & 12 deletions src/rpc/methods/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub use types::*;
use crate::blocks::Tipset;
use crate::cid_collections::CidHashSet;
use crate::libp2p::NetworkMessage;
use crate::shim::actors::market::BalanceTableExt as _;
use crate::shim::actors::{market::BalanceTableExt as _, miner::MinerStateExt as _};
use crate::shim::message::Message;
use crate::shim::piece::PaddedPieceSize;
use crate::shim::state_tree::StateTree;
Expand Down Expand Up @@ -388,11 +388,8 @@ impl RpcMethod<2> for StateMinerActiveSectors {
Ok(())
})
})?;
let sectors = miner_state
.load_sectors(ctx.store(), Some(&BitField::union(&active_sectors)))?
.into_iter()
.map(SectorOnChainInfo::from)
.collect::<Vec<_>>();
let sectors =
miner_state.load_sectors_ext(ctx.store(), Some(&BitField::union(&active_sectors)))?;
Ok(sectors)
}
}
Expand Down Expand Up @@ -455,11 +452,7 @@ impl RpcMethod<3> for StateMinerSectors {
.state_manager
.get_required_actor(&address, *ts.parent_state())?;
let miner_state = miner::State::load(ctx.store(), actor.code, actor.state)?;
let sectors_info = miner_state
.load_sectors(ctx.store(), sectors.as_ref())?
.into_iter()
.map(SectorOnChainInfo::from)
.collect::<Vec<_>>();
let sectors_info = miner_state.load_sectors_ext(ctx.store(), sectors.as_ref())?;
Ok(sectors_info)
}
}
Expand Down Expand Up @@ -1791,7 +1784,6 @@ impl RpcMethod<3> for StateSectorGetInfo {
.get_all_sectors(&miner_address, &ts)?
.into_iter()
.find(|info| info.sector_number == sector_number)
.map(SectorOnChainInfo::from)
.context(format!("Info for sector number {sector_number} not found"))?)
}
}
Expand Down
13 changes: 7 additions & 6 deletions src/rpc/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ pub struct ApiState {

lotus_json_with_self!(ApiState);

#[derive(Clone, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "PascalCase")]
pub struct SectorOnChainInfo {
pub sector_number: SectorNumber,
Expand All @@ -285,6 +285,9 @@ pub struct SectorOnChainInfo {
/// Epoch during which the sector expires
pub expiration: ChainEpoch,

/// Additional flags, see [`fil_actor_miner_state::v12::SectorOnChainInfoFlags`]
pub flags: u32,

#[schemars(with = "LotusJson<BigInt>")]
#[serde(with = "crate::lotus_json")]
/// Integral of active deals over sector lifetime
Expand All @@ -306,24 +309,22 @@ pub struct SectorOnChainInfo {
/// time
pub expected_day_reward: TokenAmount,

/// Epoch at which this sector's power was most recently updated
pub power_base_epoch: ChainEpoch,

#[schemars(with = "LotusJson<TokenAmount>")]
#[serde(with = "crate::lotus_json")]
/// Expected twenty day projection of reward for sector computed at
/// activation time
pub expected_storage_pledge: TokenAmount,

pub replaced_sector_age: ChainEpoch,

#[schemars(with = "LotusJson<TokenAmount>")]
#[serde(with = "crate::lotus_json")]
pub replaced_day_reward: TokenAmount,

#[schemars(with = "LotusJson<Option<Cid>>")]
#[serde(with = "crate::lotus_json", rename = "SectorKeyCID")]
pub sector_key_cid: Option<Cid>,

#[serde(rename = "SimpleQAPower")]
pub simple_qa_power: bool,
}

lotus_json_with_self!(SectorOnChainInfo);
Expand Down
163 changes: 141 additions & 22 deletions src/rpc/types/sector_impl.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,150 @@
// Copyright 2019-2024 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use fil_actor_miner_state::v13::SectorOnChainInfoFlags;

use super::*;

impl From<fil_actor_interface::miner::SectorOnChainInfo> for SectorOnChainInfo {
fn from(other: fil_actor_interface::miner::SectorOnChainInfo) -> Self {
SectorOnChainInfo {
sector_number: other.sector_number,
seal_proof: other.seal_proof.into(),
sealed_cid: other.sealed_cid,
deal_ids: other.deal_ids,
activation: other.activation,
expiration: other.expiration,
deal_weight: other.deal_weight,
verified_deal_weight: other.verified_deal_weight,
initial_pledge: other.initial_pledge.into(),
expected_day_reward: other.expected_day_reward.into(),
expected_storage_pledge: other.expected_storage_pledge.into(),
replaced_sector_age: other.replaced_sector_age,
// `replaced_day_reward` has to be zero and Lemmih cannot figure out
// why. Lotus casts all `SectorOnChainInfo` structs to the miner-v9
// version which clears some fields (like `simple_qa_power`) but it
// shouldn't clear `replaced_day_reward`. Oh well, maybe one day
// Lemmih will figure it out.
impl From<fil_actor_miner_state::v8::SectorOnChainInfo> for SectorOnChainInfo {
fn from(info: fil_actor_miner_state::v8::SectorOnChainInfo) -> Self {
Self {
sector_number: info.sector_number,
seal_proof: info.seal_proof.into(),
sealed_cid: info.sealed_cid,
deal_ids: info.deal_ids,
activation: info.activation,
expiration: info.expiration,
flags: Default::default(),
deal_weight: info.deal_weight,
verified_deal_weight: info.verified_deal_weight,
initial_pledge: info.initial_pledge.into(),
expected_day_reward: info.expected_day_reward.into(),
expected_storage_pledge: info.expected_storage_pledge.into(),
replaced_day_reward: TokenAmount::default(),
sector_key_cid: other.sector_key_cid,
simple_qa_power: other.simple_qa_power,
sector_key_cid: info.sector_key_cid,
power_base_epoch: info.activation,
}
}
}

impl From<fil_actor_miner_state::v9::SectorOnChainInfo> for SectorOnChainInfo {
fn from(info: fil_actor_miner_state::v9::SectorOnChainInfo) -> Self {
Self {
sector_number: info.sector_number,
seal_proof: info.seal_proof.into(),
sealed_cid: info.sealed_cid,
deal_ids: info.deal_ids,
activation: info.activation,
expiration: info.expiration,
flags: if info.simple_qa_power {
SectorOnChainInfoFlags::SIMPLE_QA_POWER.bits()
} else {
Default::default()
},
deal_weight: info.deal_weight,
verified_deal_weight: info.verified_deal_weight,
initial_pledge: info.initial_pledge.into(),
expected_day_reward: info.expected_day_reward.into(),
expected_storage_pledge: info.expected_storage_pledge.into(),
replaced_day_reward: info.replaced_day_reward.into(),
sector_key_cid: info.sector_key_cid,
power_base_epoch: info.activation,
}
}
}

impl From<fil_actor_miner_state::v10::SectorOnChainInfo> for SectorOnChainInfo {
fn from(info: fil_actor_miner_state::v10::SectorOnChainInfo) -> Self {
Self {
sector_number: info.sector_number,
seal_proof: info.seal_proof.into(),
sealed_cid: info.sealed_cid,
deal_ids: info.deal_ids,
activation: info.activation,
expiration: info.expiration,
flags: if info.simple_qa_power {
SectorOnChainInfoFlags::SIMPLE_QA_POWER.bits()
} else {
Default::default()
},
deal_weight: info.deal_weight,
verified_deal_weight: info.verified_deal_weight,
initial_pledge: info.initial_pledge.into(),
expected_day_reward: info.expected_day_reward.into(),
expected_storage_pledge: info.expected_storage_pledge.into(),
replaced_day_reward: info.replaced_day_reward.into(),
sector_key_cid: info.sector_key_cid,
power_base_epoch: info.activation,
}
}
}

impl From<fil_actor_miner_state::v11::SectorOnChainInfo> for SectorOnChainInfo {
fn from(info: fil_actor_miner_state::v11::SectorOnChainInfo) -> Self {
Self {
sector_number: info.sector_number,
seal_proof: info.seal_proof.into(),
sealed_cid: info.sealed_cid,
deal_ids: info.deal_ids,
activation: info.activation,
expiration: info.expiration,
flags: if info.simple_qa_power {
SectorOnChainInfoFlags::SIMPLE_QA_POWER.bits()
} else {
Default::default()
},
deal_weight: info.deal_weight,
verified_deal_weight: info.verified_deal_weight,
initial_pledge: info.initial_pledge.into(),
expected_day_reward: info.expected_day_reward.into(),
expected_storage_pledge: info.expected_storage_pledge.into(),
replaced_day_reward: info.replaced_day_reward.into(),
sector_key_cid: info.sector_key_cid,
power_base_epoch: info.activation,
}
}
}

impl From<fil_actor_miner_state::v12::SectorOnChainInfo> for SectorOnChainInfo {
fn from(info: fil_actor_miner_state::v12::SectorOnChainInfo) -> Self {
Self {
sector_number: info.sector_number,
seal_proof: info.seal_proof.into(),
sealed_cid: info.sealed_cid,
deal_ids: info.deal_ids,
activation: info.activation,
expiration: info.expiration,
flags: info.flags.bits(),
deal_weight: info.deal_weight,
verified_deal_weight: info.verified_deal_weight,
initial_pledge: info.initial_pledge.into(),
expected_day_reward: info.expected_day_reward.into(),
expected_storage_pledge: info.expected_storage_pledge.into(),
replaced_day_reward: info.replaced_day_reward.into(),
sector_key_cid: info.sector_key_cid,
power_base_epoch: info.power_base_epoch,
}
}
}

impl From<fil_actor_miner_state::v13::SectorOnChainInfo> for SectorOnChainInfo {
fn from(info: fil_actor_miner_state::v13::SectorOnChainInfo) -> Self {
Self {
sector_number: info.sector_number,
seal_proof: info.seal_proof.into(),
sealed_cid: info.sealed_cid,
deal_ids: info.deprecated_deal_ids,
activation: info.activation,
expiration: info.expiration,
flags: info.flags.bits(),
deal_weight: info.deal_weight,
verified_deal_weight: info.verified_deal_weight,
initial_pledge: info.initial_pledge.into(),
expected_day_reward: info.expected_day_reward.into(),
expected_storage_pledge: info.expected_storage_pledge.into(),
replaced_day_reward: info.replaced_day_reward.into(),
sector_key_cid: info.sector_key_cid,
power_base_epoch: info.power_base_epoch,
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions src/shim/actors/miner.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2019-2024 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

mod state;

use fil_actor_interface::miner::State;
use fil_actors_shared::fvm_ipld_bitfield::BitField;
use fvm_ipld_blockstore::Blockstore;

use crate::rpc::types::SectorOnChainInfo;

pub trait MinerStateExt {
/// Loads sectors corresponding to the bitfield. If no bitfield is passed
/// in, return all.
fn load_sectors_ext<BS: Blockstore>(
&self,
store: &BS,
sectors: Option<&BitField>,
) -> anyhow::Result<Vec<SectorOnChainInfo>>;
}
Loading

0 comments on commit 74e23e6

Please sign in to comment.