Giter Site home page Giter Site logo

fisco-bcos / python-sdk Goto Github PK

View Code? Open in Web Editor NEW
67.0 12.0 60.0 11.17 MB

python sdk for FISCO BCOS

License: MIT License

Python 86.07% Shell 3.54% JavaScript 0.30% Dockerfile 0.09% C 2.35% Solidity 3.18% C++ 3.60% Makefile 0.60% Cython 0.27%
python sdk client console

python-sdk's Issues

部署合约出现问题

**命令行:python ./console3.py deploy HelloWorld

情况1: 已经安装solc编译器并且在remix上将sol转为了abi和bin文件:
截屏2023-03-25 22 38 19

但仍然报以下下错误:**

INFO >> user input : ['deploy', 'HelloWorld']

BCOS3 Deploy start------------->
user input: ['HelloWorld']
backup [./contracts/HelloWorld.abi] to [./contracts/backup/HelloWorld.abi.20230325094945]
backup [./contracts/HelloWorld.bin] to [./contracts/backup/HelloWorld.bin.20230325094953]
INFO >> compile with nodejs compiler
/usr/bin/env: ‘node’: No such file or directory
ERROR >> execute deploy failed
ERROR >> error information: compile error for compile failed, error information: Command '['./solcjs', '--bin', '--abi', './contracts/HelloWorld.sol', '-o', 'contracts']' returned non-zero exit status 127.

**情况2: 后尝试安装nodejs

报错如下:**
INFO >> user input : ['deploy', 'HelloWorld']

BCOS3 Deploy start------------->
user input: ['HelloWorld']
backup [./contracts/HelloWorld.abi] to [./contracts/backup/HelloWorld.abi.20230325094945]
backup [./contracts/HelloWorld.bin] to [./contracts/backup/HelloWorld.bin.20230325094953]
INFO >> compile with nodejs compiler
/opt/distributed_architecture_/Blockchain+Flask/python-sdk/solcjs:93
let readCallback = (importContractName) => {
^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
ERROR >> execute deploy failed
ERROR >> error information: compile error for compile failed, error information: Command '['./solcjs', '--bin', '--abi', './contracts/HelloWorld.sol', '-o', 'contracts']' returned non-zero exit status 1.

情况3:后尝试升级node:
报错如下:

BCOS3 Deploy start------------->
user input: ['HelloWorld']
backup [./contracts/HelloWorld.abi] to [./contracts/backup/HelloWorld.abi.20230325094945]
backup [./contracts/HelloWorld.bin] to [./contracts/backup/HelloWorld.bin.20230325094953]
INFO >> compile with nodejs compiler
node: /lib/x86_64-linux-gnu/libm.so.6: version GLIBC_2.27' not found (required by node) node: /lib/x86_64-linux-gnu/libc.so.6: version GLIBC_2.25' not found (required by node)
node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by node)
ERROR >> execute deploy failed
ERROR >> error information: compile error for compile failed, error information: Command '['./solcjs', '--bin', '--abi', './contracts/HelloWorld.sol', '-o', 'contracts']' returned non-zero exit status 1.

crud_service工具问题

使用crud_service创建table需要设置key,但是

  1. 插入entry时并不检查key是否重复
  2. 使用CRUDService.select()方法时,condition内必须含有对key的限制
  3. 基于(2),调用CRUDService.desc()方法时,会报错
    Must set condition for the primary key

Python SDK部分接口返回信息是十六进制,用户体验不友好

getTotalTransactionCount, getPendingTxSize和getPbftView接口返回的信息十六进制,用户体验不友好,建议优化为十进制。

# getTotalTransactionCount原本输出:
INFO >> getTotalTransactionCount
     >> {
    "blockNumber": "0x10",
    "failedTxSum": "0x0",
    "txSum": "0x10"
}

# 建议优化为:
INFO >> getTotalTransactionCount
     >> {
    "blockNumber": "16",
    "failedTxSum": "0",
    "txSum": "16"
}
# getPendingTxSize原本输出
INFO >> getPendingTxSize
     >> 0x16

# 建议优化为:
INFO >> getPendingTxSize
     >> 22
# getPbftView原本输出
INFO >> getPbftView
     >> 0x11

# 建议优化为:
INFO >> getPbftView
     >> 17

Python SDK不能插入

我根据TableTest.sol写了一个合约,只是把TableTest里的int256类型也换成了string类型,然后使用python SDK去进行合约调用,表现出以下行为:

  • 调用select没有任何问题,能select到内容
  • 调用insert能获得返回值,能返回count值1,也能返回输入参数
  • 再次调用select,检索不到插入的内容,非常奇怪,因为上一步有返回值但就是无法select到
  • 使用console的方式去同样调用insert
  • 再次调用select,能检索到插入的内容
  • 还是使用python sdk的方式去insert,不行

python 调用部分

script_path = "../console/demo.exp"
ContractAddr = "0xd5d0b10598272471824256b5a336d76dae29d278"
abi_file = "../console/contracts/.compiled/1/TableDemo/"+ ContractAddr+"/TableDemo.abi"
data_parser = DatatypeParser()
data_parser.load_abi_file(abi_file)
contract_abi = data_parser.contract_abi
try:
    client = BcosClient()
    print(client.getinfo())
    # 尝试进行TableDemo合约的调用
    # 表名、主key、值域
    print("\n>>Call:------------------------------------------------------------------------")
    res = client.call(ContractAddr, contract_abi, "insert",["TEST","TEST2"])
    client.finish()
except:
    pass

合约:

pragma solidity>=0.4.24 <0.6.11;
pragma experimental ABIEncoderV2;

import "./Table.sol";

contract TableDemo {
    event CreateResult(int256 count);
    event InsertResult(int256 count);
    event UpdateResult(int256 count);
    event RemoveResult(int256 count);

    TableFactory tableFactory;
    string constant TABLE_NAME = "test04";
    constructor() public {
        tableFactory = TableFactory(0x1001); //The fixed address is 0x1001 for TableFactory
        // the parameters of createTable are tableName,keyField,"vlaueFiled1,vlaueFiled2,vlaueFiled3,..."
        tableFactory.createTable(TABLE_NAME, "mmsg", "mtype,mcontent");
    }

    //select records
    function selectAll()
    public
    view
    returns (string[] memory, string[] memory)
    {
        Table table = tableFactory.openTable(TABLE_NAME);

        Condition condition = table.newCondition();

        Entries entries = table.select("records", condition);
        // string[] memory mmsg_list = new string[](
        //     uint256(entries.size())
        // );
        string[] memory mtype_list = new string[](uint256(entries.size()));
        string[] memory mcontent_list = new string[](
            uint256(entries.size())
        );

        for (int256 i = 0; i < entries.size(); ++i) {
            Entry entry = entries.get(i);

            // mmsg_list[uint256(i)] = entry.getString("mmsg");
            mtype_list[uint256(i)] = entry.getString("mtype");
            mcontent_list[uint256(i)] = entry.getString("mcontent");
        }

        return (mtype_list, mcontent_list);
    }

    function selectByType(string memory mtype)
    public
    view
    returns (string[] memory, string[] memory)
    {
        Table table = tableFactory.openTable(TABLE_NAME);

        Condition condition = table.newCondition();
        condition.EQ("mtype", mtype);

        Entries entries = table.select("records", condition);
        // string[] memory mmsg_list = new string[](
        //     uint256(entries.size())
        // );
        string[] memory mtype_list = new string[](uint256(entries.size()));
        string[] memory mcontent_list = new string[](
            uint256(entries.size())
        );

        for (int256 i = 0; i < entries.size(); ++i) {
            Entry entry = entries.get(i);

            // mmsg_list[uint256(i)] = entry.getString("mmsg");
            mtype_list[uint256(i)] = entry.getString("mtype");
            mcontent_list[uint256(i)] = entry.getString("mcontent");
        }

        return (mtype_list, mcontent_list);
    }

    //insert records
    function insert(string memory mtype, string memory mcontent)
    public
    returns (int256, string memory, string memory)
    {
        Table table = tableFactory.openTable(TABLE_NAME);

        Entry entry = table.newEntry();
        entry.set("mmsg", "records");
        entry.set("mtype", mtype);
        entry.set("mcontent", mcontent);

        int256 count = table.insert("records", entry);
        emit InsertResult(count);

        return (count,mtype,mcontent);
    }
    //update records
    function update(string memory mmsg, string memory mtype, string memory mcontent)
    public
    returns (int256)
    {
        Table table = tableFactory.openTable(TABLE_NAME);

        Entry entry = table.newEntry();
        entry.set("mcontent", mcontent);

        Condition condition = table.newCondition();
        condition.EQ("mmsg", mmsg);
        condition.EQ("mtype", mtype);

        int256 count = table.update(mmsg, entry, condition);
        emit UpdateResult(count);

        return count;
    }
    //remove records
    function remove(string memory mmsg, string memory mtype) public returns (int256) {
        Table table = tableFactory.openTable(TABLE_NAME);

        Condition condition = table.newCondition();
        condition.EQ("mmsg", mmsg);
        condition.EQ("mtype", mtype);

        int256 count = table.remove(mmsg, condition);
        emit RemoveResult(count);

        return count;
    }
}

parsimonious库有冲突

parsimonious库和SDK里的parsimonious有冲突。在SDK目录外调用时,结果解析会报错。

向游离节点发起请求,返回信息含有反斜杠,对用户不友好

向游离状态的节点发起请求,展示返回信息包含反斜杠包含""不友好,需要优化:

例:

  • python SDK直连的节点做退网操作
# 获取直连节点Node ID(搭链操作参考FISCO-BCOS文档:https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/installation.html)
$ cat ~/fisco/nodes/127.0.0.1/node0/conf/node.nodeid
2f0a2cfb4b2e5f63fda88c2bdb9edd8f8dd2a408c04c1d4fda8a75ad1047baf87c2b18f4dbf20d67db84019b221bf50b683eeebade7e5eaffefef876e5db9a8c

# 调用removeNode进行退网操作
$ ./console.py removeNode 2f0a2cfb4b2e5f63fda88c2bdb9edd8f8dd2a408c04c1d4fda8a75ad1047baf87c2b18f4dbf20d67db84019b221bf50b683eeebade7e5eaffefef876e5db9a8c
  • 向已经退网的节点发送交易(如getSealerList)
$ ./console.py  getSealerList 
# 输出信息如下:error_infomation中含有反斜杠

INFO >> user input : ['getSealerList']

ERROR >> execute getSealerList failed
ERROR >> error information: init bcosclient failed, reason: (-1, None, 'getBlockNumber failed, params: [1], response: {\'result\': {\'error\': {\'code\': -40009, \'data\': None, \'message\': "Don\'t send request to this node who doesn\'t belong to the group"}, \'id\': 0, \'jsonrpc\': \'2.0\'}}, error information: (-40009, None, "Don\'t send request to this node who doesn\'t belong to the group")')

建议处理以上json信息中的反斜杠

调用合约,返回的解析结果需要优化

例:
调用HelloWorld合约,返回的解析信息 ('Hello, World!',)包含多余的括号和逗号,建议去掉:

  • 部署HelloWorld合约
$ ./console.py  deploy HelloWorld

获取到输出的合约地址是0x84139e0d46160aa2dd2541f499049095596891c9

  • 调用HelloWorld合约的get接口:
$  ./console.py  call  HelloWorld  0x84139e0d46160aa2dd2541f499049095596891c9 get
# 输出如下:call result结果中,包含多余的括号和逗号,需要将元组转换成字符串输出
INFO >> user input : ['call', 'HelloWorld', '0x84139e0d46160aa2dd2541f499049095596891c9', 'get']

INFO >> call HelloWorld , address: 0x84139e0d46160aa2dd2541f499049095596891c9, func: get, args:[]
INFO >> call result: ('Hello, World!',)

建议将call result后直接输出的元组转换为字符串输出。

部署了contracts文件夹下的KVTableTest合约,发起交易失败

我是bicos3版本,成功部署了contracts文件夹下的KVTableTest合约,但是调用sendRawTransaction失败。
代码如下:
receipt = client.sendRawTransaction(
to_address,
contract_abi,
"set",
['aa', 11, 'haha']
)
返回的recipt如下:
{
'blockNumber':14
'checksumContractAddress':''
'contractAddress':''
'extraData':''
'from':'0x2b21ed440abb9a6b493d75c0e5260a9e0609e2d6'
'gasUsed':'11300'
'hash':'0x'
'input':'0xed0c8b170000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000b00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000002616100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046861686100000000000000000000000000000000000000000000000000000000'
'logEntries':[]
'message':''
'output':'0x'
'status':16
'to':'0x2b5dcbae97f9d9178e8b051b08c9fb4089bae71b'
'transactionHash':'0x1e6c6a6b4491cd987508a5eb0e2e54feca18a080eb079003ae05f6f615c0393e'
'version':0
}
请问是哪里有问题,急

[parsimonious 合适版本问题] 当前版本的Python-sdk 在合约调用的参数解析,以及对节点返回结果的解析都存在问题。

下载安装之前的Python SDK(不是新推出的 Dev220209 版本),用python sdk自带控制台操作,

  1. 部署 HelloWorld 合约,正常。
  2. ./console.py call HelloWorld address get
    Fisco 节点能正常返回结果,但是Client端无法正确解析,结果如下。

$ python3 ./console.py call HelloWorld 0x83592a3cf1af302612756b8687c8dc7935c0ad1d get

INFO >> user input : ['call', 'HelloWorld', '0x83592a3cf1af302612756b8687c8dc7935c0ad1d', 'get']

contract_abi_path contracts/HelloWorld.abi, contract_bin_path contracts/HelloWorld.bin
INFO>> client info: channel 127.0.0.1:20202,groupid :1,crypto type:ECDSA,ssl type:ECDSA
INFO >> call HelloWorld , address: 0x83592a3cf1af302612756b8687c8dc7935c0ad1d, func: get, args:[]
0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d48656c6c6f2c20576f726c642100000000000000000000000000000000000000
[Exception] (when decoding the output in response):
TypeError: isinstance() arg 2 must be a type or tuple of types

Parse tree:
<Node matching ""> <-- *** We were here. ***
reuslt: currentBlockNumber,
reuslt: output,
reuslt: status,

以上例外输出本人新增于 bcosclient.py 中BcosClient类的方法 call(...)中
错误发生于下面语句:
decoderesult = decode_abi(fn_output_types,decode_hex(outputdata))
即 decode_abi() 调用出错,没能正常解析出返回的结果,只是解析出了返回结果的几个 keys,而没有正确解析出 Values。

  1. ./console.py sendtx HelloWorld address set "some string."
    Client 就不能正确编码输入的参数以提交给Fisco 节点,以上操作无法调用合约中的set(...)函数以更新字符串。
    命令执行的终端输出如下:
    $ python3 ./console.py sendtx HelloWorld last set "some string."

INFO >> user input : ['sendtx', 'HelloWorld', 'last', 'set', 'some string.']

contract_abi_path contracts/HelloWorld.abi, contract_bin_path contracts/HelloWorld.bin
INFO>> client info: channel 127.0.0.1:20202,groupid :1,crypto type:ECDSA,ssl type:ECDSA
INFO >> sendtx HelloWorld , address: 0x83592a3cf1af302612756b8687c8dc7935c0ad1d, func: set, args:['some string.']
ERROR >> execute sendtx failed
ERROR >> error information: TypeError: isinstance() arg 2 must be a type or tuple of types

Parse tree:
<Node matching ""> <-- *** We were here. ***

SDK支持域名访问

希望SDK连接节点支持基于域名的TLS访问,我们就可以通过nginx的SNI转发访问,收拢所有节点的访问ip和端口

linux 环境下 账户pem无法读取

client.bcoserror.BcosException: START SDK error res:-1,[b'Throw location unknown (consider using BOOST_THROW_EXCEPTION)\nDynamic exception type: boost::wrapexceptboost::system::system_error\nstd::exception::what: use_private_key: no start line\n']
bcos3 rpc init error START SDK error res:-1,[b'Throw location unknown (consider using BOOST_THROW_EXCEPTION)\nDynamic exception type: boost::wrapexceptboost::system::system_error\nstd::exception::what: use_private_key: no start line\n']

部署合约提示错误

INFO >> compile with nodejs compiler
(node:27566) V8: /Users/zhengjingyi/python-sdk/node_modules/solc/soljson.js:3 Invalid asm.js: Invalid member of stdlib
(Use node --trace-warnings ... to show where the warning was created)
Deploy bin file: ./contracts/HelloWorld.bin
deploy exception! [Errno 2] No such file or directory: './contracts/HelloWorld.abi'
Traceback (most recent call last):
File "/Users/zhengjingyi/python-sdk/console_utils/cmd_bcos3_transaction.py", line 93, in deploy
abiparser = DatatypeParser(contract_abi_file)
File "/Users/zhengjingyi/python-sdk/client/datatype_parser.py", line 45, in init
self.load_abi_file(abi_file)
File "/Users/zhengjingyi/python-sdk/client/datatype_parser.py", line 56, in load_abi_file
with open(abi_file, 'r') as load_f:
FileNotFoundError: [Errno 2] No such file or directory: './contracts/HelloWorld.abi'

solc和nodejs都安装了

智能合约抛出的事件如何监听

智能合约里面有一个emit方法,作用是抛出一个事件,但是在文档和demo中,我都只看到可以从调用合约的返回值里获取log从而看到事件,找不到如何监听这个event的方法。所以这个有没有提供监听的途径呢?或者说我有没有办法通过一个for循环来轮询获得这个log呢?

console2.py execute rpc command error

Environment:
OS: Ubuntu 20.04
Python: 3.8.10
Node : 2.9 GM version

(venv3) root@SD-20210414ZMQA:~/bcos/python-sdk# python console2.py getBlockNumber

INFO >> user input : ['getBlockNumber']

INFO >> BcosClient: rpc:RPC connection http://118.195.226.179:8545
,groupid :1,crypto type:GM,ssl type:GM
1
ERROR >> execute getBlockNumber failed
ERROR >> error information: (-1, None, "getBlockNumber failed, params: [1], response: null, error information: 'Response' object has no attribute 'cb_context'")

(venv3) root@SD-20210414ZMQA:~/bcos/python-sdk#

python-sdk 跑demo_get.py报错

但是跑console2.py没有问题。
感觉是solc的问题。
以下是报错信息。

python3 demo_get.py
INFO >> compile with solc compiler : ./bin/solc/v0.4.25/solc --bin --abi contracts/HelloWorld.sol -o contracts --overwrite
Traceback (most recent call last):
File "/opt/fl-bc/pysdk/client/common/compiler.py", line 99, in compile_file
Compiler.compile_with_solc(sol_file, contract_name, output_path)
File "/opt/fl-bc/pysdk/client/common/compiler.py", line 79, in compile_with_solc
common.execute_cmd(command)
File "/opt/fl-bc/pysdk/client/common/common.py", line 113, in execute_cmd
data = subprocess.check_output(cmd.split(), shell=False, universal_newlines=True)
File "/opt/anaconda3/envs/flbc_3.7.3/lib/python3.7/subprocess.py", line 395, in check_output
**kwargs).stdout
File "/opt/anaconda3/envs/flbc_3.7.3/lib/python3.7/subprocess.py", line 487, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['./bin/solc/v0.4.25/solc', '--bin', '--abi', 'contracts/HelloWorld.sol', '-o', 'contracts', '--overwrite']' died with <Signals.SIGSEGV: 11>.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "demo_get.py", line 27, in
Compiler.compile_file("contracts/HelloWorld.sol")
File "/opt/fl-bc/pysdk/client/common/compiler.py", line 112, in compile_file
raise CompileError("compile error for compile failed, error information: {}".format(e))
client.bcoserror.CompileError: compile error for compile failed, error information: Command '['./bin/solc/v0.4.25/solc', '--bin', '--abi', 'contracts/HelloWorld.sol', '-o', 'contracts', '--overwrite']' died with <Signals.SIGSEGV: 11>.

call函数返回值是否有长度限制

请问call函数返回值是不是有长度要求,我在预编译合约中返回了很长的字符串,用call调用合约时报预编译错误(precomiled error),但是我将我返回的字符串减半后正常运行,不报错;请问这个限制怎么改

运行testclient.py报错

运行时报错需要bin/accounts/pemtest.pem
image
但实际上目录只存在文件.keystore,不存在.pem
image

运行demo代码时出现问题

在运行demo 中的demo_transaction2.py文件时出现了以下错误:
image
请问该如何解决?
在contracts中能够看到helloworld6.sol被编译完成,已有helloworld6.bin和helloworld6.abi文件

win10 安装python-sdk报错

问题描述:win10系统,参考文档进行安装,python版本3.10.5fisco版本2.9.2

image
image

问题1:python-sdk没有console.py文件,我理解是console2.py对应的fisco 2版本,相应的配置我都配置了,包括solc,sdk证书

image
image
image

问题2:执行.console2.py getNodeVersion 报错
image

部署Python SDK过程中执行./console.py getNodeVersion报错

image
部署Python SDK过程中执行./console.py getNodeVersion报错,怎么解决啊?安装Python SDK依赖过程中没有报错,到这里不行了

(python-sdk) wpg@ubuntu:~/python-sdk$ python3 ./console.py getNodeVersion
Traceback (most recent call last):
File "./console.py", line 19, in
from console_utils.cmd_account import CmdAccount
File "/home/wpg/python-sdk/console_utils/cmd_account.py", line 21, in
from client.common import common
File "/home/wpg/python-sdk/client/common/common.py", line 20, in
from client.datatype_parser import DatatypeParser
File "/home/wpg/python-sdk/client/datatype_parser.py", line 17, in
from eth_abi import decode_single, decode_abi
File "/home/wpg/python-sdk/eth_abi/init.py", line 3, in
from eth_abi.abi import ( # NOQA
File "/home/wpg/python-sdk/eth_abi/abi.py", line 1, in
from eth_abi.codec import (
File "/home/wpg/python-sdk/eth_abi/codec.py", line 11, in
from eth_utils import (
File "/home/wpg/python-sdk/eth_utils/init.py", line 24, in
from .applicators import ( # noqa: F401
File "/home/wpg/python-sdk/eth_utils/applicators.py", line 29, in
def combine_argument_formatters(*formatters: List[Callable[..., Any]]) -> Formatters:
File "/usr/lib/python3.5/typing.py", line 1025, in getitem
tvars = _type_vars(params)
File "/usr/lib/python3.5/typing.py", line 284, in _type_vars
_get_type_vars(types, tvars)
File "/usr/lib/python3.5/typing.py", line 279, in _get_type_vars
t._get_type_vars(tvars)
File "/usr/lib/python3.5/typing.py", line 786, in _get_type_vars
_get_type_vars(self.args, tvars)
File "/usr/lib/python3.5/typing.py", line 277, in _get_type_vars
for t in types:
TypeError: 'ellipsis' object is not iterable

执行pip install -r requirements.txt 命令报错

问题描述:阿里云服务器:版本CentOS Linux release 8.5.2111
python版本 3.6.8
image

执行下载依赖命令报错
ERROR: Could not find a version that satisfies the requirement exceptiongroup==1.1.0 (from versions: 0.0.0a0)
ERROR: No matching distribution found for exceptiongroup==1.1.0
image

使用过程的报错

在使用过程会出现如下错误,可以怎么解决

non-resource variables are not supported in the long term
INFO >> compile with nodejs compiler
internal/modules/cjs/loader.js:965
throw err;
^

Error: Cannot find module 'fs-extra'
Require stack:

  • /home/dyson/Dyson/FISCO_BFLC/python-sdk/solcjs
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:962:15)
    at Function.Module._load (internal/modules/cjs/loader.js:838:27)
    at Module.require (internal/modules/cjs/loader.js:1022:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object. (/home/dyson/Dyson/FISCO_BFLC/python-sdk/solcjs:6:10)
    at Module._compile (internal/modules/cjs/loader.js:1118:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1138:10)
    at Module.load (internal/modules/cjs/loader.js:982:32)
    at Function.Module._load (internal/modules/cjs/loader.js:875:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [ '/home/dyson/Dyson/FISCO_BFLC/python-sdk/solcjs' ]
    }
    Traceback (most recent call last):
    File "/home/dyson/Dyson/FISCO_BFLC/python-sdk/client/common/compiler.py", line 102, in compile_file
    Compiler.compile_with_js(sol_file, contract_name, output_path)
    File "/home/dyson/Dyson/FISCO_BFLC/python-sdk/client/common/compiler.py", line 49, in compile_with_js
    common.execute_cmd(command)
    File "/home/dyson/Dyson/FISCO_BFLC/python-sdk/client/common/common.py", line 113, in execute_cmd
    data = subprocess.check_output(cmd.split(), shell=False, universal_newlines=True)
    File "/home/dyson/anaconda3/envs/tf/lib/python3.7/subprocess.py", line 411, in check_output
    **kwargs).stdout
    File "/home/dyson/anaconda3/envs/tf/lib/python3.7/subprocess.py", line 512, in run
    output=stdout, stderr=stderr)
    subprocess.CalledProcessError: Command '['./solcjs', '--bin', '--abi', 'contracts/CommitteePrecompiled.sol', '-o', 'contracts']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "main.py", line 73, in
Compiler.compile_file("contracts/CommitteePrecompiled.sol")
File "/home/dyson/Dyson/FISCO_BFLC/python-sdk/client/common/compiler.py", line 112, in compile_file
raise CompileError("compile error for compile failed, error information: {}".format(e))
client.bcoserror.CompileError: compile error for compile failed, error information: Command '['./solcjs', '--bin', '--abi', 'contracts/CommitteePrecompiled.sol', '-o', 'contracts']' returned non-zero exit status 1.

Reconnect nodes problem

Hello,

When restart fisco bcos nodes, the tranaction will appear timeout by sending the python sdk. What's problem?

Thank you!

code_gen 函数问题

不支持True和False写法,只能在abi文件手动改成ture 和false才可以生成模版。

请问发送交易的时候如何指定from地址?

demo_transaction里有这样一个示例:
receipt = client.sendRawTransactionGetReceipt(to_address, contract_abi, "set", args)
receipt里可以看到from地址的信息,但之前并没有指定过from地址,如果要显式指定from地址该如何操作?

Smart contract error not returned

The smart contract has a function
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}

I expect the SDK to return an error "caller is not the owner" if user != owner, but If there was an error in the smart contract, it is not returned.
abi_parser.parse_output(fn_name, output) function returns empty result.
status in transaction = 16 - RevertInstruction.

How can I read an error from a smart contract?

将节点加入为观察者节点没有做防止重复限制

搭链操作参考

https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/installation.html

节点入网、退网相关操作参考:
https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/manual/node_management.html

例:

  • 将指定节点(node0)加入为观察者节点
# 以将node0加入观察者节点为例: 
# 获取node0的NodeID
$ cat ~/fisco/nodes/127.0.0.1/node0/conf/node.nodeid
2f0a2cfb4b2e5f63fda88c2bdb9edd8f8dd2a408c04c1d4fda8a75ad1047baf87c2b18f4dbf20d67db84019b221bf50b683eeebade7e5eaffefef876e5db9a8c

# 将node0加入为观察者节点
$ ./console.py  addObserver 2f0a2cfb4b2e5f63fda88c2bdb9edd8f8dd2a408c04c1d4fda8a75ad1047baf87c2b18f4dbf20d67db84019b221bf50b683eeebade7e5eaffefef876e5db9a8c
# 输出信息如下:
INFO >> user input : ['addObserver', '2f0a2cfb4b2e5f63fda88c2bdb9edd8f8dd2a408c04c1d4fda8a75ad1047baf87c2b18f4dbf20d67db84019b221bf50b683eeebade7e5eaffefef876e5db9a8c']

INFO >> compile with solc compiler
INFO >> addObserver
     >> status: 0x0
     >> transactionHash: 0x3d416bdabdb2e9032c019b73c1eefc71f2edf75c7c5eaca7cd1134de688901e2
     >> gasUsed: 0x7658
     >> addObserver succ, output: 1
  • 再次将指定节点(node0)加入为观察者节点,期望返回提示信息“the node is already in the observer list”,可是仍然返回添加成功
# 将node0加入为观察者节点
$ ./console.py  addObserver 2f0a2cfb4b2e5f63fda88c2bdb9edd8f8dd2a408c04c1d4fda8a75ad1047baf87c2b18f4dbf20d67db84019b221bf50b683eeebade7e5eaffefef876e5db9a8c
# 输出信息如下:
INFO >> user input : ['addObserver', '2f0a2cfb4b2e5f63fda88c2bdb9edd8f8dd2a408c04c1d4fda8a75ad1047baf87c2b18f4dbf20d67db84019b221bf50b683eeebade7e5eaffefef876e5db9a8c']
INFO >> compile with solc compiler
INFO >> addObserver
     >> status: 0x0
     >> transactionHash: 0x39fdc047e31ebc1c6d1b33a0a6bc2c825810fa12e2354b8655287cbd2d2afb28
     >> gasUsed: 0x7658
     >> addObserver succ, output: 1

需要在Python SDK中,对addObserver操作做防重:

  • 通过getObserverList接口获取当前观察节点列表
  • 将要添加的节点Node ID与获取的节点列表做对比,若已经在观察节点列表中,则返回提示信息the node is already in the observer list

console2.py执行报错

ubuntu20.04 Python 3.8.3 fisco 2.9

File "./console2.py", line 10
SyntaxError: Non-ASCII character '\xef' in file ./console2.py on line 11, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

但是我看文件头已经加了# -- coding: utf-8 --
不知道为什么报错?

参数序列化问题

TransactionCommon.format_args_by_abi 这个方法参数序列化不支持数组和动态类型

BcosClient不使用finish函数重启,连续使用sendRawTransaction400+次后,会报错

(-1, None, 'sendRawTransaction failed, params: [1, '0xf90235842f0627438401c9c3808401c9c380821983949181e725a6c78f47722ed26b1bb76b5acf66e26980b901c45d28560a000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000294144535f53545544454e545f55475f4558414d524553554c54535f31375f7465737458585858626363000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000164f5f53545544454e545f45525f53545544454e5449440000000000000000000000000000000000000000000000000000000000000000000000000000000000a04f5f53545544454e545f45525f434f5552534549442c4f5f53545544454e545f45525f5343484f4f4c594541522c4f5f53545544454e545f45525f5343484f4f4c5445524d2c4f5f53545544454e545f45525f434f555253454e414d452c4f5f53545544454e545f45525f434f5552534554595045434f44452c4f5f53545544454e545f45525f4352454449542c4f5f53545544454e545f45525f53434f52450101801ba04c621a0d5eedcc2f43694925ad165e64d6a5efa7a044d9bcdcebe428335ac37fa06d0e21e9c4385bcd72099f575cbe3beac83273af4745d180d0548dae1957dd93'], response: {"result": {"error": {"code": -32603, "data": null, "message": "INTERNAL_ERROR: : INTERNAL_ERROR: : /FISCO-BCOS/libtxpool/TxPool.cpp(191): Throw in function virtual std::pair<h256, Address> dev::txpool::TxPool::submitTransactions(dev::eth::Transaction::Ptr)\nDynamic exception type: boost::exception_detail::clone_impldev::eth::TransactionRefused\nstd::exception::what: std::exception\n[dev::tag_comment*] = BlockLimitCheckFailed, txBlockLimit=6531, txHash=c499052a...\n"}, "id": 3529, "jsonrpc": "2.0"}}, error information: (-32603, None, 'INTERNAL_ERROR: : INTERNAL_ERROR: : /FISCO-BCOS/libtxpool/TxPool.cpp(191): Throw in function virtual std::pair<h256, Address> dev::txpool::TxPool::submitTransactions(dev::eth::Transaction::Ptr)\nDynamic exception type: boost::exception_detail::clone_impldev::eth::TransactionRefused\nstd::exception::what: std::exception\n[dev::tag_comment*] = BlockLimitCheckFailed, txBlockLimit=6531, txHash=c499052a...\n')')

代码有错误

client/local_lib_helper.py第38行
应该是aarch64,没有arch这个版本

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.