What happens to the state of a smart contract when it is selfdestruct. Are the last state variables still visible on the blockchain afterwards?
If I'm not mistaken, the docs are a little misleading on this point. A lot of danger around the illusion of safe destruction. Immutability wins over "delete". Nothing really gets destroyed.
Blockchain has no concept that corresponds to overwrite like DB or a disk. It can only ever add changes to what it had before. If data, or a contract was ever present, then it always will be present.
The docs say the storage is removed from the state. In a manner of speaking, yes. Possibly it should say "from the easily accessible current state". It doesn't zero out mappings. That is a potentially huge operation that doesn't occur. The blockchain doesn't get any smaller.
The data is still there, and even if the dev goes the extra mile to destroy it, a determined adversary can roll back time to a pre-destruction block, and there it is. As is the "destroyed" contract.
selfdestruct clears all the contract's data, it frees up space on the blockchain (exactly from the current and future state tree (a Merkle patricia tree) not from the previous blocks, the contract bytecode will remain in a old block but its account will be no longer accessible).
we talk about freeing space because there will be no entry for the contract in the state tree(the mapping between the contract's account and its states), but the data is still immutable as it's will be stored in previous blocks.
in other words after selfdestruct the state tree will be updated without the contract states.
after selfdestruct (initial illustration source)
the contract's funds are sent to the address given as parameter to selfdestruct. After calling selfdestruct the sent ethers to such contract are lost.
in the documentation you'll find :
The only possibility that code is removed from the blockchain is when a contract at that address performs the selfdestruct operation. The remaining Ether stored at that address is sent to a designated target and then the storage and code is removed from the state.
According to the http://solidity.readthedocs.io/en/v0.3.1/frequently-asked-questions.html It removes the contract bytecode and storage from the current block into the future, but since the blockchain stores every single block (i.e. all history), this will not actually free up space on full/achive nodes.