Smart Contract Bug: Reentrancy Attacks and How to Fix Them