I'm running version 2.0.7
I've started the server this way:
testrpc --account='<some key>,<ether balance' -p 6767
In my testing scripts, I'm referencing it like this:
var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:6767'));
My contract is fairly trivial, taken from Solidity docs Voting example.
The contract is being deployed successfully, but when I try to execute a test, it fails with the following error:
[Error: Error: VM Exception while executing transaction: stack underflow
Here is my test case:
it('', function(done){
ballot.vote.sendTransaction(
0,
{
from: web3.eth.accounts[0]
},
function(e, result) {
expect(e).to.not.exist;
expect(result).to.exist;
result.should.be.above(0);
}
);
});
Any ideas?
Oh, BTW, if I run this same test on an actual node, it works perfectly.
I was running into this same problem (throwing this exact error on TestRPC but working normally when deployed on Morden) and then I realized something interesting: using truffle test the contract is correctly deployed on TestRPC. So, the problem is somehow related to how the contract is deployed.
I just received another report on this issue, and it was a result of trying to execute code on a contract with no address. I'm going to close this issue as it seems to be related to how the contract is deployed. Oddly, when there's no code the TestRPC will report a stack underflow. That might be a bug, but if so it's within ethereumjs-vm, and we'll need to explore the cause further.
@tcoulter I have this issue also. I fail to understand your analysis. Would you be willing to specify "trying to execute code on a contract with no address". Also, please have a look at my console. Does it look as if mine is the same case?
By the way, thank you for fixing another issue, since you did I run TestRpc's beta of last week.
Same here. here's the input:
{
"jsonrpc": "2.0",
"id": 40,
"method": "eth_sendTransaction",
"params": [
{
"from": "0x0b046f9e580ffe534ebae659d1fce83928793ff6",
"gas": "0x47e7c4",
"gasPrice": "0x174876e800",
"value": "0x8ac7230489e80000",
"to": "0xecb3b9226b0ab9a4e14b2bb6af07691579afb16e"
}
]
}
Result:
eth_call
eth_blockNumber
eth_call
eth_blockNumber
eth_sendTransaction
PUSH1
PUSH1
MSTORE
CALLDATASIZE
ISZERO
PUSH2
JUMPI
JUMPDEST
Transaction: 0x60dc94d86f63a02f1f75ce3e06460979a7266b90727ffa279fbf9b11d875db31
Gas usage: 0x47e7c4
Block Number: 0x14
Block Time: Tue Jun 27 2017 10:15:47 GMT-0700 (PDT)
Runtime Error: invalid opcode
I also have the same problem with testrpc and try to execute one "assert" exception in my Solidity contract. Without "assert" no problem.
Same issue, but only certain function of the contract return this error, and all these function have already be used and work on geth and parity with Web3...
This:
return instance.method(0x..., 880 * 500, 0x0100000001, {from: accounts[1]}).then(function (res) {
assert.equal(res, true, "...");
});
Return this in the console:
eth_sendTransaction
Transaction: 0x8b29e86f6ded9978d81db41976111f78a05e69d4b06c5e8304474da01430bf0a
Gas usage: 0x47e7c4
Block Number: 0x01d2
Block Time: Thu Aug 03 2017 14:02:44 GMT+0200 (CEST)
Runtime Error: invalid opcode
eth_getLogs
(before that i have call other method with the same instance, it work)
so what?
If I try to run with single object {"a":"b}" it works. But, as soon as I add multiple objects {"a":"b","c":"d"} it returns me with invalid opcode.
Anybody, can tell me why?
I've encountered the issue consistently using testrpc and truffle.
I tried to write some tests, and had it when I tried a simple eth transfer to a contract.
I even tried this tutorial http://truffleframework.com/tutorials/robust-smart-contracts-with-openzeppelin using metamask for transferring tokens, and the transaction fails - looking to testrpc log shows:
eth_sendRawTransaction
Transaction: 0x479e58108c4deb5d8d96a5e97a98355f389407b32f27e70a3945d3339e559064
Gas usage: 50000
Block Number: 6
Block Time: Tue Oct 10 2017 15:38:29 GMT+0200 (CEST)
Runtime Error: invalid opcode
I'm getting the same thing. Trying to deploy a contract via node to the testrpc. It works fine for other contracts, but I can't get this one to push through.
Transaction: 0x9ef48bee4efe4c20895c6d640246d1c8dbbfc1eee08fa974fa01e091a0b826c
6
Contract created: 0xe348ad9660ed9c0ec142e9ba9d7c399f197d06b3
Gas usage: 0x47e7c4
Block Number: 0x10
Block Time: Sat Oct 21 2017 16:06:58 GMT-0400 (Eastern Daylight Time)
Runtime Error: stack underflow
Same here, using metamask.
eth_sendRawTransaction
Transaction: 0x4809185ff480539f05313d17a5f80ac9a2f3174f776aef34544c0d6b5d6a1714
Gas usage: 99000
Block Number: 9
Block Time: Sat Oct 21 2017 13:44:59 GMT-0700 (PDT)
Runtime Error: invalid opcode
same here on testrpc
Definately a testrpc issue. Deployed a contract to the testnet. works fine
I was getting this error trying to call a contract in metamask. I noticed my to variable was mistyped, meaning I was passing undefined as the calling contract address. Please double check your variables.
Same issue here. Works on Rinkeby, but doesn't work with truffle test / truffle develop.
The issue I have is with the line of code: teams.push(_team); below:
Team memory _team = Team({
owner: msg.sender,
fighterIds: _fighterIds, // uint256[]
leaderId: _leaderId // uint256
});
teams.push(_team); // no error thrown when this line is commented out. works fine on rinkeby
I figured out our issue in case anyone runs into this in the future. It does seem like a bug in truffle in any case because it worked fine on Rinkeby.
I solved it by doing a push to the array in the contract constructor. After this, a push to the array in the function also worked as expected. I assume the error was thrown due to pushing to a null array, but this somehow works when you do it in the ctor and then it'll continue to work after that too.
I've observed this bug again in latest beta. Reopening, and will closed once I've got it licked.
Most helpful comment
I also have the same problem with testrpc and try to execute one "assert" exception in my Solidity contract. Without "assert" no problem.