ethereum / tests

Common tests for all Ethereum implementations
MIT License
557 stars 319 forks source link

Questionable EOF validity test case #1386

Closed wavefnx closed 4 months ago

wavefnx commented 4 months ago

Issue

This issue questions the validity of the EOF test Valid Invalid 1.

We see the code 0xef0001010004020001000304000400008000013050000bad marked as passing for Prague, which can have undesirable effects.

Following deconstruction we see that the data section of the header expects the body to have four (4) instead of two (2) bytes.

### header
magic  : ef00         ; eof prefix
version: 01           ; eof version
types  : 01 0004      ; 4 bytes assigned to the types section
code   : 02 0001 0003 ; 1 code section, 3 bytes
data   : 04 0004      ; 4 bytes assigned to the data section  <-- important
term   : 00           ; terminator

### body 
types  : 00 80 0001   ; 0 outputs, non-returning(0x80), 1 max stack height  
code   : 30 50 00     ; ADDRESS, POP, STOP
data   : 0b ad        ; found 2 bytes, expected 4             <-- important

Are there any reasons why the above should be valid?

If not, I'm providing alternative replacements below.

Remediation

It should be straight-forward. I can gladly open a PR or you're free to do so.

Either by replacing the affected data header to expect two (2) bytes:

0xef0001010004020001000304000200008000013050000bad

Or add two (2) additional bytes on the data body:

0xef0001010004020001000304000400008000013050000badbeef
pdobacz commented 4 months ago

The top-level container validation changed recently, this PR should adapt to it.

wavefnx commented 4 months ago

Sounds good, closing