Questions: Contract Verification (Blockchain)

4 questions to test your understanding

Score: 0 / 4
Question 1 Short Answer

The 'reentrancy bug' in the DAO contract (2016) allowed an attacker to withdraw funds repeatedly. In pseudo-code: function withdraw(amount) { if (balance[msg.sender] >= amount) { call(msg.sender).send(amount); balance[msg.sender] -= amount; } }. Why is this vulnerable?

Think about your answer, then reveal below.
Question 2 Short Answer

A formal specification for a smart contract token might state: 'the total supply of tokens is immutable — the sum of all balances equals the initial supply.' How would you formally verify this invariant?

Think about your answer, then reveal below.
Question 3 Multiple Choice

Contracts interact with other contracts through external calls. If contract A calls contract B, and B calls back to A, how does formal verification ensure no reentrancy occurs?

AReentrancy is impossible on blockchains, so no verification is needed
BVerification establishes an invariant (e.g., a lock or state flag) that prevents recursion. Before calling external code, the contract sets a state flag (locked = true). External calls cannot reenter because the flag prevents re-execution of the critical section. The proof shows that the lock is always set before external calls and released after
CVerification randomly tests the contract with concurrent calls
DReentrancy must be prevented by manually auditing code
Question 4 Short Answer

Many contract verification efforts focus on 'functional correctness' (the contract does what it's supposed to do) but overlook 'economic properties' (incentives are sound). Why is verifying economic properties harder?

Think about your answer, then reveal below.