Skip to content

Commit

Permalink
Merge pull request #121 from aitos-io/boatiotsdk_2_0-dev
Browse files Browse the repository at this point in the history
Candidate for BoAT-X-Framework V2.0.5
  • Loading branch information
flyfft authored Jul 9, 2021
2 parents c344380 + 93f336e commit 7ea44fd
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 124 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ For public blockchain, you must prepare some gas for transaction fee in advance.
For consortium blockchain , you must consult the administrator to give you access permission on the blockchain. Or you may deploy your own consortium blockchain node for test purpose.

See blockchain official website for details:
For [Ethereum](https://ethereum.org/)
For [Ganache: an Ethereum Simulator](https://www.trufflesuite.com/truffle/)
For [PlatON Enterprise](https://github.com/PlatONEnterprise/)
+ [Ethereum](https://ethereum.org/)
+ [Ganache: an Ethereum Simulator](https://www.trufflesuite.com/truffle/)
+ [PlatON Enterprise](https://github.com/PlatONEnterprise/)

#### Deploy the smart contract
The smart contracts used in the demo locate in ./contract.
Expand Down
3 changes: 2 additions & 1 deletion SUPPORTED_LIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ BF2 |跃昉LeapFive |WiFi |LeapFive B
SLM320 |美格 MEIG |LTE Cat.1 |UNISOC UIS8910DM
Yanfei CUIoT-MZ-6 |联通 China Unicom|LTE Cat.1 |UNISOC UIS8910DM
MN316 |中移物联 China Mobile|NB-IoT |Xinyi XY1100
BeagleV-StarLight星光 |seeed, StarFive and beagleboard|Ethernet|StarFive JH7100 |BeagleV-StarLight星光 is a development board


*Last update on April 4th, 2021*
*Last update on June 29th, 2021*

NOTE: Some of the blockchains are not supported on some modules due to resource constraint.
177 changes: 89 additions & 88 deletions docs/en-us/BoAT_Overall_Design_en.md

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions docs/en-us/BoAT_System_Requirements_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This technical paper describes the system requirements of the BoAT Framework (C language version) for cellular modules. BoAT is an SDK that runs on the module's application processor. For the OpenCPU cellular module, BoAT is linked and called by the application as a library. For non-OpenCPU cellular modules, BoAT's API needs to be extended to AT commands for applications on the upper MCU to call.

## Part One. Storage requirements
## Part One. Storage Requirements

For Ethereum/PlatONE/FISCO BCOS, the storage requirements of the BoAT Framework (C language version) itself are:
- Flash (code and read-only data): about 210kB
Expand All @@ -17,13 +17,13 @@ For HyperLedger Fabric, the storage requirements of the BoAT Framework (C langua

The above does not include the system libraries that the BoAT Framework (C language version) depends on. The exact values may vary with different blockchain protocols.

## Part Two. Processing power requirements
## Part Two. Computing Performance Requirements

For supporting Ethereum, the BoAT Framework (C language version) takes about 1 second (excluding network communication time) to complete the cryptographic operations for a blockchain transaction or smart contract call, on an ARM Cortex M4 running at about 100MHz . The exact time can vary with different blockchain protocols.

The exact processing power requirements depend on the power consumption and latency requirements of the application calling (porting in) the BoAT Framework SDK. BoAT itself has no special requirements.
The exact computing performance requirements depend on the power consumption and latency requirements of the application calling (porting in) the BoAT Framework SDK. BoAT itself has no special requirements.

## Part Three. Operating system and communication requirements
## Part Three. Operating System and Communication Requirements

There really are no special requirements for the operating system. Generally BoAT Framework (C language version) can be ported over most operating systems (e.g. linux, various RTOS), as long as the following capabilities (below) are supported:

Expand Down Expand Up @@ -54,7 +54,7 @@ If the device can only connect to the IoT platform of a specific operator or ser

8. If the cellular IoT Module utilizes a Linux operating system, during debugging it should support adb or similar login mechanism and have root privileges.

## Part Four TEE and remote attestation(optional)
## Part Four TEE and Remote Attestation (optional)

### TEE

Expand All @@ -64,15 +64,15 @@ If the application processor of the cellular module supports the TEE (Trusted Ex
2. Supporting Secure Boot, fuse, etc.
3. Support for secure storage

### Remote attestation
### Remote Attestation

Remote attestation is a mechanism that uses the Root of Trust embedded in the chip to provide signature services for device data, and may probe device operating environment characteristic information. Remote attestation can help service providers remotely authenticate the authenticity of equipment. If the module's chip supports remote authentication, it should support at least the following capabilities:

1. Support for signing given data on the device, and verifying the signature on the remote server
2. If the TEE is supported, the data should be signed in TEE (optional)


## Part Five. Cryptography hardware acceleration (optional)
## Part Five. Cryptography Hardware Acceleration (optional)

If the hardware supports cryptographic hardware acceleration, utilizing this technology will improve the performance of cryptographic operations.

Expand Down
43 changes: 21 additions & 22 deletions docs/en-us/BoAT_User_Guide_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The intended readers of this article are customers who integrate the BoAT IoT Fr


## Function and architecture
BoAT IoT Framework is a C language blockchain client framework software for cellular modules, which is easy to be ported to various modules and helps IoT applications based on cellular modules connect to the blockchain and realize data on-chain services. The functions provided by the BoAT IoT Framework SDK to IoT applications include initiating on-chain transactions, automatic generation of smart contract C interface code, calling smart contracts, and managing blockchain keys.
BoAT IoT Framework is a C language blockchain client framework software for cellular modules, which is easy to be ported to various modules and helps IoT applications based on cellular modules connect to the blockchain and access on-chain services. The functions provided by the BoAT IoT Framework SDK to IoT applications include initiating on-chain transactions, automatic generation of smart contract C interface code, calling smart contracts, and managing blockchain keys.

**Supported blockchain:**
Ethereum
Expand All @@ -33,12 +33,12 @@ Hyperledger Fabric


**Supported Target Operating System:**
linux
Linux
RTOS


**Supported Build Operating System:**
linux/cygwin
Linux/Cygwin

**Main features:**
Blockchain account (wallet) parameter configuration
Expand Down Expand Up @@ -72,7 +72,7 @@ The blockchain client interface protocol mainly implements transaction interface
The remote procedure call(RPC) interface implements a warpper for different communication protocols. This component needs to be ported according to the specific communication method supported by the IoT device.
Public components implement common functions such as RLP encoding, JSON codec, string processing, etc.
Hardware dependent components are ported components involving different hardware, such as cryptography accelerators, secure storage, random numbers, etc. This component needs to be ported according to specific hardware. SDK also provides a set of default Hardware dependent components witch implementations by software.
The tool component provides a set of Python tools, that be used to generate C language contract call interface of smart contract ABI interface based on Solidity or WASM C++.
The tool component provides a set of Python tools, which are used to generate C language contract call interface of smart contract ABI interface based on Solidity or WASM C++.



Expand Down Expand Up @@ -162,7 +162,7 @@ BOAT_PROTOCOL_USE_FISCOBCOS ?= 1
BOAT_PROTOCOL_USE_HLFABRIC ?= 1
````

As needed, change the value of the corresponding variable to `1` or `0` to enable or disable the corresponding blockchain protocol. Or when compiling the SDK, use make \<BOAT_PROTOCOL_USE_XXX\>=<1|0> to enable or disable the corresponding blockchain protocol.
As needed, change the value of the corresponding variable to `1` or `0` to enable or disable the corresponding blockchain protocol. Or while compiling the SDK, use make \<BOAT_PROTOCOL_USE_XXX\>=<1|0> to enable or disable the corresponding blockchain protocol.
-Log printing level adjustment
If necessary, adjust the value of `BOAT_LOG_LEVEL` in the path \<SDKRoot\>/vendor/platform/\<platform_name\>/src/log/boatlog.h to adjust the printer type of the log.

Expand Down Expand Up @@ -291,7 +291,7 @@ Among them, boatiotsdk is the directory where the SDK is located, and the -C par

*Note: In the Makefile, the command under target must start with a Tab (ASCII code 0x09), not a space.*

The above steps are only used to compile the SDK library. After the SDK library compile completed, the compiled library needs to be integrated into the module development environment. See the [Header Files and Libraries](###Header Files and Libraries) chapter for details.
The above steps are only used to compile the SDK library. After the SDK library compilation completes, the compiled library needs to be integrated into the module development environment. See the [Header Files and Libraries](###Header Files and Libraries) chapter for details.

###### The module development environment is compiled with non-GNU make
Since BoAT IoT Framework SDK uses GNU make as the compilation project, if the module development environment uses non-GNU Make compilation projects (such as Ninja, ant, etc.), or uses the automatic generation tools of the compilation project (such as automake, CMake), it cannot Compile the SDK directly in the module development environment.
Expand Down Expand Up @@ -363,14 +363,13 @@ The smart contract used by the demo and its ABI JSON file are placed in:
| \<SDKRoot\>/demo/demo_fiscobcos/demo_contract/HelloWorld.sol | \<SDKRoot\>/demo/demo_fiscobcos/demo_contract/HelloWorld.json | FISCO-BCOS demo |


Before running Ethereum's Demo, you need to install the Ethereum node simulator ganache, as well as the Ethereum smart contract compilation deployment tool truffle.
Ganache and truffle tools can visit this website: https://truffleframework.com
Before running Ethereum's Demo, you need to install the Ethereum node simulator ganache, as well as the Ethereum smart contract compilation deployment tool truffle, could visit this website: https://truffleframework.com .
Ganache has a ganache-cli version of the command line interface, and a Ganache version of the graphical interface. The ganache-cli of the command line interface and the Ganache 1.x version of the graphical interface will not be saved. If the process of ganache-cli or Ganache 1.x is terminated, the deployed contract will be lost. The command truffle migrate - reset Redeploy the contract, the address of the redeployed contract may change. The Ganache 2.x version of the graphical interface can create a Workspace save state. After closing and reopening the Workspace next time, the deployed contract still does not need to be redeployed.
In addition to using the ganache simulator, you can also use the Ethereum test network such as Ropsten (you need to apply for a free test token).


Before running the PlatONE Demo, you need to install the PlatONE node, as well as smart contract compilation and deployment tools.
PlatONE source code and tools can visit this website: https://platone.wxblockchain.com
Before running the PlatONE Demo, you need to install the PlatONE node, as well as smart contract compilation and deployment tools,could visit this website: https://platone.wxblockchain.com .

Before running the FISCO-BCOS Demo, you need to install the FISCO-BCOS node and contract deployment.
FISCO-BCOS source code and installation and deployment steps can visit this website: https://fisco-bcos-documentation.readthedocs.io
Expand Down Expand Up @@ -458,15 +457,15 @@ After the SDK is compiled, only the following files are needed for the applicati
1. Refer to the SDK header file in the application

- Add \<SDKRoot\>/include to the header file search path of the application, or copy all header files under \<SDKRoot\>/include to the application header file directory.
-In the application header file search path, add \<SDKRoot\>/vendor/platform/include, or copy the boatconfig.h header file under \<SDKRoot\>/vendor/platform/include to the application header file directory .
-In the application-related C code, add the following header files:
- In the application header file search path, add \<SDKRoot\>/vendor/platform/include, or copy the boatconfig.h header file under \<SDKRoot\>/vendor/platform/include to the application header file directory .
- In the application-related C code, add the following header files:

````
#include "boatiotsdk.h" //SDK entry header file
#include "boatconfig.h" //SDK configuration header file
````

-The application does not need to include the other header file directories of the SDK into the search path.
- The application does not need to include the other header file directories of the SDK into the search path.

If you use the automatically generated C interface code based on the contract ABI JSON file, you also need to include the generated smart contract C interface code header file, and add the generated `*.c` file to the application compilation script.

Expand Down Expand Up @@ -690,15 +689,15 @@ In some contract programming languages, the two types of contract functions have
For example, take the following Ethereum Solidity contract as an example:

contract StoreRead {
bytes32[] eventList;
bytes32[] eventList;

function saveList(bytes32 newEvent) public {
eventList.push(newEvent);
}
function saveList(bytes32 newEvent) public {
eventList.push(newEvent);
}

function readListLength() public view returns (uint32 length_) {
length_ = uint32(eventList.length);
}
function readListLength() public view returns (uint32 length_) {
length_ = uint32(eventList.length);
}
}


Expand Down Expand Up @@ -739,7 +738,7 @@ After the contract is compiled, the ABI corresponding to the two functions are d

In the above contract, eventList is a member variable of the contract. saveList() will change the value of eventList, which is a contract function that changes the state of the blockchain; readListLength() has a view modifier and only reads the attributes of eventList without changing its value. It is a contract function that does not change the state of the blockchain .

Pay special attention to the fact that although the contract function and C call interface function that change the state of the blockchain and do not change the state of the blockchain are very similar in prototype, the calling principles of the two are quite different.
In particular, there are significant differences in the principles of invoking between smart contract functions that update the ledger and those who don’t, even though the two types of functions are quite similar in prototype. The same is true for the interface functions in C language generated through the conversion tool.

Any change to the state of the blockchain needs to be implemented through blockchain transactions and reach a consensus across the entire network. The contract function that changes the state of the blockchain is called asynchronously. When called, it only initiates the blockchain transaction, and the contract will not be executed before the blockchain network packs the transaction into blocks. Therefore, when the contract function that changes the state of the blockchain is called, the return value is only the hash value used to identify the transaction, not the return value in the form of the contract function. When designing a smart contract, the public interface function that changes the state of the blockchain, the information it tries to return should be stored in the contract member variable, and the receipt of the transaction is queried through BoatEthGetTransactionReceipt(). After success, use another Obtained in the form of a read function.

Expand Down Expand Up @@ -1009,4 +1008,4 @@ A HEX string representing the recipient (payee) address.
## Reference
BoAT API Reference Manual

[1].BoAT IoT Framework SDK Reference Manual, AITOS.20.70.100IF, V1.0.0
[1].BoAT IoT Framework SDK Reference Manual, AITOS.20.70.100IF, V1.0.0
2 changes: 1 addition & 1 deletion docs/zh-cn/BoAT_Overall_Design_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ BoAT SDK应提供一种硬件依赖的全软件实现,以使BoAT在硬件无


#### TEE支持
BoAT的设计应考虑TE环境的支持。对于有TE环境的硬件,BoAT应可以通过少量的修改将敏感信息放到TE环境中。为满足此目标,钱包的设计满足以下标准:
BoAT的设计应考虑TEE环境的支持。对于有TEE环境的硬件,BoAT应可以通过少量的修改将敏感信息放到TEE环境中。为满足此目标,钱包的设计满足以下标准:
+ 钱包相关的数据结构独立设计
+ 钱包相关的实现独立设计
+ 钱包相关的敏感信息不在钱包以外的地方体现
Expand Down
4 changes: 2 additions & 2 deletions docs/zh-cn/BoAT_User_Guide_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ set PATH=%PATH%;\<Path_to_Cygwin\>\bin

<font color=grey>注:上述命令可以编写在一个bat批处理文件中,或者直接加入Windows系统环境变量中,方便调用。注意,如果直接加入Windows系统环境变量,不得将Cygwin置于%SystemRoot%\System32路径之前,否则在其他场景中调用Windows的FIND命令时,将错误地调用Cygwin的find版本,这将影响其他场景中使用Windows自带命令。</font>

然后,修改`\<SDKRoot\>/vendor/platform/<platform_name>/external.env`,为依赖工具加上路径:
然后,修改`<SDKRoot>/vendor/platform/<platform_name>/external.env`,为依赖工具加上路径:
```
# Commands
CYGWIN_BASE := C:\cygwin64 # Modify to actual path to Cygwin
Expand Down Expand Up @@ -725,7 +725,7 @@ contract StoreRead {
```
上述合约中,eventList是合约的成员变量。saveList()会改变eventList的值,是改变区块链状态的合约函数;readListLength()有view修饰符,只读取eventList的属性,不改变它的值,是不改变区块链状态的合约函数。

特别注意,尽管改变区块链状态和不改变区块链状态的合约函数和C调用接口函数在原型上非常相似,但两者的调用原理有很大差别。
特别注意,尽管改变区块链状态和不改变区块链状态的合约函数在原型上非常相似,但两者的调用原理有很大差别。通过该工具生成的C接口函数也是同样情况

对区块链状态的任何改变,都需要通过区块链交易实施并在全网达成共识。改变区块链状态的合约函数是异步调用,在调用时,只是发起该次区块链交易,而在区块链网络将该交易打包出块前,该合约不会被执行。因此,调用改变区块链状态的合约函数时,其返回值仅仅是用于标识该次交易的哈希值,而不是该合约函数形式上的返回值。在设计智能合约时,改变区块链状态的对外(public)接口函数,其试图返回的信息,应当保存在合约成员变量中,通过BoatEthGetTransactionReceipt()查询该次交易的回执,成功后,用另一个读函数的形式获取。

Expand Down

0 comments on commit 7ea44fd

Please sign in to comment.