Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

fix unconstrained is_warm in sload/sstore #1596

Conversation

lightsing
Copy link
Contributor

@lightsing lightsing commented Sep 11, 2023

Description

This PR fixes the soundness problem in the implementation of SLOAD and SSTORE opcodes by adding constraints to the is_warm cell. The problem is detailed in issue #1049.

Issue Link

#1049

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Contents

  • Update bus-mapping/src/evm/opcodes/sload.rs
  • Update bus-mapping/src/evm/opcodes/sstore.rs
  • Update zkevm-circuits/src/evm_circuit/execution/sload.rs
  • Update zkevm-circuits/src/evm_circuit/execution/sstore.rs

Rationale

The current implementation of SSTORE and SLOAD didn't constrain the is_warm cell, which could result in any value and lead to soundness problems. This PR adds constraints to the is_warm cell in order to ensure correctness.

How Has This Been Tested?

@github-actions github-actions bot added crate-bus-mapping Issues related to the bus-mapping workspace member crate-zkevm-circuits Issues related to the zkevm-circuits workspace member labels Sep 11, 2023
@lightsing lightsing changed the title add is_warm read, fix privacy-scaling-explorations/zkevm-circuits#1049 fix unconstrained is_warm in sload/sstore Sep 11, 2023
@lightsing lightsing marked this pull request as ready for review September 11, 2023 06:00
@lightsing
Copy link
Contributor Author

r? @ChihChengLiang

@ChihChengLiang
Copy link
Collaborator

Hi @lightsing, I see failing tests sstore_opcode_impl_cold and sload_opcode_impl_warm. Do you have some thoughts for that?

@lightsing
Copy link
Contributor Author

Hi @lightsing, I see failing tests sstore_opcode_impl_cold and sload_opcode_impl_warm. Do you have some thoughts for that?

The unit test assertion need to be updated due to rw changes, on it

Copy link
Collaborator

@ChihChengLiang ChihChengLiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the fix!

@ChihChengLiang ChihChengLiang added this pull request to the merge queue Sep 12, 2023
Merged via the queue into privacy-scaling-explorations:main with commit 77c16e4 Sep 12, 2023
11 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
crate-bus-mapping Issues related to the bus-mapping workspace member crate-zkevm-circuits Issues related to the zkevm-circuits workspace member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants