Curriculum·Graduate·G302

The EVM: Gas, Calls, and Reverts

GovernMental, 2016. GovernMental was a Ponzi-style game that kept a growing list of every participant, and paying out required looping over and clearing that entire list.

Taught in G302-01 ›Source ↗

Start with lesson 14 lessons · about 2.3 hours · free account to read in full

Lesson 1 opens on

GovernMental, 2016

GovernMental was a Ponzi-style game that recorded every participant in growing lists stored on-chain, and paying out a round required looping over and clearing those entire lists. Each step of that loop cost gas, and the total gas for the operation rose as the lists grew, until it exceeded the maximum gas that could fit in a single block. At that point the payout transaction could no longer be included in any block at all, because no block had room for it, so roughly 1,100 ether sat in a contract that could not run its own payout logic.

The lessons

  1. G302-01The EVM executes, and it charges gasExplain that every EVM operation costs gas and that gas per block is cappedabout 34 min · opens on GovernMental, 2016
  2. G302-02An external call can fail, and returns a valueExplain that a low-level value transfer forwards limited gas, can fail, and returns a success valueabout 34 min · opens on The King of the Ether Throne, 2016
  3. G302-03Reentrancy: the call that calls backExplain that an external call can call back into your contract before its state is updatedabout 33 min · opens on SpankChain, October 2018
  4. G302-04Arithmetic: overflow, and why the checks existExplain that fixed-size integers wrap around on overflow and underflow rather than growingabout 34 min · opens on The SMT proxyOverflow, 2018