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

selfdestruct in initcode should destroy #5913

Merged
merged 12 commits into from
Jul 24, 2023

Conversation

smartprogrammer93
Copy link
Contributor

Fixes Ethereum tests

Changes

  • selfdestruct in initcode should destory
  • add tests for above case
  • add codehash assertion to tests

Types of changes

What types of changes does your code introduce?

  • Bugfix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a change that causes existing functionality not to work as expected)
  • Optimization
  • Refactoring
  • Documentation update
  • Build-related changes
  • Other: Description

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • No

Documentation

Requires documentation update

  • Yes
  • No

Requires explanation in Release Notes

  • Yes
  • No

Copy link
Contributor

@Demuirgos Demuirgos left a comment

Choose a reason for hiding this comment

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

can you elaborate what selfdestruct in initcode should destroy? and in this context do we only mean initcode as the argument to CREATE/CREATE2 or CreateTx as well ?

src/Nethermind/Nethermind.Evm/VirtualMachine.cs Outdated Show resolved Hide resolved
@smartprogrammer93
Copy link
Contributor Author

can you elaborate what selfdestruct in initcode should destroy? and in this context do we only mean initcode as the argument to CREATE/CREATE2 or CreateTx as well ?

@Demuirgos so basically, selfdestruct in the initcode should act how it acted before the EIP. so adding the contract for destruction

@smartprogrammer93 smartprogrammer93 force-pushed the fix/eip6780_initcode_selfdestruct_should_destroy branch from edc59f4 to 3505d6f Compare July 8, 2023 03:06
@smartprogrammer93
Copy link
Contributor Author

@Demuirgos for create transaction no need to worry about destroy, it results in the same output (no contract created)

@rubo rubo changed the title selfdestruct in initcode should destory selfdestruct in initcode should destroy Jul 8, 2023
Copy link
Contributor

@MarekM25 MarekM25 left a comment

Choose a reason for hiding this comment

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

Added a few comments

[Parallelizable(ParallelScope.All)]
public class Eip6780Tests : BlockchainTestBase
{
//[TestCaseSource(nameof(LoadTests))]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why commented?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tests are not merged yet.

src/Nethermind/Nethermind.Evm.Test/Eip6780Tests.cs Outdated Show resolved Hide resolved
src/Nethermind/Nethermind.Evm.Test/Eip6780Tests.cs Outdated Show resolved Hide resolved
src/Nethermind/Nethermind.Evm/VirtualMachine.cs Outdated Show resolved Hide resolved
Copy link
Member

@LukaszRozmej LukaszRozmej left a comment

Choose a reason for hiding this comment

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

Also re-reviewing original PR made me find this which is weird: https://github.com/NethermindEth/nethermind/pull/4704/files#r1258001674

@smartprogrammer93 smartprogrammer93 marked this pull request as draft July 11, 2023 17:45
@smartprogrammer93 smartprogrammer93 marked this pull request as ready for review July 15, 2023 22:01

private void AssertNotDestroyed()
{
AssertCodeHash(_contractAddress, Keccak.Compute(_selfDestructCode.AsSpan()));
Copy link
Contributor

Choose a reason for hiding this comment

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

why doesn't this do the opposite of AssertDestroyed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because with this call, i can make sure the account has the keccak of the deployed code. but I am not sure how useful that is.

src/Nethermind/Nethermind.Evm/EvmState.cs Outdated Show resolved Hide resolved
@MarekM25 MarekM25 merged commit e9b62cd into master Jul 24, 2023
61 checks passed
@MarekM25 MarekM25 deleted the fix/eip6780_initcode_selfdestruct_should_destroy branch July 24, 2023 14:41
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.

None yet

4 participants