Consensys/quorum-examples

Issue updating a struct field

Closed this issue · 2 comments

System information

Geth version: v1.8.12-stable-c6f0ae4e

OS & Version: Linux

Environment: docker

Expected behavior

updating fields of transactions struct

Actual behavior

no update

Smart contract code

pragma solidity ^0.4.24;

contract Test {

    uint public start;
    uint public end;

    struct test {
        uint value;
        uint value2;
    }
    
    mapping (uint => test) public tests;
    
    function update(uint _value1, uint _value2) {
    
        start++;
        
        tests[end].value=_value1;
        tests[end].value2=_value2;
        
        end++;
    }
}

Deployment script

var abi = [ { "constant": false, "inputs": [ { "name": "_value1", "type": "uint256" }, { "name": "_value2", "type": "uint256" } ], "name": "update", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "start", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "", "type": "uint256" } ], "name": "tests", "outputs": [ { "name": "value", "type": "uint256" }, { "name": "value2", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "end", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" } ];
var bytecode = "0x608060405234801561001057600080fd5b506101f9806100206000396000f300608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632fb565e814610067578063be9a65551461009e578063de22c8d4146100c9578063efbe1c1c14610111575b600080fd5b34801561007357600080fd5b5061009c600480360381019080803590602001909291908035906020019092919050505061013c565b005b3480156100aa57600080fd5b506100b361019d565b6040518082815260200191505060405180910390f35b3480156100d557600080fd5b506100f4600480360381019080803590602001909291905050506101a3565b604051808381526020018281526020019250505060405180910390f35b34801561011d57600080fd5b506101266101c7565b6040518082815260200191505060405180910390f35b6000808154809291906001019190505550816002600060015481526020019081526020016000206000018190555080600260006001548152602001908152602001600020600101819055506001600081548092919060010191905055505050565b60005481565b60026020528060005260406000206000915090508060000154908060010154905082565b600154815600a165627a7a72305820f7672f4e39453a568da8be01fe5b2b70ec4d0cbe5e026ea46fc67e17f2040dc50029";
var contract = web3.eth.contract(abi);

var test = contract.new({from:web3.eth.accounts[0], data: bytecode, gas: 0x47b760, privateFor: ["BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo=", "QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc=",
        "1iTZde/ndBHvzhcl7V68x44Vx7pl8nwx9LqnM/AfJUg=", "oNspPPgszVUFw0qmGFfWwh1uxVUXgvBxleXORHj07g8="]}, 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("test contract mined! Address: " + contract.address);
        }
    }
});

Issue

i have a problem with updating the struct params
1- When i execute the update function (struct with 2 params) and without privateFor, the transaction is mined but no changes.
2params with-privatefor

2- When i execute the update function (struct with 2 params) and with privateFor, the transaction is not mined so no changes.
2params with-privatefor

3- When i execute the update function (struct with 1 param) and with privateFor, the transaction mined and the struct fields are updated.
Smart contract code

pragma solidity ^0.4.24;

contract Test {

    uint public start;
    uint public end;

    struct test {
        uint value;
    }
    
    mapping (uint => test) public tests;
    
    function update(uint _value) {
    
        start++;
        tests[end].value=_value;
        end++;
    }
}

1param with-privatefor

Hi @yosrahelal, apologies for delay.

I'm testing the provided contracts and I see that updates are successful in either case: when updating 2 or 1 value in a struct. The only thing I had to do was to run this from a node not in the privateFor list -- in my case, node 6.

Were you accessing the right tests structure after your successive tests? test.tests(0) would correspond to the first update, tests.tests(1) would be second, etc...

Please reopen if this is still an issue.