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

feat: add sload op (non-bus-mapping version)#334

Merged
ed255 merged 47 commits into
privacy-ethereum:mainfrom
scroll-tech:re-init
Mar 8, 2022
Merged

feat: add sload op (non-bus-mapping version)#334
ed255 merged 47 commits into
privacy-ethereum:mainfrom
scroll-tech:re-init

Conversation

@0xmountaintop
Copy link
Copy Markdown
Collaborator

@0xmountaintop 0xmountaintop commented Feb 17, 2022

privacy-ethereum/zkevm-specs#106

Notes:

  1. would like to separate sload and sstore PR. because the gas calculation and the TxRefund calculation for sstore are more complicated.
  2. bus-mapping version: feat: add sload op (bus-mapping version) #347

@github-actions github-actions Bot added the T-opcode Type: opcode-related and focused PR/Issue label Feb 17, 2022
@0xmountaintop 0xmountaintop changed the title feat: add sload op (WIP) feat: add sload op Feb 18, 2022
@github-actions github-actions Bot added the crate-bus-mapping Issues related to the bus-mapping workspace member label Feb 21, 2022
@github-actions github-actions Bot removed the crate-bus-mapping Issues related to the bus-mapping workspace member label Feb 21, 2022
@0xmountaintop 0xmountaintop changed the title feat: add sload op feat: add sload op (non-bus-mapping version) Mar 1, 2022
Comment thread zkevm-circuits/src/evm_circuit/execution/storage.rs Outdated
Comment thread zkevm-circuits/src/evm_circuit/execution/storage/sload.rs Outdated
Comment thread zkevm-circuits/src/evm_circuit/execution/storage/sload.rs Outdated
Copy link
Copy Markdown
Contributor

@CPerezz CPerezz left a comment

Choose a reason for hiding this comment

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

A couple of nits and questions.

But so far LGTM. I don't see any inconsistencies with the specs.

/// Transaction ID: Transaction index in the block starting at 1.
pub tx_id: usize,
/// Storage Value before the transaction
pub committed_value: Word,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure committed_value is the best name to describe the Value before the transaction.
Since we have value_prev we can also have value_after maybe.

Comment thread zkevm-circuits/src/evm_circuit/execution/storage.rs Outdated
}
}

pub fn aux_pair(&self) -> (usize, Word) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If this is going to be exported as pub, add some docs for it please.

Comment thread zkevm-circuits/src/state_circuit/state.rs Outdated
Comment thread zkevm-circuits/src/state_circuit/state.rs Outdated
Comment thread zkevm-circuits/src/state_circuit/state.rs Outdated
Comment thread zkevm-circuits/src/state_circuit/state.rs Outdated
Comment thread zkevm-circuits/src/state_circuit/state.rs Outdated
Comment thread zkevm-circuits/src/state_circuit/state.rs Outdated
.input
.0
.iter()
.fold(0, |acc, byte| acc + if *byte == 0 { 4 } else { 16 });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We might want to add Byte storage costs or something similar in like an enum form. So that these values are contained in a const or somewhere similar and if they change or whatever, we just need to change the constant to update them all.

@0xmountaintop
Copy link
Copy Markdown
Collaborator Author

I agree with @icemelon here. Unless storage module provides benefits in regards readability or organization, we should avoid it and stick to the current format.

No problem. I will fix it

@0xmountaintop
Copy link
Copy Markdown
Collaborator Author

0xmountaintop commented Mar 5, 2022

@CPerezz previously we were using Word::from(0) in zkevm-circuits/src/state_circuit/state.rs.
I just change all Word::from(0) to Word::zero() according to your feedback: 02b9f2b

@CPerezz CPerezz requested a review from ed255 March 6, 2022 10:40
Copy link
Copy Markdown
Contributor

@CPerezz CPerezz left a comment

Choose a reason for hiding this comment

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

LGTM!

Would like a re-review from @ed255 before this gets merged.

As for the test that can't be performed now due to being blocked by #354, please fill an issue so that we have it listed somewhere :)

Nice job @HAOYUatHZ 😄

Copy link
Copy Markdown
Contributor

@ed255 ed255 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 working on this opcode :)

I've left a suggestion in my review, feel free to take a look and update if you consider it appropriate. Otherwise we can proceed with merging this PR!

Comment thread zkevm-circuits/src/evm_circuit/execution/sload.rs Outdated
@ed255 ed255 merged commit cddf16a into privacy-ethereum:main Mar 8, 2022
@0xmountaintop 0xmountaintop deleted the re-init branch March 9, 2022 05:39
zemse pushed a commit to zemse/zkevm-circuits that referenced this pull request Mar 22, 2023
…reum#334)

* modify pi circuit to be compatible with bridge contract

* fix

* fmt
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 T-opcode Type: opcode-related and focused PR/Issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants