@@ -27,6 +27,9 @@ use crate::kernel::SupportedHashes;
27
27
// https://docs.rs/wasmtime/2.0.2/wasmtime/struct.InstanceLimits.html#structfield.table_elements
28
28
const TABLE_ELEMENT_SIZE : u32 = 8 ;
29
29
30
+ // Parallelism for batch seal verification.
31
+ const BATCH_SEAL_PARALLELISM : usize = 8 ;
32
+
30
33
/// Create a mapping from enum items to values in a way that guarantees at compile
31
34
/// time that we did not miss any member, in any of the prices, even if the enum
32
35
/// gets a new member later.
@@ -129,7 +132,10 @@ lazy_static! {
129
132
tipset_cid_historical: Gas :: new( 215_000 ) ,
130
133
131
134
compute_unsealed_sector_cid_base: Gas :: new( 98647 ) ,
132
- verify_seal_base: Gas :: new( 2000 ) , // TODO revisit potential removal of this
135
+ verify_seal_batch: ScalingCost {
136
+ flat: Gas :: zero( ) , // TODO: Determine startup overhead.
137
+ scale: Gas :: new( 34721049 ) , // TODO: Maybe re-benchmark?
138
+ } ,
133
139
134
140
verify_aggregate_seal_per: [
135
141
(
@@ -426,7 +432,7 @@ pub struct PriceList {
426
432
pub ( crate ) tipset_cid_historical : Gas ,
427
433
428
434
pub ( crate ) compute_unsealed_sector_cid_base : Gas ,
429
- pub ( crate ) verify_seal_base : Gas ,
435
+ pub ( crate ) verify_seal_batch : ScalingCost ,
430
436
pub ( crate ) verify_aggregate_seal_per : HashMap < RegisteredSealProof , Gas > ,
431
437
pub ( crate ) verify_aggregate_seal_steps : HashMap < RegisteredSealProof , StepCost > ,
432
438
@@ -613,9 +619,20 @@ impl PriceList {
613
619
614
620
/// Returns gas required for seal verification.
615
621
#[ inline]
616
- pub fn on_verify_seal ( & self , _info : & SealVerifyInfo ) -> GasCharge {
617
- GasCharge :: new ( "OnVerifySeal" , self . verify_seal_base , Zero :: zero ( ) )
622
+ pub fn on_batch_verify_seal ( & self , vis : & [ SealVerifyInfo ] ) -> GasCharge {
623
+ // Charge based on the expected parallelism, rounding up.
624
+ let mut count = vis. len ( ) ;
625
+ let remainder = count % BATCH_SEAL_PARALLELISM ;
626
+ if remainder > 0 {
627
+ count += BATCH_SEAL_PARALLELISM - remainder;
628
+ }
629
+ GasCharge :: new (
630
+ "OnBatchVerifySeal" ,
631
+ self . verify_seal_batch . apply ( count) ,
632
+ Zero :: zero ( ) ,
633
+ )
618
634
}
635
+
619
636
#[ inline]
620
637
pub fn on_verify_aggregate_seals (
621
638
& self ,
0 commit comments