title: Remix Web3 Provider: Out of Gas - Ethereum Ganache and TestRPC
body: <p>I'm having an issue with ganache and testRPC where I keep getting an <code>out of gas</code> error only when using the web3 provider but not when using Javascript VM or from truffle javascript tests.</p>
  
  <p>My mappings are set up like so:</p>
  
  <pre><code>mapping (uint =&gt; address) public reservers;
  mapping (uint =&gt; Reservation) public reservations;
  
  mapping (uint =&gt; address) public bidders;
  mapping (uint =&gt; Bid) public bids;
  mapping (uint =&gt; uint) public lastSoldFor;
  </code></pre>
  
  <p>And the method that throws a <code>VM Exception while processing transaction: out of gas</code> is:</p>
  
  <pre><code>function sell(uint rId) public {
      reservations[rId].publicKey = bids[rId].publicKey;
      reservers[rId] = bidders[rId];
      lastSoldFor[rId] = bids[rId].price;
  
      delete bids[rId];
      delete bidders[rId];
  }
  </code></pre>
  
  <p>If I comment out the two <code>delete</code> lines it runs successfully. However if I use <code>delete</code> or even if I simply re-assign them they fail. </p>
  
  <p>When running this through Truffle's testing suite it works, and also when manually committing those actions through Remix using Javascript VM it works. Only when it's connected to testRPC or ganache does it fail. </p>
  
  <p>Every other method seems to work fine from ganache as well, it only seems to have a problem with deletion. I've also seen some references to this being because gas is refunded and since the gas price of this method is fairly low it causes some weirdness in ganache. Is there a workaround for this which doesn't make me have to upload the contract to a test network each time I want to make changes?</p>
  
  <hr>
  
  <p>Edit: It seems I can prove this is not related to low gas consumption but to clearing of mapping indexes. I added some massive gas consumption into the method and it still exits with the same out of gas error.</p>
  
  <p>New state variable:</p>
  
  <pre><code>uint[] memorysink;
  </code></pre>
  
  <p>And then in the method I added </p>
  
  <pre><code>memorysink.push(200000000);
  memorysink.push(200000000);
  memorysink.push(200000000);
  memorysink.push(200000000);
  memorysink.push(200000000);
  </code></pre>
  
  <p>which took the gas consumption from <code>43279</code> to <code>141513</code> however it still provides the out of gas error.</p>