Hi everyone:
hope you can help me.
i'm now developing smart contracts using truffle (5.0.7) and i just join to a project and i have an assignment to upgrade truffle and ganache-cli.
i just check all the requirements that solidity demands but right now i have a strange error:
"BitsUtilities" hit an invalid opcode while deploying. Try:
- Verifying that your constructor params satisfy all assert conditions.
- Verifying your constructor code doesn't access an array out of bounds.
- Adding reason strings to your assert statements.
at /usr/lib/node_modules/truffle/build/webpack:/packages/truffle-deployer/src/deployment.js:364:1
at
at process._tickCallback (internal/process/next_tick.js:189:7)
Truffle v5.0.7 (core: 5.0.7)
Node v8.15.1
Any idea of the reason? it is not saying any reason. i was expecting some overflow error but i already test the library without anything and still have this error.
Library code:
pragma solidity >=0.4.22 <0.6.0;
library BitsUtilities {
function and(byte a, byte b) public pure returns (byte) {
return a & b;
}
function or(bytes1 a, bytes1 b) public pure returns (byte) {
return a | b;
}
function xor(bytes1 a, bytes1 b) public pure returns (byte) {
return a ^ b;
}
function negate(byte a) public pure returns (byte) {
return (~a);
}
function shiftLeft(byte a, uint8 n) public pure returns (byte) {
uint8 a1 = uint8(a);
uint8 shifted = a1 << n;
return toByte (shifted);
}
function shiftRight(byte a, uint8 n) public pure returns (byte) {
uint8 shifted = uint8(a) >> n;
return byte(shifted);
}
function getFirstN(byte a, uint8 n) public pure returns (byte) {
byte nOnes = byte(power(2, n) - 1);
byte mask = shiftLeft(nOnes, 8 - n); // Total 8 bits
return a & mask;
}
function getLastN(byte a, uint8 n) public pure returns (byte) {
uint8 lastN = uint8(a) % power(2,n);
return byte(lastN);
}
// Get bit value at position
function getBit(byte a, uint8 n) public pure returns (bool) {
return a & shiftLeft(0x01, n) != 0;
}
// Set bit value at position
function setBit(byte a, uint8 n) public pure returns (byte) {
return a | shiftLeft(0x01, n);
}
// Set the bit into state "false"
function clearBit(byte a, uint8 n) public pure returns (byte) {
bytes1 mask = negate(shiftLeft(0x01, n));
return a & mask;
}
function power(uint8 base, uint8 exponent) public pure returns (uint8) {
return base ** exponent;
}
function toByte (uint8 decimalValue) public pure returns (byte b) {
require(decimalValue <= 255);
return byte (decimalValue);
}
}