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

Remote object call triggers an assumption error #1578

Open
Gungy2 opened this issue Mar 31, 2023 · 0 comments
Open

Remote object call triggers an assumption error #1578

Gungy2 opened this issue Mar 31, 2023 · 0 comments

Comments

@Gungy2
Copy link
Contributor

Gungy2 commented Mar 31, 2023

Describe the error

When calling a remote object method inside a parallelReduce.api_, an assumption error that should not be triggered can be seen.

To Reproduce

const ctcSol = remote(slbContractAddress, SLB);
void ctcSol.transferFrom(this, getAddress(), 5);

const slbsHeld = parallelReduce(5)
     .invariant(balance() > 0)
     .invariant(slbsHeld > 0)
     .while(true)
     .api_(Retailer.buySLBs,
            (volume) => {
                check(volume < slbsHeld, "Cannot buy more SLBs than currently in the pool");

                return [0, (apiReturn) => {
                    void ctcSol.transfer(this, volume);

                    apiReturn(true);
                    return slbsHeld;
                }]
            }
     );

Here SLB is simply an ERC20 (I cannot use a Token interface because I need a more complicated interface later). When Retailer.buySLBs is called with, for example, 2, nothing should be triggered. Instead, at runtime, we get:

Error: Retailer.buySLBs errored with Error: Assertion failed: Retailer_buySLBs: Cannot buy more SLBs than currently in the pool
  at reach standard library:57:5:application
  at ./index.rsh:69:22:application call to "check" (defined at: reach standard library:49:32:function exp)
  at ./index.rsh:67:22:application call to [unknown function] (defined at: ./index.rsh:67:22:function exp)
  at ./index.rsh:67:22:application call to [unknown function] (defined at: ./index.rsh:67:22:function exp)
    at /stdlib/dist/cjs/shared_impl.js:345:34
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Expected behavior

I would expect no error, the program should run normally. When the line void ctcSol.transfer(this, volume); is removed, everything works fine.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant