-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Comments
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... |
I'm adding the test case here to incorporate in the future: Solidity:
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);
}); |
This is fixed in Thanks! :) |
Thanks @ricmoo this issue is fixed but we are experience some significant performance degradation after the upgrade. Investigating now. |
Yikes! Please let me know what you find. Nothing that affects performance should have changed for this... What is slower? |
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 ablockTag
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 thegetCode
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?
The text was updated successfully, but these errors were encountered: