It essentially means you can write programs (contracts) that can (for the most part) solve any reasonable computational problem.
Using Solidity and Serpent you have the ability to perform looping and branching statements as well as local state storage. This functionality is important to have in order to implement most non-trivial computer programs.
Because the Ethereum VM is turing complete, I can technically implement logic in say Python and translate to solidity if I want.
Turing completeness is important for Ethereum smart contracts because you have the ability to implement sophisticated logic.
Where exactly the contract code get stored, i read that it kind of
stores in block chain, so does that mean every node that has a
instance of a full block chain has the contract code too??
The state gets stored in the blockchain, yes. You are also correct in saying that every full-node has a copy of the entire blockchain, including all the states.
Should a miner in order to mine a new block first run all the contract
calls and set the values and then start too looking for POW puzzle
solving and nonce value, and if so then can we have ASIC miners for
ethereum like bitcoin, because they can do only a specific job but
running a contract codes are different every time??
The miners job is to simply solve the POW puzzle. When they do that, they have the ability to mine the block. They now choose which transactions they want included in that specific block. These transactions define all the state changes that were made, so the miner technically doesn't have to look into that.
In terms of the ASIC question, Ethereum POW was designed to be memory-hard, meaning that it is difficult for ASICs to mine.
When a miner wants to verify a transaction which has a contract call
should it run the contract code?? if so, does it mean that each
contract gets to run multiple time until finally one miner can find
the right nonce and solve the pow puzzle? if thats true it means the
contract code gets to run many times unnecessarily?
See my answer above as the answer to this question as well. To summarize, the miner simply chooses a transaction. The reason it doesn't get run multiple times is because there is only one miner that finds the block first and gets rewarded for it. This is the only miner that broadcasts the transaction, as well as the contract calls, to the Ethereum network.
Where does the values of contract variables store, i mean if we have a
solidity mapping it can contains lots of key values, so where does
this key, values stores?? if they store in block chain then they
should be stored in every node that has a copy of block chain which
means a massive data gets to store over and over and over again, and
that would be such a storage waste
See answer one. You are correct—blockchains (as they stand) are quite inefficient and slow, and each node does hold a copy of this state.
When a contract Self-destructs what exactly happens, it mentioned that
the code will be removed from block chain, so does it mean a
transaction make it unavailable for following transactions or it
really really alter the block chain and remove it coded from older
blocks??
It does not alter the blockchain, as that is impossible. What it does do (without getting too technical) is disallows anybody from calling that contract again. The best example to look at is the Parity wallet exploit, as it is a critical example of the usage of selfdestruct
.
Best Answer
Code is run on the blockchain through the use of smart contracts. Each smart contract has an address, storage, and code. When a transaction is sent to a contract's address, it's code is run on every node, inside the Ethereum Virtual Machine (EVM), and the contract can send Ether, call other contracts, and write to it's own storage.
Scaling is handled through the use of gas. Every computational step, even sending a regular transaction or creating a contract, requires some amount of gas (which can be negative for operations like deleting stored data). This gas is sent along with the transaction, and is paid to the miner, and if insufficient gas is provided, all state changes are rolled back.
When a transaction is sent, the user specifies the maximum gas that they are willing to spend, and the price (in Ether per gas) that they are willing to pay for it. Miners are then able to choose to process transactions that provide the highest gas price.
Miners also get to choose the block gas limit
The gas limit determines how much computation and storage can be used per block. On each block, the miner gets to set the new gas limit, but may only increase or decrease the limit by 1/1024th of the previous limit.
This means that miners are able to vote to keep the block sizes small enough to process, and the price of computation is flexible, depending on supply and demand.
Other scaling techniques
Off-chain computation:
State Channels:
More theoreticall stuff: