21 Matching Annotations
  1. Feb 2022
  2. ethernaut.openzeppelin.com ethernaut.openzeppelin.com
    1. uint32(uint64(_gateKey)) == uint16(tx.origin)

      the _gateKey should be the tx.origin parsed as uint16

    2. require(uint32(uint64(_gateKey)) != uint64(_gateKey),

      _gateKey that is not converted to either uint32 or uint16 should be different to the uint64 version

    3. require(uint32(uint64(_gateKey)) == uint16(uint64(_gateKey)),

      _gateKey should be able to be converted to both uint32 and uint16 without information loss

    4. require(gasleft().mod(8191) == 0);

      Presumably we should send gas in multiples of 8191?

    5. require(msg.sender != tx.origin);

      tx.origin is the originator of a contract call, no matter how many contracts sit in between it and the final destination. msg.sender is the most recent sender of the call. We can handle this condition by creating 2 contracts.

  3. ethernaut.openzeppelin.com ethernaut.openzeppelin.com
    1. balances[msg.sender] -= _amount;

      Our balance isn't reduced until here, leaving the door open to reenter the contract in the msg.sender.call

    2. (bool result,) = msg.sender.call{value:_amount}("");

      Violates checks-effects-interactions. Call is to payable address backup or receive function

  4. ethernaut.openzeppelin.com ethernaut.openzeppelin.com
    1. king.transfer(msg.value);

      This function violates the checks-effects-interact pattern by including a call to an external contract before state variables are changed.

  5. ethernaut.openzeppelin.com ethernaut.openzeppelin.com
    1. uint256(blockhash(block.number.sub(1)))

      get the previous block's number, get the hash of that block, and convert to uint256, then assign to the variable blockValue.

      If the placeholder lastHash is equal to blockValue, we are in the same block and the call to flip will revert.

      Otherwise, update lastHash to equal blockValue (thus storing the record of the block)

    2. blockhash

      get the hash of the given block (only works for 256 most recent blocks, excluding current)

    3. block.number

      Current block number

  6. ethernaut.openzeppelin.com ethernaut.openzeppelin.com
    1. modifier onlyOwner { require( msg.sender == owner, "caller is not the owner" ); _; }

      If a function is annotated with the onlyOwner modifier, the sender of the transaction must be the owner otherwise the tx will revert.

    2. receive() external payable { require(msg.value > 0 && contributions[msg.sender] > 0); owner = msg.sender; }

      By sending any amount of Ether to the contract once your contributions are more than 0, you will become the owner of the contract and can withdraw all of the tokens

    3. function contribute() public payable {

      Anyone can call this function, and can send ether to the function

    4. mapping(address => uint) public contributions;

      We're storing user contributions, mapping an address to the amount of the contribution

    5. using SafeMath for uint256;

      SafeMath is used to prevent over / underflows

  7. Feb 2019
    1. For that reason, “overuse” of the internet and social media today may not be such a bad thing. It is our primary way of exploring all of the potential of that cultural mode, and that mode will at some point be tamed and neutered, just as Baroque music composition is now dormant.

      I don't think that we can so easily equate a Baroque music fad with internet & social media addiction - it feels like a genuinely different mode of human interaction that is causing large, potentially negative changes in our societies at a core level.

    2. That would have some positive effects on gdp in the short run, but its major effects would be in the much longer run, namely the prevention of a very destructive war.

      As far as I understand most large, destructive wars have led to large jumps in technological prowess that has eventually 'trickled down' to the consumer market & society in general, raising GDP in the process (think the internet, jet propulsion, lasers, reconstructive surgery, etc)

  8. Sep 2018
    1. it executes before the browser’s next style/layout calculation step.

      requestAnimationFrame allows for fluid and predictable execution.

    2. Broadly speaking, a setTimeout(0) doesn’t really run in zero milliseconds. Usually, it runs in 4.

      The 0 in a setTimeout(0) call is actually only a minimum amount of time - due to the Event Loop cycles the 0 call will usually run in no less than 4ms.

    3. It's important to understand that in the Event Loop there are Tasks & Microtasks. The Microtask queue is exhausted before returning to the Task queue - and Microtasks can queue other Microtasks, hance why the for loop in this example will block any other execution.