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

Possible wrong post state root on ZeroCallTests #770

Closed
leonardostsouza opened this issue Dec 11, 2020 · 2 comments
Closed

Possible wrong post state root on ZeroCallTests #770

leonardostsouza opened this issue Dec 11, 2020 · 2 comments

Comments

@leonardostsouza
Copy link

Some of the tests seem to be considering empty accounts to calculate the post state root. From what I understand about the protocol, the empty accounts should be treated similar to non-existing accounts, so this would be incorrect behavior. Is there any exception to this rule I am not aware of?

A quick example to illustrate what I am talking about:

==> LegacyTests/Constantinople/GeneralStateTests/stZeroCallsTest/ZeroValue_CALLCODE_ToEmpty (Byzantium):
Final State:
================
::: Account 0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba
:::     nonce   :  0x0
:::     balance :  0x13f46
:::     code    :  0x
:::     storage : {}

::: Account 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b
:::     nonce   :  0x1
:::     balance :  0xe8d4a3d0ba
:::     code    :  0x
:::     storage : {}

::: Account 0xb94f5374fce5edbc8e2a8697c15331677e6ebf0b
:::     nonce   :  0x0
:::     balance :  0x0
:::     code    :  0x5a6000556000600060006000600073c94f5374fce5edbc8e2a8697c15331677e6ebf0b61ea60f26001555a606455
:::     storage : {'0x00': '0x08d5b6', '0x01': '0x01', '0x64': '0x08369d'}

::: Account 0xc94f5374fce5edbc8e2a8697c15331677e6ebf0b
:::     nonce   :  0x0
:::     balance :  0x0
:::     code    :  0x
:::     storage : {}

Correct final state root according to the test file (includes the empty account 0xc94f5374fce5edbc8e2a8697c15331677e6ebf0b): 0x1c57ca04dea8d4f09c81c54593838c45cf059d13dcfb9f9d70dca2bc1ad285e9

State root I would expect (not considering account 0xc94f5374fce5edbc8e2a8697c15331677e6ebf0b): 0x1531bd9ebfed425c01ab97871c2f5415683b614160c0de07e95ca46a3f8222e3

I could observe similar behavior in the following tests for all forks:

  • LegacyTests/Constantinople/GeneralStateTests/stZeroCallsTest/ZeroValue_CALLCODE_ToEmpty
  • LegacyTests/Constantinople/GeneralStateTests/stZeroCallsTest/ZeroValue_CALLCODE_ToOneStorageKey
  • LegacyTests/Constantinople/GeneralStateTests/stZeroCallsTest/ZeroValue_DELEGATECALL_ToEmpty
  • LegacyTests/Constantinople/GeneralStateTests/stZeroCallsTest/ZeroValue_DELEGATECALL_ToOneStorageKey

I didn't check how the non-legacy tests are behaving.
Are the tests really expecting the correct state root?

@winsvega
Copy link
Collaborator

winsvega commented Dec 11, 2020

The empty account present in a state for the root hash by default. Unless after eip158, if it was touched during the call, it is removed from state.

ethereum/EIPs#158

@leonardostsouza
Copy link
Author

I see. Thanks for the clarification. It was very helpful

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

No branches or pull requests

2 participants