How Reentrancy Attacks in Smart Contracts Work