Skip to content

EIP-3541 ethereum/tests Run#1247

Closed
holgerd77 wants to merge 59 commits into
eip1559from
eip-3541-test
Closed

EIP-3541 ethereum/tests Run#1247
holgerd77 wants to merge 59 commits into
eip1559from
eip-3541-test

Conversation

@holgerd77

Copy link
Copy Markdown
Member

This is a test run of a our EIP-3541 implementation from #1240 towards the tests implemented at ethereum/tests#835.

DO NOT MERGE!!!

@axic I noted that our test setup is very much not prepared to adhoc integrate these invented fork names, I couldn't imminently get this work to run on CI.

I will instead take this PR as a base and do manual tests runs of the different files.

jochem-brouwer and others added 30 commits May 9, 2021 16:33
tx: create access list utility
common: add docs getEIPActivationBlockNumber

common: add extra constant
block: add more EIP1559 tests
block: enable access list transactions as TxData and EIP1559 transactions
block: add base fee test check
tx: add EIP1559-related gas logic
block: use EIP1559 api from tx
tx: fix gas limit not present in signed EIP1559 txns

tx/vm: lint
…rice (with extended 0x-instantiation guard) to legacy and EIP-2930 txs
…igned default value instantiation for fromValuesArray() calls
…uctor, introduced TRANSACTION_TYPE and TRANSACTION_TYPE_BUFFER constants to EIP-2930 tx, added v, r, s aliases for consistency
…two fixes on TRANSACTION_TYPE_BUFFER Buffer initialization, fixed transaction type Buffer comparison in fromSerializedTx()
Co-authored-by: Ryan Ghods <ryan@ryanio.com>
@holgerd77 holgerd77 mentioned this pull request May 9, 2021
@holgerd77

Copy link
Copy Markdown
Member Author

ts-node ./tests/tester --state --customStateTest=../ethereum-tests/GeneralStateTests/stBadOpcode/undefinedOpcodeFirstByte.json --fork=Berlin+3541

1..114
# tests 114
# pass  114

Counter test:

1..114
# tests 114
# pass  114

Actually also pass, this doesn't seem to be right I guess? 🤔

@holgerd77

Copy link
Copy Markdown
Member Author

ts-node ./tests/tester --state --customStateTest=../ethereum-tests/GeneralStateTests/stCreate2/CREATE2_EOF1_loop.json --fork=Berlin+3541

1..1
# tests 1
# pass  1

Counter test:

# tests 1
# pass  0
# fail  1

Everything ok here.

@holgerd77

Copy link
Copy Markdown
Member Author

ts-node ./tests/tester --state --customStateTest=../ethereum-tests/GeneralStateTests/stCreateTest/CREATE_EOF1.json --fork=Berlin+3541

1..4
# tests 4
# pass  4

Counter test:

# tests 4
# pass  0
# fail  4

Everything ok here.

@holgerd77

Copy link
Copy Markdown
Member Author

ts-node ./tests/tester --state --customStateTest=../ethereum-tests/GeneralStateTests/stCreateTest/CREATE_EOF1_loop.json --fork=Berlin+3541

1..1
# tests 1
# pass  1

Counter test:

# tests 1
# pass  0
# fail  1

Everything ok here.

@holgerd77

Copy link
Copy Markdown
Member Author

ts-node ./tests/tester --state --customStateTest=../ethereum-tests/GeneralStateTests/stTransactionTest/CreateTransactionEOF1.json --fork=Berlin+3541

# tests 4
# pass  4

Counter test:

# tests 4
# pass  0
# fail  4

Everything ok here.

@holgerd77

Copy link
Copy Markdown
Member Author

ts-node ./tests/tester --state --customStateTest=../ethereum-tests/GeneralStateTests/stTransactionTest/Opcodes_TransactionInit.json --fork=Berlin+3541

1..130
# tests 130
# pass  130
ok 128 the state roots should match
ok 129 the state roots should match
not ok 130 the state roots should match

1..130
# tests 130
# pass  129
# fail  1

On counter test run only the last failing? 🤔 Is this correct?

@axic

axic commented May 9, 2021

Copy link
Copy Markdown
Member

@gumb0 can you comment when you get a chance please?

@holgerd77

Copy link
Copy Markdown
Member Author

For undefinedOpcodeFirstByte actually the post sections for Berlin and Berlin+3541 seem to be indentical.

@holgerd77

Copy link
Copy Markdown
Member Author

Ah, ok, have found the following comment from @gumb0 on the original PR:

"This could be merged separately already, because EIP-3541 doesn't change this behavior."

😄

@holgerd77

holgerd77 commented May 9, 2021

Copy link
Copy Markdown
Member Author

Have found this comment for Opcodes_TransactionInit on the tests PR, also from @gumb0:

"I didn't care to make all possible invalid opcodes here.

And this also can be merged independently, because this behavior is not changing yet."

This actually doesn't explain yet why 1 test is failing for us on berlin. If the test case is new for berlin then this might be a bug in our implementation. If the test case is old (we passed before) this might be a newly introduced bug in the tests.

(there is also always the third possibility that there is something wrong in our test setup 😄 )

@holgerd77

holgerd77 commented May 9, 2021

Copy link
Copy Markdown
Member Author

It's the data=129 test failing on berlin (so with data set to 0x6000600060006000600073b94f5374fce5edbc8e2a8697c15331677e6ebf0b61c350f15060ef60005360016000f3) which can be run in isolation with ts-node ./tests/tester --state --customStateTest=../ethereum-tests/GeneralStateTests/stTransactionTest/Opcodes_TransactionInit.json --fork=Berlin+3541 --data=129.

@jochem-brouwer

Copy link
Copy Markdown
Member

Found the problem, we are deploying a contract with 0xEF as code.


const state = new Trie()
const hardfork = options.forkConfigVM
const hardfork = 'berlin'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

?? Now we run all in Berlin and thus the --fork param is ignored?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah ok this PR is supposed to be hacky :)

@codecov

codecov Bot commented May 9, 2021

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (eip1559@3efb919). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

Flag Coverage Δ
block 81.92% <0.00%> (?)
blockchain 84.16% <0.00%> (?)
client 84.93% <0.00%> (?)
devp2p 83.97% <0.00%> (?)
ethash 82.08% <0.00%> (?)
tx 68.25% <0.00%> (?)
vm 80.80% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

@jochem-brouwer

Copy link
Copy Markdown
Member

Ran this;

ts-node ./tests/tester --state --customStateTest=../ethereum-tests/GeneralStateTests/stCreate2/CREATE2_EOF1.json --fork=Berlin+3541
ts-node ./tests/tester --state --customStateTest=../ethereum-tests/GeneralStateTests/stBadOpcode/undefinedOpcodeFirstByte.json --fork=Berlin+3541
ts-node ./tests/tester --state --customStateTest=../ethereum-tests/GeneralStateTests/stCreate2/CREATE2_EOF1_loop.json --fork=Berlin+3541
ts-node ./tests/tester --state --customStateTest=../ethereum-tests/GeneralStateTests/stCreateTest/CREATE_EOF1.json --fork=Berlin+3541
ts-node ./tests/tester --state --customStateTest=../ethereum-tests/GeneralStateTests/stCreateTest/CREATE_EOF1_loop.json --fork=Berlin+3541
ts-node ./tests/tester --state --customStateTest=../ethereum-tests/GeneralStateTests/stTransactionTest/CreateTransactionEOF1.json --fork=Berlin+3541
ts-node ./tests/tester --state --customStateTest=../ethereum-tests/GeneralStateTests/stTransactionTest/Opcodes_TransactionInit.json --fork=Berlin+3541

Result: all pass.

Counter test, all fail except

ethereum-tests/GeneralStateTests/stBadOpcode/undefinedOpcodeFirstByte.json: all pass
ethereum-tests/GeneralStateTests/stTransactionTest/Opcodes_TransactionInit.json: all pass except the final test (deploy 0xEF contract and store value in some other contract)

CC @axic @gumb0

@jochem-brouwer

Copy link
Copy Markdown
Member

Ah ok I think I got a bit confused by the process here.

@holgerd77 Yes that one test fails is correct, I reproduced this as well; in your final test a 0xEF contract is deployed. For Berlin this is fine (it is allowed) but for Berlin+3541 this is not OK as it is an invalid contract. So it is correct that this is the only test which fails on Berlin+3541.

@holgerd77

holgerd77 commented May 9, 2021

Copy link
Copy Markdown
Member Author

@jochem-brouwer I have to say I can't completely "read" this explanation. First - these are not "my tests", these are the tests from @gumb0 submitted to the ethereum/tests repo.

Also: if there is a test case failing, there definitely something behaves wrong. Either in:

a) Our code
b) our test setup
c) the test itself

What are you suggesting and with what argumentation? 😄

(again: I'm just not able to interpret your current answer).

@jochem-brouwer

jochem-brouwer commented May 9, 2021

Copy link
Copy Markdown
Member

@holgerd77 I just passed all tests on Berlin+EIP3541. This runs on a Common with Berlin as hardfork and 3541 activated as EIP.

So this is the test in question right?

ts-node ./tests/tester --state --customStateTest=../ethereumtests/GeneralStateTests/stTransactionTest/Opcodes_TransactionInit.json --fork=Berlin+3541 --data=129

Except now in the counter test we run this with no EIPs (so EIP 3541 is not activated). We still run it in the context of Berlin+3541. Then this test indeed fails. This is because:

  • This test creates a contract
  • In the deploy code of creating this contract, it calls to another contract.
  • This contract stores 1 in storage slot 0.
  • Now we return to the deploy code
  • This MSTORE8s 0xEF at memory slot 0
  • We return memory [0:1] (so we return 0xEF)
  • This thus deploys a contract with code 0xEF

If we activate 3541, this creation fails, and thus the storage slot write gets reverted.
If we don't activate it, then the creation does not fail, and thus the storage slot gets written. Therefore, there is a difference between the test where we activated the EIP and where we did not; since we are running the test with the same expected results, at least one has thus fail (and in this case the one where we don't activate the EIP thus fails, which is correct per the spec).

@holgerd77

Copy link
Copy Markdown
Member Author

@jochem-brouwer ah, yes, you're right, sorry, I was confused as well. So I guess the tests created are all ok. 😄

@gumb0

gumb0 commented May 10, 2021

Copy link
Copy Markdown

Confirming that tests/GeneralStateTests/stBadOpcode/undefinedOpcodeFirstByte.json should pass for both EIP3541 activated and not. (I'll remove it from ethereum/tests#835, the improved version is in ethereum/tests#836, you could check that, too)

In Opcodes_TransactionInit.json one new test is also supposed to behave without change after fork:
https://github.com/ethereum/tests/pull/835/files#diff-767d260c1cb56c8ea5548501176577874ca06d50339aa65fc236dfc37e3cb20eR373
and another one changes behavior with EIP3541:
https://github.com/ethereum/tests/pull/835/files#diff-767d260c1cb56c8ea5548501176577874ca06d50339aa65fc236dfc37e3cb20eR374
I think you've already figured this out correctly.

@holgerd77

Copy link
Copy Markdown
Member Author

@gumb0 cool, thanks for the feedback here! 👍

@holgerd77 holgerd77 force-pushed the eip1559 branch 2 times, most recently from 4a92829 to c8aeabf Compare May 11, 2021 13:00
@holgerd77

Copy link
Copy Markdown
Member Author

Results have been picked up on the ethereum/tests side, will close.

@holgerd77 holgerd77 closed this May 17, 2021
@holgerd77 holgerd77 deleted the eip-3541-test branch May 17, 2021 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants