Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Adria0/fix/tests #11597

Merged
merged 22 commits into from
May 14, 2020
Merged

Adria0/fix/tests #11597

merged 22 commits into from
May 14, 2020

Conversation

adria0
Copy link

@adria0 adria0 commented Apr 3, 2020

Issue for this PR is https://github.com/openethereum/openethereum/issues/11647

Fixing/syncing #11085 [json-tests] run all tests (or justify why not)
with the last available ethereum/tests@5841af6

Copy link
Collaborator

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

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

Good stuff! LGTM but let's wait for CI.

ethcore/src/json_tests/test_common.rs Outdated Show resolved Hide resolved
ethcore/src/test_helpers/evm_test_client.rs Outdated Show resolved Hide resolved
evmbin/src/main.rs Show resolved Hide resolved
@adria0 adria0 mentioned this pull request Apr 22, 2020
6 tasks
@adria0 adria0 marked this pull request as ready for review May 4, 2020 07:29
@adria0 adria0 requested review from vorot93 and niklasad1 May 4, 2020 07:30
@adria0 adria0 requested a review from dvdplm May 4, 2020 07:30
Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
Comment on lines 454 to 461
// EIP161 - reverted calls cancels state trie cleaning
if initial_builtin_balance.is_zero() {
let prune = UNPRUNABLE_PRECOMPILE_ADDRESS
.map_or(true, |addr| addr != params.code_address);
if prune {
substate.touched.remove(&params.code_address);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

just to make sure I understand this correctly: for tests this will remove all but ripemd builtints with zero balance and for production this revert all zero-balanced builtins (although in practice all builtins have balance: 1, maybe there are some exceptions https://github.com/openethereum/openethereum/pull/11482/files#r378702588, this needs to be double checked)

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's a great observation, classic and foundation have balance == 0 more might have it too.

Copy link
Author

Choose a reason for hiding this comment

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

for tests this will remove all but ripemd builtints with zero balance

we need to be able to reproduce the RIPEMD removal at block #2686351 in tests

for production this revert all zero-balanced builtins

afaik, all precompiles has balance: 1 due the EIP161 rule. for instance, when you create a new clique genesis with geth, all precompiles balances are set to 1

maybe there are some exceptions

this issue happened due that both geth and parity allowed the removal of 0x3 account for different reasons, and nobody noticed about it after some time, so core devs decided to introduce this "irregular state transition".

I agree with you that this change could affect to PoA chains with the same scenario:

  • they initially specified the precompile in the trie with balance=0
  • they called a precompile without enough gas and the precompile reverted and was removed from the trie

Maybe we can add there a eip161_touch_prunning_bug, but this is really ugly 😱

Copy link
Author

@adria0 adria0 May 4, 2020

Choose a reason for hiding this comment

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

Moving everything to chain definitions is another option,

  • eip161_unprunable_precompiles: list of precompile addresses that cannot be pruned if touched with zero balance in a reverted call.

we have to add this flag to the testnet with 0x3, and also allows fixing existing PoA chains. I think that we need to generate some kind of an explicit warn! log there to help to identity the problem.

Copy link
Author

Choose a reason for hiding this comment

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

@ordian @niklasad1,

I see these options now:

  • (a) Fix EIP161 only in tests: in real deployments, this is "tactically fixed" by setting balances to >=1 in precompile accounts.
  • (b) Fix EIP161 at all
    • (b.1) add a chain option eip161_unprunable_precompiles=addr, addr,... and define it in mainnet chains with 0x3
    • (b.2) add a chain option eip161_touch_prunning_bug, a flag that could be activated by any existing PoA chains that removed some precompile accounts
  • (c) Introduce generic irregular state transitions (I do not like this)

Any other idea? Thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would go for option (a) as the easiest one, but we would need to ensure (somehow via CI and document it enough) that each precompile has balance >= 1 indeed. The problem with changing balance for existing chains is that it's a breaking change (see e.g. #11108).

Copy link
Author

@adria0 adria0 May 13, 2020

Choose a reason for hiding this comment

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

@ordian, implemented (a) in this PR, commit openethereum/openethereum@04dc267

Copy link
Collaborator

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

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

Overall this looks good (great actually). I have a doubt about the "legacy" tests: unless we have a compelling reason for keeping them I am not sure they are worth keeping. Do you think you can expand the description with a motivation why?

ethcore/machine/src/executive.rs Outdated Show resolved Hide resolved
ethcore/machine/src/executive.rs Outdated Show resolved Hide resolved
ethcore/machine/src/executive.rs Show resolved Hide resolved
json/src/test_helpers/skip.rs Show resolved Hide resolved
json/src/test_helpers/blockchain/mod.rs Show resolved Hide resolved
ethcore/src/json_tests/state.rs Show resolved Hide resolved
ethcore/src/json_tests/chain.rs Outdated Show resolved Hide resolved
ethcore/machine/src/executive.rs Outdated Show resolved Hide resolved
@dvdplm
Copy link
Collaborator

dvdplm commented May 4, 2020

I know this isn't a fair comparison but I ran $ time cargo test --all --release --features=json-tests > /dev/null 2>&1 on both this branch and master and got:

Master:

real	3m0.105s
user	4m27.378s
sys	0m7.523s

This branch:

real	4m17.238s
user	10m55.691s
sys	0m23.453s

(This does not include build times; I ran both commands twice.)

Co-authored-by: David <dvdplm@gmail.com>
@adria0
Copy link
Author

adria0 commented May 4, 2020

Absolutely aware of it. It's horrible how compilation+test times are growing :(

We need a better strategy than adding and adding more tests. Removing legacy ones for the "normal" builds is an option.

@ordian
Copy link
Collaborator

ordian commented May 4, 2020

please merge with master (just merged #11675 which updated the submodule)

@adria0 adria0 force-pushed the adria0/fix/tests branch from ff16ee4 to 04dc267 Compare May 13, 2020 21:51
@adria0 adria0 requested review from dvdplm, niklasad1 and ordian May 14, 2020 06:55
Copy link
Collaborator

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

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

Let's get this merged. Awesome job @adria0 🍰

Copy link
Collaborator

@niklasad1 niklasad1 left a comment

Choose a reason for hiding this comment

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

Very good job looks good modulo some style nits in ethcore/src/json_tests/chain.rs.

  • Make sure that your editor removes trailing whitespaces
  • Function calls/function definitions should have a space between for example fn foo(a: usize, b: usize)

Copy link
Collaborator

@ordian ordian left a comment

Choose a reason for hiding this comment

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

Great job!

@adria0 adria0 merged commit 1ace3c7 into openethereum:master May 14, 2020
@ordian ordian added the A9-buythatmanabeer 🍻 Pull request is reviewed well and worth buying the author a beer. label May 14, 2020
ordian added a commit that referenced this pull request May 14, 2020
dvdplm added a commit that referenced this pull request May 25, 2020
* master:
  Implement Simple Subroutines for the EVM (EIP 2315) (#11629)
  Adria0/fix/tests (#11597)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A9-buythatmanabeer 🍻 Pull request is reviewed well and worth buying the author a beer.
Projects
None yet
4 participants