Skip to content

Conversation

@cameel
Copy link
Collaborator

@cameel cameel commented Dec 22, 2020

Depends on #10676. Don't merge until that PR is merged! It's on develop now.

This is a set of workarounds for #10183, to make prepare_report.py and prepare_report.js work with older versions of the compiler:

  • The option to disable SMT Checker only appeared in 0.7.6. Before that we need to fall back to stripping pragmas.
  • Some versions have more whitespace in CLI output.
  • On 0.6.0 and 0.6.1 Yul optimizer was enabled by default which results in different metadata.
  • Before 0.4.6 the --metadata option was not supported. Up to 0.4.4 it was ignored but on 0.4.5 and 0.4.6 it cause an error so I added a step to detect that and prevent the script from using it.
  • On 0.4.11 the emscripten builds of the compiler raise exceptions instead of reporting an error on some invalid input (specifically: extracted examples that are actually LLL, not Solidity). Now there's a try/catch block that handles this like all other errors.

@cameel cameel self-assigned this Dec 22, 2020
@cameel cameel force-pushed the backwards-compatibility-for-bytecode-comparison branch from 6333cd8 to a46f225 Compare January 11, 2021 16:08
@cameel cameel force-pushed the cli-bytecode-comparison branch 3 times, most recently from d0b3402 to 429c711 Compare January 19, 2021 17:24
@cameel cameel marked this pull request as draft January 20, 2021 11:19
@cameel cameel force-pushed the cli-bytecode-comparison branch 5 times, most recently from 5f41135 to 27bdb4a Compare January 21, 2021 15:24
@cameel cameel force-pushed the backwards-compatibility-for-bytecode-comparison branch from a46f225 to 0ff9a2b Compare January 22, 2021 10:46
@cameel cameel force-pushed the cli-bytecode-comparison branch from 27bdb4a to b5951da Compare January 22, 2021 11:18
@cameel cameel force-pushed the backwards-compatibility-for-bytecode-comparison branch from 0ff9a2b to 6501925 Compare January 22, 2021 11:18
@cameel cameel force-pushed the cli-bytecode-comparison branch from b5951da to eb081ad Compare January 22, 2021 12:14
@cameel cameel force-pushed the backwards-compatibility-for-bytecode-comparison branch from 6501925 to 998ee0c Compare January 22, 2021 12:14
@cameel cameel force-pushed the cli-bytecode-comparison branch from eb081ad to 5e70dd1 Compare January 22, 2021 14:32
@cameel cameel force-pushed the backwards-compatibility-for-bytecode-comparison branch 4 times, most recently from 249416c to 8769936 Compare January 22, 2021 23:14
@cameel cameel force-pushed the cli-bytecode-comparison branch from 7f879cd to 8d34c08 Compare January 22, 2021 23:30
@cameel cameel force-pushed the backwards-compatibility-for-bytecode-comparison branch from 8769936 to 83cd9dc Compare January 22, 2021 23:30
@cameel cameel force-pushed the cli-bytecode-comparison branch from 8d34c08 to dd95291 Compare January 23, 2021 00:12
@cameel cameel force-pushed the backwards-compatibility-for-bytecode-comparison branch 2 times, most recently from a20f654 to 7d23c0d Compare January 23, 2021 00:24
@cameel cameel force-pushed the cli-bytecode-comparison branch from dd95291 to 3b03bc7 Compare January 26, 2021 13:13
@cameel cameel force-pushed the backwards-compatibility-for-bytecode-comparison branch from 08a20f4 to 087be9b Compare January 26, 2021 13:13
@cameel cameel force-pushed the backwards-compatibility-for-bytecode-comparison branch from 087be9b to abdea8c Compare January 26, 2021 22:31
Base automatically changed from cli-bytecode-comparison to develop January 28, 2021 10:58
@cameel cameel force-pushed the backwards-compatibility-for-bytecode-comparison branch from abdea8c to 6d3d6bf Compare January 28, 2021 11:24
@cameel cameel marked this pull request as ready for review January 28, 2021 11:24
@cameel
Copy link
Collaborator Author

cameel commented Jan 28, 2021

#10676 has just been merged so I'm marking this a ready for review.

Copy link
Contributor

@hrkrshnn hrkrshnn left a comment

Choose a reason for hiding this comment

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

Generally looks good. I'll do one more review later.

Comment on lines 16 to 21
CONTRACT_SEPARATOR_PATTERN = re.compile(r'^ *======= +(?:(?P<file_name>.+) *:)? *(?P<contract_name>[^:]+) +======= *$', re.MULTILINE)
BYTECODE_REGEX = re.compile(r'^ *Binary: *\n(?P<bytecode>.*[0-9a-f$_]+.*)$', re.MULTILINE)
METADATA_REGEX = re.compile(r'^ *Metadata: *\n *(?P<metadata>\{.*\}) *$', re.MULTILINE)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do these regex have to change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The old regex was enough to handle the current output but in older versions there are some variations:

  • File name is not present in the ======= header on 0.4.8 and earlier.
  • There are some minor differences in whitespace between versions. Not as big at the change in the regex would imply but I just made it handle extra whitespace in all reasonable places.
  • On older versions bytecode or metadata sections in the output are sometimes empty. The original regex just assumes that the next line after the Bytecode: contains the bytecode and it grabs the metadata header if that happens to be empty so I had to make it more strict.

There are test cases on sample output from 0.4.8 and 0.4.0 to make sure they're parsed correctly and also a synthetic case that checks what happens when the sections are empty or if there is extra whitespace.

…agma stripping and only disabling the SMT checker
… that do not support it

- Before 0.4.3 the option was unavailable but ignored.
- Between 0.4.3 and 0.4.6 an attempt to use that option causes an error.
…tion instead of failing

- Our v0.4.11 release raises an exception on some LLL snippets containing returnlll (extracted from its end-to-end tests).
- The report comparison will fail anyway because emscripten prints an abort code to stdout in that case but at least we'll be able to continue if we're comparing multiple versions.
@cameel cameel force-pushed the backwards-compatibility-for-bytecode-comparison branch from 6d3d6bf to 7bebcb7 Compare February 2, 2021 15:16
@chriseth chriseth merged commit 358324e into develop Feb 2, 2021
@chriseth chriseth deleted the backwards-compatibility-for-bytecode-comparison branch February 2, 2021 15:59
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.

4 participants