Skip to content

Sapling smart contract compatibility

Danny Willems requested to merge sapling-sc-compatibility into sapling-integration

Intro

This MR fixes/implements features previously discussed offline and/or in issues.

  • client commands only compatible with the shielded-tez contract have been prefixed with sapling shielded-tez. Examples:
    • tezos-client sapling shielded-tez shield
    • tezos-client sapling shielded-tez unshield
    • tezos-client sapling shielded-tez submit

EDIT: After discussion, it has been decided to not add commands with shielded-tez in the name to avoid confusion.

  • some encodings have been registered with Data_encoding.Registration.register. It is used by tezos-codec (see tezos-codec list encodings). It is not fully documented. I would leave it for another MR IMO
  • https://gitlab.com/cryptiumlabs/tezos/-/commit/fe35db537c0db9912f4e6b13aaf691280c5bef60 is from master. Hence no conflict later. I included it to be able to use with the public node running sapling on sapling.tezos.badaas.be.
  • tezos-client sapling forge ... outputs only a sapling transaction and not like previously a pair. The binary output is the micheline representation of the sapling transaction, which can be used directly in the --arg argument of tezos-client transfer 0 from account to shielded-tez --arg .... The last python test shows an example.

Giving the micheline representation in the forge command is a requirement for other smart contract compatibility. The forge command is now focused on building a single sapling transaction object. I haven't tried it yet but it allows to use the client to forge sapling transaction independently from the shielded-tez smart contract and allows to call other smart contract using the usual tezos-client transfer command. This is for another MR.

How to test

To test, you can use:

eval `./src/bin_client/tezos-init-sandboxed-client.sh 1 sapling.tezos.badaas.be`
tezos-client sapling import key test_key_name \
  --mnemonic 'ecology basic over impose movie ten party kiwi certain arrest decline abandon inspire picture rotate spare chair pond crucial subject soon differ connect actual' \
  --unencrypted
tezos-client remember contract shielded-tez KT1EAxkMZJCDMir7VF3wCaDyeref88nZo6uL
tezos-client sapling use key test_key_name for contract shielded-tez
# May require some shielding before.
tezos-client sapling forge transaction 1 from test_key_name to zet13yz6m1RTCrRtqMyyPzyoJNzF42D3b2VpJ1uPeSyGXHKH7Bvj4akc2pSVvx3DuQyzC using shielded-tez --file sapling_transaction.bin

cat sapling_transaction.bin should give you the hexadecimal encoding of the micheline representation of the sapling transaction. The option --json can be added to the forge transaction to get the JSON representation. To submit the transaction, you use the tezos-client sapling shielded-tez submit command.

Edited by Danny Willems

Merge request reports