@@ -781,7 +781,12 @@ impl Actor {
781781 return Err ( actor_error ! ( illegal_argument, "no sectors" ) ) ;
782782 }
783783
784- validate_seal_aggregate_proof ( & params. aggregate_proof , sector_numbers. len ( ) , policy) ?;
784+ validate_seal_aggregate_proof (
785+ & params. aggregate_proof ,
786+ sector_numbers. len ( ) ,
787+ policy,
788+ false ,
789+ ) ?;
785790
786791 // Load and validate pre-commits.
787792 // Fail if any don't exist, but otherwise continue with valid ones.
@@ -1801,6 +1806,7 @@ impl Actor {
18011806 & params. aggregate_proof ,
18021807 params. sector_activations . len ( ) as u64 ,
18031808 policy,
1809+ false ,
18041810 ) ?;
18051811 }
18061812
@@ -1961,13 +1967,6 @@ impl Actor {
19611967
19621968 if params. sectors . is_empty ( ) {
19631969 return Err ( actor_error ! ( illegal_argument, "batch empty" ) ) ;
1964- } else if params. sectors . len ( ) > policy. prove_commit_ni_sector_batch_max_size {
1965- return Err ( actor_error ! (
1966- illegal_argument,
1967- "batch of {} too large, max {}" ,
1968- params. sectors. len( ) ,
1969- policy. pre_commit_sector_batch_max_size
1970- ) ) ;
19711970 }
19721971
19731972 if !can_prove_commit_ni_seal_proof ( rt. policy ( ) , params. seal_proof_type ) {
@@ -1978,51 +1977,53 @@ impl Actor {
19781977 ) ) ;
19791978 }
19801979
1981- if params. sector_proofs . is_empty ( ) == params. aggregate_proof . is_empty ( ) {
1980+ if params. aggregate_proof . is_empty ( ) {
1981+ return Err ( actor_error ! ( illegal_argument, "aggregate proof must be non-empty" ) ) ;
1982+ }
1983+
1984+ if params. aggregate_proof_type != RegisteredAggregateProof :: SnarkPackV2 {
1985+ return Err ( actor_error ! ( illegal_argument, "aggregate proof type must be SnarkPackV2" ) ) ;
1986+ }
1987+
1988+ let sector_count = params. sectors . len ( ) as u64 ;
1989+ if sector_count > policy. max_aggregated_sectors_ni {
19821990 return Err ( actor_error ! (
19831991 illegal_argument,
1984- "exactly one of sector proofs or aggregate proof must be non-empty"
1992+ "too many sectors addressed, addressed {} want <= {}" ,
1993+ sector_count,
1994+ policy. max_aggregated_sectors
19851995 ) ) ;
19861996 }
1987-
1988- if !params. sector_proofs . is_empty ( ) {
1989- // Batched proofs, one per sector
1990- if params. aggregate_proof_type . is_some ( ) {
1991- return Err ( actor_error ! (
1992- illegal_argument,
1993- "aggregate proof type must be null with batched proofs"
1994- ) ) ;
1995- }
1996- if params. sectors . len ( ) != params. sector_proofs . len ( ) {
1997- return Err ( actor_error ! (
1998- illegal_argument,
1999- "mismatched lengths: {} sectors, {} proofs" ,
2000- params. sectors. len( ) ,
2001- params. sector_proofs. len( )
2002- ) ) ;
2003- }
2004- validate_seal_proofs ( params. seal_proof_type , & params. sector_proofs ) ?;
2005- } else {
2006- if params. aggregate_proof_type != Some ( RegisteredAggregateProof :: SnarkPackV2 ) {
2007- return Err ( actor_error ! (
2008- illegal_argument,
2009- "aggregate proof type must be SnarkPackV2"
2010- ) ) ;
2011- }
2012- validate_seal_aggregate_proof (
2013- & params. aggregate_proof ,
2014- params. sectors . len ( ) as u64 ,
2015- policy,
2016- ) ?;
1997+ if sector_count < policy. min_aggregated_sectors_ni {
1998+ return Err ( actor_error ! (
1999+ illegal_argument,
2000+ "too few sectors addressed, addressed {} want >= {}" ,
2001+ sector_count,
2002+ policy. min_aggregated_sectors_ni
2003+ ) ) ;
20172004 }
20182005
2006+ validate_seal_aggregate_proof (
2007+ & params. aggregate_proof ,
2008+ params. sectors . len ( ) as u64 ,
2009+ policy,
2010+ true ,
2011+ ) ?;
2012+
20192013 if params. sectors . iter ( ) . any ( |sector| sector. sealer_id != miner_id) {
20202014 return Err ( actor_error ! (
20212015 illegal_argument,
20222016 "all sectors must be sealed for the same receiver actor"
20232017 ) ) ;
20242018 }
20252019
2020+ if params. sectors . iter ( ) . any ( |sector| sector. sector_number != sector. sealing_number ) {
2021+ return Err ( actor_error ! (
2022+ illegal_argument,
2023+ "all sealing number must be same as sector numbers"
2024+ ) ) ;
2025+ }
2026+
20262027 let curr_epoch = rt. curr_epoch ( ) ;
20272028 let challenge_earliest = curr_epoch - rt. policy ( ) . max_prove_commit_ni_randomness_lookback ;
20282029 let unsealed_cid = CompactCommD :: empty ( ) . get_cid ( params. seal_proof_type ) . unwrap ( ) ;
@@ -2068,47 +2069,13 @@ impl Actor {
20682069 info. control_addresses . iter ( ) . chain ( & [ info. worker , info. owner ] ) ,
20692070 ) ?;
20702071
2071- let base_sector_power = base_power_for_sector ( info. sector_size ) ;
2072-
2073- let rew = request_current_epoch_block_reward ( rt) ?;
2074- let pwr = request_current_total_power ( rt) ?;
2075- let circulating_supply = rt. total_fil_circ_supply ( ) ;
2076- let pledge_inputs = NetworkPledgeInputs {
2077- network_qap : pwr. quality_adj_power_smoothed ,
2078- network_baseline : rew. this_epoch_baseline_power ,
2079- circulating_supply,
2080- epoch_reward : rew. this_epoch_reward_smoothed ,
2081- } ;
2082-
2083- let initial_pledge = initial_pledge_for_power (
2084- & base_sector_power,
2085- & pledge_inputs. network_baseline ,
2086- & pledge_inputs. epoch_reward ,
2087- & pledge_inputs. network_qap ,
2088- & pledge_inputs. circulating_supply ,
2089- ) ;
2090-
2091- let day_reward = expected_reward_for_power (
2092- & pledge_inputs. epoch_reward ,
2093- & pledge_inputs. network_qap ,
2094- & base_sector_power,
2095- fil_actors_runtime:: EPOCHS_IN_DAY ,
2096- ) ;
2097-
2098- let storage_pledge = expected_reward_for_power (
2099- & pledge_inputs. epoch_reward ,
2100- & pledge_inputs. network_qap ,
2101- & base_sector_power,
2102- INITIAL_PLEDGE_PROJECTION_PERIOD ,
2103- ) ;
2104-
21052072 let proof_inputs = params
21062073 . sectors
21072074 . iter ( )
21082075 . map ( |sector| -> Result < SectorSealProofInput , ActorError > {
21092076 Ok ( SectorSealProofInput {
21102077 registered_proof : params. seal_proof_type ,
2111- sector_number : sector. sector_number ,
2078+ sector_number : sector. sealing_number ,
21122079 randomness : Randomness (
21132080 rt. get_randomness_from_tickets (
21142081 DomainSeparationTag :: SealRandomness ,
@@ -2135,56 +2102,53 @@ impl Actor {
21352102 } )
21362103 . collect :: < Result < Vec < _ > , _ > > ( ) ?;
21372104
2138- let verified_sectors = if !params. sector_proofs . is_empty ( ) {
2139- let sector_verify_info = proof_inputs
2140- . iter ( )
2141- . zip ( params. sector_proofs . into_iter ( ) )
2142- . map ( |( proof_inputs, proof) | SealVerifyInfo {
2143- registered_proof : params. seal_proof_type ,
2144- sector_id : fvm_shared:: sector:: SectorID {
2145- miner : miner_id,
2146- number : proof_inputs. sector_number ,
2147- } ,
2148- randomness : proof_inputs. randomness . clone ( ) ,
2149- proof : proof. into ( ) ,
2150- sealed_cid : proof_inputs. sealed_cid ,
2151- unsealed_cid,
2152- deal_ids : vec ! [ ] ,
2153- interactive_randomness : proof_inputs. interactive_randomness . clone ( ) ,
2154- } )
2155- . collect :: < Vec < _ > > ( ) ;
2105+ verify_aggregate_seal (
2106+ rt,
2107+ // All the proof inputs, even for invalid pre-commits,
2108+ // must be provided as witnesses to the aggregate proof.
2109+ & proof_inputs,
2110+ params. sectors [ 0 ] . sealer_id ,
2111+ params. seal_proof_type ,
2112+ params. aggregate_proof_type ,
2113+ & params. aggregate_proof ,
2114+ ) ?;
21562115
2157- let sector_verifications = rt
2158- . batch_verify_seals ( & sector_verify_info)
2159- . context_code ( ExitCode :: USR_ILLEGAL_ARGUMENT , "failed to batch verify" ) ?;
2160- log:: info!( "sector_verifications: {:?}" , sector_verifications) ;
2161- params
2162- . sectors
2163- . into_iter ( )
2164- . zip ( sector_verifications)
2165- . filter ( |( _, verified) | * verified)
2166- . map ( |( sector, _) | sector)
2167- . collect :: < Vec < _ > > ( )
2168- } else {
2169- verify_aggregate_seal (
2170- rt,
2171- // All the proof inputs, even for invalid pre-commits,
2172- // must be provided as witnesses to the aggregate proof.
2173- & proof_inputs,
2174- miner_id,
2175- params. seal_proof_type ,
2176- params. aggregate_proof_type . unwrap ( ) ,
2177- & params. aggregate_proof ,
2178- ) ?;
2116+ let base_sector_power = base_power_for_sector ( info. sector_size ) ;
21792117
2180- params. sectors
2118+ let rew = request_current_epoch_block_reward ( rt) ?;
2119+ let pwr = request_current_total_power ( rt) ?;
2120+ let circulating_supply = rt. total_fil_circ_supply ( ) ;
2121+ let pledge_inputs = NetworkPledgeInputs {
2122+ network_qap : pwr. quality_adj_power_smoothed ,
2123+ network_baseline : rew. this_epoch_baseline_power ,
2124+ circulating_supply,
2125+ epoch_reward : rew. this_epoch_reward_smoothed ,
21812126 } ;
21822127
2183- if verified_sectors. is_empty ( ) {
2184- return Err ( actor_error ! ( illegal_argument, "no valid proofs specified" ) ) ;
2185- }
2128+ let initial_pledge = initial_pledge_for_power (
2129+ & base_sector_power,
2130+ & pledge_inputs. network_baseline ,
2131+ & pledge_inputs. epoch_reward ,
2132+ & pledge_inputs. network_qap ,
2133+ & pledge_inputs. circulating_supply ,
2134+ ) ;
2135+
2136+ let day_reward = expected_reward_for_power (
2137+ & pledge_inputs. epoch_reward ,
2138+ & pledge_inputs. network_qap ,
2139+ & base_sector_power,
2140+ fil_actors_runtime:: EPOCHS_IN_DAY ,
2141+ ) ;
21862142
2187- let sectors_to_add = verified_sectors
2143+ let storage_pledge = expected_reward_for_power (
2144+ & pledge_inputs. epoch_reward ,
2145+ & pledge_inputs. network_qap ,
2146+ & base_sector_power,
2147+ INITIAL_PLEDGE_PROJECTION_PERIOD ,
2148+ ) ;
2149+
2150+ let sectors_to_add = params
2151+ . sectors
21882152 . iter ( )
21892153 . map ( |sector| SectorOnChainInfo {
21902154 sector_number : sector. sector_number ,
@@ -2204,8 +2168,10 @@ impl Actor {
22042168 flags : SectorOnChainInfoFlags :: SIMPLE_QA_POWER ,
22052169 } )
22062170 . collect :: < Vec < SectorOnChainInfo > > ( ) ;
2171+ let sectors_len = sectors_to_add. len ( ) ;
22072172
2208- let total_pledge = BigInt :: from ( sectors_to_add. len ( ) ) * initial_pledge;
2173+ let total_pledge = BigInt :: from ( sectors_len) * initial_pledge;
2174+ let mut needs_cron = false ;
22092175
22102176 rt. transaction ( |state : & mut State , rt| {
22112177 let current_balance = rt. current_balance ( ) ;
@@ -2222,6 +2188,8 @@ impl Actor {
22222188 available_balance
22232189 ) ) ;
22242190 }
2191+ needs_cron = !state. deadline_cron_active ;
2192+ state. deadline_cron_active = true ;
22252193
22262194 state
22272195 . put_sectors ( store, sectors_to_add. clone ( ) )
@@ -2253,6 +2221,17 @@ impl Actor {
22532221 Ok ( ( ) )
22542222 } ) ?;
22552223
2224+ pay_aggregate_seal_proof_fee ( rt, sectors_len) ?;
2225+
2226+ if needs_cron {
2227+ let new_dl_info = state. deadline_info ( rt. policy ( ) , curr_epoch) ;
2228+ enroll_cron_event (
2229+ rt,
2230+ new_dl_info. last ( ) ,
2231+ CronEventPayload { event_type : CRON_EVENT_PROVING_DEADLINE } ,
2232+ ) ?;
2233+ }
2234+
22562235 Ok ( ( ) )
22572236 }
22582237
@@ -5094,20 +5073,26 @@ fn validate_seal_aggregate_proof(
50945073 proof : & RawBytes ,
50955074 sector_count : u64 ,
50965075 policy : & Policy ,
5076+ interactive : bool ,
50975077) -> Result < ( ) , ActorError > {
5098- if sector_count > policy. max_aggregated_sectors {
5078+ let ( min, max) = match interactive {
5079+ true => ( policy. min_aggregated_sectors_ni , policy. max_aggregated_sectors_ni ) ,
5080+ false => ( policy. min_aggregated_sectors , policy. max_aggregated_sectors ) ,
5081+ } ;
5082+
5083+ if sector_count > max {
50995084 return Err ( actor_error ! (
51005085 illegal_argument,
51015086 "too many sectors addressed, addressed {} want <= {}" ,
51025087 sector_count,
5103- policy . max_aggregated_sectors
5088+ max
51045089 ) ) ;
5105- } else if sector_count < policy . min_aggregated_sectors {
5090+ } else if sector_count < min {
51065091 return Err ( actor_error ! (
51075092 illegal_argument,
51085093 "too few sectors addressed, addressed {} want >= {}" ,
51095094 sector_count,
5110- policy . min_aggregated_sectors
5095+ min
51115096 ) ) ;
51125097 }
51135098 if proof. len ( ) > policy. max_aggregated_proof_size {
0 commit comments