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

Nested startPrank() doesn't work #420

Closed
igorganich opened this issue Nov 28, 2024 · 4 comments
Closed

Nested startPrank() doesn't work #420

igorganich opened this issue Nov 28, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@igorganich
Copy link

Describe the bug
In foundry testing, we can use nested startPrank():

startHoax(deployer, 1 << 80);
...
vm.startPrank(alice);
vm.stopPrank(); // stop alice prank
vm.stopPrank(); // stop deployer prank

But in Halmos it leads to crash:

WARNING:halmos:Warning: setUp() execution encountered an issue at CALL: <function error at 0x7fb7a4c2cae0> 

To Reproduce

  1. checkout on igorganich/damn-vulnerable-defi-halmos@f44a686
  2. halmos --solver-timeout-assertion 0 --function check_theRewarder
  3. Wait, setUp() in this test in quite long
    Environment:
  • ubuntu wsl
  • Python 3.12.3
  • halmos 0.2.2.dev1+gd4cac2e
@igorganich igorganich added the bug Something isn't working label Nov 28, 2024
@daejunpark
Copy link
Collaborator

if i remember correctly, foundry previously didn't allow nested pranks, but it seems the behavior has changed.

i'm curious whether allowing nested pranks are intentional. it seems potentially confusing and prone to making mistakes. could you please provide a pointer to other use cases of nested pranks or the rationale behind them?

@igorganich
Copy link
Author

if i remember correctly, foundry previously didn't allow nested pranks, but it seems the behavior has changed.

i'm curious whether allowing nested pranks are intentional. it seems potentially confusing and prone to making mistakes. could you please provide a pointer to other use cases of nested pranks or the rationale behind them?

@daejunpark
I can agree that nested pranks may be not so important to implement it at all. But, since there may be such tests, we can imagine a scenario when user spends some time (for example, I spent about an hour to fix it :)) when migrating test from foundry to halmos.
So I think this thing deserves to have some explicit warning. Smth like "Halmos does not support nested pranks).

@karmacoma-eth karmacoma-eth self-assigned this Dec 11, 2024
@karmacoma-eth
Copy link
Collaborator

in a test function, this fails with the expected error message:

    function test_nestedPrank() external {
        vm.startPrank(address(0));
        vm.startPrank(address(0));
    }

(sort of)

WARNING  Encountered You have an active prank already.                                                                                                                                                                                                                                                        
         (see https://github.com/a16z/halmos/wiki/warnings#internal-error)

But in setUp(), the message is lost:

WARNING  Warning: setUp() execution encountered an issue at CALL: <function error at 0x10201fec0>                                                                                                                                                                                                             
         (see https://github.com/a16z/halmos/wiki/warnings#internal-error)                                                                                                                                                                                                                                              
ERROR    Error: setUp() failed: HalmosException: No successful path found in setUp()         

karmacoma-eth added a commit that referenced this issue Dec 12, 2024
@karmacoma-eth
Copy link
Collaborator

I think we'd be happy if an external contributor added support for nested pranks (would need to change our Prank object to be a stack instead of a single value), but for now we'll focus on prioritizing core features.

I'll close this for now after fixing the error message in #428

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants