solidity icon indicating copy to clipboard operation
solidity copied to clipboard

External function call not working in 0.4.22, 0.4.23, 0.4.24, 0.25

Open aas312 opened this issue 8 years ago • 8 comments

Steps to reproduce in Quorum

  1. Clone https://github.com/jpmorganchase/quorum-examples/tree/master/examples/7nodes. 2../raft-init.sh 3../raft-start.sh
  2. Used truffle to deploy the contracts.. truffle version 4.1.11

2_deploy_contract.js

let InfoFeed = artifacts.require("./InfoFeed.sol");
let Consumer = artifacts.require("./Consumer.sol");

module.exports = function(deployer) {
  deployer.deploy(InfoFeed) 
  .then(() => {
    return deployer.deploy(Consumer, InfoFeed.address);
  })
};

Expected: Consumer.getInfo must return 42. Observed: Consumer.getInfo returns 0.

However, if I used 0.4.21 this works.

\\InfoFeed.sol
pragma solidity 0.4.24;

contract InfoFeed {
    function info() 
        public 
        pure 
        returns (uint8 ret) 
    { 
        return 42; 
        
    }
}

\\Consumer.sol
contract Consumer {
    InfoFeed feed;
    function Consumer(address addr) public { feed = InfoFeed(addr); }
    function getInfo(uint8 _someInt) public view returns (uint8 _someInfo) { return feed.info(); }
}

aas312 avatar May 25 '18 19:05 aas312

Please give a bit more information. Which EVM version and environment are you running this against? Does getInfo really return 0 or does it revert?

chriseth avatar May 28 '18 17:05 chriseth

How do I get the EVM version? I am using Ubuntu 16.04 LTS.

aas312 avatar May 29 '18 17:05 aas312

@aas312 this depends on a lot of factors. When you say "Deploy InfoFeed contract" - what exactly are you doing? Which blockchain are you using and how do you run it?

chriseth avatar May 30 '18 10:05 chriseth

@chriseth I am using Parity v1.10.1. I setup my parity network using https://github.com/folsen/parity-poa-playground. When I say deploy I am clicking on the Deploy button in the Contract (Click Settings and check the Contract checkbox) tab in the Parity wallet. getInfo is returning 0.

aas312 avatar Jun 01 '18 14:06 aas312

Shouldn't you be changing your constructor definition to the new format? I'm surprised you're not getting errors during compilation.

i.e: function Consumer(address addr) public { feed = InfoFeed(addr); }

will be: constructor(address addr) public { feed = InfoFeed(addr); }

jackneil avatar Jun 04 '18 13:06 jackneil

@jackneil yes i do get warnings for the constructor. This warning will become error in 0.4.25, but for now it works.

aas312 avatar Jun 04 '18 14:06 aas312

I think this should be covered by #4259.

axic avatar Jun 11 '18 11:06 axic

Relevant issue in the quorum repository: https://github.com/jpmorganchase/quorum/issues/397

chriseth avatar Jun 11 '18 13:06 chriseth