This question already has an answer here:
Can someone tell me where smart contracts are actually executed? Is it on the miners or the nodes? Is it run in all miners/nodes, or just one? Also if I declare a variable where is that state persisted? On the blockchain or other storage?