Skip to content

Commit 7c46480

Browse files
authored
fix: use FullPubdataBuilder for all pre-gateway batches (#4265)
## What ❔ Use `FullPubdataBuilder` for all pre-gateway batches in `pubdata_params_to_builder` ## Why ❔ There are chains like Cronos that have NoDA batches created pre-v26. For them, the EN's state-keeper is failing to process such batches because `HashedPubdataBuilder` can't be used in pre-v26 batches. ## Is this a breaking change? - [ ] Yes - [x] No ## Operational changes <!-- Any config changes? Any new flags? Any changes to any scripts? --> <!-- Please add anything that non-Matter Labs entities running their own ZK Chain may need to know --> ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zkstack dev fmt` and `zkstack dev lint`.
1 parent d06697d commit 7c46480

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

core/lib/multivm/src/pubdata_builders/mod.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ use std::rc::Rc;
22

33
pub use full_builder::FullPubdataBuilder;
44
pub use hashed_builder::HashedPubdataBuilder;
5-
use zksync_types::commitment::{PubdataParams, PubdataType};
5+
use zksync_types::{
6+
commitment::{PubdataParams, PubdataType},
7+
ProtocolVersionId,
8+
};
69

710
use crate::interface::pubdata::PubdataBuilder;
811

@@ -12,7 +15,14 @@ mod hashed_builder;
1215
mod tests;
1316
mod utils;
1417

15-
pub fn pubdata_params_to_builder(params: PubdataParams) -> Rc<dyn PubdataBuilder> {
18+
pub fn pubdata_params_to_builder(
19+
params: PubdataParams,
20+
protocol_version: ProtocolVersionId,
21+
) -> Rc<dyn PubdataBuilder> {
22+
if protocol_version.is_pre_gateway() {
23+
return Rc::new(FullPubdataBuilder::new(params.l2_da_validator_address));
24+
}
25+
1626
match params.pubdata_type {
1727
PubdataType::NoDA => Rc::new(HashedPubdataBuilder::new(params.l2_da_validator_address)),
1828
PubdataType::Rollup

core/lib/tee_verifier/src/lib.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use zksync_prover_interface::inputs::{StorageLogMetadata, WitnessInputMerklePath
2323
use zksync_tee_prover_interface::inputs::V1TeeVerifierInput;
2424
use zksync_types::{
2525
block::L2BlockExecutionData, commitment::PubdataParams, u256_to_h256, L1BatchNumber,
26-
StorageLog, StorageValue, Transaction, H256,
26+
ProtocolVersionId, StorageLog, StorageValue, Transaction, H256,
2727
};
2828

2929
/// A structure to hold the result of verification.
@@ -87,8 +87,13 @@ impl Verify for V1TeeVerifierInput {
8787

8888
let storage_snapshot = StorageSnapshot::new(storage, factory_deps);
8989
let storage_view = StorageView::new(storage_snapshot).to_rc_ptr();
90-
let vm = LegacyVmInstance::new(self.l1_batch_env, self.system_env, storage_view);
91-
let vm_out = execute_vm(self.l2_blocks_execution_data, vm, self.pubdata_params)?;
90+
let vm = LegacyVmInstance::new(self.l1_batch_env, self.system_env.clone(), storage_view);
91+
let vm_out = execute_vm(
92+
self.l2_blocks_execution_data,
93+
vm,
94+
self.pubdata_params,
95+
self.system_env.version,
96+
)?;
9297

9398
let block_output_with_proofs = get_bowp(self.merkle_paths)?;
9499

@@ -179,6 +184,7 @@ fn execute_vm<S: ReadStorage>(
179184
l2_blocks_execution_data: Vec<L2BlockExecutionData>,
180185
mut vm: LegacyVmInstance<S, HistoryEnabled>,
181186
pubdata_params: PubdataParams,
187+
protocol_version: ProtocolVersionId,
182188
) -> anyhow::Result<FinishedL1Batch> {
183189
let next_l2_blocks_data = l2_blocks_execution_data.iter().skip(1);
184190

@@ -207,7 +213,7 @@ fn execute_vm<S: ReadStorage>(
207213

208214
tracing::trace!("about to vm.finish_batch()");
209215

210-
Ok(vm.finish_batch(pubdata_params_to_builder(pubdata_params)))
216+
Ok(vm.finish_batch(pubdata_params_to_builder(pubdata_params, protocol_version)))
211217
}
212218

213219
/// Map `LogQuery` and `TreeLogEntry` to a `TreeInstruction`

core/lib/vm_executor/src/batch/factory.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ impl<S: ReadStorage + Send + 'static, Tr: BatchTracer> BatchExecutorFactory<S>
169169
executor.run(
170170
storage,
171171
l1_batch_params,
172-
system_env,
173-
pubdata_params_to_builder(pubdata_params),
172+
system_env.clone(),
173+
pubdata_params_to_builder(pubdata_params, system_env.version),
174174
)
175175
});
176176
Box::new(MainBatchExecutor::new(handle, commands_sender))

0 commit comments

Comments
 (0)