Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用前端按文件夹导出的abi和bin文件部署合约错误 #773

Open
JacksonRGB opened this issue May 25, 2022 · 5 comments
Open
Labels
bug Something isn't working

Comments

@JacksonRGB
Copy link
Contributor

JacksonRGB commented May 25, 2022

webase 1.5.4
fisco-bcos 2.8.0
solidity 0.6.10

场景:A、B两个合约,A合约引用B合约,在A合约的构造函数中引用了B合约的public函数,且修改了B合约的状态变量

这两个合约在WeBASE中都可以正确部署并运行


出现错误的操作

按文件夹导出abi、bin文件,使用go sdk中的abigen工具生成go文件

使用go代码部署B合约,正确返回

使用go代码部署A合约,错误,状态码0x16,revert


使用以下方法避免了该错误

导出sol文件后,使用solc重新编译A、B合约的 abi文件和bin文件

再次使用abigen生成go文件,使用go代码部署合约,A、B均成功部署


因此对于有引用的合约,使用前端导出abi文件和bin文件生成go文件并部署合约时会有报错

@CodingCattwo
Copy link
Contributor

可以列出一下通过文件夹到处的abi和bin文件,与通过solc编译sol
文件得到的abi和bin文件的差异,方便我们定位一下问题所在

@CodingCattwo
Copy link
Contributor

webase到处的abi格式如下,bin则是直接的bin值
企业微信截图_1653535742415

image

@JacksonRGB
Copy link
Contributor Author

JacksonRGB commented May 26, 2022

测试时发现另一个小问题,创建合约文件是如果合约名长度为1时(如A),弹出框提示“请输入数字或字母,长度1-32位”


创建test文件夹,在文件夹下创建AA和BB文件

BB.sol

pragma solidity 0.6.10;


contract BB {
    
    uint x = 1;
    
    function add() public {
        x += 1;
    }
}

AA.sol

pragma solidity 0.6.10;
import "./BB.sol";


contract AA {
    
    constructor(address bAddress) public {
        BB(bAddress).add();
    }
    
    
}

在webase界面,编译AA.sol合约,界面下方显示的bin code
6080604052348015600f57600080fd5b5060405160eb38038060eb83398181016040526020811015602f57600080fd5b81019080805190602001909291905050508073ffffffffffffffffffffffffffffffffffffffff16634f2be91f6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015608757600080fd5b505af1158015609a573d6000803e3d6000fd5b5050505050603f8060ac6000396000f3fe6080604052600080fdfea2646970667358221220ab09a19d37100eec8e367a9f3ef656b908fde127bbd2494f5f1a00c7636d0b2864736f6c634300060a0033

abi

[{"inputs":[{"internalType":"address","name":"bAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"}]

在web界面右键导出test.zip,解压缩后文件夹中AA.bin文件内容
6080604052600080fdfea2646970667358221220ab09a19d37100eec8e367a9f3ef656b908fde127bbd2494f5f1a00c7636d0b2864736f6c634300060a0033

AA.abi文件内容
[{"inputs":[{"internalType":"address","name":"bAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"}]

使用solc手动编译AA.sol文件

./solc --abi --bin AA.sol --overwrite -o ./

再次查看AA.bin文件内容,现在与webase界面中bin code数据一致
6080604052348015600f57600080fd5b5060405160eb38038060eb83398181016040526020811015602f57600080fd5b81019080805190602001909291905050508073ffffffffffffffffffffffffffffffffffffffff16634f2be91f6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015608757600080fd5b505af1158015609a573d6000803e3d6000fd5b5050505050603f8060ac6000396000f3fe6080604052600080fdfea2646970667358221220ab09a19d37100eec8e367a9f3ef656b908fde127bbd2494f5f1a00c7636d0b2864736f6c634300060a0033

AA.abi

[{"inputs":[{"internalType":"address","name":"bAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"}]

@CodingCattwo
Copy link
Contributor

举例的BIN数据十分详尽,我们检查一下该问题

@CodingCattwo
Copy link
Contributor

企业微信截图_1654592681564

经确认,此处为bug,前端应该使用后台返回的bytecodeBin字段中的值,却错误使用了contractBin的值

@CodingCattwo CodingCattwo added the bug Something isn't working label Sep 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants