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

Feat/#434 Implement ErrorInvalidCreationCode error state#478

Merged
KimiWu123 merged 9 commits into
masterfrom
feat/#434-The-InvalidCreationCode-Error
Aug 4, 2023
Merged

Feat/#434 Implement ErrorInvalidCreationCode error state#478
KimiWu123 merged 9 commits into
masterfrom
feat/#434-The-InvalidCreationCode-Error

Conversation

@KimiWu123
Copy link
Copy Markdown
Contributor

and updated version of #400 and closed #434

@KimiWu123 KimiWu123 self-assigned this Jul 31, 2023
@KimiWu123 KimiWu123 marked this pull request as draft July 31, 2023 06:35
@KimiWu123 KimiWu123 force-pushed the feat/#434-The-InvalidCreationCode-Error branch from 1ac18db to 8e8ec2d Compare July 31, 2023 06:36
@KimiWu123 KimiWu123 marked this pull request as ready for review July 31, 2023 07:00
@KimiWu123 KimiWu123 force-pushed the feat/#434-The-InvalidCreationCode-Error branch from f6fa5cc to 1084dc9 Compare July 31, 2023 07:02
@KimiWu123 KimiWu123 force-pushed the feat/#434-The-InvalidCreationCode-Error branch from 1084dc9 to 581a37c Compare July 31, 2023 07:07
@miha-stopar miha-stopar self-requested a review July 31, 2023 13:16
Copy link
Copy Markdown
Contributor

@davidnevadoc davidnevadoc left a comment

Choose a reason for hiding this comment

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

Just a question and a typo fix, all the rest LGTM! 👍

Comment thread src/zkevm_specs/evm_circuit/execution/error_invalid_creation_code.py Outdated
# opcode mut be `RETURN`
instruction.constrain_equal(opcode, Opcode.RETURN)

# the call must be coming from CREATE or CREATE2
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.

Can it also be that tx.to == null as it is mentioned in the MD?

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.

I think we couldn't add this constraint. There are two routes for this error, a.) it's a CREATE/CREATE2 opcode execution and b.) it's a contract deployment transaction (which is tx.to == null). If we add this constraint, then the first case a.) would be failed.

KimiWu123 and others added 2 commits August 1, 2023 12:23
…ode.py

Co-authored-by: David Nevado <davidnevadoc@users.noreply.github.com>

### EVM behavior

When handling a contract creation transaction, initial bytecode are executed and the current call context is `CREATE` or `CREATE2`. The last opcode to store for new contract is `RETURN`. It returns `memory[offset...offset + length]` content as contract bytecode to store into state DB.
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.

This is similar description as here where @rrtoledo suggested an improved text. Might be applied here too :).

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.

fixed in 4a3594a

2. The first byte of contract code is `0xEF`.
3. Current call must be failed.
4. If it's a root call, it transits to `EndTx`.
5. if it is not root call, it restores caller's context by reading to `rw_table`, then does step state transition to it.
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.

Do we need to check that it's not a static call?

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.

I think we don't. If it's a CREATE callcontext and also a static call, it would hit ErrorWriteProtection first. Correct me if I misunderstand error states handling mechanism.

@KimiWu123 KimiWu123 requested a review from miha-stopar August 3, 2023 01:33
@KimiWu123 KimiWu123 merged commit 2ce9b82 into master Aug 4, 2023
@KimiWu123 KimiWu123 deleted the feat/#434-The-InvalidCreationCode-Error branch September 6, 2023 06:17
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.

The InvalidCreationCode Error

3 participants