Error de falta de gas en TesRPC

Oye, he estado jugando con trufa y sigo recibiendo un error de falta de gas cuando pruebo los comandos después de cierto punto. Incluso si desinstalo y reinstalo testrpc, el problema persiste.

Me disculpo por los problemas de formato del código.

Tenga en cuenta que todo lo que quiero hacer es tener gas ilimitado en mi entorno de prueba.

aquí está mi código `

  contract Organization {



 struct Proposal {
   uint code;
   uint amount;
  string description;
  uint numberOfVotes;
  string name;
}

Proposal[] public proposals;
uint public numberOfProposals;


 event ProposalAdded(uint code, uint amount, string description, int 
 numberOfVotes , string name);


 function addProposal(uint amount, string description , string name) 
 returns (uint) {

proposals.push(Proposal(numberOfProposals,amount,description,0,name));
ProposalAdded(numberOfProposals,amount,description, 0, name);
numberOfProposals++;
return numberOfProposals;

}



 function proposalExists (uint code) returns (bool) {
   for(uint i = 0; i < proposals.length; i++) {
     if (proposals[i].code == code) {
        return true;
      }
    }
     return false;
 }

function numOfProposals() returns (uint){
    return numberOfProposals;
  }

function getProposalName(uint index) returns (string){
    return proposals[index].name;
}

function getProposalDescription(uint index) returns (string){
    return proposals[index].description;
}

function getProposalIndex(string name) returns (uint){
  for(uint i = 0; i < proposals.length; i++) {
      bytes memory a = bytes(proposals[i].name);
      bytes memory b = bytes(name);
    if (a.length == b.length) {
        return i;
    }
  }
  return 1000000;
}

function voteFotProposal(uint index) {
    proposals[index].numberOfVotes++;
  }

function getProposalVotesIndex(uint index) {
    proposals[index].numberOfVotes;
  }


struct Memmber {
  uint id;
  string name;
}

struct Commitee {
  uint id;
  string name;
  string missionStatement;
  uint balance;
  string [] memmbers;
}

event MemmberAdded(uint id, string name);
event CommiteeCreated(string name,string missionStatement );

string [] public memmbersArray;
string[] public comitees;
uint public numOfComitees = 0;
uint public numOfTotalMemmbers = 0;
Commitee [] fullComitees;




  function convertMemmberStrings (bytes32 [] values) internal returns 
  (string []){

        for(uint i=0;i<values.length;i++){
            MemmberAdded(numOfTotalMemmbers, 
            bytes32ToString(values[i]));
            memmbersArray.push(bytes32ToString(values[i]));
            numOfTotalMemmbers++;
    }
    return memmbersArray;
}


function addCommitee 
(string name, string missionStatement , uint funds, bytes32 [] values)
returns (string)
{
  comitees.push(name);
  CommiteeCreated(name,missionStatement );
  fullComitees.push(Commitee(numOfComitees, name, missionStatement, funds, convertMemmberStrings(values)));
  numOfComitees++;
  return name;
}

function getComitees (uint index) returns (string){
  return comitees[index];
}

function numberOfCommitees () returns (uint){
  return numOfComitees;
}

 function bytes32ToString(bytes32 x) constant returns (string) {
    bytes memory bytesString = new bytes(32);
    uint charCount = 0;
    for (uint j = 0; j < 32; j++) {
      byte char = byte(bytes32(uint(x) * 2 ** (8 * j)));
      if (char != 0) {
        bytesString[charCount] = char;
        charCount++;
     }
 }
bytes memory bytesStringTrimmed = new bytes(charCount);
for (j = 0; j < charCount; j++) {
    bytesStringTrimmed[j] = bytesString[j];
}
return string(bytesStringTrimmed);
}

 function uintToBytes(uint v) constant returns (bytes32 ret) {
    if (v == 0) {
      ret = '0';
   }
   else {
    while (v > 0) {
        ret = bytes32(uint(ret) / (2 ** 8));
        ret |= bytes32(((v % 10) + 48) * 2 ** (8 * 31));
        v /= 10;
    }
 }
 return ret;
}


}

`

¿Cómo estás ejecutando testrpc?
simplemente a través del comando testrpc

Respuestas (3)

Puede aumentar el límite de gas del bloque iniciando testrpc con un límite más alto

testrpc -l 4500000000000

https://github.com/trufflesuite/ganache-cli/releases/tag/v3.0.0

TestRPC 3.0.0 Cambios importantes: el límite de gas predeterminado para las transacciones ahora es 90000 gas en lugar del límite de gas de bloque completo.

Para evitar estos nuevos errores de falta de gas, ahora puede pasar un límite de gas más alto como parámetro a web3:

web3.eth.sendTransaction({..., gas: 3141592}) // choose your own gas limit suitable for you

Estaba enfrentando los mismos errores. Cuerdas muy caras en la EVM. Pruebe bytes o trate de evitar cadenas. Tuve problemas similares con mi dApp y Smart Contract. Eliminé todas las cadenas (por lo tanto rediseñadas) y ahora todo funciona bien. Además, sus eventos solicitan una gran cantidad de parámetros y, por lo tanto, requieren una gran cantidad de gas. comente sus llamadas de eventos y pruebe sus funciones nuevamente. Testrpc tiene un límite en la cantidad de gas que puedes dar en cada transacción. Así que intente ejecutar sus comandos en múltiples transacciones. Use el compilador en línea Remix para ver si sus funciones funcionan correctamente. Eso permite gas ilimitado.