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

zktrie part1: change storage proof from per step to per block #102

Merged
merged 9 commits into from
Jun 8, 2022

Conversation

lispc
Copy link

@lispc lispc commented May 19, 2022

Step-wise proof will be reconstructed in prover side.

Core design: when storage related opcodes are traced(eg: sstore, create2..), no storage proof are generated then, only "storage diff" are recorded. Later when sealing a block, the miner traverse all the "recorded accessed storage", and make proofs of them for the state before this block. So for every storage slot, there will be only one proof for it, corresponding to state before the block execution.

we add some methods to StateDb for this purpose. StateDb writes to trie only when a block is sealing, while during execution inside block, it only keeps pending writes in its inner buffer. So when we are making proofs, we can access state trie before this block, since the pending changes are not committed yet.

@lispc lispc requested review from noel2004 and 0xmountaintop May 19, 2022 14:27
@lispc lispc changed the title change storage proof from step-wise to block-wise. Step-wise proof wi… change storage proof from step-wise to block-wise. May 19, 2022
@lispc lispc changed the title change storage proof from step-wise to block-wise. change storage proof from per stepto per block May 19, 2022
@lispc lispc changed the title change storage proof from per stepto per block change storage proof from per step to per block May 19, 2022
noel2004
noel2004 previously approved these changes May 19, 2022
@noel2004
Copy link
Member

Step-wise proof will be reconstructed in prover side.

Will this break current roller codes?

I don't think it would break roller's code because nothing in roller would touch the SMT proof fields, which would be purged from blockResult after this PR.

We can simply remove the "proof" fields which is defined in AccountProofWrapper/StorageProofWrapper@eth.rs in roller and the code still works.

noel2004
noel2004 previously approved these changes May 20, 2022
core/types/l2trace.go Outdated Show resolved Hide resolved
core/types/l2trace.go Outdated Show resolved Hide resolved
mask-pp
mask-pp previously approved these changes May 23, 2022
noel2004
noel2004 previously approved these changes May 23, 2022
@lispc
Copy link
Author

lispc commented May 23, 2022

@HAOYUatHZ will do a bit refactor here. So don't merge now.

@lispc lispc changed the title change storage proof from per step to per block zktrie part1: change storage proof from per step to per block May 23, 2022
@lispc lispc dismissed stale reviews from noel2004 and mask-pp via 2c94a84 May 26, 2022 05:46
core/vm/logger.go Outdated Show resolved Hide resolved
Comment on lines 14 to 15
CALL: {traceToAddressCode, traceLastNAddressCode(1), traceCallerProof, traceLastNAddressProof(1)},
CALLCODE: {traceToAddressCode, traceLastNAddressCode(1), traceCallerProof, traceLastNAddressProof(1)},
Copy link

@0xmountaintop 0xmountaintop Jun 2, 2022

Choose a reason for hiding this comment

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

what's the different between traceLastNAddressProof(1) and doing it in CaptureEnter? If they are the same can we remove traceLastNAddressProof here?

then change ExtraData comments in core/types/l2trace.go to

CALL | CALLCODE: [caller contract address’s account state, 
    callee contract address’s account state (before called)]

Copy link
Member

Choose a reason for hiding this comment

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

The data created by traceLastNAddressProof is left for background compatible. I think we should use the account data captured in CaptureEnter, since the balance of called account may be updated and it would only be captured here.

* rename GetStateData to GetLiveStateObject

* revert EvmTxTraces type

* rename GetLiveStateObject to GetLiveStateAccount

* fix typo

* some renamings

* format codes

* fix typo

* fix typos

* format codes

some reverts

some renamings

some renamings

format codes

* update comments

update comments

* update comments

update comments

update comments

* update comments

update comments

update comments

* rename

* rename

* update

* update comments
@scroll-dev scroll-dev merged commit d3bc832 into zkrollup Jun 8, 2022
@scroll-dev scroll-dev deleted the l2witness/opt-storage-proof branch June 8, 2022 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants