quorum icon indicating copy to clipboard operation
quorum copied to clipboard

Not able to call function in another contract

Open aas312 opened this issue 8 years ago • 13 comments

System information

Geth version: geth version 1.7.2

OS & Version: Ubuntu 16.04

Branch, Commit Hash or Release: master ee21fdb101bf82144f11d599efbfda0c3ec30c97

Expected behaviour

setInfo() must change the value of the info state variable.

Actual behaviour

setInfo() does not change the value of the info state variable.

Steps to reproduce the behaviour

PreReq: node v8, truffle v4.1.6

Run the 7 node network Clone https://github.com/aas312/consumer-quorum Run npm run build Run node sandbox.js

aas312 avatar May 31 '18 18:05 aas312

Hi @aas312 I know we exchanged messages on Slack, please reopen if this is still an issue.

fixanoid avatar Jun 05 '18 22:06 fixanoid

@fixanoid this is still an issue. The issue is only resolved if I use 0.4.18. For 0.4.21 and above this is not fixed.

aas312 avatar Jun 07 '18 12:06 aas312

@aas312 , testing and reproducing error as per your specification. Will revert on this. Thanks

0zAND1z avatar Jun 07 '18 13:06 0zAND1z

So, here's the code deployed on a raft-based quorum standalone node:

pragma solidity ^0.4.18;

contract A {
    string abc = "abc";
    function foo() returns (string _fooRet) {
        return abc;
    }
}

contract B {
  A public aref;
  string public ret;

  function createFoo (address _contractAddress) {
    aref = A(_contractAddress);
    ret = aref.foo();
  }
}

Unable to fetch the updated value of aref & ret once the createFoo() was called with the address of A deployed.

@aas312 , can you concur?

0zAND1z avatar Jun 07 '18 14:06 0zAND1z

I get the error :

TypeError: Type inaccessible dynamic type is not implicitly convertible to expected type string storage ref. ret = aref.foo();
 ^--------^

when I compile the code

The problem is that dynamic returns for strings wasn't supported until solidity 0.4.22

The options are to either use 0.4.22 or pass it as bytes32 or something and convert it on the front end

realcodywburns avatar Jun 07 '18 17:06 realcodywburns

I changed the contract to use uint8

pragma solidity ^0.4.18;

contract A {
    uint8 abc = 1;
    function foo() public returns (uint8 _fooRet) {
        return abc;
    }
}

pragma solidity ^0.4.18;

import './A.sol';

contract B {
  A private aref;
  
  function B(address _contractAddress) {
    aref = A(_contractAddress);
  }

  function getFoo() public returns (uint8) {
    return aref.foo();
  }    
}

WIth solc 0.4.18 I get 1 when I call getFoo but with 0.4.24 i don't get the same value

aas312 avatar Jun 07 '18 19:06 aas312

Same, with solc 0.4.18 i get the correct value, with 0.4.24 it fails

Same when deploying on non- quorum chains

realcodywburns avatar Jun 07 '18 20:06 realcodywburns

Same when deploying on non-quorum chains

@realcodywburns do you mean using 0.4.24 fails on other clients as well, not just Quorum ?

jpmsam avatar Jul 09 '18 20:07 jpmsam

Yes, ETC is having the same issue when using solc 0.4.24. The contracts compile and run correctly on eth mainnet & testnets, however they fail on etc mainnet and morden. I'm looking into it now.

realcodywburns avatar Jul 10 '18 15:07 realcodywburns

The breaking change came with version 0.4.22 . It looks like it is something involving Support accessing dynamic return data in post-byzantium EVMs.

Code compiled with cross contract calls using 0.4.21 is functional, same code with 0.4.22 is unable to make cross contract calls.

Solution(?) it seems that >0.4.22 versions of solc compile for Byzantium by default. Adding ByzantiumBlock=0 to genesis should fix the problem on quorum

Fixed in 7 nodes example with: https://github.com/jpmorganchase/quorum-examples/commit/90a2895a5335ac0e23b769479f0527f5336597a7

Related threads: https://github.com/ethereum/solidity/issues/3969 https://github.com/ethereum/solidity/issues/4259

realcodywburns avatar Jul 10 '18 16:07 realcodywburns

It has been updated for both IBFT and RAFT but you have to re-initialize the chain.

jpmsam avatar Jul 15 '18 02:07 jpmsam

@jpmsam , we tried to re-init the chain with the updated genesis but still encountering same issues.

Is there a docker image which has these changes resolved? Thanks

0zAND1z avatar Oct 05 '18 12:10 0zAND1z

@kggp1995 please open new issue with detailed description of the problem.

Quorum official docker images are here: https://hub.docker.com/u/quorumengineering/

fixanoid avatar Oct 05 '18 15:10 fixanoid