hyperledger-archives / burrow

https://wiki.hyperledger.org/display/burrow
https://hyperledger.github.io/burrow
Apache License 2.0
1.03k stars 346 forks source link

Burrow's EVM returns results different from Remix(Javascript VM) #696

Closed pouladzade closed 6 years ago

pouladzade commented 6 years ago

Please include in your bug report:

Burrow's EVM issue : I did deployed this smart contract on the Burrow, and called the Test method with this parameters 5,6,7 but the result is very different with Remix Ide (Ethereum JavaScript VM) Here is the issue information :


Smart Contract :

pragma solidity ^0.4.16;

contract ByteCasting {

      function Test(int8 _in1, int256 _in2, int16 _in3) public pure 
                returns(bytes out,int8 _out1, int256 _out2, int16 _out3) {

        bytes memory _buff = new  bytes(128);

        //////////////
        // Serializing
        uint128 _offst = 128;

        int8ToBytes(_offst,_in1,_buff);
        _offst -= 1;

        int256ToBytes(_offst,_in2,_buff);
        _offst -= 32;        

        int16ToBytes(_offst,_in3,_buff);
        _offst -= 2; 

        out = _buff;
        ////////////////
        // Deserializing
        _offst = 128;

        _out1 = bytesToInt8(_offst,_buff);
        _offst -= 1;

        _out2 = bytesToInt256(_offst,_buff);
        _offst -= 32;

        _out3 = bytesToInt16(_offst,_buff);
        _offst -= 2;

    }

    function int8ToBytes(uint128 _offst, int8 _input, bytes _output) public pure {

        assembly {
            mstore(add(_output, _offst), _input)
        }
    }

    function int16ToBytes(uint128 _offst, int16 _input, bytes _output) public pure {

        assembly {
            mstore(add(_output, _offst), _input)
        }
    }

    function int256ToBytes(uint128 _offst, int256 _input, bytes _output) public pure {

        assembly {
            mstore(add(_output, _offst), _input)
        }
    }

    function bytesToInt8(uint128 _offst, bytes _input) public pure returns (int8 _output) {

        assembly {
            _output := mload(add(_input, _offst))
        }
    }

    function bytesToInt16(uint128 _offst, bytes _input) public pure returns (int16 _output) {

        assembly {
            _output := mload(add(_input, _offst))
        }
    }

    function bytesToInt256(uint128 _offst, bytes _input) public pure returns (int256 _output) {

        assembly {
            _output := mload(add(_input, _offst))
        }
    }
}

Function call :

Test(5,6,7)


what actually happened: Burrow's output :+1: Burrow-EVM-Issue.txt

"0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000800600 0000000000000000000000000000000000000000000000000000000000000684", "-124", "6", "-32762"


silasdavis commented 6 years ago

Run this code in remix here: https://remix.ethereum.org/#optimize=false&version=soljson-v0.4.20+commit.3155dd80.js&gist=05ec3120d970a1fc9f87ae4d7ed37d09

silasdavis commented 6 years ago

resolved by #704