TezosTaqueria / taqueria

*BETA* Taqueria provides a seamless development workflow to easily build, test and deploy your Tezos applications.
https://taqueria.io
Apache License 2.0
64 stars 20 forks source link

๐Ÿ› Bug โžพ Cannot use taq call when I have one entrypoint named default #1931

Open zamrokk opened 9 months ago

zamrokk commented 9 months ago

๐Ÿšฅ Status (Internal Taqueria Team Use Only)

๐Ÿ†˜ What happened?

I found a crappy corner case while running taq call. I suppose that Taqueria works as it : compile the parameter in ligo to a .tz Michelson call octez-cli on default entrypoint with this Michelson parameter It works on 99% of the time, because there is a corner case : the default entrypoint ! If we have a contract having multiple entrypoints and 1 of thses entrypoints is named default, then Taqueria will pass the compiled parameter as it to the default entrypoint like it will dispatch it (i.e the current behavior of a main function). In our case it does not work , because the default entrypoint is not a main dispatcher function, but a real entrypoint with Unit as parameter for example, to be able to receive Tez... yes this is the way a contract can receive XTZ using a simple transfer command. What happen ? If I try to call any other entrypoint, the node will not like it as the param sent by Taq does not match the default entrypoint signature Ex :

"expected_type": {
        "prim": "unit"
      },
      "wrong_expression": {
        "prim": "Right",
        "args": [
          {
            "prim": "Unit"
          }
        ]
      }
    },

So what should be done instead ? Call with the --entrypoint argument and skip the Right / Left directives on --arg , like below octez-client transfer 0 from alice to KT1NKLZE9HkGJxjopowLqxA4pswutgMrrXyE --entrypoint attack --arg 'Unit' --burn-cap 1

๐Ÿ†˜ Steps to Reproduce?

It is part of my current work here : https://github.com/marigold-dev/training-security-2/blob/main/contracts/3-reentrancyMaliciousContract.parameterList.jsligo Look at the project Readme.md on Chapter 3 At the end , I will run theoctez-cli octez-client transfer 0 from alice to KT1NKLZE9HkGJxjopowLqxA4pswutgMrrXyE --entrypoint attack --arg 'Unit' --burn-cap 1 instead of taq call Taq call should be : taq call 3-reentrancyMaliciousContract --param 3-reentrancyMaliciousContract.parameter.default_parameter.tz -e testing Taqueria will work "as design" but the contract is a bit special here ... Look at line 21 (https://github.com/marigold-dev/training-security-2/blob/main/contracts/3-reentrancyMaliciousContract.jsligo#L21) If Taqueria is not passing the entrypoint name on the octez-cli , it will never work :/

๐Ÿชต Relevant log output

No response

๐Ÿ˜ How impactful is this bug?

None

โฑ๏ธ Prevalance

No response

๐Ÿ’ป Operating System

None

๐Ÿ•ธ๏ธ System Architecture

None

๐ŸŒฎ Taqueria Version

No response

๐ŸŒฟ Node.js Version

No response

โ˜Ž๏ธ Contact Details

No response

Code of Conduct