second-state / SOLL

SOLL is a new compiler for generate Ewasm from solidity and yul. See a demo here: https://asciinema.org/a/ezJqNLicn5fya02zwu4VXIo8a
https://www.secondstate.io/
377 stars 23 forks source link

Compile Yul fail when original contract has use ecrecover function #107

Closed CaptainVincent closed 3 years ago

CaptainVincent commented 3 years ago

ex. builtin_test.sol

// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// RUN: %soll %s
pragma solidity =0.8.6;

contract TestBuiltIn {
  constructor() payable {
  }

  function builtin(bytes32 digest, uint8 v, bytes32 r, bytes32 s) external pure {
    ecrecover(digest, v, r, s);
  }
}
solc builtin_test.sol --ir -o . --overwrite
soll --lang=Yul TestBuiltIn.yul

Error message as below:

Invalid bitcast %23 = bitcast i256 %19 to i8*

I think the issue is relative with emit Yul staticcall has a type casting issue.

jacky860226 commented 3 years ago

Error happened here.

object "TestBuiltIn" {
    code {
        function allocate_unbounded() -> memPtr {
            memPtr := mload(64)
        }
        let GG := allocate_unbounded()
        staticcall(gas(), 1, GG, sub(GG, GG), 0, 32)
    }
}