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

Deal failing on some tokens on mainnet (e.g. DIGG) #444

Closed
amountin opened this issue Aug 29, 2023 · 1 comment
Closed

Deal failing on some tokens on mainnet (e.g. DIGG) #444

amountin opened this issue Aug 29, 2023 · 1 comment

Comments

@amountin
Copy link

Component

forge-std

Have you ensured that all of these are up to date?

Foundry
Foundryup

What version of Foundry are you on?

forge 0.2.0 (bff4ed9 2023-08-29T00:32:25.634676000Z)

What command(s) is the bug in?

forge test

Operating System

macOS (M2)

Describe the bug

I have not been able to call deal on DIGG token (0x798D1bE841a82a273720CE31c822C61a67a601C3) with error
[FAIL. Reason: stdStorage find(StdStorage): Slot(s) not found.].

To reproduce

pragma solidity ^0.8.19;

import "forge-std/Test.sol";

contract DealTest is Test {
    function testDealDai() public {
        deal(0x6B175474E89094C44Da98b954EedeAC495271d0F, address(1), 100);
    }

    function testDealDigg() public {
        deal(0x798D1bE841a82a273720CE31c822C61a67a601C3, address(1), 100);
    }
}

Stacktrace

[⠊] Compiling...
No files changed, compilation skipped

Running 2 tests for test/executors/DealTest.t.sol:DealTest
[PASS] testDealDai() (gas: 144156)
Traces:
[148369] DealTest::testDealDai()
├─ [2602] 0x6B175474E89094C44Da98b954EedeAC495271d0F::balanceOf(0x0000000000000000000000000000000000000001)
│ └─ ← 0x00000000000000000000000000000000000000000000012f775b3376f86d2167
├─ [0] VM::record()
│ └─ ← ()
├─ [602] 0x6B175474E89094C44Da98b954EedeAC495271d0F::balanceOf(0x0000000000000000000000000000000000000001) [staticcall]
│ └─ ← 0x00000000000000000000000000000000000000000000012f775b3376f86d2167
├─ [0] VM::accesses(0x6B175474E89094C44Da98b954EedeAC495271d0F)
│ └─ ← [0xe90b7bceb6e7df5418fb78d8ee546e97c83a08bbccc01a0644d599ccd2a7c2e0], []
├─ [0] VM::load(0x6B175474E89094C44Da98b954EedeAC495271d0F, 0xe90b7bceb6e7df5418fb78d8ee546e97c83a08bbccc01a0644d599ccd2a7c2e0) [staticcall]
│ └─ ← 0x00000000000000000000000000000000000000000000012f775b3376f86d2167
├─ emit SlotFound(who: 0x6B175474E89094C44Da98b954EedeAC495271d0F, fsig: 0x70a08231, keysHash: 0xada5013122d395ba3c54772283fb069b10426056ef8ca54750cb9bb552a59e7d, slot: 105409183525425523237923285454331214386340807945685310246717412709691342439136 [1.054e77])
├─ [602] 0x6B175474E89094C44Da98b954EedeAC495271d0F::balanceOf(0x0000000000000000000000000000000000000001) [staticcall]
│ └─ ← 0x00000000000000000000000000000000000000000000012f775b3376f86d2167
├─ [0] VM::load(0x6B175474E89094C44Da98b954EedeAC495271d0F, 0xe90b7bceb6e7df5418fb78d8ee546e97c83a08bbccc01a0644d599ccd2a7c2e0) [staticcall]
│ └─ ← 0x00000000000000000000000000000000000000000000012f775b3376f86d2167
├─ [0] VM::store(0x6B175474E89094C44Da98b954EedeAC495271d0F, 0xe90b7bceb6e7df5418fb78d8ee546e97c83a08bbccc01a0644d599ccd2a7c2e0, 0x0000000000000000000000000000000000000000000000000000000000000064)
│ └─ ← ()
└─ ← ()

[FAIL. Reason: stdStorage find(StdStorage): Slot(s) not found.] testDealDigg() (gas: 188200)
Traces:
[188200] DealTest::testDealDigg()
├─ [12304] 0x798D1bE841a82a273720CE31c822C61a67a601C3::balanceOf(0x0000000000000000000000000000000000000001)
│ ├─ [5028] 0x020eb84309243Ed4B8E6C197AF145125dDE4AFDa::balanceOf(0x0000000000000000000000000000000000000001) [delegatecall]
│ │ └─ ← 0x0000000000000000000000000000000000000000000000000000000000000000
│ └─ ← 0x0000000000000000000000000000000000000000000000000000000000000000
├─ [0] VM::record()
│ └─ ← ()
├─ [1804] 0x798D1bE841a82a273720CE31c822C61a67a601C3::balanceOf(0x0000000000000000000000000000000000000001) [staticcall]
│ ├─ [1028] 0x020eb84309243Ed4B8E6C197AF145125dDE4AFDa::balanceOf(0x0000000000000000000000000000000000000001) [delegatecall]
│ │ └─ ← 0x0000000000000000000000000000000000000000000000000000000000000000
│ └─ ← 0x0000000000000000000000000000000000000000000000000000000000000000
├─ [0] VM::accesses(0x798D1bE841a82a273720CE31c822C61a67a601C3)
│ └─ ← [0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103, 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc, 0x000000000000000000000000000000000000000000000000000000000000009f, 0xf4875fff8b0cf986238a93aa5a1c4dd6cdbe2f1045b9974e1f43ef715569af66], []
├─ [0] VM::load(0x798D1bE841a82a273720CE31c822C61a67a601C3, 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103) [staticcall]
│ └─ ← 0x00000000000000000000000020dce41acca85e8222d6861aa6d23b6c941777bf
├─ [0] VM::store(0x798D1bE841a82a273720CE31c822C61a67a601C3, 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103, 0x1337000000000000000000000000000000000000000000000000000000000000)
│ └─ ← ()
├─ [1804] 0x798D1bE841a82a273720CE31c822C61a67a601C3::balanceOf(0x0000000000000000000000000000000000000001) [staticcall]
│ ├─ [1028] 0x020eb84309243Ed4B8E6C197AF145125dDE4AFDa::balanceOf(0x0000000000000000000000000000000000000001) [delegatecall]
│ │ └─ ← 0x0000000000000000000000000000000000000000000000000000000000000000
│ └─ ← 0x0000000000000000000000000000000000000000000000000000000000000000
├─ [0] VM::store(0x798D1bE841a82a273720CE31c822C61a67a601C3, 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103, 0x00000000000000000000000020dce41acca85e8222d6861aa6d23b6c941777bf)
│ └─ ← ()
├─ [0] VM::load(0x798D1bE841a82a273720CE31c822C61a67a601C3, 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc) [staticcall]
│ └─ ← 0x000000000000000000000000020eb84309243ed4b8e6c197af145125dde4afda
├─ [0] VM::store(0x798D1bE841a82a273720CE31c822C61a67a601C3, 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc, 0x1337000000000000000000000000000000000000000000000000000000000000)
│ └─ ← ()
├─ [3273] 0x798D1bE841a82a273720CE31c822C61a67a601C3::balanceOf(0x0000000000000000000000000000000000000001) [staticcall]
│ ├─ [0] 0x0000000000000000000000000000000000000000::balanceOf(0x0000000000000000000000000000000000000001) [delegatecall]
│ │ └─ ← ()
│ └─ ← ()
├─ [0] VM::store(0x798D1bE841a82a273720CE31c822C61a67a601C3, 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc, 0x000000000000000000000000020eb84309243ed4b8e6c197af145125dde4afda)
│ └─ ← ()
├─ [0] VM::load(0x798D1bE841a82a273720CE31c822C61a67a601C3, 0x000000000000000000000000000000000000000000000000000000000000009f) [staticcall]
│ └─ ← 0x00000000021c4670c74db8a66c88be12a956b791789b1ed9d3313f88ac2b9149
├─ [0] VM::store(0x798D1bE841a82a273720CE31c822C61a67a601C3, 0x000000000000000000000000000000000000000000000000000000000000009f, 0x1337000000000000000000000000000000000000000000000000000000000000)
│ └─ ← ()
├─ [1804] 0x798D1bE841a82a273720CE31c822C61a67a601C3::balanceOf(0x0000000000000000000000000000000000000001) [staticcall]
│ ├─ [1028] 0x020eb84309243Ed4B8E6C197AF145125dDE4AFDa::balanceOf(0x0000000000000000000000000000000000000001) [delegatecall]
│ │ └─ ← 0x0000000000000000000000000000000000000000000000000000000000000000
│ └─ ← 0x0000000000000000000000000000000000000000000000000000000000000000
├─ [0] VM::store(0x798D1bE841a82a273720CE31c822C61a67a601C3, 0x000000000000000000000000000000000000000000000000000000000000009f, 0x00000000021c4670c74db8a66c88be12a956b791789b1ed9d3313f88ac2b9149)
│ └─ ← ()
├─ [0] VM::load(0x798D1bE841a82a273720CE31c822C61a67a601C3, 0xf4875fff8b0cf986238a93aa5a1c4dd6cdbe2f1045b9974e1f43ef715569af66) [staticcall]
│ └─ ← 0x0000000000000000000000000000000000000000000000000000000000000000
├─ emit WARNING_UninitedSlot(who: 0x798D1bE841a82a273720CE31c822C61a67a601C3, slot: 110603521963395171899735330315556823543698862821855419343863432992412742037350 [1.106e77])
├─ [0] VM::store(0x798D1bE841a82a273720CE31c822C61a67a601C3, 0xf4875fff8b0cf986238a93aa5a1c4dd6cdbe2f1045b9974e1f43ef715569af66, 0x1337000000000000000000000000000000000000000000000000000000000000)
│ └─ ← ()
├─ [1804] 0x798D1bE841a82a273720CE31c822C61a67a601C3::balanceOf(0x0000000000000000000000000000000000000001) [staticcall]
│ ├─ [1028] 0x020eb84309243Ed4B8E6C197AF145125dDE4AFDa::balanceOf(0x0000000000000000000000000000000000000001) [delegatecall]
│ │ └─ ← 0x000000000000000000000000000000000000000000000000000000091ac85ff4
│ └─ ← 0x000000000000000000000000000000000000000000000000000000091ac85ff4
├─ [0] VM::store(0x798D1bE841a82a273720CE31c822C61a67a601C3, 0xf4875fff8b0cf986238a93aa5a1c4dd6cdbe2f1045b9974e1f43ef715569af66, 0x0000000000000000000000000000000000000000000000000000000000000000)
│ └─ ← ()
└─ ← "stdStorage find(StdStorage): Slot(s) not found."

Test result: FAILED. 1 passed; 1 failed; 0 skipped; finished in 3.20s
Ran 1 test suites: 1 tests passed, 1 failed, 0 skipped (2 total tests)

Failing tests:
Encountered 1 failing test in test/executors/DealTest.t.sol:DealTest
[FAIL. Reason: stdStorage find(StdStorage): Slot(s) not found.] testDealDigg() (gas: 188200)

Encountered a total of 1 failing tests, 1 tests succeeded

@mds1
Copy link
Collaborator

mds1 commented Aug 29, 2023

As you can see in L589 of the implementation, the DIGG contract's balanceOf method dynamically computes the balance to return (like a rebase token), whereas the deal cheat only supports tokens that return balanceOf by reading a value directly form a storage slot, because deal works by changing the value in the balanceOf storage slot. As a result this token is not currently supported by forge-std, similar to #140

As a workaround you can find an DIGG whale from etherscan, prank as that user, and transfer tokens to any address you need.

Going to close as a duplicate of #140

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

2 participants