Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 of 6 tasks
zamrokk opened this issue Dec 4, 2023 · 0 comments
Open
1 of 6 tasks
Labels
bug Something isn't working triage Requires triage

Comments

@zamrokk
Copy link

zamrokk commented Dec 4, 2023

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

  • ๐Ÿ”ฌ Investigated and Verified
  • โš—๏ธ Solution Identified and Designed
  • ๐Ÿงซ Dev Implementation of Fix
  • ๐Ÿงช Fix Tested and Validated
  • ๐Ÿ† PR Merged

๐Ÿ†˜ 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 the octez-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

  • I agree to follow this project's Code of Conduct
@zamrokk zamrokk added bug Something isn't working triage Requires triage labels Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Requires triage
Projects
None yet
Development

No branches or pull requests

1 participant