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

fix: extend allowed storage slots for validation as per EIP-7562 #3166

Merged
merged 6 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
22 changes: 18 additions & 4 deletions core/lib/multivm/src/tracers/validator/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
use std::{collections::HashSet, marker::PhantomData, sync::Arc};
use std::{
collections::{BTreeSet, HashSet},
marker::PhantomData,
sync::Arc,
};

use once_cell::sync::OnceCell;
use zksync_system_constants::{
Expand Down Expand Up @@ -32,7 +36,7 @@ mod vm_virtual_blocks;
#[derive(Debug, Clone)]
pub struct ValidationTracer<H> {
validation_mode: ValidationTracerMode,
auxilary_allowed_slots: HashSet<H256>,
auxilary_allowed_slots: BTreeSet<H256>,

user_address: Address,
#[allow(dead_code)]
Expand All @@ -51,6 +55,8 @@ pub struct ValidationTracer<H> {
type ValidationRoundResult = Result<NewTrustedValidationItems, ViolatedValidationRule>;

impl<H> ValidationTracer<H> {
const MAX_ALLOWED_SLOT_OFFSET: u32 = 127;

pub fn new(
params: ValidationParams,
vm_version: VmVersion,
Expand Down Expand Up @@ -131,9 +137,17 @@ impl<H> ValidationTracer<H> {
}

// The user is allowed to touch its own slots or slots semantically related to him.
let from = u256_to_h256(key.saturating_sub(Self::MAX_ALLOWED_SLOT_OFFSET.into()));
let to = u256_to_h256(key);
let valid_users_slot = address == self.user_address
|| u256_to_account_address(&key) == self.user_address
|| self.auxilary_allowed_slots.contains(&u256_to_h256(key));
// we don't allow dirty bytes in front of the address
|| key < U256::from(2).pow(160.into())
&& u256_to_account_address(&key) == self.user_address
|| self
ly0va marked this conversation as resolved.
Show resolved Hide resolved
.auxilary_allowed_slots
.range(from..=to)
.next()
.is_some();
if valid_users_slot {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions etc/env/base/chain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ fee_model_version = "V2"
validation_computational_gas_limit = 300000
save_call_traces = true

bootloader_hash = "0x010008c37ecadea8b003884eb9d81fdfb7161b3b309504e5318f15da19c500d8"
default_aa_hash = "0x0100055da70d970f98ca4677a4b2fcecef5354f345cc5c6d13a78339e5fd87a9"
bootloader_hash = "0x010008c3be57ae5800e077b6c2056d9d75ad1a7b4f0ce583407961cc6fe0b678"
ly0va marked this conversation as resolved.
Show resolved Hide resolved
default_aa_hash = "0x0100055dba11508480be023137563caec69debc85f826cb3a4b68246a7cabe30"

protective_reads_persistence_enabled = false

Expand Down
4 changes: 2 additions & 2 deletions etc/env/base/contracts.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ RECURSION_NODE_LEVEL_VK_HASH = "0x1186ec268d49f1905f8d9c1e9d39fc33e98c74f91d91a2
RECURSION_LEAF_LEVEL_VK_HASH = "0x101e08b00193e529145ee09823378ef51a3bc8966504064f1f6ba3f1ba863210"
RECURSION_CIRCUITS_SET_VKS_HASH = "0x18c1639094f58177409186e8c48d9f577c9410901d2f1d486b3e7d6cf553ae4c"
GENESIS_TX_HASH = "0xb99ebfea46cbe05a21cd80fe5597d97b204befc52a16303f579c607dc1ac2e2e"
GENESIS_ROOT = "0x28a7e67393021f957572495f8fdadc2c477ae3f4f413ae18c16cff6ee65680e2"
GENESIS_BATCH_COMMITMENT = "0xc57085380434970021d87774b377ce1bb12f5b6064af11595e70011965747def"
GENESIS_ROOT = "0x7275936e5a0063b159d5d22734931fea07871e8d57e564d61ef56e4a6ee23e5c"
GENESIS_BATCH_COMMITMENT = "0xf5f9a5abe62e8a6e0cb2d34d27435c3e5a8fbd7e2e54ca1d108fc58cb86c708a"
PRIORITY_TX_MAX_GAS_LIMIT = 72000000
DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT = 10000000
GENESIS_ROLLUP_LEAF_INDEX = "54"
Expand Down
Loading