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

Should be able to interact with a contract that has self destructed at a blockTag when it existed #411

Closed
area opened this issue Feb 1, 2019 · 5 comments
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published.

Comments

@area
Copy link

area commented Feb 1, 2019

The historical state of the blockchain is of interest, and I greatly appreciate you adding the blockTag parameter as a first class citizen for that reason. However, if I attempt to .call a function on a contract that has since self-destructed, even if I pass a blockTag when it did exist, I get an error:

Error: contract not deployed (contractAddress="0x62808F3d4b19AB63703d4750AEeA2a9B25C29574", operation="getDeployed", version=4.0.20)

Our tests pass as expected with these changes, passing blockTag through to the getCode that checks the contract exists before trying to query it, though I certainly don't claim this is a sufficient commit as I'm pretty unfamiliar with the codebase.

For completeness, this is the same issue @elenadimitrova raised in gitter here, which you replied to here but we didn't pick up again - sorry about that!

EDIT: While I've not tried it, presumably there is also some unexpected behaviour if I try and query a contract that currently exists at a blockTag before it was deployed?

@ricmoo
Copy link
Member

ricmoo commented Feb 2, 2019

Good point; today too far longer than expected to knock out #405, but I will look into this early next week. I still have a few other tasks I want to focus on first, but this seems like a completely reasonable issue. :)

I need to catch up on the Gitter channel too...

@ricmoo ricmoo added investigate Under investigation and may be a bug. on-deck This Enhancement or Bug is currently being worked on. labels Feb 2, 2019
@ricmoo
Copy link
Member

ricmoo commented Feb 12, 2019

I'm adding the test case here to incorporate in the future:

Solidity:

contract Test {
    function sixTimesEight() public pure returns (uint256) {
        return 42;
    }

    function bArk() public {
        selfdestruct(0x58Bb4221245461E1d4cf886f18a01E3Df40Bd359);
    }
}

JavaScript:

let bytecode = "0x608060405234801561001057600080fd5b5060e68061001f6000396000f3fe6080604052600436106043576000357c0100000000000000000000000000000000000000000000000000000000900480631ce81ee5146048578063348fbafa146070575b600080fd5b348015605357600080fd5b50605a6084565b6040518082815260200191505060405180910390f35b348015607b57600080fd5b506082608d565b005b6000602a905090565b7358bb4221245461e1d4cf886f18a01e3df40bd35973ffffffffffffffffffffffffffffffffffffffff16fffea165627a7a7230582024f4e3896c9eca7185a319613686484f2f94e811aaf3fc82d56da8252dbed2820029"
let abi = [
    "function sixTimesEight() public pure returns (uint256)",
    "function bArk() public"
];

let provider = new ethers.providers.InfuraProvider("ropsten");
let signer = new ethers.Wallet(privateKey, provider);

/*
// Deploy Contract: Block 5000956
// See: https://ropsten.etherscan.io/address/0xEA3EcF5dF30eE4421aA32B380c383D06d58e5Abc
let factory = new ethers.ContractFactory(abi, bytecode, signer);
factory.deploy().then((contract) => {
    console.log(contract);
});
*/

let contractAddres = "0xEA3EcF5dF30eE4421aA32B380c383D06d58e5Abc";

/*
// Self-Destruct the Contract: Block 5001043
let contract = new ethers.Contract(contractAddress, abi, provider);
contract.bArk().then((tx) => {
    console.log(tx);
});
*/

let contract = new ethers.Contract(contractAddress, abi, provider);

// Should Succeed
contract.sixTimesEight({ blockTag: 5001035 }).then((result) =>{
    console.log("Result=5001035:", result);
}, (error) => {
    console.log("Error=5001035:", error);
});

// Should Fail
contract.sixTimesEight().then((result) =>{
    console.log("Result:", result);
}, (error) => {
    console.log("Error:", error);
});

@ricmoo ricmoo added bug Verified to be an issue. and removed investigate Under investigation and may be a bug. labels Feb 12, 2019
@ricmoo
Copy link
Member

ricmoo commented Feb 12, 2019

This is fixed in 4.0.25. Try it out and let me know if you still have any problems.

Thanks! :)

@ricmoo ricmoo removed the on-deck This Enhancement or Bug is currently being worked on. label Feb 12, 2019
@ricmoo ricmoo closed this as completed Feb 12, 2019
@elenadimitrova
Copy link

Thanks @ricmoo this issue is fixed but we are experience some significant performance degradation after the upgrade. Investigating now.

@ricmoo
Copy link
Member

ricmoo commented Feb 15, 2019

Yikes! Please let me know what you find. Nothing that affects performance should have changed for this... What is slower?

@ricmoo ricmoo added the fixed/complete This Bug is fixed or Enhancement is complete and published. label Jan 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified to be an issue. fixed/complete This Bug is fixed or Enhancement is complete and published.
Projects
None yet
Development

No branches or pull requests

3 participants