aeternity / aesophia

Stand alone compiler for the Sophia smart contract language
https://docs.aeternity.com/aesophia
ISC License
51 stars 19 forks source link

[Ceres] Can't decode contract return value including AENS raw pointer #498

Closed davidyuk closed 7 months ago

davidyuk commented 7 months ago

I've registered a name and set a raw pointer using a delegation signature (probably this is not important). Node's /name/ endpoint returned pointers correctly.

Then I deployed a contract that lookups name, and requested details of the previously registered name. Then I tried to decode the return value, but aesophia failed with the below error.

aesophia_cli binary is built on the top of https://github.com/aeternity/aesophia_cli/tree/ceres with aesophia switched to a1c9517ce66d9062a71bcc52ead12135b08979f5.

@compiler >= 6

main contract Test =
    entrypoint getName(name: string): option(AENSv2.name) = AENSv2.lookup(name)
$ ./aesophia_cli ./Reproduction.aes --call_result_fun "getName"  --call_result "cb_r4IAAQEbrwMAO58AoIH4eKgXxJ6Ktj+Sp+ebis4D5HS5wCEKuy9iT0F/Yx9kr4IBAQEbb4MCxaQvAhlvcmFjbGWvhQEBAQEBARufAKBm3bjOHJpnGQwXBFf5OHorRBYsSVY+zZW+WJkgVVbrOyF0ZXN0IGtlea+FAQEBAQEEG1F0ZXN0IHZhbHVldGVzdCB2YWx1ZTfNwTI="
Data error:
Cannot translate FATE value {variant,
                             [0,1],
                             1,
                             {{variant,
                               [3],
                               0,
                               {{address,
                                 <<129,248,120,168,23,196,158,138,182,63,146,
                                   167,231,155,138,206,3,228,116,185,192,33,
                                   10,187,47,98,79,65,127,99,31,100>>},
                                {variant,[1,1],1,{181732}},
                                #{<<"oracle">> =>
                                   {variant,
                                    [1,1,1,1,1],
                                    1,
                                    {{address,
                                      <<102,221,184,206,28,154,103,25,12,23,
                                        4,87,249,56,122,43,68,22,44,73,86,
                                        62,205,149,190,88,153,32,85,86,235,
                                        59>>}}},
                                  <<"test key">> =>
                                   {variant,
                                    [1,1,1,1,1],
                                    4,
                                    {<<"test valuetest value">>}}}}}}}
  of Sophia type option(AENSv2.name)

works correctly without DataPt:

$ ./bin/aesophia_cli ./contracts/Reproduction.aes --call_result_fun "getName"  --call_result "cb_r4IAAQEbrwMAO58AoMKGQdJqGPP8r2M3KZMY9/LqftwqiL7s+U/hhEwRgu82r4IBAQEbb4MCxw8vARlvcmFjbGWvhQEBAQEBARufAKAP6MnWPb0/4Yn/o6520i5kR4v2l3WeQiH6PY9Yab+hLEPV1XM="
Decoded call result:
Some(AENSv2.Name(ak_2UfsDWdAUorKTEYPDry6sS6oqtGko62E5H96C2SUJ9gNEA5n8P,
                 FixedTTL(182095),
                 {["oracle"] =
                    AENSv2.OraclePt(ak_81PBepLRGw1MQRK7vue3LdtQSygxH3fxAQjprfTvRfRJSFLmr)}))
hanssv commented 7 months ago

Not a compiler issue, FATE (VM version 3) did return the old thing (containing a string value).