Skip to content

Proto/Michelson: de-duplicate parse_contract(_for_script)

Mehdi Bouaziz requested to merge mehdi@parse_contract_for_script into master

Context

In the elaborator, we have parse_contract used to parse_data of type contract ... and parse_contract_for_script used to execute the instruction CONTRACT.

They only differ by the fact that parse_contract_for_script ignores (virtually all -- ideally all) non-gas errors and turns them into None, the rest is strictly the same.

Code duplicate is never a good thing, we may forget to update one and not the other.

This MR merges both by reusing the error_details type to differentiate between verbose (for parse_contract) and non-verbose (for parse_contract_for_script) errors.

Yeah, and some cleanups like moving 2 functions out of the way and renaming parse_contract into parse_contract_data.

To make both functions exactly the same I added a small gas consumption at the beginning, that was lost in some branch in one version only. See updated gas in regression traces.

Manually testing the MR

CI

Checklist

  • Document the interface of any function added or modified (see the coding guidelines)
  • Document any change to the user interface, including configuration parameters (see node configuration)
  • Provide automatic testing (see the testing guide).
  • For new features and bug fixes, add an item in the appropriate changelog (docs/protocols/alpha.rst for the protocol and the environment, CHANGES.rst at the root of the repository for everything else).
  • Select suitable reviewers using the Reviewers field below.
  • Select as Assignee the next person who should take action on that MR
Edited by Mehdi Bouaziz

Merge request reports

Loading