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

LEVM: CREATE type transactions not checking if address exists #1517

Open
LeanSerra opened this issue Dec 16, 2024 · 0 comments
Open

LEVM: CREATE type transactions not checking if address exists #1517

LeanSerra opened this issue Dec 16, 2024 · 0 comments
Assignees
Labels
levm Lambda EVM implementation

Comments

@LeanSerra
Copy link
Contributor

LeanSerra commented Dec 16, 2024

When sending a transaction of type TxKind::CREATE, the code is not checking if the address exists.
Steps to Reproduce

  • Run TransactionCollisionToEmptyButCode.json test
    • This test should fail LEVM continues with the creation but REVM halts with CreateCollision error

Possible fix

  • Check against the db if the address already exists.
    • This check could be added after this line:
      let new_contract_address =
      VM::calculate_create_address(env.origin, db.get_account_info(env.origin).nonce)
      .map_err(|_| {
      VMError::Internal(InternalError::CouldNotComputeCreateAddress)
      })?;
@LeanSerra LeanSerra added the levm Lambda EVM implementation label Dec 16, 2024
@LeanSerra LeanSerra removed this from ethrex_l1 Dec 16, 2024
@damiramirez damiramirez self-assigned this Dec 17, 2024
github-merge-queue bot pushed a commit that referenced this issue Dec 18, 2024
**Motivation**

The `CREATE` transaction logic did not handle the case where the address
where we the contract will be deploy already exists.

**Description**

- Add a check in `VM::new()` where the transaction is `CREATE`. If
`new_contract_address` exists in the db and it has nonce or bytecode, we
don't create the new account and we don't add it in the cache. We know
this is an error and the revert will be handled in `transact()`
- Something similar in `transact()`, we check if the transaction is
`CREATE` and if `new_address_acc` has code or nonce. In that case we
return a `TransactionReport` with `TxResult::Revert`.
- Support the creation of a contract even if the account has balance.

Related #1517

---------

Co-authored-by: Tomas Fabrizio Orsi <[email protected]>
Co-authored-by: Jeremías Salomón <[email protected]>
Co-authored-by: JereSalo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
levm Lambda EVM implementation
Projects
None yet
Development

No branches or pull requests

2 participants