Closed aion-ollie closed 5 years ago
Hey thanks for submitting the request, possible for you guys to submit the commands, contract source code and compiled code that triggers the success case and failcase?
Titan config: { "host": "http://138.197.130.7", "port": 8555, "defaultAccount": "0xa004be15cab6e6c7bf141b1d7039c677c42437437680ae8689f6b4ec6b650589", "password": "12345" }
Command : titan deploy contracts/Test
Test.sol that succeeds:
pragma solidity ^0.4.15;
contract Test{
struct SubData{
uint32 item;
}
struct Data{
SubData[] subData;
}
mapping(uint32=>Data) dataMap;
function Test() {
Data storage data = dataMap[0];
data.subData.push(SubData(7));
data.subData.push(SubData(9));
Data storage dataTwo = dataMap[1];
dataTwo.subData.push(SubData(17));
dataTwo.subData.push(SubData(19));
}
function getItems() public returns (uint32[]){
uint32 one = dataMap[0].subData[0].item;
uint32 two = dataMap[0].subData[1].item;
uint32 three = dataMap[1].subData[0].item;
uint32 four = dataMap[1].subData[1].item;
uint32[] memory out = new uint32[](4);
out[0]=one;
out[1]=two;
out[2]=three;
out[3]=four;
return out;
}
}
Successfully deployed! Deployment Details: contract: Test address: 0xa01bcf4e1d919b3c2e3c950debab3900ecdafa5d32096cf8a6e673c077594754 transaction hash: 0x7a913326e2c1062466c7258ae8ef0d2fb38f881d374a843e0ce8ea67995481fe NRG used: 465742 block number: 955195 from: 0xa004be15cab6e6c7bf141b1d7039c677c42437437680ae8689f6b4ec6b650589 to: 0x logs: [] deploying... done
Test.sol that fails, the only difference from the success case is that this .sol file is 1 method larger:
pragma solidity ^0.4.15;
contract Test{
struct SubData{
uint32 item;
}
struct Data{
SubData[] subData;
}
mapping(uint32=>Data) dataMap;
function Test() {
Data storage data = dataMap[0];
data.subData.push(SubData(7));
data.subData.push(SubData(9));
Data storage dataTwo = dataMap[1];
dataTwo.subData.push(SubData(17));
dataTwo.subData.push(SubData(19));
}
function getItems() public returns (uint32[]){
uint32 one = dataMap[0].subData[0].item;
uint32 two = dataMap[0].subData[1].item;
uint32 three = dataMap[1].subData[0].item;
uint32 four = dataMap[1].subData[1].item;
uint32[] memory out = new uint32[](4);
out[0]=one;
out[1]=two;
out[2]=three;
out[3]=four;
return out;
}
function getMoreItems() public returns (uint32[]){
uint32 one = dataMap[0].subData[0].item;
uint32 two = dataMap[0].subData[1].item;
uint32 three = dataMap[1].subData[0].item;
uint32 four = dataMap[1].subData[1].item;
uint32[] memory out = new uint32[](4);
out[0]=one;
out[1]=two;
out[2]=three;
out[3]=four;
return out;
}
}
Error: Invalid JSON RPC response: ""
at Object.InvalidResponse (~/.npm-global/lib/node_modules/@titan-suite/cli/node_modules/aion-web3/lib/web3/errors.js:38:16)
at XMLHttpRequest.request.onreadystatechange (~/.npm-global/lib/node_modules/@titan-suite/cli/node_modules/aion-web3/lib/web3/httpprovider.js:117:32)
at XMLHttpRequestEventTarget.dispatchEvent (~/.npm-global/lib/node_modules/@titan-suite/cli/node_modules/xhr2/lib/xhr2.js:64:18)
at XMLHttpRequest._setReadyState (~/.npm-global/lib/node_modules/@titan-suite/cli/node_modules/xhr2/lib/xhr2.js:354:12)
at XMLHttpRequest._onHttpResponseEnd (~/.npm-global/lib/node_modules/@titan-suite/cli/node_modules/xhr2/lib/xhr2.js:509:12)
at IncomingMessage.<anonymous> (~/.npm-global/lib/node_modules/@titan-suite/cli/node_modules/xhr2/lib/xhr2.js:469:24)
Can confirm that atleast from a blockchain point of view, the "failing" contract deploys successfully
I was able to successfully deploy the contract via a eth_sendRawTransaction
call:
At this point I'm going to conclude the following:
Unfortunately I don't have enough time to see this through, @arajasek @aion-kelvin, possible for you guys to confirm whats going on?
I tried deploying without titan to mastery and it's not working for me. This is my deploying script:
const solc = require('solc');
let Web3 = require('aion-web3');
let web3 = new Web3(new Web3.providers.HttpProvider("https://api.nodesmith.io/v1/aion/testnet/jsonrpc?apiKey=454a0bf9a09b404e817669bcae1c0a54"));
async function send(transaction) {
let gas = await transaction.estimateGas({from: "0xa0d84a7c8409668f3249b1478ea8253e8f707004494fa9f50afc9012c8a5f7be"});
let private_key = '...';
let options = {
to : transaction._parent._address,
data: transaction.encodeABI(),
gas : gas
};
let signedTransaction = await web3.eth.accounts.signTransaction(options, private_key);
return await web3.eth.sendSignedTransaction(signedTransaction.rawTransaction);
}
async function deploy(contractArgs) {
const input = fs.readFileSync('../contracts/Platypus.sol');
const contract_data = solc.compile(input.toString(), 1);
let abi = JSON.parse(contract_data.contracts[':Platypus'].interface);
let bin = contract_data.contracts[':Platypus'].bytecode;
let contract = new web3.eth.Contract(abi);
let handle = await send(contract.deploy({data: "0x" + bin, arguments: contractArgs}));
console.log(`contract deployed at address ${handle.contractAddress}`);
return new web3.eth.Contract(JSON.parse(abi), handle.contractAddress);
}
deploy(['Platypus','PLAT','1','50000000000000000000000000','0xa0d84a7c8409668f3249b1478ea8253e8f707004494fa9f50afc9012c8a5f7be']);
error:
(node:48175) UnhandledPromiseRejectionWarning: Error: Transaction has been reverted by the EVM:
{
"blockHash": "0x7092fd17633b37060b93c298bd7b02b6b889aeb24582c3722e6e01793837b26a",
"nrgPrice": "0x02540be400",
"logsBloom": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"nrgUsed": "0x1e8480",
"contractAddress": "0xA0f719B3DED9514f78dF6cd76F567c91001daF2416AA90ac5c9667D956885e49",
"transactionIndex": 0,
"transactionHash": "0xe03d6341a25f07ac7e6df6aa57b0615b486acd46fdf512292578a57671c21731",
"gasLimit": "0x1e8480",
"cumulativeNrgUsed": "0x1e8480",
"gasUsed": 2000000,
"blockNumber": 962077,
"root": "8b67a47b6a2b345379737e21ab94498e00f8ad687508fadee29a6349b0743809",
"cumulativeGasUsed": 2000000,
"from": "0xa0d84a7c8409668f3249b1478ea8253e8f707004494fa9f50afc9012c8a5f7be",
"to": "0x",
"logs": [],
"gasPrice": "0x02540be400",
"status": false
}
Mastery dashboard for the transaction hash from the above error message: https://mastery.aion.network/#/transaction/e03d6341a25f07ac7e6df6aa57b0615b486acd46fdf512292578a57671c21731
It says it is out of NRG. I see that the the gas you're using is from estimateGas -- it seems it is estimating too low of an amount. Could you try a larger gas limit and see if that works?
In particular with this call here:
const solc = require('solc');
Is this a library you're referring to, or solc.js
? If so our VM is probably not compatible with that.
@aion-kelvin I tried with a larger gas limit and still didn't work. @qoire it is, I'm using version 0.4.15. How should I compile the contract instead?
@jonathanjm from the error it showed the transaction consumed all of the gas you assigned into this transaction, which is 2M, I assume you might be trying to deploy a large contract. Could you set your gas limit more than 2M? the system will accept up to 5M gas consumed when you are trying to deploy a smart contract.
While trying to deploy a smart contract to a node that is connected to mastery net I get the following exception in the node's console output:
ERROR io.undertow.request [XNIO-1 I/O-7]: UT005071: Undertow request failed HttpServerExchange{ POST / request {Connection=[keep-alive], Content-Type=[application/json], Content-Length=[23165], User-Agent=[Mozilla/5.0 (Darwin x64) node.js/8.11.4 v8/6.2.414.54], Host=[138.197.130.7:8555]} response {}} java.lang.IllegalStateException: UT000126: Attempted to do blocking IO from the IO thread. This is prohibited as it may result in deadlocks at io.undertow.io.UndertowInputStream.read(UndertowInputStream.java:84) at io.undertow.io.BlockingReceiverImpl.receiveFullString(BlockingReceiverImpl.java:124) at io.undertow.io.BlockingReceiverImpl.receiveFullString(BlockingReceiverImpl.java:76) at org.aion.api.server.http.undertow.UndertowRpcServer.lambda$handleRequest$1(Unknown Source) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:360) at io.undertow.server.handlers.RequestBufferingHandler$1.handleEvent(RequestBufferingHandler.java:99) at io.undertow.server.handlers.RequestBufferingHandler$1.handleEvent(RequestBufferingHandler.java:78) at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) at io.undertow.channels.DetachableStreamSourceChannel$SetterDelegatingListener.handleEvent(DetachableStreamSourceChannel.java:231) at io.undertow.channels.DetachableStreamSourceChannel$SetterDelegatingListener.handleEvent(DetachableStreamSourceChannel.java:218) at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66) at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:88) at org.xnio.nio.WorkerThread.run(WorkerThread.java:561)
What works: