Skip to content

Commit

Permalink
Merge pull request #678 from aitos-io/release-v2.1.11
Browse files Browse the repository at this point in the history
Candidate for BoAT-X-Framework V2.1.11
  • Loading branch information
flyfft authored Apr 24, 2022
2 parents 92ad8f1 + e9bb3c5 commit 70ceba9
Show file tree
Hide file tree
Showing 78 changed files with 8,166 additions and 282 deletions.
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ BOAT_PROTOCOL_USE_HLFABRIC ?= 1
BOAT_PROTOCOL_USE_HWBCS ?= 1
BOAT_PROTOCOL_USE_CHAINMAKER ?= 1
BOAT_DISCOVERY_PEER_QUERY ?= 1
BOAT_PROTOCOL_USE_VENACHAIN ?= 1

# Chain config check
ifeq ($(BOAT_PROTOCOL_USE_ETHEREUM)_$(BOAT_PROTOCOL_USE_PLATON)_$(BOAT_PROTOCOL_USE_PLATONE)_$(BOAT_PROTOCOL_USE_FISCOBCOS)_$(BOAT_PROTOCOL_USE_HLFABRIC)_$(BOAT_PROTOCOL_USE_HWBCS)_$(BOAT_PROTOCOL_USE_CHAINMAKER), 0_0_0_0_0_0_0)
ifeq ($(BOAT_PROTOCOL_USE_ETHEREUM)_$(BOAT_PROTOCOL_USE_PLATON)_$(BOAT_PROTOCOL_USE_PLATONE)_$(BOAT_PROTOCOL_USE_FISCOBCOS)_$(BOAT_PROTOCOL_USE_HLFABRIC)_$(BOAT_PROTOCOL_USE_HWBCS)_$(BOAT_PROTOCOL_USE_CHAINMAKER)_$(BOAT_PROTOCOL_USE_VENACHAIN), 0_0_0_0_0_0_0)
$(error Select at least one chain)
endif
ifeq ($(BOAT_PROTOCOL_USE_ETHEREUM)_$(BOAT_PROTOCOL_USE_FISCOBCOS), 0_1)
Expand All @@ -31,6 +32,9 @@ endif
ifeq ($(BOAT_PROTOCOL_USE_HLFABRIC)_$(BOAT_PROTOCOL_USE_HWBCS), 0_1)
$(error HWBCS depends on FABRIC, set 'BOAT_PROTOCOL_USE_HLFABRIC' to 1 if enable HWBCS)
endif
ifeq ($(BOAT_PROTOCOL_USE_ETHEREUM)_$(BOAT_PROTOCOL_USE_VENACHAIN), 0_1)
$(error VENACHAIN depends on ETHEREUM, set 'BOAT_PROTOCOL_USE_ETHEREUM' to 1 if enable VENACHAIN)
endif


# Set parameter to scripts
Expand All @@ -41,7 +45,8 @@ SCRIPTS_PARAM += "BOAT_PROTOCOL_USE_ETHEREUM=$(BOAT_PROTOCOL_USE_ETHEREUM)" \
"BOAT_PROTOCOL_USE_HLFABRIC=$(BOAT_PROTOCOL_USE_HLFABRIC)" \
"BOAT_PROTOCOL_USE_HWBCS=$(BOAT_PROTOCOL_USE_HWBCS)" \
"BOAT_PROTOCOL_USE_CHAINMAKER=$(BOAT_PROTOCOL_USE_CHAINMAKER)" \
"BOAT_DISCOVERY_PEER_QUERY=$(BOAT_DISCOVERY_PEER_QUERY)"
"BOAT_DISCOVERY_PEER_QUERY=$(BOAT_DISCOVERY_PEER_QUERY)" \
"BOAT_PROTOCOL_USE_VENACHAIN=$(BOAT_PROTOCOL_USE_VENACHAIN)"


# Platform target
Expand Down Expand Up @@ -100,6 +105,7 @@ BOAT_INCLUDE := -I$(BOAT_BASE_DIR)/include \
-I$(BOAT_SDK_DIR)/protocol/boatethereum \
-I$(BOAT_SDK_DIR)/protocol/boatplaton \
-I$(BOAT_SDK_DIR)/protocol/boatplatone \
-I$(BOAT_SDK_DIR)/protocol/boatvenachain \
-I$(BOAT_SDK_DIR)/protocol/boatfiscobcos \
-I$(BOAT_SDK_DIR)/third-party/nghttp2/include \
-I$(BOAT_SDK_DIR)/third-party/protobuf-c/include \
Expand Down Expand Up @@ -224,6 +230,7 @@ export BOAT_PROTOCOL_USE_FISCOBCOS
export BOAT_PROTOCOL_USE_HLFABRIC
export BOAT_PROTOCOL_USE_HWBCS
export BOAT_PROTOCOL_USE_CHAINMAKER
export BOAT_PROTOCOL_USE_VENACHAIN
export BOAT_DISCOVERY_PEER_QUERY
export BOAT_USE_DEFAULT_CJSON

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ The direct approach is suitable for IoT devices capable of direct access to a bl

The indirect approach accomodates IoT devices that can not otherwise directly access the blockchain node, due to various possible reasons such as an IP whitelist restriction and unmatched cryptographic algorithm capability.

By calling *BoAT-Engine* APIs, the IoT device signs the data with the device's cryptographic key. It then may pack the signature and the data in a datagram and send the datagram to an intermediate edge gateway. The gateway which runs the *BoAT-Anchor* splits the datagram, and then sends the data to the IoT platform and the signature (i.e. digital fingerprint) to the blockchain. It also requests *BoAT-Mast* to check if the data come from a registered device.
By calling *BoAT-Engine* APIs, the IoT device signs the data with the device's cryptographic key. It then send the signature to an intermediate edge gateway. The gateway which runs the *BoAT-Anchor* relays the signature (i.e. digital fingerprint) to the blockchain. It also requests *BoAT-Mast* to check if the data come from a registered device.

The data consumer could later verify the data stored on the IoT platform against the on-chain signature.

Expand Down
9 changes: 6 additions & 3 deletions SUPPORTED_LIST.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Supported Blockchain List

+ Ethereum
+ Ethereum/Polygon
+ PlatON
+ PlatON Enterprise (PlatONE)
+ FISCO-BCOS
+ Hyperledger Fabric
+ Huawei BCS (华为链)
+ Chainmaker
+ Venachain

### Blockchain Official Websites
+ [Ethereum](https://ethereum.org/)
+ [Ganache: an Ethereum Simulator](https://www.trufflesuite.com/truffle/)
+ [Ganache: an Ethereum Simulator](https://trufflesuite.com/ganache/)
+ [PlatON](https://www.platon.network/)
+ [PlatON Enterprise](https://github.com/PlatONEnterprise/)
+ [FISCO BCOS](http://fisco-bcos.org/)
Expand All @@ -20,6 +21,8 @@
+ [Huawei BCS](https://www.huaweicloud.com/product/bcs)
+ [ChainMaker](https://chainmaker.org.cn/)
+ [ChainMaker Docs](https://docs.chainmaker.org.cn/)
+ [Venachain Docs](https://venachain-docs.readthedocs.io/zh/latest/)
+ [Polygon](https://polygon.technology/)

# Supported Module List

Expand Down Expand Up @@ -50,6 +53,6 @@ MN316 |中移物联 China Mobile|NB-IoT |Xinyi XY
BeagleV-StarLight星光 |seeed, StarFive and beagleboard|Ethernet|StarFive JH7100 |BeagleV-StarLight星光 is a development board


*Last update on January 25th, 2022*
*Last update on April 24th, 2022*

NOTE: Some of the blockchains are not supported on some modules due to resource constraint.
10 changes: 8 additions & 2 deletions demo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Generate sub-directory list
OBJECTS_DIR = $(BOAT_BUILD_DIR)/demo

.PHONY: all demo_ethereum demo_platon demo_platone demo_fiscobcos demo_fabric demo_hw_bcs demo_chainmaker
all: $(OBJECTS_DIR) demo_ethereum demo_platon demo_platone demo_fiscobcos demo_fabric demo_hw_bcs demo_chainmaker
.PHONY: all demo_ethereum demo_platon demo_platone demo_fiscobcos demo_fabric demo_hw_bcs demo_chainmaker demo_venachain
all: $(OBJECTS_DIR) demo_ethereum demo_platon demo_platone demo_fiscobcos demo_fabric demo_hw_bcs demo_chainmaker demo_venachain

demo_ethereum:
ifeq ($(BOAT_PROTOCOL_USE_ETHEREUM), 1)
Expand Down Expand Up @@ -41,6 +41,11 @@ ifeq ($(BOAT_PROTOCOL_USE_CHAINMAKER), 1)
make -C $(BOAT_BASE_DIR)/demo/demo_chainmaker all
endif

demo_venachain:
ifeq ($(BOAT_PROTOCOL_USE_VENACHAIN), 1)
make -C $(BOAT_BASE_DIR)/demo/demo_venachain all
endif

$(OBJECTS_DIR):
$(BOAT_MKDIR) -p $(OBJECTS_DIR)

Expand All @@ -52,4 +57,5 @@ clean:
make -C $(BOAT_BASE_DIR)/demo/demo_fabric clean
make -C $(BOAT_BASE_DIR)/demo/demo_hw_bcs clean
make -C $(BOAT_BASE_DIR)/demo/demo_chainmaker clean
make -C $(BOAT_BASE_DIR)/demo/demo_venachain clean
-$(BOAT_RM) $(BOAT_BUILD_DIR)/demo
14 changes: 10 additions & 4 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### 编译和运行Demo
#### 准备
SDK提供基于以太坊、PlatON、PlatONE、FISCO-BCOS、Hyperledger Fabric和HW-BCS的Demo。在运行这些Demo之前,需要首先安装相应的区块链节点软件(或者有已知节点),并部署Demo所需的智能合约。
SDK提供基于以太坊、PlatON、PlatONE、Venachain、FISCO-BCOS、Hyperledger Fabric和HW-BCS的Demo。在运行这些Demo之前,需要首先安装相应的区块链节点软件(或者有已知节点),并部署Demo所需的智能合约。

Demo所使用的智能合约及其ABI JSON文件放置在:

Expand All @@ -21,6 +21,9 @@ PlatON源码及工具可以访问该网站:https://platon.network/
在运行PlatONE的Demo之前,需要安装PlatONE节点,以及智能合约编译和部署工具。
PlatONE源码及工具可以访问该网站:https://platone.wxblockchain.com

在运行Venachain的Demo之前,需要安装Venachain节点,以及智能合约编译和部署工具。
Venachain源码及工具可以访问该网站:https://github.com/Venachain/Venachain

在运行FISCO-BCOS的Demo之前,需要安装FISCO-BCOS节点和合约部署。
FISCO-BCOS源码及安装部署步骤可以访问该网站:https://fisco-bcos-documentation.readthedocs.io

Expand All @@ -38,18 +41,21 @@ FISCO-BCOS源码及安装部署步骤可以访问该网站:https://fisco-bcos-
|\<SDKRoot\>/demo/demo_fabric/demo_fabric_abac.c |FABRIC合约演示用例 |
|\<SDKRoot\>/demo/demo_hw_bcs/demo_hw_bcs.c |HW-BCS合约演示用例 |
|\<SDKRoot\>/demo/demo_chainmaker/demo_chainmaker.c |CHAINMAKER合约演示用例 |
|\<SDKRoot\>/demo/demo_venachain/demo_venachain_mycontract.c |Venachain合约演示用例 |

编译Demo之前,需要修改Demo的C代码中以下部分:
- 对于ETHEREUM、PLATON、FISCO-BCOS、PLATONE:
- 对于ETHEREUM、PLATON、FISCO-BCOS、PLATONE、Venachain:
1. 搜索`demoUrl`,将节点URL(含端口)填写为实际部署的节点或模拟器的IP地址和RPC端口
2. 如果demo需使用原生私钥, 则搜索`native_demoKey`,并将客户端私钥设置为:
- 对于ETHEREUM,设置为ganache生成的任意一个账户的私钥
- 对于PlatON,无需修改Demo中的私钥
- 对于PlatONE,无需修改Demo中的私钥
- 对于Venachain,无需修改Demo中的私钥
- 对于FISCO-BCOS,设置为<FISCO-BCOS_ROOT>/console/accounts下私钥对应的原生格式私钥
3. 如果demo需使用原生私钥, 则搜索`pkcs_demoKey`,并将客户端私钥设置为:
3. 如果demo需使用pkcs格式私钥, 则搜索`pkcs_demoKey`,并将客户端私钥设置为:
- 对于以太坊,设置为ganache生成的任意一个账户的私钥对应的PKCS格式私钥
- 对于PlatONE,无需修改Demo中的私钥
- 对于Venachain,无需修改Demo中的私钥
- 对于FISCO-BCOS,设置为<FISCO-BCOS_ROOT>/console/accounts下私钥
4. 搜索`demoRecipientAddress`,修改为Demo合约的部署地址。
- 对于FABRIC:
Expand All @@ -76,7 +82,7 @@ FISCO-BCOS源码及安装部署步骤可以访问该网站:https://fisco-bcos-
```
$make demo
```
生成的Demo程序分别位于\<SDKRoot\>/build/demo/demo_\<protocol\>/<demo_name>路径下,< protocol>可以为`ethereum` `platon` `fisco-bcos` `platone` `fabric` `hwbcs`
生成的Demo程序分别位于\<SDKRoot\>/build/demo/demo_\<protocol\>/<demo_name>路径下,< protocol>可以为`ethereum` `platon` `fisco-bcos` `platone` `fabric` `hwbcs` `venachain`

### 编译中的常见问题
1. 编译中提示类似“Makefile: 120: *** 缺失分隔符。 停止”的信息。
Expand Down
67 changes: 35 additions & 32 deletions demo/demo_chainmaker/demo_chainmaker.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,47 @@
#include "boatiotsdk.h"
#include "boatlog.h"

const BCHAR* chainmaker_user_key = "-----BEGIN EC PRIVATE KEY-----\n"
"MHcCAQEEIKra8nWWBSPS/AejMaW+yonu8d9dBoj+SPWDrJbmIh1HoAoGCCqGSM49\n"
"AwEHoUQDQgAEMc5rXZAi7DJkvOdGAlEw/kOsLIhb6L5DXwSYltVYAndlKKubd7HO\n"
"MrZBWP5+xAw/3eB6A8aBwqOWdx9Hv4vX+A==\n"
const BCHAR* chainmaker_user_key = "------BEGIN EC PRIVATE KEY-----\n"
"MHcCAQEEIObTIWiOPC014eokTlChY2zqolJvkjPsObydiDTBAg8boAoGCCqGSM49\n"
"AwEHoUQDQgAETvjoYFEqRN/PediSM3Op6rTOWORSuSiv/hyoSqBfb5Os0+aNYfjM\n"
"AylgQ8ug/EcXrnpCqijjwbeR4nFzoZf4RA==\n"
"-----END EC PRIVATE KEY-----\n";

const BCHAR* chainmaker_user_cert = "-----BEGIN CERTIFICATE-----\n"
"MIICijCCAi+gAwIBAgIDDgl6MAoGCCqGSM49BAMCMIGKMQswCQYDVQQGEwJDTjEQ\n"
"MA4GA1UECBMHQmVpamluZzEQMA4GA1UEBxMHQmVpamluZzEfMB0GA1UEChMWd3gt\n"
"b3JnMS5jaGFpbm1ha2VyLm9yZzESMBAGA1UECxMJcm9vdC1jZXJ0MSIwIAYDVQQD\n"
"ExljYS53eC1vcmcxLmNoYWlubWFrZXIub3JnMB4XDTIxMTIyODA4MDczNVoXDTI2\n"
"MTIyNzA4MDczNVowgZExCzAJBgNVBAYTAkNOMRAwDgYDVQQIEwdCZWlqaW5nMRAw\n"
"DgYDVQQHEwdCZWlqaW5nMR8wHQYDVQQKExZ3eC1vcmcxLmNoYWlubWFrZXIub3Jn\n"
"MQ8wDQYDVQQLEwZjbGllbnQxLDAqBgNVBAMTI2NsaWVudDEuc2lnbi53eC1vcmcx\n"
"LmNoYWlubWFrZXIub3JnMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEMc5rXZAi\n"
"7DJkvOdGAlEw/kOsLIhb6L5DXwSYltVYAndlKKubd7HOMrZBWP5+xAw/3eB6A8aB\n"
"wqOWdx9Hv4vX+KN7MHkwDgYDVR0PAQH/BAQDAgGmMA8GA1UdJQQIMAYGBFUdJQAw\n"
"KQYDVR0OBCIEIOaCMaVI//RuFz8f8kZkjB6MeBP/E7WtWF8S7TcpT0MEMCsGA1Ud\n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R0OBCIEIE2++CJNZObR1Gih2bf+ZpgA1sm5bvtr5G0m\n"
"E1Ur2vaLMEUGA1UdEQQ+MDyCDmNoYWlubWFrZXIub3Jngglsb2NhbGhvc3SCGWNh\n"
"Lnd4LW9yZzEuY2hhaW5tYWtlci5vcmeHBH8AAAEwCgYIKoZIzj0EAwIDSAAwRQIg\n"
"CpL7BZ88AWei7Kx20u+U3QYiYfRugaVqz3FSVsKA/7wCIQC3VxwMdrsEKJexNGSL\n"
"sNHNihrTET6DD5/3pPSpf9HL7g==\n"
"YWtlci5vcmcwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQ3IktxZ7XhTCaYt54a\n"
"01oXyPoDwHPd1c6aqUyuu8QhAprPKkiOjeQ02nVaQ1/M4fgdHADdLgAxeU5iifAD\n"
"pw04o4GnMIGkMA4GA1UdDwEB/wQEAwIBpjAPBgNVHSUECDAGBgRVHSUAMA8GA1Ud\n"
"EwEB/wQFMAMBAf8wKQYDVR0OBCIEIAmbbnImfl7WRFdfnVcN75avqpER441lOyLR\n"
"E59F2GBGMEUGA1UdEQQ+MDyCDmNoYWlubWFrZXIub3Jngglsb2NhbGhvc3SCGWNh\n"
"Lnd4LW9yZzEuY2hhaW5tYWtlci5vcmeHBH8AAAEwCgYIKoZIzj0EAwIDSQAwRgIh\n"
"AMx1WVoT0vZQEuc+383n0vwB/jXUYQhdNUzpsI8o0RUsAiEAl51FmBKPZQBoURz/\n"
"Da0VTpq1XNH7wUU22CMqG+KkU+A=\n"
"-----END CERTIFICATE-----\n";

//wallet para
Expand Down Expand Up @@ -161,14 +162,15 @@ int main(int argc, char *argv[])
boat_throw(result, chainmaker_demo_catch);
}

/* step-4: add invoke parameters */
result = BoatHlchainmakerAddTxParam(&tx_ptr, 6, "time", "6543235", "file_hash", "ab3456df5799b87c77e7f85", "file_name", "name005", NULL);
if (result != BOAT_SUCCESS)
{
BoatLog(BOAT_LOG_CRITICAL, "BoatHlchainmakerAddTxParam() failed.");
boat_throw(result, chainmaker_demo_catch);
}

/* step-4: set transaction 'invoke' command */
/* step-5: execute invoke command */
result = BoatHlchainmakerContractInvoke(&tx_ptr, "save","fact", false, &invoke_response);
if (result != BOAT_SUCCESS)
{
Expand All @@ -177,7 +179,7 @@ int main(int argc, char *argv[])
}
BoatLog( BOAT_LOG_CRITICAL, "response code = %d, message = %s, gas_used = %d\n", invoke_response.code, invoke_response.message, invoke_response.gas_used);

/* step-5: wait seconds and 'query' the gas */
/* step-6: add query parameters*/
BoatSleep(2);
result = BoatHlchainmakerAddTxParam(&tx_ptr, 2, "file_hash", "ab3456df5799b87c77e7f85", NULL);
if (result != BOAT_SUCCESS)
Expand All @@ -186,6 +188,7 @@ int main(int argc, char *argv[])
boat_throw(result, chainmaker_demo_catch);
}

/* step-7: execute query command*/
result = BoatHlchainmakerContractQuery(&tx_ptr, "find_by_file_hash","fact", &query_response);
if (result != BOAT_SUCCESS)
{
Expand Down
10 changes: 5 additions & 5 deletions demo/demo_ethereum/demo_ethereum_storeread.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ BOAT_RESULT ethereum_call_ReadStore(BoatEthWallet *wallet_ptr)
BUINT32 index;
BoatEthTx tx_ctx;
BOAT_RESULT result;
BoatFieldVariable prase_result = {NULL, 0};
BoatFieldVariable parse_result = {NULL, 0};

/* Set Contract Address */
result = BoatEthTxInit(wallet_ptr, &tx_ctx, BOAT_TRUE, NULL,
Expand All @@ -205,22 +205,22 @@ BOAT_RESULT ethereum_call_ReadStore(BoatEthWallet *wallet_ptr)
if (result_str != NULL)
{
result_str = StoreRead_readListLength(&tx_ctx);
result = BoatEthPraseRpcResponseStringResult(result_str, &prase_result);
result = BoatEthParseRpcResponseStringResult(result_str, &parse_result);
if (result == BOAT_SUCCESS && result_str != NULL)
{
//BoatLog(BOAT_LOG_NORMAL, "readListLength returns: %s", result_str);

UtilityHexToBin((BUINT8*)index_u256_big, sizeof(index_u256_big),
(BCHAR*)prase_result.field_ptr, TRIMBIN_TRIM_NO, BOAT_FALSE);
(BCHAR*)parse_result.field_ptr, TRIMBIN_TRIM_NO, BOAT_FALSE);
UtilityChangeEndian(index_u256_big, sizeof(index_u256_big));
list_len = index_u256_big[0];
for (index = 0; index < list_len; index++)
{
result_str = StoreRead_readListByIndex(&tx_ctx, index);
result = BoatEthPraseRpcResponseStringResult(result_str, &prase_result);
result = BoatEthParseRpcResponseStringResult(result_str, &parse_result);
if (result == BOAT_SUCCESS && result_str != NULL)
{
//BoatLog(BOAT_LOG_NORMAL, "readListByIndex returns: %s", prase_result.field_ptr);
//BoatLog(BOAT_LOG_NORMAL, "readListByIndex returns: %s", parse_result.field_ptr);
}
else
{
Expand Down
12 changes: 6 additions & 6 deletions demo/demo_ethereum/demo_ethereum_transfer.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,17 @@ BOAT_RESULT ethereumGetBalance(BoatEthWallet *wallet_ptr)
//BCHAR *balance_wei;
BCHAR *cur_balance_wei = NULL;
BOAT_RESULT result;
BoatFieldVariable prase_result = {NULL, 0};
BoatFieldVariable parse_result = {NULL, 0};

cur_balance_wei = BoatEthWalletGetBalance(wallet_ptr, NULL);
result = BoatEthPraseRpcResponseStringResult(cur_balance_wei, &prase_result);
//BoatLog(BOAT_LOG_NORMAL, "Balance: %s wei", prase_result.field_ptr);
if(prase_result.field_ptr != NULL){
BoatFree(prase_result.field_ptr);
result = BoatEthParseRpcResponseStringResult(cur_balance_wei, &parse_result);
//BoatLog(BOAT_LOG_NORMAL, "Balance: %s wei", parse_result.field_ptr);
if(parse_result.field_ptr != NULL){
BoatFree(parse_result.field_ptr);
}
if (result == BOAT_SUCCESS)
{
//BoatLog(BOAT_LOG_NORMAL, "BoatEthWalletGetBalance returns: %s", prase_result.field_ptr);
//BoatLog(BOAT_LOG_NORMAL, "BoatEthWalletGetBalance returns: %s", parse_result.field_ptr);
}
else
{
Expand Down
Loading

0 comments on commit 70ceba9

Please sign in to comment.