-
Notifications
You must be signed in to change notification settings - Fork 159
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
feat(rpc): implement Filecoin.StateSectorPartition #4381
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b1f631c
feat(rpc): implement Filecoin.StateSectorPartition
hanabi1224 2a478c0
use From trait for Policy conversions
hanabi1224 e8e312e
Merge remote-tracking branch 'origin/main' into hm/StateSectorPartition
hanabi1224 8dae900
Merge remote-tracking branch 'origin/main' into hm/StateSectorPartition
hanabi1224 f3882c4
bump fil-actor-states
hanabi1224 5b4bade
Merge branch 'main' into hm/StateSectorPartition
hanabi1224 4859e7f
changelog
hanabi1224 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,276 @@ | ||
// Copyright 2019-2024 ChainSafe Systems | ||
// SPDX-License-Identifier: Apache-2.0, MIT | ||
|
||
use fil_actors_shared::v10::runtime::Policy as PolicyV10; | ||
use fil_actors_shared::v11::runtime::Policy as PolicyV11; | ||
use fil_actors_shared::v11::runtime::ProofSet as ProofSetV11; | ||
use fil_actors_shared::v12::runtime::Policy as PolicyV12; | ||
use fil_actors_shared::v12::runtime::ProofSet as ProofSetV12; | ||
use fil_actors_shared::v13::runtime::Policy as PolicyV13; | ||
use fil_actors_shared::v9::runtime::Policy as PolicyV9; | ||
|
||
pub fn from_policy_v13_to_v9(policy: &PolicyV13) -> PolicyV9 { | ||
let valid_post_proof_type = policy | ||
.valid_post_proof_type | ||
.clone() | ||
.into_inner() | ||
.iter() | ||
.enumerate() | ||
.filter_map(|(i, &p)| if p { Some((i as i64).into()) } else { None }) | ||
.collect(); | ||
|
||
let valid_pre_commit_proof_type = policy | ||
.valid_pre_commit_proof_type | ||
.clone() | ||
.into_inner() | ||
.iter() | ||
.enumerate() | ||
.filter_map(|(i, &p)| if p { Some((i as i64).into()) } else { None }) | ||
.collect(); | ||
|
||
PolicyV9 { | ||
max_aggregated_sectors: policy.max_aggregated_sectors, | ||
min_aggregated_sectors: policy.min_aggregated_sectors, | ||
max_aggregated_proof_size: policy.max_aggregated_proof_size, | ||
max_replica_update_proof_size: policy.max_replica_update_proof_size, | ||
pre_commit_sector_batch_max_size: policy.pre_commit_sector_batch_max_size, | ||
prove_replica_updates_max_size: policy.prove_replica_updates_max_size, | ||
expired_pre_commit_clean_up_delay: policy.expired_pre_commit_clean_up_delay, | ||
wpost_proving_period: policy.wpost_proving_period, | ||
wpost_challenge_window: policy.wpost_challenge_window, | ||
wpost_period_deadlines: policy.wpost_period_deadlines, | ||
wpost_max_chain_commit_age: policy.wpost_max_chain_commit_age, | ||
wpost_dispute_window: policy.wpost_dispute_window, | ||
sectors_max: policy.sectors_max, | ||
max_partitions_per_deadline: policy.max_partitions_per_deadline, | ||
max_control_addresses: policy.max_control_addresses, | ||
max_peer_id_length: policy.max_peer_id_length, | ||
max_multiaddr_data: policy.max_multiaddr_data, | ||
addressed_partitions_max: policy.addressed_partitions_max, | ||
declarations_max: policy.declarations_max, | ||
addressed_sectors_max: policy.addressed_sectors_max, | ||
max_pre_commit_randomness_lookback: policy.max_pre_commit_randomness_lookback, | ||
pre_commit_challenge_delay: policy.pre_commit_challenge_delay, | ||
wpost_challenge_lookback: policy.wpost_challenge_lookback, | ||
fault_declaration_cutoff: policy.fault_declaration_cutoff, | ||
fault_max_age: policy.fault_max_age, | ||
worker_key_change_delay: policy.worker_key_change_delay, | ||
min_sector_expiration: policy.min_sector_expiration, | ||
max_sector_expiration_extension: policy.max_sector_expiration_extension, | ||
deal_limit_denominator: policy.deal_limit_denominator, | ||
consensus_fault_ineligibility_duration: policy.consensus_fault_ineligibility_duration, | ||
new_sectors_per_period_max: policy.new_sectors_per_period_max, | ||
chain_finality: policy.chain_finality, | ||
valid_post_proof_type, | ||
valid_pre_commit_proof_type, | ||
minimum_verified_allocation_size: policy.minimum_verified_allocation_size.clone(), | ||
minimum_verified_allocation_term: policy.minimum_verified_allocation_term, | ||
maximum_verified_allocation_term: policy.maximum_verified_allocation_term, | ||
maximum_verified_allocation_expiration: policy.maximum_verified_allocation_expiration, | ||
end_of_life_claim_drop_period: policy.end_of_life_claim_drop_period, | ||
deal_updates_interval: policy.deal_updates_interval, | ||
prov_collateral_percent_supply_num: policy.prov_collateral_percent_supply_num, | ||
prov_collateral_percent_supply_denom: policy.prov_collateral_percent_supply_denom, | ||
market_default_allocation_term_buffer: policy.market_default_allocation_term_buffer, | ||
minimum_consensus_power: policy.minimum_consensus_power.clone(), | ||
} | ||
} | ||
|
||
pub fn from_policy_v13_to_v10(policy: &PolicyV13) -> PolicyV10 { | ||
let valid_post_proof_type = policy | ||
.valid_post_proof_type | ||
.clone() | ||
.into_inner() | ||
.iter() | ||
.enumerate() | ||
.filter_map(|(i, &p)| if p { Some((i as i64).into()) } else { None }) | ||
.collect(); | ||
|
||
let valid_pre_commit_proof_type = policy | ||
.valid_pre_commit_proof_type | ||
.clone() | ||
.into_inner() | ||
.iter() | ||
.enumerate() | ||
.filter_map(|(i, &p)| if p { Some((i as i64).into()) } else { None }) | ||
.collect(); | ||
|
||
PolicyV10 { | ||
max_aggregated_sectors: policy.max_aggregated_sectors, | ||
min_aggregated_sectors: policy.min_aggregated_sectors, | ||
max_aggregated_proof_size: policy.max_aggregated_proof_size, | ||
max_replica_update_proof_size: policy.max_replica_update_proof_size, | ||
pre_commit_sector_batch_max_size: policy.pre_commit_sector_batch_max_size, | ||
prove_replica_updates_max_size: policy.prove_replica_updates_max_size, | ||
expired_pre_commit_clean_up_delay: policy.expired_pre_commit_clean_up_delay, | ||
wpost_proving_period: policy.wpost_proving_period, | ||
wpost_challenge_window: policy.wpost_challenge_window, | ||
wpost_period_deadlines: policy.wpost_period_deadlines, | ||
wpost_max_chain_commit_age: policy.wpost_max_chain_commit_age, | ||
wpost_dispute_window: policy.wpost_dispute_window, | ||
sectors_max: policy.sectors_max, | ||
max_partitions_per_deadline: policy.max_partitions_per_deadline, | ||
max_control_addresses: policy.max_control_addresses, | ||
max_peer_id_length: policy.max_peer_id_length, | ||
max_multiaddr_data: policy.max_multiaddr_data, | ||
addressed_partitions_max: policy.addressed_partitions_max, | ||
declarations_max: policy.declarations_max, | ||
addressed_sectors_max: policy.addressed_sectors_max, | ||
max_pre_commit_randomness_lookback: policy.max_pre_commit_randomness_lookback, | ||
pre_commit_challenge_delay: policy.pre_commit_challenge_delay, | ||
wpost_challenge_lookback: policy.wpost_challenge_lookback, | ||
fault_declaration_cutoff: policy.fault_declaration_cutoff, | ||
fault_max_age: policy.fault_max_age, | ||
worker_key_change_delay: policy.worker_key_change_delay, | ||
min_sector_expiration: policy.min_sector_expiration, | ||
max_sector_expiration_extension: policy.max_sector_expiration_extension, | ||
deal_limit_denominator: policy.deal_limit_denominator, | ||
consensus_fault_ineligibility_duration: policy.consensus_fault_ineligibility_duration, | ||
new_sectors_per_period_max: policy.new_sectors_per_period_max, | ||
chain_finality: policy.chain_finality, | ||
valid_post_proof_type, | ||
valid_pre_commit_proof_type, | ||
minimum_verified_allocation_size: policy.minimum_verified_allocation_size.clone(), | ||
minimum_verified_allocation_term: policy.minimum_verified_allocation_term, | ||
maximum_verified_allocation_term: policy.maximum_verified_allocation_term, | ||
maximum_verified_allocation_expiration: policy.maximum_verified_allocation_expiration, | ||
end_of_life_claim_drop_period: policy.end_of_life_claim_drop_period, | ||
deal_updates_interval: policy.deal_updates_interval, | ||
prov_collateral_percent_supply_num: policy.prov_collateral_percent_supply_num, | ||
prov_collateral_percent_supply_denom: policy.prov_collateral_percent_supply_denom, | ||
market_default_allocation_term_buffer: policy.market_default_allocation_term_buffer, | ||
minimum_consensus_power: policy.minimum_consensus_power.clone(), | ||
} | ||
} | ||
|
||
pub fn from_policy_v13_to_v11(policy: &PolicyV13) -> PolicyV11 { | ||
let mut valid_post_proof_type = ProofSetV11::default(); | ||
policy | ||
.valid_post_proof_type | ||
.clone() | ||
.into_inner() | ||
.iter() | ||
.for_each(|proof| valid_post_proof_type.insert(*proof)); | ||
|
||
let mut valid_pre_commit_proof_type = ProofSetV11::default(); | ||
policy | ||
.valid_pre_commit_proof_type | ||
.clone() | ||
.into_inner() | ||
.iter() | ||
.for_each(|proof| valid_pre_commit_proof_type.insert(*proof)); | ||
|
||
PolicyV11 { | ||
max_aggregated_sectors: policy.max_aggregated_sectors, | ||
min_aggregated_sectors: policy.min_aggregated_sectors, | ||
max_aggregated_proof_size: policy.max_aggregated_proof_size, | ||
max_replica_update_proof_size: policy.max_replica_update_proof_size, | ||
pre_commit_sector_batch_max_size: policy.pre_commit_sector_batch_max_size, | ||
prove_replica_updates_max_size: policy.prove_replica_updates_max_size, | ||
expired_pre_commit_clean_up_delay: policy.expired_pre_commit_clean_up_delay, | ||
wpost_proving_period: policy.wpost_proving_period, | ||
wpost_challenge_window: policy.wpost_challenge_window, | ||
wpost_period_deadlines: policy.wpost_period_deadlines, | ||
wpost_max_chain_commit_age: policy.wpost_max_chain_commit_age, | ||
wpost_dispute_window: policy.wpost_dispute_window, | ||
sectors_max: policy.sectors_max, | ||
max_partitions_per_deadline: policy.max_partitions_per_deadline, | ||
max_control_addresses: policy.max_control_addresses, | ||
max_peer_id_length: policy.max_peer_id_length, | ||
max_multiaddr_data: policy.max_multiaddr_data, | ||
addressed_partitions_max: policy.addressed_partitions_max, | ||
declarations_max: policy.declarations_max, | ||
addressed_sectors_max: policy.addressed_sectors_max, | ||
max_pre_commit_randomness_lookback: policy.max_pre_commit_randomness_lookback, | ||
pre_commit_challenge_delay: policy.pre_commit_challenge_delay, | ||
wpost_challenge_lookback: policy.wpost_challenge_lookback, | ||
fault_declaration_cutoff: policy.fault_declaration_cutoff, | ||
fault_max_age: policy.fault_max_age, | ||
worker_key_change_delay: policy.worker_key_change_delay, | ||
min_sector_expiration: policy.min_sector_expiration, | ||
max_sector_expiration_extension: policy.max_sector_expiration_extension, | ||
deal_limit_denominator: policy.deal_limit_denominator, | ||
consensus_fault_ineligibility_duration: policy.consensus_fault_ineligibility_duration, | ||
new_sectors_per_period_max: policy.new_sectors_per_period_max, | ||
chain_finality: policy.chain_finality, | ||
valid_post_proof_type, | ||
valid_pre_commit_proof_type, | ||
minimum_verified_allocation_size: policy.minimum_verified_allocation_size.clone(), | ||
minimum_verified_allocation_term: policy.minimum_verified_allocation_term, | ||
maximum_verified_allocation_term: policy.maximum_verified_allocation_term, | ||
maximum_verified_allocation_expiration: policy.maximum_verified_allocation_expiration, | ||
end_of_life_claim_drop_period: policy.end_of_life_claim_drop_period, | ||
deal_updates_interval: policy.deal_updates_interval, | ||
prov_collateral_percent_supply_num: policy.prov_collateral_percent_supply_num, | ||
prov_collateral_percent_supply_denom: policy.prov_collateral_percent_supply_denom, | ||
market_default_allocation_term_buffer: policy.market_default_allocation_term_buffer, | ||
minimum_consensus_power: policy.minimum_consensus_power.clone(), | ||
} | ||
} | ||
|
||
#[allow(dead_code)] | ||
pub fn from_policy_v13_to_v12(policy: &PolicyV13) -> PolicyV12 { | ||
let mut valid_post_proof_type = ProofSetV12::default(); | ||
policy | ||
.valid_post_proof_type | ||
.clone() | ||
.into_inner() | ||
.iter() | ||
.for_each(|proof| valid_post_proof_type.insert(*proof)); | ||
|
||
let mut valid_pre_commit_proof_type = ProofSetV12::default(); | ||
policy | ||
.valid_pre_commit_proof_type | ||
.clone() | ||
.into_inner() | ||
.iter() | ||
.for_each(|proof| valid_pre_commit_proof_type.insert(*proof)); | ||
|
||
PolicyV12 { | ||
max_aggregated_sectors: policy.max_aggregated_sectors, | ||
min_aggregated_sectors: policy.min_aggregated_sectors, | ||
max_aggregated_proof_size: policy.max_aggregated_proof_size, | ||
max_replica_update_proof_size: policy.max_replica_update_proof_size, | ||
pre_commit_sector_batch_max_size: policy.pre_commit_sector_batch_max_size, | ||
prove_replica_updates_max_size: policy.prove_replica_updates_max_size, | ||
expired_pre_commit_clean_up_delay: policy.expired_pre_commit_clean_up_delay, | ||
wpost_proving_period: policy.wpost_proving_period, | ||
wpost_challenge_window: policy.wpost_challenge_window, | ||
wpost_period_deadlines: policy.wpost_period_deadlines, | ||
wpost_max_chain_commit_age: policy.wpost_max_chain_commit_age, | ||
wpost_dispute_window: policy.wpost_dispute_window, | ||
sectors_max: policy.sectors_max, | ||
max_partitions_per_deadline: policy.max_partitions_per_deadline, | ||
max_control_addresses: policy.max_control_addresses, | ||
max_peer_id_length: policy.max_peer_id_length, | ||
max_multiaddr_data: policy.max_multiaddr_data, | ||
addressed_partitions_max: policy.addressed_partitions_max, | ||
declarations_max: policy.declarations_max, | ||
addressed_sectors_max: policy.addressed_sectors_max, | ||
max_pre_commit_randomness_lookback: policy.max_pre_commit_randomness_lookback, | ||
pre_commit_challenge_delay: policy.pre_commit_challenge_delay, | ||
wpost_challenge_lookback: policy.wpost_challenge_lookback, | ||
fault_declaration_cutoff: policy.fault_declaration_cutoff, | ||
fault_max_age: policy.fault_max_age, | ||
worker_key_change_delay: policy.worker_key_change_delay, | ||
min_sector_expiration: policy.min_sector_expiration, | ||
max_sector_expiration_extension: policy.max_sector_expiration_extension, | ||
deal_limit_denominator: policy.deal_limit_denominator, | ||
consensus_fault_ineligibility_duration: policy.consensus_fault_ineligibility_duration, | ||
new_sectors_per_period_max: policy.new_sectors_per_period_max, | ||
chain_finality: policy.chain_finality, | ||
valid_post_proof_type, | ||
valid_pre_commit_proof_type, | ||
minimum_verified_allocation_size: policy.minimum_verified_allocation_size.clone(), | ||
minimum_verified_allocation_term: policy.minimum_verified_allocation_term, | ||
maximum_verified_allocation_term: policy.maximum_verified_allocation_term, | ||
maximum_verified_allocation_expiration: policy.maximum_verified_allocation_expiration, | ||
end_of_life_claim_drop_period: policy.end_of_life_claim_drop_period, | ||
deal_updates_interval: policy.deal_updates_interval, | ||
prov_collateral_percent_supply_num: policy.prov_collateral_percent_supply_num, | ||
prov_collateral_percent_supply_denom: policy.prov_collateral_percent_supply_denom, | ||
market_default_allocation_term_buffer: policy.market_default_allocation_term_buffer, | ||
minimum_consensus_power: policy.minimum_consensus_power.clone(), | ||
posted_partitions_max: policy.posted_partitions_max, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please explain why you copied https://github.com/ChainSafe/fil-actor-states/blob/main/fil_actor_interface/src/convert.rs here? If you intend to move it out of
fil-actor-states
, let's have a separate PR for this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These methods are not publicly exported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So right now we have two lengthy implementations doing basically the same thing. I'd rather we have only one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!