Skip to content

Proto/Michelson: add the SOURCE_KEY_HASH instruction

Raphaël Cauderlier requested to merge rafoo@michelson_source_key_hash into master

What

Add a variant SOURCE_KEY_HASH of the SOURCE instruction which returns in type key_hash instead of address.

Why

Since protocol Athens' removal of spendable smart contracts, we have the invariant that the source of a contract call is always an implicit account but this is not reflected in the SOURCE instruction which returns a mere address. This invariant can be used for example to check that the sender is an implicit account (with SENDER; SOURCE; ASSERT_CMPEQ) but this is not sufficient when a key_hash is needed, for example to pass as input to VOTING_POWER (see also !12425) or SET_DELEGATE.

Note: this is less generic than !12436 because SOURCE_KEY_HASH could be implemented as SOURCE; IS_IMPLICIT_ACCOUNT; ASSERT_SOME.

How

Straightforward implementation.

Manually testing the MR

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

Merge request reports