trufflesuite / truffle-artifactor

A contract packager for Ethereum and Javascript (formerly ether-pudding)
MIT License
253 stars 54 forks source link

RangeError: Invalid array length #1

Closed tymat closed 9 years ago

tymat commented 9 years ago

Versions

ether-pudding@0.0.7
truffle@0.0.10
web3@0.7.1

Geth/v0.9.36/freebsd/go1.4.2

stack

Unhandled rejection RangeError: Invalid array length
  at Object.padRight (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/utils/utils.js:88:22)
  at [object Object].formatInputBytes [as _inputFormatter] (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/solidity/formatters.js:53:24)
  at [object Object].SolidityType.formatInput (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/solidity/coder.js:83:17)
  at [object Object].SolidityCoder._formatInput (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/solidity/coder.js:161:36)
  at /usr/local/lib/node_modules/truffle/node_modules/web3/lib/solidity/coder.js:187:21
  at Array.map (native)
  at [object Object].SolidityCoder.encodeParams (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/solidity/coder.js:186:32)
  at /usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/contract.js:45:22
  at Array.map (native)
  at encodeConstructorParams (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/contract.js:44:8)
  at [object Object].ContractFactory.new (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/contract.js:196:17)
  at [object Object].<anonymous> (/usr/local/lib/node_modules/truffle/node_modules/ether-pudding/build/ether-pudding.js:114:28)
  at [object Object].contract_class.new (/usr/local/lib/node_modules/truffle/node_modules/ether-pudding/build/ether-pudding.js:294:26)
  at [object Object].contract_class.new (/usr/local/lib/node_modules/truffle/node_modules/ether-pudding/build/ether-pudding.js:207:26)
  at [object Object].<anonymous> (/usr/local/lib/node_modules/truffle/node_modules/ether-pudding/build/ether-pudding.js:177:26)
  at [object Object].tryCatcher (/usr/local/lib/node_modules/truffle/node_modules/bluebird/js/main/util.js:24:31)
  at [object Object].ret (<anonymous>:14:23)
  at Context.<anonymous> (/Users/aeufemio/projects/digixglobal/digixgold/test/gold.coffee:15:9)
  at Test.Runnable.run (/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runnable.js:233:15)
  at Runner.runTest (/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runner.js:390:10)
  at /usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runner.js:473:12
  at next (/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runner.js:315:14)
  at /usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runner.js:325:7
  at next (/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runner.js:260:23)
  at Immediate._onImmediate (/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runner.js:292:5)
  at processImmediate [as _immediateCallback] (timers.js:358:17)
tcoulter commented 9 years ago

This is an issue somewhere in web3 (at least, that's where the error is). Can you tell me what command you're running, and try running with --verbose-rpc?

tymat commented 9 years ago
   > {
   >   "jsonrpc": "2.0",
   >   "method": "eth_getTransactionReceipt",
   >   "params": [
   >     "0x860ac4f5c16514f4cbf3128c56452e2c666b35394b87310fc8e161ee3b2d5048"
   >   ],
   >   "id": 1436399494130
   > }
 <   {
 <     "id": 1436399494130,
 <     "jsonrpc": "2.0",
 <     "result": null
 <   }
   > {
   >   "jsonrpc": "2.0",
   >   "method": "eth_getTransactionReceipt",
   >   "params": [
   >     "0x860ac4f5c16514f4cbf3128c56452e2c666b35394b87310fc8e161ee3b2d5048"
   >   ],
   >   "id": 1436399495133
   > }
 <   {
 <     "id": 1436399495133,
 <     "jsonrpc": "2.0",
 <     "result": {
 <       "transactionHash": "0x860ac4f5c16514f4cbf3128c56452e2c666b35394b87310fc8e161ee3b2d5048",
 <       "transactionIndex": "0x0",
 <       "blockNumber": "0x4b3d",
 <       "blockHash": "0x8813dc11e5222521adaf521df8322584d670c112d5288a8dee14a3f1e32e966f",
 <       "cumulativeGasUsed": "0x55dd3",
 <       "gasUsed": "0x55dd3",
 <       "contractAddress": "0x3874ad0c70d249e36bf2fca312c31471334e2d76",
 <       "logs": []
 <     }
 <   }
   > {
   >   "jsonrpc": "2.0",
   >   "method": "eth_sendTransaction",
   >   "params": [
   >     {
   >       "from": "0xba2a9f5e51b28dc1d86790f5bc2279ed7cf12c51",
   >       "gas": "0x2fefd8",
   >       "gasPrice": "0xe8d4a51000",
   >       "data": "0x60606040525b33600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b6107e6806100406000396000f300606060405236156100c1576000357c01000000000000000000000000000000000000000000000000000000009004806307546172146100c357806359255e7e146100fa57806376542f6514610113578063780988e21461012c578063836a10401461014b57806386ec85531461016a5780639f5062d614610191578063a1de414a146101aa578063a3d34a24146101c3578063af89ab8e146101ea578063cdc9b9b014610211578063edd51b541461022a578063f46eccc414610243576100c1565b005b6100ce6004506107c0565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b610111600480359060200180359060200150610490565b005b61012a6004803590602001803590602001506105de565b005b61014960048035906020018035906020018035906020015061030c565b005b61016860048035906020018035906020018035906020015061026a565b005b61017b600480359060200150610765565b6040518082815260200191505060405180910390f35b6101a8600480359060200180359060200150610694565b005b6101c16004803590602001803590602001506103f8565b005b6101d4600480359060200150610780565b6040518082815260200191505060405180910390f35b6101fb60048035906020015061074a565b6040518082815260200191505060405180910390f35b610228600480359060200180359060200150610528565b005b610241600480359060200180359060200150610360565b005b61025460048035906020015061079b565b6040518082815260200191505060405180910390f35b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561030657600060ff168114156102d7576102d68383610360565b5b600160ff168114156102ee576102ed83836103f8565b5b600260ff168114156103055761030483836103f8565b5b5b5b505050565b600060ff168160ff161415610326576103258383610528565b5b600160ff168160ff1614156103405761033f83836105de565b5b600260ff168160ff16141561035a576103598383610694565b5b5b505050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156103f35781600060005060008373ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828282505401925050819055505b5b5050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561048b5781600160005060008373ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828282505401925050819055505b5b5050565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156105235781600260005060008373ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828282505401925050819055505b5b5050565b81600060005060003373ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600050541015156105d95781600060005060003373ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282825054039250508190555081600060005060008373ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828282505401925050819055505b5b5050565b81600160005060003373ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000505410151561068f5781600160005060003373ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282825054039250508190555081600160005060008373ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828282505401925050819055505b5b5050565b81600260005060003373ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600050541015156107455781600260005060003373ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282825054039250508190555081600260005060008373ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828282505401925050819055505b5b5050565b60006000506020528060005260406000206000915090505481565b60016000506020528060005260406000206000915090505481565b60026000506020528060005260406000206000915090505481565b600360005060205280600052604060002060009150909054906101000a900460ff1681565b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168156"
   >     }
   >   ],
   >   "id": 16
   > }
 <   {
 <     "id": 16,
 <     "jsonrpc": "2.0",
 <     "result": "0xfd577652ccfecbcd69cf94522922428eab0983b71c39b1a33ce88510c7caf9ca"
 <   }
   > {
   >   "jsonrpc": "2.0",
   >   "method": "eth_getTransactionReceipt",
   >   "params": [
   >     "0xfd577652ccfecbcd69cf94522922428eab0983b71c39b1a33ce88510c7caf9ca"
   >   ],
   >   "id": 1436399496192
   > }
 <   {
 <     "id": 1436399496192,
 <     "jsonrpc": "2.0",
 <     "result": null
 <   }
   > {
   >   "jsonrpc": "2.0",
   >   "method": "eth_getTransactionReceipt",
   >   "params": [
   >     "0xfd577652ccfecbcd69cf94522922428eab0983b71c39b1a33ce88510c7caf9ca"
   >   ],
   >   "id": 1436399497193
   > }
 <   {
 <     "id": 1436399497193,
 <     "jsonrpc": "2.0",
 <     "result": null
 <   }
   > {
   >   "jsonrpc": "2.0",
   >   "method": "eth_getTransactionReceipt",
   >   "params": [
   >     "0xfd577652ccfecbcd69cf94522922428eab0983b71c39b1a33ce88510c7caf9ca"
   >   ],
   >   "id": 1436399498195
   > }
.....
<   {
 <     "id": 1436399532384,
 <     "jsonrpc": "2.0",
 <     "result": null
 <   }
   > {
   >   "jsonrpc": "2.0",
   >   "method": "eth_getTransactionReceipt",
   >   "params": [
   >     "0xd04a291d33bd1fac75b70d5f17175785e074013432993adb28e77705d609e493"
   >   ],
   >   "id": 1436399533388
   > }
 <   {
 <     "id": 1436399533388,
 <     "jsonrpc": "2.0",
 <     "result": {
 <       "transactionHash": "0xd04a291d33bd1fac75b70d5f17175785e074013432993adb28e77705d609e493",
 <       "transactionIndex": "0x0",
 <       "blockNumber": "0x4b42",
 <       "blockHash": "0xd736c388819c6caa0e6ddef4e3c3613d8972613bed87624ace52440bbf8a4526",
 <       "cumulativeGasUsed": "0x2d282",
 <       "gasUsed": "0x2d282",
 <       "contractAddress": "0x665f3b3afd4adbe712a08d9a285a1cb441d3364a",
 <       "logs": []
 <     }
 <   }
   > {
   >   "jsonrpc": "2.0",
   >   "method": "eth_getCode",
   >   "params": [
   >     "0x665f3b3afd4adbe712a08d9a285a1cb441d3364a",
   >     "latest"
   >   ],
   >   "id": 18
   > }
 <   {
 <     "id": 18,
 <     "jsonrpc": "2.0",
 <     "result": "0x60606040526000357c0100000000000000000000000000000000000000000000000000000000900480632f898cc31461005a5780638da5cb5b1461006d578063af640d0f146100a4578063db0b0da8146100c557610058565b005b61006b600480359060200150610133565b005b61007860045061018e565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100af6004506101b4565b6040518082815260200191505060405180910390f35b6100d66004803590602001506100d8565b005b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561012f575b5b50565b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561018a575b5b50565b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6001600050548156"
 <   }
Unhandled rejection RangeError: Invalid array length
  at Object.padRight (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/utils/utils.js:88:22)
  at [object Object].formatInputBytes [as _inputFormatter] (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/solidity/formatters.js:53:24)
  at [object Object].SolidityType.formatInput (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/solidity/coder.js:83:17)
  at [object Object].SolidityCoder._formatInput (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/solidity/coder.js:161:36)
  at /usr/local/lib/node_modules/truffle/node_modules/web3/lib/solidity/coder.js:187:21
  at Array.map (native)
  at [object Object].SolidityCoder.encodeParams (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/solidity/coder.js:186:32)
  at /usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/contract.js:45:22
  at Array.map (native)
  at encodeConstructorParams (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/contract.js:44:8)
  at [object Object].ContractFactory.new (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/contract.js:196:17)
  at [object Object].<anonymous> (/usr/local/lib/node_modules/truffle/node_modules/ether-pudding/build/ether-pudding.js:114:28)
  at [object Object].contract_class.new (/usr/local/lib/node_modules/truffle/node_modules/ether-pudding/build/ether-pudding.js:294:26)
  at [object Object].contract_class.new (/usr/local/lib/node_modules/truffle/node_modules/ether-pudding/build/ether-pudding.js:207:26)
  at [object Object].<anonymous> (/usr/local/lib/node_modules/truffle/node_modules/ether-pudding/build/ether-pudding.js:177:26)
  at [object Object].tryCatcher (/usr/local/lib/node_modules/truffle/node_modules/bluebird/js/main/util.js:24:31)
  at [object Object].ret (<anonymous>:14:23)
  at Context.<anonymous> (/Users/aeufemio/projects/digixglobal/digixgold/test/gold.coffee:15:9)
  at Test.Runnable.run (/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runnable.js:233:15)
  at Runner.runTest (/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runner.js:390:10)
  at /usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runner.js:473:12
  at next (/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runner.js:315:14)
  at /usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runner.js:325:7
  at next (/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runner.js:260:23)
  at Immediate._onImmediate (/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runner.js:292:5)
  at processImmediate [as _immediateCallback] (timers.js:358:17)
tcoulter commented 9 years ago

That looks fine. The only other thing I can think of is to look at your javascript code. Are you calling the correct contract function? Are you passing the right params? Are you giving web3 what it expects? As far as I can tell, web3 is trying to to process input that you're sending to a contract function and it's not getting what it expects. Make sure what your passing matches the ABI.

tymat commented 9 years ago

I'm doing this:

somevar = true
MyContract = Pudding.whisk(MyContract.abi, {from: web3.eth.coinbase})
MyContract.new(somevar).then(function(mc) {
   mc.somevar.call().then(function(result) {
        console.log(result)
   }
}

The contract's constructor accepts one boolean as parameter.

Come to think of it doesn't MyContract.new() also require to pass the object with the binary of the contract?

tcoulter commented 9 years ago

I'm going to guess that this is old and no longer applies. Please try version 1.0.2 and see if you still receive the error.