I am thinking about a scenario, where an attacker modifies my local blockchain. However, since if one block is modified and then all subsequent blocks are required to re-mine. So, the attacker chooses to change the last block of my local blockchain. Then, a new transaction arrived and the hash of last block can't be matched with "the previous block hash" value in new transaction. What will happen now? Will the blockchain reject every new transaction?
1 Answer
I don’t think this would be defined in the Ethereum specification. As such, the result is implementation specific. In any case, I have not tested my answer; the below is speculative.
Given the protocol specified that the longest chain is valid, as long as the attacker can prevent your node from re-checking history (e.g., by continually mining faster than the legitimate chain) the attacker can choose to censor transactions and receive all the ether generated on the fake chain. The attacker can’t steal ether aside from anything in the manipulated block (not entirely true - depends on the manipulations) because the attacker can’t impersonate other users (I.e. sign transactions as other existing users) given your attacker capability description.
If the attacker cannot keep your node from reorganizing the blockchain, your node software should eventually pick up the longer chain (again, implementation-specific optimizations may prevent this from happening, e.g., via caching or memoization). When the longer chain (from a normally mined new block) is found, the node should go back and check the validity of this new chain; it will eventually find the falsified block and just treat it as a fork point and re-org the chain. Thus, such an attack is likely to have only a very limited period of effectiveness; waiting for a few blocks to be mined should likely lead to self-correction.