Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

[Private transactions] Cannot deploy private smart contract #9708

Closed
julienbourdette opened this issue Oct 5, 2018 · 5 comments
Closed

[Private transactions] Cannot deploy private smart contract #9708

julienbourdette opened this issue Oct 5, 2018 · 5 comments
Assignees
Labels
M8-contracts 🤝 Smart Contracts / Wasm / Solidity. Z1-question 🙋‍♀️ Issue is a question. Closer should answer.
Milestone

Comments

@julienbourdette
Copy link

julienbourdette commented Oct 5, 2018

Parity Ethereum version: Parity-Ethereum
Operating system: Linux
Installation: built from source with secretstore feature
Fully synchronized: yes
Network: Tobalaba
Restarted: yes

actual
I'm tested the private transactions tutorial https://github.com/ngyam/tutorial-secretstore-privatetx
on tobalaba_local
All steps on private transactions works well, but when i change the smart contract sample (Test.sol) by a new one, i cannot deploy the contracts with the error:

UnhandledPromiseRejectionWarning: Error: Returned error: Transaction cost exceeds current gas limit. Limit: 8012172, got: 10200000. Try decreasing supplied gas.

But the deployment of this contract works well in public mode (and cost half time gas)
Imported #133 0xab28…9de3 (1 txs, 0.44 Mgas, 1 ms, 2.12 KiB)

Code of the smart contract that cause the issue.

pragma solidity ^0.4.24;

contract Consumption {

   mapping (address => mapping (bytes32 => Data))  consumption;
   mapping (address => mapping (address => bool))  authorization;

   struct Data {
       uint[] timestamp;
       uint256[] value;
   }

   function consume(uint256 _consumption, uint _timestamp,  string _date) public {
       bytes32 hash = keccak256(_date);
       consumption[msg.sender][hash].timestamp.push(_timestamp);
       consumption[msg.sender][hash].value.push(_consumption);
   }

   function getConsumption(address _consumptionAdress, string _date) public returns (uint[],uint256[]) {
       require(authorization[_consumptionAdress][msg.sender]);
       bytes32 hash = keccak256(_date);
       return (consumption[_consumptionAdress][hash].timestamp,consumption[_consumptionAdress][hash].value);
   }

   function authorize(address _address, bool _authorize) public {
       authorization[msg.sender][_address] = _authorize;
   }

expected behavior
Smart contracts can be deployed

steps to reproduce
Follow the https://github.com/ngyam/tutorial-secretstore-privatetx, by replacing Test.Sol by the code above

@jam10o-new jam10o-new assigned jam10o-new and unassigned jam10o-new Oct 5, 2018
@jam10o-new jam10o-new added Z1-question 🙋‍♀️ Issue is a question. Closer should answer. M8-contracts 🤝 Smart Contracts / Wasm / Solidity. labels Oct 5, 2018
@ngyam
Copy link
Contributor

ngyam commented Oct 5, 2018

I could also reproduce it.
Network: local tobalaba like

(node:16565) UnhandledPromiseRejectionWarning: Error: Returned error: Transaction cost exceeds current gas limit. Limit: 8000000, got: 11288000. Try decreasing supplied gas.

In the logs:

2018-10-05 17:23:30   DEBUG txqueue  [0x0bea5a78ab6272fb6a4908db54c18ed70a81bc4cbace2e865bba36ae17068503] Rejected transaction above gas limit: 11288000 > min(8000000, 115792089237316195423570985008687907853269984665640564039457584007913129639935)

Can something be done about the gas cost of private contracts? (if this is not some kind of other bug)
This contract doesn't seem to be that complex, so it seems like an uncomfortable limitation.

@jam10o-new
Copy link
Contributor

jam10o-new commented Oct 5, 2018

I'm unsure why you're experiencing something different between networks, but it appears that the tutorial attempts to hardcode the gas provided by the transaction:

https://github.com/ngyam/tutorial-secretstore-privatetx/blob/6d5a2884e6b4396e79bd31563598b4b042881662/src/private-tx/tutorial_part3_deploy.js#L26

It is a fact that private contracts are significantly more costly to deploy, you are storing the entirity of encrypted bytecode onchain, and there's nothing to optimise there, however, tweaking the hardcoded gas value (or removing it) might help you.

@julienbourdette
Copy link
Author

Thanks for feedbacks.

But even if i remove the gas value, the cost is the same, and so the issue is the same, i cannot deploy it. So if i understand well, only very basic contracts can be used as private?

@Tbaut
Copy link
Contributor

Tbaut commented Oct 8, 2018

This error might indeed be not related to the amount of gas. This is a blanket error (that was fixed in #9615). There must be something weird with the contract itself. If you have a moment to have a look @grbIzl :)

@ngyam
Copy link
Contributor

ngyam commented Oct 8, 2018

I could deploy it with no issues on the live Tobalaba network:
https://tobalaba.etherscan.com/tx/0x923cc7178246b74a54aed000a64dcdca16eefea37e2bc1da4c56c58e1b95778d

Gas Limit: 11288000
Gas Used By Transaction: 1715630 

So actually, not much gas was consumed

@5chdn 5chdn added this to the 2.2 milestone Oct 10, 2018
@grbIzl grbIzl self-assigned this Oct 17, 2018
@grbIzl grbIzl changed the title Cannot deploy private smart contract [Private transactions] Cannot deploy private smart contract Oct 17, 2018
@5chdn 5chdn modified the milestones: 2.2, 2.3 Oct 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
M8-contracts 🤝 Smart Contracts / Wasm / Solidity. Z1-question 🙋‍♀️ Issue is a question. Closer should answer.
Projects
None yet
Development

No branches or pull requests

6 participants