@@ -51,6 +51,65 @@ pub struct SharedStateKeeperConfig {
5151 pub protective_reads_persistence_enabled : bool ,
5252}
5353
54+ #[ derive( Debug , Clone , PartialEq , DescribeConfig , DeserializeConfig ) ]
55+ pub struct SealCriteriaConfig {
56+ /// The max number of slots for txs in a block before it should be sealed by the slots sealer.
57+ #[ config( default_t = 8_192 ) ]
58+ pub transaction_slots : usize ,
59+ /// Configuration option for tx to be rejected in case
60+ /// it takes more percentage of the block capacity than this value.
61+ #[ config( default_t = 0.95 , validate( ZERO_TO_ONE ) ) ]
62+ pub reject_tx_at_geometry_percentage : f64 ,
63+ /// Configuration option for tx to be rejected in case
64+ /// it takes more percentage of the block capacity than this value.
65+ #[ config( default_t = 0.95 , validate( ZERO_TO_ONE ) ) ]
66+ pub reject_tx_at_eth_params_percentage : f64 ,
67+ /// Configuration option for tx to be rejected in case
68+ /// it takes more percentage of the block capacity than this value.
69+ #[ config( default_t = 0.95 , validate( ZERO_TO_ONE ) ) ]
70+ pub reject_tx_at_gas_percentage : f64 ,
71+ /// Denotes the percentage of geometry params used in L2 block that triggers L2 block seal.
72+ #[ config( default_t = 0.95 , validate( ZERO_TO_ONE ) ) ]
73+ pub close_block_at_geometry_percentage : f64 ,
74+ /// Denotes the percentage of L1 params used in L2 block that triggers L2 block seal.
75+ #[ config( default_t = 0.95 , validate( ZERO_TO_ONE ) ) ]
76+ pub close_block_at_eth_params_percentage : f64 ,
77+ /// Denotes the percentage of L1 gas used in L2 block that triggers L2 block seal.
78+ #[ config( default_t = 0.95 , validate( ZERO_TO_ONE ) ) ]
79+ pub close_block_at_gas_percentage : f64 ,
80+ /// The maximum amount of pubdata that can be used by the batch.
81+ /// This variable should not exceed:
82+ /// - 128kb for calldata-based rollups
83+ /// - 120kb * n, where `n` is a number of blobs for blob-based rollups
84+ /// - the DA layer's blob size limit for the DA layer-based validiums
85+ /// - 100 MB for the object store-based or no-da validiums
86+ #[ config( with = Fallback ( SizeUnit :: Bytes ) ) ]
87+ pub max_pubdata_per_batch : ByteSize ,
88+ /// The maximum number of circuits that a batch can support.
89+ /// Note, that this number corresponds to the "base layer" circuits, i.e. it does not include
90+ /// the recursion layers' circuits.
91+ #[ config( default_t = 31_100 ) ]
92+ pub max_circuits_per_batch : usize ,
93+ }
94+
95+ impl SealCriteriaConfig {
96+ /// Creates a config object suitable for use in unit tests.
97+ /// Values mostly repeat the values used in the localhost environment.
98+ pub fn for_tests ( ) -> Self {
99+ SealCriteriaConfig {
100+ transaction_slots : 250 ,
101+ max_pubdata_per_batch : ByteSize ( 100_000 ) ,
102+ reject_tx_at_geometry_percentage : 0.95 ,
103+ reject_tx_at_eth_params_percentage : 0.95 ,
104+ reject_tx_at_gas_percentage : 0.95 ,
105+ close_block_at_geometry_percentage : 0.95 ,
106+ close_block_at_eth_params_percentage : 0.95 ,
107+ close_block_at_gas_percentage : 0.95 ,
108+ max_circuits_per_batch : 24100 ,
109+ }
110+ }
111+ }
112+
54113/// State keeper config.
55114///
56115/// # Developer notes
@@ -61,9 +120,8 @@ pub struct SharedStateKeeperConfig {
61120pub struct StateKeeperConfig {
62121 #[ config( flatten) ]
63122 pub shared : SharedStateKeeperConfig ,
64- /// The max number of slots for txs in a block before it should be sealed by the slots sealer.
65- #[ config( default_t = 8_192 ) ]
66- pub transaction_slots : usize ,
123+ #[ config( flatten) ]
124+ pub seal_criteria : SealCriteriaConfig ,
67125
68126 /// Deadline after which an L1 batch is going to be unconditionally sealed.
69127 #[ config( deprecated = "block_commit_deadline" ) ]
@@ -85,28 +143,6 @@ pub struct StateKeeperConfig {
85143 #[ config( default_t = 15_000_000_000 ) ]
86144 pub max_allowed_l2_tx_gas_limit : u64 ,
87145
88- /// Configuration option for tx to be rejected in case
89- /// it takes more percentage of the block capacity than this value.
90- #[ config( default_t = 0.95 , validate( ZERO_TO_ONE ) ) ]
91- pub reject_tx_at_geometry_percentage : f64 ,
92- /// Configuration option for tx to be rejected in case
93- /// it takes more percentage of the block capacity than this value.
94- #[ config( default_t = 0.95 , validate( ZERO_TO_ONE ) ) ]
95- pub reject_tx_at_eth_params_percentage : f64 ,
96- /// Configuration option for tx to be rejected in case
97- /// it takes more percentage of the block capacity than this value.
98- #[ config( default_t = 0.95 , validate( ZERO_TO_ONE ) ) ]
99- pub reject_tx_at_gas_percentage : f64 ,
100- /// Denotes the percentage of geometry params used in L2 block that triggers L2 block seal.
101- #[ config( default_t = 0.95 , validate( ZERO_TO_ONE ) ) ]
102- pub close_block_at_geometry_percentage : f64 ,
103- /// Denotes the percentage of L1 params used in L2 block that triggers L2 block seal.
104- #[ config( default_t = 0.95 , validate( ZERO_TO_ONE ) ) ]
105- pub close_block_at_eth_params_percentage : f64 ,
106- /// Denotes the percentage of L1 gas used in L2 block that triggers L2 block seal.
107- #[ config( default_t = 0.95 , validate( ZERO_TO_ONE ) ) ]
108- pub close_block_at_gas_percentage : f64 ,
109-
110146 // Parameters without defaults.
111147 /// The minimal acceptable L2 gas price, i.e. the price that should include the cost of computation/proving as well
112148 /// as potentially premium for congestion.
@@ -125,25 +161,12 @@ pub struct StateKeeperConfig {
125161 pub batch_overhead_l1_gas : u64 ,
126162 /// The maximum amount of gas that can be used by the batch. This value is derived from the circuits limitation per batch.
127163 pub max_gas_per_batch : u64 ,
128- /// The maximum amount of pubdata that can be used by the batch.
129- /// This variable should not exceed:
130- /// - 128kb for calldata-based rollups
131- /// - 120kb * n, where `n` is a number of blobs for blob-based rollups
132- /// - the DA layer's blob size limit for the DA layer-based validiums
133- /// - 100 MB for the object store-based or no-da validiums
134- #[ config( with = Fallback ( SizeUnit :: Bytes ) ) ]
135- pub max_pubdata_per_batch : ByteSize ,
136164 /// The version of the fee model to use.
137165 #[ config( default_t = FeeModelVersion :: V2 , with = Serde ![ str ] ) ]
138166 pub fee_model_version : FeeModelVersion ,
139167 /// Max number of computational gas that validation step is allowed to take. Also applied on the API server.
140168 #[ config( default_t = 300_000 ) ]
141169 pub validation_computational_gas_limit : u32 ,
142- /// The maximum number of circuits that a batch can support.
143- /// Note, that this number corresponds to the "base layer" circuits, i.e. it does not include
144- /// the recursion layers' circuits.
145- #[ config( default_t = 31_100 ) ]
146- pub max_circuits_per_batch : usize ,
147170 /// Allowed deployers for L2 transactions.
148171 #[ config( nest) ]
149172 pub deployment_allowlist : Option < DeploymentAllowlist > ,
@@ -155,27 +178,19 @@ impl StateKeeperConfig {
155178 pub fn for_tests ( ) -> Self {
156179 Self {
157180 shared : SharedStateKeeperConfig :: default ( ) ,
158- transaction_slots : 250 ,
181+ seal_criteria : SealCriteriaConfig :: for_tests ( ) ,
159182 l1_batch_commit_deadline : Duration :: from_millis ( 2500 ) ,
160183 l2_block_commit_deadline : Duration :: from_secs ( 1 ) ,
161184 l2_block_max_payload_size : ByteSize ( 1_000_000 ) ,
162185 max_single_tx_gas : 6000000 ,
163186 max_allowed_l2_tx_gas_limit : 4000000000 ,
164- reject_tx_at_geometry_percentage : 0.95 ,
165- reject_tx_at_eth_params_percentage : 0.95 ,
166- reject_tx_at_gas_percentage : 0.95 ,
167- close_block_at_geometry_percentage : 0.95 ,
168- close_block_at_eth_params_percentage : 0.95 ,
169- close_block_at_gas_percentage : 0.95 ,
170187 compute_overhead_part : 0.0 ,
171188 pubdata_overhead_part : 1.0 ,
172189 batch_overhead_l1_gas : 800_000 ,
173190 max_gas_per_batch : 200_000_000 ,
174- max_pubdata_per_batch : ByteSize ( 100_000 ) ,
175191 minimal_l2_gas_price : 100000000 ,
176192 fee_model_version : FeeModelVersion :: V2 ,
177193 validation_computational_gas_limit : 300000 ,
178- max_circuits_per_batch : 24100 ,
179194 deployment_allowlist : None ,
180195 }
181196 }
@@ -269,27 +284,29 @@ mod tests {
269284 save_call_traces : false ,
270285 protective_reads_persistence_enabled : true ,
271286 } ,
272- transaction_slots : 50 ,
287+ seal_criteria : SealCriteriaConfig {
288+ transaction_slots : 50 ,
289+ close_block_at_eth_params_percentage : 0.2 ,
290+ close_block_at_gas_percentage : 0.8 ,
291+ close_block_at_geometry_percentage : 0.5 ,
292+ reject_tx_at_eth_params_percentage : 0.8 ,
293+ reject_tx_at_geometry_percentage : 0.3 ,
294+ reject_tx_at_gas_percentage : 0.5 ,
295+ max_pubdata_per_batch : ByteSize ( 131_072 ) ,
296+ max_circuits_per_batch : 24100 ,
297+ } ,
273298 l1_batch_commit_deadline : Duration :: from_millis ( 2500 ) ,
274299 l2_block_commit_deadline : Duration :: from_millis ( 1000 ) ,
275300 l2_block_max_payload_size : ByteSize ( 1_000_000 ) ,
276301 max_single_tx_gas : 1_000_000 ,
277302 max_allowed_l2_tx_gas_limit : 2_000_000_000 ,
278- close_block_at_eth_params_percentage : 0.2 ,
279- close_block_at_gas_percentage : 0.8 ,
280- close_block_at_geometry_percentage : 0.5 ,
281- reject_tx_at_eth_params_percentage : 0.8 ,
282- reject_tx_at_geometry_percentage : 0.3 ,
283- reject_tx_at_gas_percentage : 0.5 ,
284303 minimal_l2_gas_price : 100000000 ,
285304 compute_overhead_part : 0.0 ,
286305 pubdata_overhead_part : 1.0 ,
287306 batch_overhead_l1_gas : 800_000 ,
288307 max_gas_per_batch : 200_000_000 ,
289- max_pubdata_per_batch : ByteSize ( 131_072 ) ,
290308 fee_model_version : FeeModelVersion :: V2 ,
291309 validation_computational_gas_limit : 10_000_000 ,
292- max_circuits_per_batch : 24100 ,
293310 deployment_allowlist : Some ( DeploymentAllowlist :: Dynamic ( DeploymentAllowlistDynamic {
294311 http_file_url : "http://deployment-allowlist/" . to_owned ( ) ,
295312 refresh_interval : Duration :: from_secs ( 120 ) ,
0 commit comments