[go: up one dir, main page]

`prepare multisig transaction` serializes lambdas incompatibly

The generic multisig uses PACK and CHECK_SIGNATURE.

PACK converts everything to Optimized, including lambda bodies (and CREATE_CONTRACT scripts!) That seems questionable, especially given past bugs, but that's the way it is.

The command prepare multisig transaction ... running lambda ... serializes its lambda input directly; it does not convert to Optimized like PACK. As a result, it will produce incompatible payloads whenever the provided lambda uses some Readable notation. Signatures of these incompatible payloads will always be rejected by the multisig.

Here is an example shell script which demonstrates the problem.

#!/bin/bash
BASE_DIR=/tmp/multisig_testlambdas
rm $BASE_DIR -rf

function client() {
    tezos-client --base-dir $BASE_DIR --mode mockup "$@"
}

client create mockup
client deploy multisig testlambdas transferring 100 from bootstrap1 with threshold 1 on public keys bootstrap1 --burn-cap 0.3
TO_SIGN=$(client prepare multisig transaction on testlambdas running lambda '{ DROP; PUSH address "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx"; DROP; NIL operation; }' --bytes-only)

echo "TO_SIGN"
echo $TO_SIGN

BOOTSTRAP1_S_SIGNATURE=$(client sign bytes "$TO_SIGN" for bootstrap1 | cut -d ' ' -f 2)
client run transaction "$TO_SIGN" on multisig contract testlambdas on behalf of bootstrap1 with signatures "$BOOTSTRAP1_S_SIGNATURE"

Comparing the signed vs expected payloads:

$ ./tezos-client --mode mockup unpack michelson data 0x05070707070a00000004f3d485540a0000001601837f0395710c2a11905c516da56cebc1ce08042100070700000505020000002703200743036e0a00000016000002298c03ed7d454a101eb7022bc95f7e5f41ac780320053d036d
Pair (Pair 0xf3d48554 0x01837f0395710c2a11905c516da56cebc1ce08042100)
     (Pair 0
           (Left { DROP ;
                   PUSH address 0x000002298c03ed7d454a101eb7022bc95f7e5f41ac78 ;
                   DROP ;
                   NIL operation }))
$ ./tezos-client --mode mockup unpack michelson data 0x05070707070a00000004f3d485540a0000001601837f0395710c2a11905c516da56cebc1ce08042100070700000505020000003503200743036e0100000024747a314b715470455a37596f62375162504534487934576f38664847384c684b785a53780320053d036d
Pair (Pair 0xf3d48554 0x01837f0395710c2a11905c516da56cebc1ce08042100)
     (Pair 0
           (Left { DROP ;
                   PUSH address "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" ;
                   DROP ;
                   NIL operation }))
Edited by Tom Jack