3

I am running a private quorum network, and I am trying to call a contract function using web3;

my contract was deployed correctly, and i am able to see it and interact with it. Next is the code i am trying to run to add data to the my contract.

for (let i =51; i<500; i++){
  let jsonObj = Array[i];
  Cin.deployed().then(
    contractInstance=>{
      //console.log(web3.fromDecimal(i+2*i))
      contractInstance.insertPerson(
        web3.fromUtf8(web3.fromDecimal(i+2*i)),
        jsonObj["email"]?web3.fromUtf8(jsonObj["email"]):"",
        jsonObj["FIRST_NAME"]?web3.fromUtf8(jsonObj["FIRST_NAME"]):"",
        jsonObj["LAST_NAME"]?web3.fromUtf8(jsonObj["LAST_NAME"]):"",
       ...
          jsonObj["DECEASED_DT"]?web3.fromUtf8(jsonObj["DECEASED_DT"].toString()):""],
        {gas: 9900000, from: web3.eth.accounts[0]}).then(function(v) {
        fs.appendFileSync('./Pushed.txt',JSON.stringify(v)+"\n \n");
        pushedNumber++;
          console.log("pushed "+i +"   N: "+pushedNumber);


      }).catch(e=>{
        console.log("error in "+i);
        fs.appendFileSync('./log.txt',"Error form Inserting"+e+"\n \n");
      });
    }
  ).catch(e=>{
    fs.appendFileSync('./log.txt',"Deployment Error "+e+"\n \n");
  })

}

The problem here is when i call these functions i get this error on my geth console : VM returned with error err="gas uint64 overflow" I can't understand why is that ? is it because i am sending too many transactions from a single account in small amount of time ?

EDIT :

this is the function that mostly does cause the error

function insertPerson(
    bytes32 personAddress,
    bytes32 email,
    bytes32 fname,
    bytes32 lname,
    Gender gender,
    string image,
    Status status,
    bytes32[13] details
)
    public
    returns(uint index)
  {
    if(isPerson(personAddress)) return;
    persons[personAddress].email = email;
    persons[personAddress].fname = fname;
    persons[personAddress].lname = lname;
    persons[personAddress].index = personIndex.push(personAddress)-1;
    persons[personAddress].deleted = false;
    persons[personAddress].gender = gender;
    persons[personAddress].image = image;
    persons[personAddress].status = status;
    persons[personAddress].RIM.Value = details[0];
    persons[personAddress].RIM.ValidationDate = bytes32(now);
    persons[personAddress].RIM.ValidationDuration = bytes32(365);
    persons[personAddress].RIM.status = Status.Validated;
    persons[personAddress].BirthCity.Value = details[1];
      persons[personAddress].BirthCity.ValidationDate = bytes32(now);
      persons[personAddress].BirthCity.ValidationDuration = bytes32(365);
      persons[personAddress].BirthCity.status = Status.Validated;
    persons[personAddress].BirthCountry.Value = details[2];
      persons[personAddress].BirthCountry.ValidationDate = bytes32(now);
      persons[personAddress].BirthCountry.ValidationDuration = bytes32(365);
      persons[personAddress].BirthCountry.status = Status.Validated;
    persons[personAddress].FatherName.Value = details[3];
      persons[personAddress].FatherName.ValidationDate = bytes32(now);
      persons[personAddress].FatherName.ValidationDuration = bytes32(365);
      persons[personAddress].FatherName.status = Status.Validated;
    persons[personAddress].MotherName.Value = details[4];
      persons[personAddress].MotherName.ValidationDate = bytes32(now);
      persons[personAddress].MotherName.ValidationDuration = bytes32(365);
      persons[personAddress].MotherName.status = Status.Validated;
    persons[personAddress].Citizenship.Value = details[5];
      persons[personAddress].Citizenship.ValidationDate = bytes32(now);
      persons[personAddress].Citizenship.ValidationDuration = bytes32(365);
      persons[personAddress].Citizenship.status = Status.Validated;
    persons[personAddress].Residency.Value = details[6];
      persons[personAddress].Residency.ValidationDate = bytes32(now);
      persons[personAddress].Residency.ValidationDuration = bytes32(365);
      persons[personAddress].Residency.status = Status.Validated;
    persons[personAddress].Grade.Value = details[7];
      persons[personAddress].Grade.ValidationDate = bytes32(now);
      persons[personAddress].Grade.ValidationDuration = bytes32(365);
      persons[personAddress].Grade.status = Status.Validated;
    persons[personAddress].CorpCountryCode.Value = details[8];
      persons[personAddress].CorpCountryCode.ValidationDate = bytes32(now);
      persons[personAddress].CorpCountryCode.ValidationDuration = bytes32(365);
      persons[personAddress].CorpCountryCode.status = Status.Validated;
    persons[personAddress].IntroducedBy.Value = details[9];
      persons[personAddress].IntroducedBy.ValidationDate = bytes32(now);
      persons[personAddress].IntroducedBy.ValidationDuration = bytes32(365);
      persons[personAddress].IntroducedBy.status = Status.Validated;
    persons[personAddress].HowIntroduced.Value = details[10];
      persons[personAddress].HowIntroduced.ValidationDate = bytes32(now);
      persons[personAddress].HowIntroduced.ValidationDuration = bytes32(365);
      persons[personAddress].HowIntroduced.status = Status.Validated;
    persons[personAddress].website.Value = details[11];
      persons[personAddress].website.ValidationDate = bytes32(now);
      persons[personAddress].website.ValidationDuration = bytes32(365);
      persons[personAddress].website.status = Status.Validated;
    persons[personAddress].DeceasedDate.Value = details[12];
      persons[personAddress].DeceasedDate.ValidationDate = bytes32(now);
      persons[personAddress].DeceasedDate.ValidationDuration = bytes32(365);
      persons[personAddress].DeceasedDate.status = Status.Validated;
    //persons[personAddress].AttributesStatus["RIM"]= AttributeStatus('');
    return(uint(1));
  }

The most tthing bugging in this error is that the blockc gets mined and added to the blockchain but the data supposed to be stored doesn't get stored. so i don't get an error through web3 to tell my UI users to retry again. isn't VM error supposed to be errors that actually cancel the transaction ?

1 Answer 1

2

You better look to the sources to find out which is your error case. Most likely your gas limit overflows a 64bit number , probably due to a bug in your contract.

here are some examples:

var errGasUintOverflow = errors.New("gas uint64 overflow")

func callGas(gasTable params.GasTable, availableGas, base uint64, callCost *big.Int) (uint64, error) {
    if gasTable.CreateBySuicide > 0 {
        availableGas = availableGas - base
        gas := availableGas - availableGas/64
        // If the bit length exceeds 64 bit we know that the newly calculated "gas" for EIP150
        // is smaller than the requested amount. Therefor we return the new gas instead
        // of returning an error.
        if callCost.BitLen() > 64 || gas < callCost.Uint64() {
            return gas, nil
        }
    }
    if callCost.BitLen() > 64 {
        return 0, errGasUintOverflow
    }

    return callCost.Uint64(), nil
}
============================ 
        var memorySize uint64
        // calculate the new memory size and expand the memory to fit
        // the operation
        if operation.memorySize != nil {
            memSize, overflow := bigUint64(operation.memorySize(stack))
            if overflow {
                return nil, errGasUintOverflow
            }
            // memory is expanded in words of 32 bytes. Gas
            // is also calculated in words.
            if memorySize, overflow = math.SafeMul(toWordSize(memSize), 32); overflow {
                return nil, errGasUintOverflow
            }
        }
3
  • 1
    Gas limit seems to be something hardcoded, how does my contract's bug overflow that limit Commented Mar 26, 2018 at 7:44
  • 1
    I think you should add the source of your contract to the question
    – Nulik
    Commented Mar 27, 2018 at 14:49
  • 1
    I can't do that actually, but i can post the function that does usually cause this overflow, which i will do. Commented Mar 29, 2018 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.