Skip to content
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

EVM Simulator code hash in witness data #249

Merged
merged 3 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/lib/prover_interface/src/inputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ pub struct VMRunWitnessInputData {
pub protocol_version: ProtocolVersionId,
pub bootloader_code: Vec<[u8; 32]>,
pub default_account_code_hash: U256,
pub evm_simulator_code_hash: U256,
pub storage_refunds: Vec<u32>,
pub pubdata_costs: Vec<i32>,
pub witness_block_state: WitnessStorageState,
Expand Down
18 changes: 18 additions & 0 deletions core/node/vm_runner/src/impls/bwip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ async fn get_updates_manager_witness_input_data(
let initial_heap_content = finished_batch.final_bootloader_memory.unwrap(); // might be just empty
let default_aa = updates_manager.base_system_contract_hashes().default_aa;
let bootloader = updates_manager.base_system_contract_hashes().bootloader;
let evm_simulator = updates_manager.base_system_contract_hashes().evm_simulator;
let bootloader_code_bytes = connection
.factory_deps_dal()
.get_sealed_factory_dep(bootloader)
Expand All @@ -220,6 +221,14 @@ async fn get_updates_manager_witness_input_data(
.ok_or_else(|| anyhow!("Default account bytecode should exist"))?;
let account_bytecode = bytes_to_chunks(&account_bytecode_bytes);

let evm_simulator_code_hash = h256_to_u256(evm_simulator);
let simulator_bytecode_bytes = connection
.factory_deps_dal()
.get_sealed_factory_dep(evm_simulator)
.await?
.ok_or_else(|| anyhow!("EVM Simulator bytecode should exist"))?;
let evm_simulator_bytecode = bytes_to_chunks(&simulator_bytecode_bytes);

let hashes: HashSet<H256> = finished_batch
.final_execution_state
.used_contract_hashes
Expand All @@ -240,6 +249,14 @@ async fn get_updates_manager_witness_input_data(
used_bytecodes.insert(account_code_hash, account_bytecode);
}

if finished_batch
.final_execution_state
.used_contract_hashes
.contains(&evm_simulator_code_hash)
{
used_bytecodes.insert(evm_simulator_code_hash, evm_simulator_bytecode);
}

let storage_refunds = finished_batch.final_execution_state.storage_refunds;
let pubdata_costs = finished_batch.final_execution_state.pubdata_costs;

Expand All @@ -261,6 +278,7 @@ async fn get_updates_manager_witness_input_data(

bootloader_code,
default_account_code_hash: account_code_hash,
evm_simulator_code_hash: evm_simulator_code_hash,
storage_refunds,
pubdata_costs,
witness_block_state,
Expand Down
3 changes: 1 addition & 2 deletions prover/crates/bin/witness_generator/src/basic_circuits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,7 @@ async fn generate_witness(
bootloader_contents,
false,
input.vm_run_data.default_account_code_hash,
// NOTE: this will be evm_simulator_code_hash in future releases
input.vm_run_data.default_account_code_hash,
input.vm_run_data.evm_simulator_code_hash,
input.vm_run_data.used_bytecodes,
Vec::default(),
MAX_CYCLES_FOR_TX as usize,
Expand Down
Loading