Consensys / quorum-dev-quickstart

The Quorum Developer Quickstart utility can be used to rapidly generate local Quorum blockchain networks for development and demo purposes using Besu and GoQuorum
Apache License 2.0
131 stars 99 forks source link

Can't send private tnx #257

Closed ToToDoDo closed 1 year ago

ToToDoDo commented 1 year ago

After I start a goquorum network with private tnx support by quorum-dev-quickstart, I deployed private contract successfully. But when I call set() method with privateFor parameter, I got an error. And I can't get tnx of contract deploying detail by eth.getPrivateTransaction().

The contract which I deployed was copied from: https://docs.goquorum.consensys.net/tutorials/send-private-transaction

~ sh ./attach.sh 1                                                                                                                                                           0 [18:39:11]
Attempting to connect to member1quorum
Welcome to the Geth JavaScript console!

instance: Geth/960556e99be0-qbft/v1.10.3-stable-93c5f781(quorum-v22.7.5)/linux-arm64/go1.16.15
coinbase: 0x13a52aab892e1322e8b52506276363d4754c122e
at block: 55 (Fri Jun 02 2023 09:39:23 GMT+0000 (UTC))
 datadir: /data
 modules: admin:1.0 debug:1.0 eth:1.0 istanbul:1.0 miner:1.0 net:1.0 personal:1.0 quorumExtension:1.0 rpc:1.0 txpool:1.0 web3:1.0

To exit, press ctrl-d
> a = eth.accounts[0]
"0xf0e2db6c8dc6c681bb5d6ad121a107f300e9b2b5"
> web3.eth.defaultAccount = a;
"0xf0e2db6c8dc6c681bb5d6ad121a107f300e9b2b5"
> var abi = [{"constant":true,"inputs":[],"name":"storedData","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"retVal","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"initVal","type":"uint256"}],"payable":false,"type":"constructor"}];
undefined
> var bytecode = "0x6060604052341561000f57600080fd5b604051602080610149833981016040528080519060200190919050505b806000819055505b505b610104806100456000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632a1afcd914605157806360fe47b11460775780636d4ce63c146097575b600080fd5b3415605b57600080fd5b606160bd565b6040518082815260200191505060405180910390f35b3415608157600080fd5b6095600480803590602001909190505060c3565b005b341560a157600080fd5b60a760ce565b6040518082815260200191505060405180910390f35b60005481565b806000819055505b50565b6000805490505b905600a165627a7a72305820d5851baab720bba574474de3d09dbeaabc674a15f4dd93b974908476542c23f00029";
undefined
> var simpleContract = web3.eth.contract(abi);
undefined
> var simple = simpleContract.new(42, {from:web3.eth.accounts[0], data: bytecode, gas: 0x47b760, privateFor: ["QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc="]}, function(e, contract) {if (e) {console.log("err creating contract", e);} else {if (!contract.address) {console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined...");} else {console.log("Contract mined! Address: " + contract.address);console.log(contract);}}});
Contract transaction send: TransactionHash: 0x8e6c2b4e84ebd294418aea67031de2a958dd6315abbc1f217347d6831101f9de waiting to be mined...
undefined
> Contract mined! Address: 0x00ffd3548725459255f1e78a61a07f1539db0271
[object Object]
> var private = eth.contract(abi).at("0x00ffd3548725459255f1e78a61a07f1539db0271")
undefined
> private.get()
42
> private.set(4,{from:eth.accounts[0],privateFor:["QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc="]});
Error: method handler crashed
    at web3.js:6355:37(47)
    at web3.js:5089:62(37)
    at web3.js:4145:41(57)
    at web3.js:4231:75(24)
    at <eval>:1:49(12)

> private.set(4,{from:eth.accounts[0],privateFor:[]});
Error: method handler crashed
    at web3.js:6355:37(47)
    at web3.js:5089:62(37)
    at web3.js:4145:41(57)
    at web3.js:4231:75(24)
    at <eval>:1:48(11)

> eth.getPrivateTransaction("0x8e6c2b4e84ebd294418aea67031de2a958dd6315abbc1f217347d6831101f9de")
Error: invalid character '`' looking for beginning of value
    at web3.js:6355:37(47)
    at web3.js:5089:62(37)
    at <eval>:1:26(4)
im1ex commented 1 year ago

Same issue. If selected GoQuorum client in npx quorum-dev-quickstart command (all other options set by default), I got same error:

lex@quorumubuntu22:~/sources/quorum-test-network/smart_contracts/privacy/scripts$ node private_tx.js
Creating contract...
Waiting for transaction to be mined ...
Getting contractAddress from txHash:  {
  blockHash: '0x6e06c5d5c112cead10ee6ba115e03c60c485b9d3eaa6919f77e0bbd141e25d84',
  blockNumber: 6,
  contractAddress: '0x00fFD3548725459255f1e78A61A07f1539Db0271',
  cumulativeGasUsed: 0,
  from: '0xf0e2db6c8dc6c681bb5d6ad121a107f300e9b2b5',
  gasUsed: 0,
  isPrivacyMarkerTransaction: false,
  logs: [
    {
      address: '0x00fFD3548725459255f1e78A61A07f1539Db0271',
      topics: [Array],
      data: '0x000000000000000000000000f0e2db6c8dc6c681bb5d6ad121a107f300e9b2b5000000000000000000000000000000000000000000000000000000000000002f',
      blockNumber: 6,
      transactionHash: '0xb7ef6289395e8ad3d49bb91dfdb12678c92f6c43b431a797203bd396fe1f6934',
      transactionIndex: 0,
      blockHash: '0x6e06c5d5c112cead10ee6ba115e03c60c485b9d3eaa6919f77e0bbd141e25d84',
      logIndex: 0,
      removed: false,
      id: 'log_68481d4d'
    }
  ],
  logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000002001000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
  status: true,
  to: null,
  transactionHash: '0xb7ef6289395e8ad3d49bb91dfdb12678c92f6c43b431a797203bd396fe1f6934',
  transactionIndex: 0,
  type: '0x0'
}
Address of transaction:  0x00fFD3548725459255f1e78A61A07f1539Db0271
Use the smart contracts 'get' function to read the contract's constructor initialized value ..
Member1 obtained value at deployed contract is: 47
Use the smart contracts 'set' function to update that value to 123 .. - from member1 to member3
Error: Returned error: method handler crashed
    at Object.ErrorResponse (/home/lex/sources/quorum-test-network/smart_contracts/privacy/node_modules/web3-core-helpers/lib/errors.js:28:19)
    at /home/lex/sources/quorum-test-network/smart_contracts/privacy/node_modules/web3-core-requestmanager/lib/index.js:302:36
    at request.onreadystatechange (/home/lex/sources/quorum-test-network/smart_contracts/privacy/node_modules/web3-providers-http/lib/index.js:98:13)
    at XMLHttpRequestEventTarget.dispatchEvent (/home/lex/sources/quorum-test-network/smart_contracts/privacy/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
    at XMLHttpRequest._setReadyState (/home/lex/sources/quorum-test-network/smart_contracts/privacy/node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
    at XMLHttpRequest._onHttpResponseEnd (/home/lex/sources/quorum-test-network/smart_contracts/privacy/node_modules/xhr2-cookies/dist/xml-http-request.js:318:14)
    at IncomingMessage.<anonymous> (/home/lex/sources/quorum-test-network/smart_contracts/privacy/node_modules/xhr2-cookies/dist/xml-http-request.js:289:61)
    at IncomingMessage.emit (node:events:525:35)
    at endReadableNT (node:internal/streams/readable:1359:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  data: null
}

If selected Hyperledger Besu client, then got error with minimum gas price:

lex@quorumubuntu22:~/sources/quorum-test-network/smart_contracts/privacy/scripts$ node private_tx.js
Creating contract...
Error: Returned error: Gas price below configured minimum gas price
    at Object.ErrorResponse (/home/lex/sources/quorum-test-network/smart_contracts/privacy/node_modules/web3-core-helpers/lib/errors.js:28:19)
    at /home/lex/sources/quorum-test-network/smart_contracts/privacy/node_modules/web3-core-requestmanager/lib/index.js:302:36
    at request.onreadystatechange (/home/lex/sources/quorum-test-network/smart_contracts/privacy/node_modules/web3-providers-http/lib/index.js:98:13)
    at XMLHttpRequestEventTarget.dispatchEvent (/home/lex/sources/quorum-test-network/smart_contracts/privacy/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
    at XMLHttpRequest._setReadyState (/home/lex/sources/quorum-test-network/smart_contracts/privacy/node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
    at XMLHttpRequest._onHttpResponseEnd (/home/lex/sources/quorum-test-network/smart_contracts/privacy/node_modules/xhr2-cookies/dist/xml-http-request.js:318:14)
    at IncomingMessage.<anonymous> (/home/lex/sources/quorum-test-network/smart_contracts/privacy/node_modules/xhr2-cookies/dist/xml-http-request.js:289:61)
    at IncomingMessage.emit (node:events:525:35)
    at endReadableNT (node:internal/streams/readable:1359:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  data: null
}

@ToToDoDo did you find any solution?

im1ex commented 1 year ago

Previous version works well, so just use:

npx quorum-dev-quickstart@0.1.2
paragao commented 1 year ago

same here, running the hyperledger besu client. Also, the tutorial tells the user to run npm install inside the ./smart_contracts directory but there is not a package.json file there. You can find it under ./smart_contracts/privacy .

joshuafernandes commented 1 year ago

@antonydenyer should we revert #244 to fix the above?

antonydenyer commented 1 year ago

That's an interesting bug.

The root cause is https://github.com/ConsenSys/quorum/blob/fbfb5dd12a8c2b8abd053f858ef539ab38196b75/core/vm/operations_acl.go#L66

This is happening because the address is indeed absent in the public statedb! Why are we seeing it now? It was introduced in the Berlin fork. The workaround is to set the Berlin fork block to a very high value. The correct answer is to fix the bug https://github.com/Consensys/quorum/issues/1657

It was introduce in https://github.com/Consensys/quorum-dev-quickstart/pull/250

joshuafernandes commented 1 year ago

Thank you @antonydenyer :)

@ToToDoDo @imlex I've pushed a fix #259 for the goquorum side of things (bandaid albeit till its fixed in the goq codebase) to master.

Re Besu: Am waiting for #259 to get merged and I'll cut a fresh release which should fix both

joshuafernandes commented 1 year ago

Closing this as this should be fixed in 0.1.4