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

feat(contracts)!: integrate protocol defense changes #2737

Merged
merged 115 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
463d27b
use forge for l2 contracts
Deniallugo Jun 25, 2024
0d267a4
Fix ignores
Deniallugo Jun 25, 2024
c9dc879
Fix libs
Deniallugo Jul 25, 2024
1a58ac6
Fix
Deniallugo Jul 25, 2024
42bdff8
Add support for new path of sol files
Deniallugo Jul 25, 2024
64a01c2
Merge branch 'main' into deniallugo-forge-l2-contracts
Deniallugo Jul 31, 2024
c619472
Some changes
Deniallugo Aug 1, 2024
3d97914
Merge branch 'main' into deniallugo-forge-l2-contracts
Deniallugo Aug 13, 2024
1e0f6d4
Forge
Deniallugo Aug 13, 2024
f1f9ab5
Fix
Deniallugo Aug 13, 2024
7bd4637
Merge branch 'main' into deniallugo-forge-l2-contracts
Deniallugo Aug 13, 2024
512b2e0
Load correct yul files
Deniallugo Aug 13, 2024
ec6662e
use foundry-zksync
Deniallugo Aug 13, 2024
4727923
Remove cludges
Deniallugo Aug 13, 2024
f617cc3
Add preprocessing
Deniallugo Aug 13, 2024
5b59255
Merge branch 'main' into deniallugo-forge-l2-contracts
Deniallugo Aug 13, 2024
2cc02d2
Remove garbage
Deniallugo Aug 14, 2024
5d49f3a
Add prerequisite for forge zksync
Deniallugo Aug 14, 2024
770999f
Fix
Deniallugo Aug 14, 2024
accf1cf
Try to use main
Deniallugo Aug 14, 2024
ddcebe1
Use main
Deniallugo Aug 14, 2024
4044fcc
Use main
Deniallugo Aug 14, 2024
839504a
Update contracts
Deniallugo Aug 15, 2024
a2906b1
Merge branch 'main' into deniallugo-forge-l2-contracts
Deniallugo Aug 23, 2024
650a63a
feat(contracts: integrate protocol defense changes
koloz193 Aug 26, 2024
dd6a4a0
Merge branch 'main' into zk-protocol-defense
koloz193 Aug 26, 2024
d3877f6
update protocol version and multivm bootloaders
koloz193 Aug 27, 2024
4b36af8
Merge branch 'main' into zk-protocol-defense
koloz193 Aug 27, 2024
ca1a396
bump contracts
koloz193 Aug 27, 2024
2f6d9bc
bump contracts
koloz193 Aug 27, 2024
cedfb16
Merge branch 'main' into zk-protocol-defense
koloz193 Aug 27, 2024
91bed09
add submodules ignored folder
StanislavBreadless Aug 28, 2024
4b8a653
Merge branch 'main' into zk-protocol-defense
StanislavBreadless Aug 28, 2024
db9a44b
Merge branch 'main' into zk-protocol-defense
koloz193 Aug 28, 2024
9c8cdf9
bump contracts
koloz193 Aug 28, 2024
23da0a0
Merge branch 'main' into zk-protocol-defense
koloz193 Aug 28, 2024
5cd6e12
bump contracts
koloz193 Aug 28, 2024
7aedc3c
bump contracts
koloz193 Aug 28, 2024
2f770f7
Merge branch 'main' into deniallugo-forge-l2-contracts
Deniallugo Sep 2, 2024
d158b42
fix
Deniallugo Sep 3, 2024
efd153f
fix
Deniallugo Sep 3, 2024
5e195c0
Update genesis
Deniallugo Sep 3, 2024
d6359aa
Add update genesis command
Deniallugo Sep 3, 2024
a4fc688
Fix genesis
Deniallugo Sep 3, 2024
1bf87ed
Fix genesis
Deniallugo Sep 3, 2024
41d4bb4
feat(contracts: integrate protocol defense changes
koloz193 Aug 26, 2024
c42e271
update protocol version and multivm bootloaders
koloz193 Aug 27, 2024
f1c18e5
Try to install all yarn deps
Deniallugo Sep 3, 2024
1d2b471
Update genesis
Deniallugo Sep 3, 2024
66d9d4a
Merge branch 'main' into deniallugo-forge-l2-contracts
Deniallugo Sep 3, 2024
716e6ca
update CI
koloz193 Sep 4, 2024
17a12bf
lint
koloz193 Sep 4, 2024
9fe34e9
Fix ci
Deniallugo Sep 4, 2024
598665f
Fix deploy contracts
Deniallugo Sep 4, 2024
4401856
another attempt
Deniallugo Sep 4, 2024
938c034
yet another fix
Deniallugo Sep 4, 2024
4e80941
Last fix
Deniallugo Sep 4, 2024
3f0f6b8
return all deps
Deniallugo Sep 4, 2024
0899de4
Try full build
Deniallugo Sep 4, 2024
69d5d7e
Fix custom token
Deniallugo Sep 4, 2024
0bc54a0
fix lint
Deniallugo Sep 4, 2024
010bb98
try to set only contracts
Deniallugo Sep 4, 2024
e4e2c51
Fix build contracts
Deniallugo Sep 4, 2024
6d49eeb
increase timeout
Deniallugo Sep 4, 2024
cc802ba
Try to build zksync_external_node before running it
Deniallugo Sep 4, 2024
f9ab44c
Upgrade test fix
Deniallugo Sep 4, 2024
694b318
Merge branch 'main' into zk-forge-l2-contracts
Deniallugo Sep 4, 2024
7ca0956
build bootloader
Deniallugo Sep 5, 2024
acad7cc
Use only forge
Deniallugo Sep 5, 2024
21c65ae
Merge branch 'main' into zk-forge-l2-contracts
Deniallugo Sep 5, 2024
e9e342d
Build contracts properly
Deniallugo Sep 5, 2024
fbab458
Fix integration tests
Deniallugo Sep 5, 2024
c7df0ba
feat(zk_toolbox): deprecate zk in ci (#2808)
Deniallugo Sep 12, 2024
180c5d6
Merge branch 'main' into zk-forge-l2-contracts
Deniallugo Sep 17, 2024
a3a7a51
Update contracts
Deniallugo Sep 17, 2024
7d43d12
Merge branch 'main' into zk-forge-l2-contracts
Deniallugo Sep 17, 2024
eddf126
Fix merge
Deniallugo Sep 17, 2024
814333f
Fix contracts
Deniallugo Sep 17, 2024
1818a30
Fix path to consensus registry
Deniallugo Sep 17, 2024
6dd0283
Fix Validation failed test
Deniallugo Sep 17, 2024
6d73800
Merge branch 'main' into zk-protocol-defense
koloz193 Oct 1, 2024
57437d0
Merge branch 'zk-protocol-defense' into zk-forge-l2-contracts
koloz193 Oct 2, 2024
7290bc9
lint docs
koloz193 Oct 2, 2024
efa4af9
lint test
koloz193 Oct 3, 2024
1ecf76c
remove unused import
koloz193 Oct 3, 2024
abdd2d8
removed unused import
koloz193 Oct 3, 2024
de6b71b
update ci
koloz193 Oct 3, 2024
27b5a40
update ci pt2
koloz193 Oct 3, 2024
e06a581
Merge pull request #3005 from matter-labs/zk-forge-l2-contracts
koloz193 Oct 3, 2024
20a42d2
Merge branch 'main' into zk-protocol-defense
koloz193 Oct 3, 2024
1d84834
bump contracts
koloz193 Oct 3, 2024
492541a
bump contracts
koloz193 Oct 3, 2024
5277545
update multivm bootloaders
koloz193 Oct 4, 2024
dc66520
bump contracts
koloz193 Oct 4, 2024
1789ce7
add stage calldata
koloz193 Oct 8, 2024
d07a4f6
Merge branch 'main' into zk-protocol-defense
koloz193 Oct 8, 2024
fe7593e
address comments
koloz193 Oct 8, 2024
863ae0b
fix test
koloz193 Oct 8, 2024
5f4bdc6
update contract path
koloz193 Oct 9, 2024
92639b7
Merge branch 'main' into zk-protocol-defense
koloz193 Oct 9, 2024
2a6192d
update transactions json
koloz193 Oct 9, 2024
e897dc2
bump contracts
koloz193 Oct 10, 2024
32f0687
bump dep
koloz193 Oct 10, 2024
846ccd9
Merge branch 'main' into zk-protocol-defense
koloz193 Oct 10, 2024
2d3aea8
update toolbox
koloz193 Oct 10, 2024
300d2a4
Merge branch 'main' into zk-protocol-defense
koloz193 Oct 10, 2024
07c7411
update txns
koloz193 Oct 10, 2024
610631b
change contracts back
koloz193 Oct 10, 2024
cfbbff9
update tests
koloz193 Oct 10, 2024
8fac87c
update bootloader path in test
koloz193 Oct 10, 2024
4e9d99d
Merge branch 'main' into zk-protocol-defense
koloz193 Oct 10, 2024
5eaf212
lint fix
koloz193 Oct 10, 2024
45ec323
Merge branch 'main' into zk-protocol-defense
Deniallugo Oct 14, 2024
81aec20
Remove foundry migration leftovers
Deniallugo Oct 14, 2024
71a0807
Pin foundry-zksync version
Deniallugo Oct 14, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/build-core-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ jobs:
ci_run git config --global --add safe.directory /usr/src/zksync/contracts
ci_run ./bin/zk || true
ci_run run_retried curl -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^26.key

- name: Install zkstack
run: |
ci_run ./zkstack_cli/zkstackup/install -g --path ./zkstack_cli/zkstackup/zkstackup || true
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/new-build-contract-verifier-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,13 @@ jobs:
crate: sqlx-cli
tag: 0.8.1

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@8f1998e9878d786675189ef566a2e4bf24869773 # v1.2.0
- name: Install foundry-zksync
run: |
mkdir ./foundry-zksync
curl -LO https://github.com/matter-labs/foundry-zksync/releases/download/nightly-15bec2f861b3b4c71e58f85e2b2c9dd722585aa8/foundry_nightly_linux_amd64.tar.gz
tar zxf foundry_nightly_linux_amd64.tar.gz -C ./foundry-zksync
chmod +x ./foundry-zksync/forge ./foundry-zksync/cast
echo "$PWD/foundry-zksync" >> $GITHUB_PATH

- name: Pre-download compilers
shell: bash
Expand All @@ -131,7 +136,7 @@ jobs:
docker compose up -d postgres

- name: Install zkstack
run: |
run: |
./zkstack_cli/zkstackup/install --path ./zkstack_cli/zkstackup/zkstackup
zkstackup --local || true

Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/new-build-core-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,13 @@ jobs:
crate: sqlx-cli
tag: 0.8.1

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@8f1998e9878d786675189ef566a2e4bf24869773 # v1.2.0
- name: Install foundry-zksync
run: |
mkdir ./foundry-zksync
curl -LO https://github.com/matter-labs/foundry-zksync/releases/download/nightly-15bec2f861b3b4c71e58f85e2b2c9dd722585aa8/foundry_nightly_linux_amd64.tar.gz
tar zxf foundry_nightly_linux_amd64.tar.gz -C ./foundry-zksync
chmod +x ./foundry-zksync/forge ./foundry-zksync/cast
echo "$PWD/foundry-zksync" >> $GITHUB_PATH

- name: Pre-download compilers
shell: bash
Expand All @@ -136,10 +141,10 @@ jobs:
docker compose up -d postgres

- name: Install zkstack
run: |
run: |
./zkstack_cli/zkstackup/install --path ./zkstack_cli/zkstackup/zkstackup
zkstackup --local || true

- name: build contracts
shell: bash
run: |
Expand Down
2 changes: 1 addition & 1 deletion contracts
Submodule contracts updated 333 files
13 changes: 10 additions & 3 deletions core/bin/system-constants-generator/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{cell::RefCell, rc::Rc};
use once_cell::sync::Lazy;
use zksync_contracts::{
load_sys_contract, read_bootloader_code, read_bytecode_from_path, read_sys_contract_bytecode,
BaseSystemContracts, ContractLanguage, SystemContractCode,
read_zbin_bytecode, BaseSystemContracts, ContractLanguage, SystemContractCode,
};
use zksync_multivm::{
interface::{
Expand Down Expand Up @@ -171,9 +171,16 @@ pub(super) fn get_l1_txs(number_of_txs: usize) -> (Vec<Transaction>, Vec<Transac
}

fn read_bootloader_test_code(test: &str) -> Vec<u8> {
read_bytecode_from_path(format!(
if let Some(contract) = read_bytecode_from_path(format!(
"contracts/system-contracts/zkout/{test}.yul/contracts-preprocessed/bootloader/{test}.yul.json",
))
)){
contract
} else {
read_zbin_bytecode(format!(
"contracts/system-contracts/bootloader/tests/artifacts/{}.yul.zbin",
test
))
}
}

fn default_l1_batch() -> L1BatchEnv {
Expand Down
7 changes: 5 additions & 2 deletions core/lib/basic_types/src/protocol_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,16 @@ pub enum ProtocolVersionId {
Version23,
Version24,
Version25,
Version26,
}

impl ProtocolVersionId {
pub const fn latest() -> Self {
Self::Version24
Self::Version25
}

pub const fn next() -> Self {
Self::Version25
Self::Version26
}

pub fn try_from_packed_semver(packed_semver: U256) -> Result<Self, String> {
Expand Down Expand Up @@ -120,6 +121,7 @@ impl ProtocolVersionId {
ProtocolVersionId::Version23 => VmVersion::Vm1_5_0SmallBootloaderMemory,
ProtocolVersionId::Version24 => VmVersion::Vm1_5_0IncreasedBootloaderMemory,
ProtocolVersionId::Version25 => VmVersion::Vm1_5_0IncreasedBootloaderMemory,
ProtocolVersionId::Version26 => VmVersion::Vm1_5_0IncreasedBootloaderMemory,
}
}

Expand Down Expand Up @@ -275,6 +277,7 @@ impl From<ProtocolVersionId> for VmVersion {
ProtocolVersionId::Version23 => VmVersion::Vm1_5_0SmallBootloaderMemory,
ProtocolVersionId::Version24 => VmVersion::Vm1_5_0IncreasedBootloaderMemory,
ProtocolVersionId::Version25 => VmVersion::Vm1_5_0IncreasedBootloaderMemory,
ProtocolVersionId::Version26 => VmVersion::Vm1_5_0IncreasedBootloaderMemory,
}
}
}
Expand Down
133 changes: 96 additions & 37 deletions core/lib/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,21 @@ fn home_path() -> PathBuf {
Workspace::locate().core()
}

fn read_file_to_json_value(path: impl AsRef<Path> + std::fmt::Debug) -> serde_json::Value {
fn read_file_to_json_value(path: impl AsRef<Path> + std::fmt::Debug) -> Option<serde_json::Value> {
let zksync_home = home_path();
let path = Path::new(&zksync_home).join(path);
let file =
File::open(&path).unwrap_or_else(|e| panic!("Failed to open file {:?}: {}", path, e));
serde_json::from_reader(BufReader::new(file))
.unwrap_or_else(|e| panic!("Failed to parse file {:?}: {}", path, e))
let file = File::open(&path).ok()?;
Some(
serde_json::from_reader(BufReader::new(file))
.unwrap_or_else(|e| panic!("Failed to parse file {:?}: {}", path, e)),
)
}

fn load_contract_if_present<P: AsRef<Path> + std::fmt::Debug>(path: P) -> Option<Contract> {
let zksync_home = home_path();
let path = Path::new(&zksync_home).join(path);
path.exists().then(|| {
serde_json::from_value(read_file_to_json_value(&path)["abi"].take())
serde_json::from_value(read_file_to_json_value(&path).unwrap()["abi"].take())
.unwrap_or_else(|e| panic!("Failed to parse contract abi from file {:?}: {}", path, e))
})
}
Expand Down Expand Up @@ -114,17 +115,26 @@ pub fn load_contract<P: AsRef<Path> + std::fmt::Debug>(path: P) -> Contract {
}

pub fn load_sys_contract(contract_name: &str) -> Contract {
load_contract(format!(
if let Some(contract) = load_contract_if_present(format!(
"contracts/system-contracts/artifacts-zk/contracts-preprocessed/{0}.sol/{0}.json",
contract_name
))
)) {
contract
} else {
load_contract(format!(
"contracts/system-contracts/zkout/{0}.sol/{0}.json",
contract_name
))
}
}

pub fn read_contract_abi(path: impl AsRef<Path> + std::fmt::Debug) -> String {
read_file_to_json_value(path)["abi"]
.as_str()
.expect("Failed to parse abi")
.to_string()
pub fn read_contract_abi(path: impl AsRef<Path> + std::fmt::Debug) -> Option<String> {
Some(
read_file_to_json_value(path)?["abi"]
.as_str()
.expect("Failed to parse abi")
.to_string(),
)
}

pub fn bridgehub_contract() -> Contract {
Expand Down Expand Up @@ -200,7 +210,7 @@ pub fn l1_messenger_contract() -> Contract {

/// Reads bytecode from the path RELATIVE to the Cargo workspace location.
pub fn read_bytecode(relative_path: impl AsRef<Path> + std::fmt::Debug) -> Vec<u8> {
read_bytecode_from_path(relative_path)
read_bytecode_from_path(relative_path).expect("Exists")
}

pub fn eth_contract() -> Contract {
Expand All @@ -212,25 +222,33 @@ pub fn known_codes_contract() -> Contract {
}

/// Reads bytecode from a given path.
pub fn read_bytecode_from_path(artifact_path: impl AsRef<Path> + std::fmt::Debug) -> Vec<u8> {
let artifact = read_file_to_json_value(&artifact_path);

let bytecode = artifact["bytecode"]
.as_str()
.unwrap_or_else(|| panic!("Bytecode not found in {:?}", artifact_path))
.strip_prefix("0x")
.unwrap_or_else(|| panic!("Bytecode in {:?} is not hex", artifact_path));
pub fn read_bytecode_from_path(
artifact_path: impl AsRef<Path> + std::fmt::Debug,
) -> Option<Vec<u8>> {
let artifact = read_file_to_json_value(&artifact_path)?;

let bytecode = if let Some(bytecode) = artifact["bytecode"].as_str() {
bytecode
.strip_prefix("0x")
.unwrap_or_else(|| panic!("Bytecode in {:?} is not hex", artifact_path))
} else {
artifact["bytecode"]["object"]
.as_str()
.unwrap_or_else(|| panic!("Bytecode not found in {:?}", artifact_path))
};

hex::decode(bytecode)
.unwrap_or_else(|err| panic!("Can't decode bytecode in {:?}: {}", artifact_path, err))
Some(
hex::decode(bytecode)
.unwrap_or_else(|err| panic!("Can't decode bytecode in {:?}: {}", artifact_path, err)),
)
}

pub fn read_sys_contract_bytecode(directory: &str, name: &str, lang: ContractLanguage) -> Vec<u8> {
DEFAULT_SYSTEM_CONTRACTS_REPO.read_sys_contract_bytecode(directory, name, lang)
}

static DEFAULT_SYSTEM_CONTRACTS_REPO: Lazy<SystemContractsRepo> =
Lazy::new(SystemContractsRepo::from_env);
Lazy::new(SystemContractsRepo::default);

/// Structure representing a system contract repository - that allows
/// fetching contracts that are located there.
Expand All @@ -240,38 +258,65 @@ pub struct SystemContractsRepo {
pub root: PathBuf,
}

impl SystemContractsRepo {
impl Default for SystemContractsRepo {
/// Returns the default system contracts repository with directory based on the Cargo workspace location.
pub fn from_env() -> Self {
fn default() -> Self {
SystemContractsRepo {
root: home_path().join("contracts/system-contracts"),
}
}
}

impl SystemContractsRepo {
pub fn read_sys_contract_bytecode(
&self,
directory: &str,
name: &str,
lang: ContractLanguage,
) -> Vec<u8> {
match lang {
ContractLanguage::Sol => read_bytecode_from_path(self.root.join(format!(
"artifacts-zk/contracts-preprocessed/{0}{1}.sol/{1}.json",
directory, name
))),
ContractLanguage::Sol => {
if let Some(contracts) = read_bytecode_from_path(
self.root
.join(format!("zkout/{0}{1}.sol/{1}.json", directory, name)),
) {
contracts
} else {
read_bytecode_from_path(self.root.join(format!(
"artifacts-zk/contracts-preprocessed/{0}{1}.sol/{1}.json",
directory, name
)))
.expect("One of the outputs should exists")
}
}
ContractLanguage::Yul => {
let artifacts_path = self
.root
.join(format!("contracts-preprocessed/{}artifacts/", directory));
read_yul_bytecode_by_path(artifacts_path, name)
if let Some(contract) = read_bytecode_from_path(self.root.join(format!(
"zkout/{name}.yul/contracts-preprocessed/{directory}/{name}.yul.json",
))) {
contract
} else {
read_zbin_bytecode_from_path(self.root.join(format!(
"contracts-preprocessed/{0}artifacts/{1}.yul.zbin",
directory, name
)))
}
}
}
}
}

pub fn read_bootloader_code(bootloader_type: &str) -> Vec<u8> {
let artifacts_path = "contracts/system-contracts/bootloader/build/artifacts/";
read_yul_bytecode(artifacts_path, bootloader_type)
if let Some(contract) =
read_bytecode_from_path(home_path().join("contracts/system-contracts").join(format!(
"zkout/{bootloader_type}.yul/contracts-preprocessed/bootloader/{bootloader_type}.yul.json",
)))
{
return contract;
};
read_zbin_bytecode(format!(
"contracts/system-contracts/bootloader/build/artifacts/{}.yul.zbin",
bootloader_type
))
}

fn read_proved_batch_bootloader_bytecode() -> Vec<u8> {
Expand Down Expand Up @@ -463,6 +508,13 @@ impl BaseSystemContracts {
BaseSystemContracts::load_with_bootloader(bootloader_bytecode)
}

pub fn playground_post_protocol_defense() -> Self {
let bootloader_bytecode = read_zbin_bytecode(
"etc/multivm_bootloaders/vm_protocol_defense/playground_batch.yul/playground_batch.yul.zbin",
);
BaseSystemContracts::load_with_bootloader(bootloader_bytecode)
}

pub fn estimate_gas_pre_virtual_blocks() -> Self {
let bootloader_bytecode = read_zbin_bytecode(
"etc/multivm_bootloaders/vm_1_3_2/fee_estimate.yul/fee_estimate.yul.zbin",
Expand Down Expand Up @@ -526,6 +578,13 @@ impl BaseSystemContracts {
BaseSystemContracts::load_with_bootloader(bootloader_bytecode)
}

pub fn estimate_gas_post_protocol_defense() -> Self {
let bootloader_bytecode = read_zbin_bytecode(
"etc/multivm_bootloaders/vm_protocol_defense/fee_estimate.yul/fee_estimate.yul.zbin",
);
BaseSystemContracts::load_with_bootloader(bootloader_bytecode)
}

pub fn hashes(&self) -> BaseSystemContractsHashes {
BaseSystemContractsHashes {
bootloader: self.bootloader.hash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ fn test_l1_tx_execution() {
let res = vm.vm.execute(VmExecutionMode::OneTx);
let storage_logs = res.logs.storage_logs;
let res = StorageWritesDeduplicator::apply_on_empty_state(&storage_logs);
// We changed one slot inside contract. However, the rewrite of the `basePubdataSpent` didn't happen, since it was the same
// as the start of the previous tx. Thus we have `+1` slot for the changed counter and `-1` slot for base pubdata spent
assert_eq!(res.initial_storage_writes, basic_initial_writes);
// We changed one slot inside contract.
assert_eq!(res.initial_storage_writes - basic_initial_writes, 1);

// No repeated writes
let repeated_writes = res.repeated_storage_writes;
Expand All @@ -146,7 +145,7 @@ fn test_l1_tx_execution() {
assert!(result.result.is_failed(), "The transaction should fail");

let res = StorageWritesDeduplicator::apply_on_empty_state(&result.logs.storage_logs);
assert_eq!(res.initial_storage_writes, basic_initial_writes);
assert_eq!(res.initial_storage_writes, basic_initial_writes + 1);
assert_eq!(res.repeated_storage_writes, 1);
}

Expand Down
Loading
Loading