Consensys / quorum

A permissioned implementation of Ethereum supporting data privacy
https://www.goquorum.com/
GNU Lesser General Public License v3.0
4.68k stars 1.29k forks source link

Extended contract state status is not changing to DONE even after approving the management Contract on Node C #1396

Closed nirajgadgil closed 2 years ago

nirajgadgil commented 2 years ago

Hi,

I have a privacy group setup with Node A & Node B. Would like to extend the contracts to new Node C. I am using Basic network permissioning. Following the below documentation steps to extend my existing contract to Node C. https://consensys.net/docs/goquorum/en/stable/concepts/privacy/contract-extension/

  1. Initiate Extension request on Node A for extending the contract to Node C.
  2. Called ActiveExtension API to get managementContract address
  3. Used that address to approve an extension request from Node C
  4. Checked the status of request using getExtensionStatus and found that it's still in ACTIVE state

Is there any Step missing which needs to be executed? Within the documentation, it is expected to perform only 2 operations and rest of the process of extension is expected to be done from backend side.

Kindly suggest.

baptiste-b-pegasys commented 2 years ago

In your step 3, do you use the contract address for approving instead of eth address of node C? Can you try to use the recipient address passed in the extension intiation?

https://consensys.net/docs/goquorum/en/stable/reference/api-methods/#quorumextension_extendcontract

nirajgadgil commented 2 years ago

In your step 3, do you use the contract address for approving instead of eth address of node C? Thanks a lot for your reply. For approval, I am using below request. Please let me know if any modification is required. curl -X POST http://127.0.0.1:22000/ --data '{"jsonrpc":"2.0","method":"quorumExtension_approveExtension","params":["Management_Contract_Address",true,{"from":"NODE_C_ACCOUNT_ADDRESS","privateFor":["NODE_A_TESSERA_PUBLIC_KEY"]}],"id":10}' --header "Content-Type: application/json"

baptiste-b-pegasys commented 2 years ago

I played with it with the current version, I have "DONE" My playbook from quorum examples:

Node6:

> quorumExtension.extendContract(address, "BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo=", "0xed9d02e382b34818e88b88a309c7fe71e65f419d", {"from":eth.accounts[0], "privateFor":["BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo="]})
"0xd1989fd054d8e2d2956c54868fa87fc3858ac3fbff668f378a19a7eb1a0659e8"

Node1:

> quorumExtension.activeExtensionContracts
[{
    contractExtended: "0x2634416c409db4a974775ea06246b387ad3a1b46",
    creationData: "HvMQ+YJRQyhZspGNafOYsUzp0xsx1CxCrLAvs1xsF8vKyNNPNRI2M7p8rOAXC1MumslS2NjZd6rbcImmw4e8Iw==",
    initiator: "0xae9bc6cd5145e67fbd1887a5145271fd182f0ee7",
    managementContractAddress: "0x11ef71290906a85f470ea16bb4b5208e8a6dba1d",
    recipient: "0xed9d02e382b34818e88b88a309c7fe71e65f419d",
    recipientPtmKey: "BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo="
}]
> quorumExtension.approveExtension("0x11ef71290906a85f470ea16bb4b5208e8a6dba1d", true, {"from":eth.accounts[0],"privateFor":["UfNSeSGySeKg11DVNEnqrUtxYRVor4+CvluI8tVv62Y="]})
"0x2029a568db7fbcb5c54db75c07b6e97cd9e3fed035bb839527a15a6365762c9b"
> private.get()
52
> quorumExtension.activeExtensionContracts
[]
> quorumExtension.getExtensionStatus("0x11ef71290906a85f470ea16bb4b5208e8a6dba1d")
"DONE"

Would you mind sharing the config files if they are different from quorum examples? (flags, genesis, toml if you use)

baptiste-b-pegasys commented 2 years ago

Might be also the id=10 that's the nonce. You can try another one, depending on the code returned

nirajgadgil commented 2 years ago

Thanks again for your reply. Will retry it one more time. We are using v21.7.1 version of Quorum. Do you think that could be the issue? But how come other APIs are working?

baptiste-b-pegasys commented 2 years ago

We have the Acceptance Tests that are testing contract extensions, we don't publish a release when one of them fails.

I will do a manual testing as well to see.

baptiste-b-pegasys commented 2 years ago

API+v21.7.1 test OK

Playbook:

> quorumExtension.activeExtensionContracts
[{
    contractExtended: "0x2634416c409db4a974775ea06246b387ad3a1b46",
    creationData: "ObHs+OggzBuRr+a0o/k9q10S1IYWyRZEkfKGVxYmy+ienheY9Rgop0opVWFxbq0e4zCCVcYwGNc5U9mdo8737w==",
    initiator: "0xed9d02e382b34818e88b88a309c7fe71e65f419d",
    managementContractAddress: "0x9d13c6d3afe1721beef56b55d303b09e021e27ab",
    recipient: "0x0fbdc686b912d7722dc86510934589e0aaf3b55a",
    recipientPtmKey: "1iTZde/ndBHvzhcl7V68x44Vx7pl8nwx9LqnM/AfJUg="
}]

{"jsonrpc":"2.0","method":"quorumExtension_approveExtension","params":["0x9d13c6d3afe1721beef56b55d303b09e021e27ab",true,{"from":"0x0fbdc686b912d7722dc86510934589e0aaf3b55a","privateFor":["BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo="]}],"id":10}

> quorumExtension.activeExtensionContracts
[]
> quorumExtension.getExtensionStatus("0x9d13c6d3afe1721beef56b55d303b09e021e27ab")
"DONE"
> var address="0x2634416c409db4a974775ea06246b387ad3a1b46"
undefined
> var private = eth.contract(abi).at(address)
undefined
> private.get()
52
> private.set(2,{"from":eth.accounts[0], "privateFor":["BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo=", "QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc="]})
"0xbedf958a2fb0362c5fcd8a6460601fd0612429033a8d9e6c6f3ff350b723742b"
> private.get()

2
nirajgadgil commented 2 years ago

We cancelled all earlier extended contract which were waiting for approval and initiate a fresh request. Extend and approve APIs/Geth calls returning us the response without any error. But still the status of contract is not updating to DONE.

nirajgadgil commented 2 years ago

Also we are using network with privacyFlag 3 value. I hope that's not giving any problem

baptiste-b-pegasys commented 2 years ago

OK I am trying with PV=3, that's might the reason.

baptiste-b-pegasys commented 2 years ago

Good with PV=3, might consider adding privacyFlag at every request.

> quorumExtension.activeExtensionContracts
[]

undefined

var private = eth.contract(abi).at(address) undefined private.get() 42 private.set(52,{"from":eth.accounts[0], "privateFor":["1iTZde/ndBHvzhcl7V68x44Vx7pl8nwx9LqnM/AfJUg=","QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc="],"privacyFlag":3}) "0x0ddd908c80b7512f34941b810519ccca59855b699e9bed113fbd06d28a6c484e"

- On Nodes 1, 2, 3:

private.get() 52

nirajgadgil commented 2 years ago

Tried with PrivacyFlag in request too but no success. The status of contract is not changing and keep displaying under Active API result. Is there anything else/configuration which needs to be managed? Which Playbook example you are using for the test?

nirajgadgil commented 2 years ago

Hi @baptiste-b-pegasys Thanks for the details provided. For more better understanding of the problem which is still not working for us, I am attaching genesis and other config file details below. Just a note, we are using IBFT consensus and may be playbook example is based on RAFT. Not sure if that's the issue.

Below is the genesis json file

{
  "alloc": {},
  "coinbase": "0x0000000000000000000000000000000000000000",
  "config": {
    "homesteadBlock": 0,
    "byzantiumBlock": 0,
    "constantinopleBlock": 0,
    "petersburgBlock": 0,
    "istanbulBlock": 0,
    "eip150Block": 0,
    "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "eip155Block": 0,
    "eip158Block": 0,
    "maxCodeSizeConfig": [
      {
        "block": 0,
        "size": 128
      }
    ],
    "txnSizeLimit": 128,
    "chainId": 1000,
    "isQuorum": true,
    "istanbul": {
      "epoch": 30000,
      "policy": 0,
      "ceil2Nby3Block": 0
    }
  },
  "difficulty": "0x1",
  "extraData": "MASKED_EXTRA_DATA",
  "gasLimit": "0xE0000000",
  "mixHash": "0x963616c2062797a616e756c7420746f6c6572616e6365",
  "nonce": "0x0",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp": "0x00"
}

And other flags config

NETWORK_ID=1000 
RPC_APIS=admin,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum 
args=" --gcmode archive --istanbul.blockperiod 5 --syncmode full " 
RPC_APIS="$RPC_APIS,quorumExtension,istanbul"

usr/local/bin/geth --datadir $QUORUM_DATA_DIR $args --allow-insecure-unlock  --permissioned --key
store /etc/quorum/qdata/keystore/ --nodekey /etc/quorum/qdata/nodekey --nodiscover --nat=none --verbosity 9 --networkid $NETWORK_ID  --emitcheckpoints -
-rpc --rpcaddr 0.0.0.0 --rpcvhosts=* --rpcport 8545 --rpcapi $RPC_APIS --wsapi $RPC_APIS --wsport 8546 --port 30303
baptiste-b-pegasys commented 2 years ago

I added privacyEnhancementsBlock to your genesis. I will test what happen without it or with an future value. You can set a future block (transition) to all nodes of your network, the extension may be played once it is activated.

{
    "alloc": {},
    "coinbase": "0x0000000000000000000000000000000000000000",
    "config": {
      "homesteadBlock": 0,
      "byzantiumBlock": 0,
      "constantinopleBlock": 0,
      "petersburgBlock": 0,
      "istanbulBlock": 0,
      "eip150Block": 0,
      "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "eip155Block": 0,
      "eip158Block": 0,
      "maxCodeSizeConfig": [
        {
          "block": 0,
          "size": 128
        }
      ],
      "txnSizeLimit": 128,
      "chainId": 1000,
      "isQuorum": true,
      "istanbul": {
        "epoch": 30000,
        "policy": 0,
        "ceil2Nby3Block": 0
      },
      "privacyEnhancementsBlock":0
    },
    "difficulty": "0x1",
    "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000f8d9f89394d8dba507e85f116b1f7e231ca8525fc9008a6966946571d97f340c8495b661a823f2c2145ca47d63c294e36cbeb565b061217930767886474e3cde903ac594f512a992f3fb749857d758ffda1330e590fa915e94b912de287f9b047b4228436e94b5b78e3ee16171948157d4437104e3b8df4451a85f7b2438ef6699ff94b131288f355bc27090e542ae0be213c20350b767b8410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0",
    "gasLimit": "0xE0000000",
    "mixHash": "0x63746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365",
    "nonce": "0x0",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "timestamp": "0x00"
  }
nirajgadgil commented 2 years ago

We double checked privacyEnhancementsBlockparameter and it was there in genesis file. But as you suggest, we activate --allowedfutureblocktime 1 on all 3 nodes. But it didn't help. The extended contract remained in ACTIVE state even after approval.

baptiste-b-pegasys commented 2 years ago

I am sorry I am not able to reproduce your case, can you try to reproduce this with quickdevstart or goq examples thank you

nirajgadgil commented 2 years ago

I am sorry I am not able to reproduce your case, can you try to reproduce this with quickdevstart or goq examples thank you

Ok. Let me try out those examples and will get back to you soon if face same issue