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

"Unknown Contract at address <address>" inside the debugger #2348

Closed
2 tasks done
HrikB opened this issue Jul 16, 2022 · 10 comments
Closed
2 tasks done

"Unknown Contract at address <address>" inside the debugger #2348

HrikB opened this issue Jul 16, 2022 · 10 comments
Assignees
Labels
C-forge Command: forge Cmd-forge-debug Command: forge run T-bug Type: bug
Milestone

Comments

@HrikB
Copy link

HrikB commented Jul 16, 2022

Component

Forge

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (153ae19 2022-06-26T00:04:15.775569508Z)

What command(s) is the bug in?

forge test --debug

Operating System

Windows

Describe the bug

I am unable to get the contract solidity code to show up in the debugger:
image

@HrikB HrikB added the T-bug Type: bug label Jul 16, 2022
@gakonst gakonst added this to Foundry Jul 16, 2022
@gakonst gakonst moved this to Todo in Foundry Jul 16, 2022
@HrikB HrikB changed the title "Unknown Contract as address <address>" inside the debugger "Unknown Contract at address <address>" inside the debugger Jul 16, 2022
@onbjerg
Copy link
Member

onbjerg commented Jul 16, 2022

Can you provide more context? What contract do you expect this to be?

@onbjerg onbjerg added C-forge Command: forge Cmd-forge-debug Command: forge run labels Jul 16, 2022
@HrikB
Copy link
Author

HrikB commented Jul 16, 2022

This is the contract I am testing:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {ClonesUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/ClonesUpgradeable.sol";
import {ContextUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";

/**
 * @dev ERC1167 Minimal Proxy Factory
 */
contract ERC1167Factory is ContextUpgradeable {
    using AddressUpgradeable for address;

    event NewClone(address instance, address implementation, bytes32 salt);

    function clone(address implementation, bytes memory data)
        public
        returns (address instance)
    {
        instance = ClonesUpgradeable.clone(implementation);

        //data is optional
        if (data.length > 0)
            instance.functionCall(
                data,
                "ERC1167Factory: Failed to call the proxy"
            );

        emit NewClone(instance, implementation, bytes32(0));
    }

    function cloneDeterministic(
        address implementation,
        bytes32 salt,
        bytes memory data
    ) public returns (address instance) {
        //Salt init data
        salt = keccak256(abi.encodePacked(salt, _msgSender(), data));
        instance = ClonesUpgradeable.cloneDeterministic(implementation, salt);

        //data is optional
        if (data.length > 0)
            instance.functionCall(
                data,
                "ERC1167Factory: Failed to call the proxy"
            );

        emit NewClone(instance, implementation, salt);
    }

    function predictDeterministicAddress(
        address implementation,
        bytes32 salt,
        bytes memory data
    ) public view returns (address predicted) {
        //Salt init data
        salt = keccak256(abi.encodePacked(salt, _msgSender(), data));
        predicted = ClonesUpgradeable.predictDeterministicAddress(
            implementation,
            salt
        );
    }
}

This is the test contract:

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "forge-std/Test.sol";
import "forge-std/console.sol";

import "../../contracts/proxy/ERC1167/ERC1167Factory.sol";
import "../../contracts/assets/ERC721/ERC721Owl.sol";

contract ERC1167FactoryTest is Test {
    uint256 constant allE =
        108072616621495115728666252674775380663051985687931193103493745074052254330606;

    ERC1167Factory c;
    ERC721Owl impl;

    function setUp() public {
        c = new ERC1167Factory();
        impl = new ERC721Owl();
    }

    function testCloneDeterministic() public {
        c.cloneDeterministic(
            address(impl),
            bytes32(abi.encode(0)),
            abi.encodeWithSignature(
                "initialize(address,string,string,string,address)",
                address(0),
                "name",
                "symbol",
                "uri",
                address(0)
            )
        );
    }
}

The command I am running is: forge test --debug "testCloneDeterministic()"

@onbjerg
Copy link
Member

onbjerg commented Jul 16, 2022

You are not at PC 0, so this is later during execution. I need to know what contract you expect to be in at that point in the program

@HrikB
Copy link
Author

HrikB commented Jul 16, 2022

This is PC 0
image

@HrikB
Copy link
Author

HrikB commented Jul 16, 2022

I've never had that part show up correctly... always says unknown contract

@onbjerg
Copy link
Member

onbjerg commented Jul 16, 2022

Does any part of the debugger show correct contracts? If you run the test with -vvvvv does the trace show the contracts as well?

@HrikB
Copy link
Author

HrikB commented Jul 16, 2022

Yes -vvvvv does show contracts but they are at different addresses than what the debugger is trying to display
image

@HrikB
Copy link
Author

HrikB commented Jul 16, 2022

Debugger trying to display 0x5b73c549... for some reason... this doesn't change

@onbjerg
Copy link
Member

onbjerg commented Jul 16, 2022

0x5b73c549 is probably the test contract itself which you don't see in traces

@onbjerg onbjerg self-assigned this Aug 11, 2022
@onbjerg onbjerg added this to the v1.0.0 milestone Aug 11, 2022
@onbjerg
Copy link
Member

onbjerg commented Aug 23, 2022

Closing this since I can't reproduce it, but feel free to reopen if this is still the case with some more context 😄

@onbjerg onbjerg closed this as completed Aug 23, 2022
Repository owner moved this from Todo to Done in Foundry Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge Cmd-forge-debug Command: forge run T-bug Type: bug
Projects
Archived in project
Development

No branches or pull requests

2 participants