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

Spec ExecutionState::{EndTx,EndBlock}#88

Merged
han0110 merged 8 commits into
privacy-ethereum:masterfrom
han0110:feature/end-tx
Jan 19, 2022
Merged

Spec ExecutionState::{EndTx,EndBlock}#88
han0110 merged 8 commits into
privacy-ethereum:masterfrom
han0110:feature/end-tx

Conversation

@han0110
Copy link
Copy Markdown
Contributor

@han0110 han0110 commented Jan 12, 2022

This PR aims to spec ExecutionState::EndTx and ExecutionState::EndBlock, for enable EVM circuit to verify block consists of minimal transaction. With BeginTx, EndTx and EndBlock, the finite state machine diagram will look like:

fsm-check-code-hash

The EndTx aims to handle tx refund to signer, and tx fee to coinbase.

The EndBlock aims to pad the EVM circuit to the fixed capacity, and checks tx_id and rw_counter at the last step.

Also it refactors random linear combination usage, to make things more straightforward. Regardless of the refactors, please refer to end_tx.py and end_block.py for spec itself.

TODO

  • Testing ExecutionState::EndTx
  • Testing ExecutionState::EndBlock

@han0110 han0110 changed the title [WIP] Spec ExecutionState::{EndTx,EndBlock} Spec ExecutionState::{EndTx,EndBlock} Jan 13, 2022
@han0110 han0110 marked this pull request as ready for review January 13, 2022 16:35
@han0110 han0110 mentioned this pull request Jan 14, 2022
1 task
Comment thread src/zkevm_specs/evm/table.py 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.

Should we also file issues for the TODOs that we will leave with this PR?

hash = rlc_store.to_rlc(keccak256(bytecode), 32)
rlc = rlc_store.to_rlc(list(reversed(bytecode)))
hash = RLC(bytes(reversed(keccak256(bytecode))), randomness)
rlc = RLC(bytes(reversed(bytecode)), randomness, len(bytecode))
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.

Question: Which is the purpose of applying the RLC to the keccak inputs? Hasn't it been done previously in assign_bytecode_circuit?

Also, why do we need to reversethe bytecodet?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Which is the purpose of applying the RLC to the keccak inputs? Hasn't it been done previously in assign_bytecode_circuit?

This is a mocking keccak_table, for lookup the hash by RLC of bytecode and length.

Also, why do we need to reversethe bytecodet?

Because in bytecode circuit, it accumulates the bytes in big-endian order, so we need to reverse it for RLC, which takes input as little-endian.

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.

Makes complete sense!

Comment thread src/zkevm_specs/evm/table.py
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!

@CPerezz CPerezz self-requested a review January 19, 2022 11:49
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!

@han0110 han0110 merged commit e7e5400 into privacy-ethereum:master Jan 19, 2022
@han0110 han0110 deleted the feature/end-tx branch January 19, 2022 14:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants