feat: auto translation

This commit is contained in:
dong9297 2022-08-05 18:29:30 +08:00
parent 213e351560
commit b382a281e9
143 changed files with 22203 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,411 @@
# BDContract management interface
- - -
## Contract node management interface
The address of this interface is: [NodePortal.html](/NodePortal.html)
### User Management Menu
User management allows login users to view the current user distribution and user active statistics.
#### An overview of
![nodeUserManager](./_static/imgs/nodeUserManager.jpg) The node user management page has four modules: user information, active user statistics, authorized user management, and unauthorized user management.
#### User Type Distribution
Calculate the number of four roles held by the current node administrator: contract provider, contract administrator, and contract user ![userList](./_static/imgs/userList.jpg)
#### Active User Statistics
![userActive](./_static/imgs/userActive.jpg) statistics 30 days **The login**, **authorization**, **To apply for** the number of times
#### Current User Information
![nodeInfo](./_static/imgs/nodeInfo.jpg)
* In this text box, you can view the public and private keys of the current user. If other users want to use their public and private keys to log in to the node administrator interface, they can copy their public and private keys to this text box.
* After copying your public and private keys, click **Import the public key** to add the public key to the local node administrator
* The first five public keys are displayed in **Local public key**. If you select your own public key, the role of the selected public key will be displayed in **My permission**. If the node has not been authenticated by the central administrator, the default value is **Anonymous**.
* If you are not a node administrator and want to join the network of a central administrator, use your own public and private keys to import the key to the user management where the central administrator resides for authentication.
* If you want to perform more operations on contracts, you need to authenticate different roles: contract administrator, contract consumer, contract provider, and then **Role of certification**
#### List of authorized and unauthorized users
![roleAuth](./_static/imgs/roleAuth.jpg)
After the node administrator authenticates the role, the node administrator will see the application information with the public key in the **Role management is not authorized** form. If yes, click . If no, click . After authorization, you will see a list of authorized nodes in the **Authorized Role Management** table. If the node administrator wants to remove a role from a node, enter **delete** in the entitlement role management list.
### Contract code management menu
![codeManageMenu](./_static/imgs/codeManageMenu.png)
#### The contract documents
![codeManage1](./_static/imgs/codeManage1.png)
In the Contract Code Management menu, users can see public contracts as well as individual private contracts. ![codeManage1-1](./_static/imgs/codeManage1-1.png)
For public contracts, node administrators can delete and upload files, and download and delete contract items. ![codeManage1-2](./_static/imgs/codeManage1-2.png)
For private contracts, the contract provider can delete and upload files, and download, delete and upload contract items to the public contract directory.
The following is an example of working with a contract file.
#### Upload a file
![codeManage6](./_static/imgs/codeManage6.png)
#### delete
![codeManage5](./_static/imgs/codeManage5.png)
#### To the public
![codeManage7](./_static/imgs/codeManage7.png)
#### A drop-down box
![codeManage2](./_static/imgs/codeManage2.png)
From the four drop-down boxes, you can select the contract status saving mode, started contract instance, cluster where the node resides, and result verification mode.
#### Button action
![codeManage3](./_static/imgs/codeManage3.png)
#### Start the
After selecting the contract file in the file list, select “Single Node Execution” in the contract operation mode and click the Start button to launch the specified file and display the return result in the result display box.
#### The P2P cluster contract is started
After selecting the contract file in the file list, select the contract cluster on which the trusted contract runs in the Contract Run mode and click the Start button to start the specified file on all nodes of the cluster and display the return result in the result display box.
#### Start all
Select “Single Node Execution” in the contract operation mode and click the “Start All” button to start all contracts in the contract file list.
#### Stop the P2P cluster contract
Select a contract instance from the drop-down box for started contract instances, select the contract cluster for which the trusted contract runs in Contract Run mode, and click the Stop button to terminate the contract process on all nodes in the cluster.
#### stop
Selecting a contract instance from the drop-down box for started contract instances and clicking the Stop button will terminate the contract process.
#### Stop all
Clicking the Stop All button stops all contract instances running on that node.
#### Static analysis
Select the contract file in the Contract file list, select the contract instance in the Contract instance drop-down box, click the static analysis button, the contract will be static analysis, and the result will be displayed in the result display box.
#### Distribution of the contract
Select a contract item in the contract file list, select a cluster in Contract operation mode, and click the Distribute contract button. The contract item will be packaged as YPK and distributed to all nodes in the cluster.
#### Returns the result
![codeManage4](./_static/imgs/codeManage4.png)
The Return Result display displays the return results of some operations.
#### Contract Permission Configuration
After starting the contract, if the current users role can view the started contract process, the IO permissions for the current contract will be displayed in the bottom right when the process is selected. ![permissionShow](./_static/imgs/permissionShow.png)
If the selected contract does not have I/O permission, the following message is displayed in the current permission display box: **The current contract does not have IO permission**![nullPermission](./_static/imgs/nullPermission.png)
If the current user is a contract administrator, you can modify the existing contract I/O permissions. The system will prompt that the contract may not run normally after modification. If you still want to cancel, click <GT R="34"/>, otherwise click <GT R="35"/><GT R="33"/>.
After clicking Close or open, the next time the process views the same contract code, it will display the IO permission after the last modification by default. ![closePermission](./_static/imgs/closePermission.png)
### Contract instance management menu
![nodeInstancesPage](./_static/imgs/nodeInstancesPage.png)
The contract instance management menu displays all the current contract instances of this node. Users can view the status of the contract instance and execute or migrate the status of the contract instance.
#### List of Contract instances
![nodeInstancesList](./_static/imgs/nodeInstancesList.png)
This list shows all the contract instance information of the current node, including the contract ID, contract name, contract type, contract status, contract process port, contract call times, contract traffic, and contract memory usage, and the result verification mode of the cluster contract.
#### Contract instance execution
![chooseInstance](./_static/imgs/chooseInstance.png)
Users can select a contract instance in the contract instance selection drop-down box to operate on the contract instance.
![intanceExecute](./_static/imgs/intanceExecute.png)
After selecting the contract instance, the user can select the method name of the contract from the “Methods” drop-down box, enter the method parameters in the “Parameters” input box, and click “Execute ”.
Users can also click on “Dynamic Analysis Execution” to perform an execution with dynamic analysis results.
If the contract is a single point contract, the contract is executed at a single point; If the contract is a cluster contract, the contract is executed on all nodes in the cluster.
#### Contract instance execution result
![executeResult](./_static/imgs/executeResult.png)
The execution result of the contract instance is displayed in the Execution Result area, including the execution ID, execution success/failure, execution time, and execution result.
![analysisExecuteResult](./_static/imgs/analysisExecuteResult.png)
If the execution mode of the contract is Dynamic Analysis execution, in addition to the execution result, the dynamic analysis result of the execution is displayed in the result box.
#### Contract status migration
![memoryDump](./_static/imgs/memoryDump.png)
For the contract instances that support manual migration, users can click “Local State Save” to save the state of the contract instance, or select the saved contract instance from the TimeTravel list of the contract to migrate the contract state to the corresponding time.
### Log Management Menu
![logMenu](./_static/imgs/logMenu.png)
This menu displays the statistics of local node logs and contract logs of the node.
Node administrators can view node log data. The contract manager and contract user can view the local contract log data of the node.
#### Log Statistics View
![log1](./_static/imgs/log1.png)
#### Operating percentage of various platforms
By default, this chart shows the pie chart of the proportion of various platform operations in the last two days, in which platform operations are divided into six categories: login, user, log, contract, maintenance and others. You can enter the desired log time range in the upper right corner of the node log details. After the time range is changed, the operation percentage of each platform is updated.
#### Operating percentage of each type of contract
Contract operations are divided into four categories: start, end, static analysis and execution. The pie chart shows the proportion of each type of contract operation in the last 2 days. You can enter the desired log time range in the upper right corner of the contract log details. After the time range is modified, the operation percentage of each contract is updated.
#### Daily platform usage statistics
The figure is a broken line chart of the number of platform operations in the last 2 days. You can enter the desired log time range in the time range box in the upper right corner of node log details. After the time range is changed, the daily platform usage statistics line chart is updated.
#### Daily contract usage statistics
The figure is a broken line chart of the number of operations performed on the node in the last two days. You can enter the desired log time range in the time range box in the upper right corner of the contract log details. After modification, the daily contract usage statistics line chart will be updated.
#### Log details
#### Node Log Details
![log2](./_static/imgs/log2.png)
The node log details table displays all data in node logs. You can click the relevant button in the table to sort the log data in different ways, and enter keywords in the upper right corner of the table to search for relevant logs. You can enter the desired log time range in the time range box in the upper right corner. After the log time range is modified, the operation percentage of each platform and daily platform usage statistics are updated simultaneously.
#### Contract Log Details
![log3](./_static/imgs/log3.png)
The contract log details table is a display of all the data in the contract log. You can click the relevant button in the table to sort the log data in different ways, and enter keywords in the upper right corner of the table to search for relevant logs. You can enter the desired log time range in the time range box at the upper right corner. After the change, the operation percentage of each type of contract and the daily contract usage statistics are updated simultaneously.
### Node Management Menu
![nodeConfig](./_static/imgs/nodeConfig.png)
The node management menu displays the configuration information about the node and its trusted execution cluster.
#### Node configuration
![nodeConfigChange](./_static/imgs/nodeConfigChange.png)
The node administrator can view the configuration information of the node, including the node name, YJS path, and network center node of the node. The node administrator can also modify the configurations.
If the node administrator changes the network center of the node, the node tries to change the connection again, and the entire page is refreshed and reloaded.
#### Node trusted execution cluster list
![nodeUnits](./_static/imgs/nodeUnits.png)
A node administrator can view information about the trusted execution cluster to which a node belongs, including the cluster creator, cluster ID, number of nodes in the cluster, and information about nodes in the cluster.
- - -
#### Node License Configuration
![nodeLicence](./_static/imgs/nodeLicence.png)
You can view the nodes license and expiration time, apply for and upload a license, and save the node UUID.
## Smart Contract online editor
### Users and Accounts
#### Create account
#### Apply for authorization
### Create a project
#### The new file
#### Upload a file
### Start the contract
![contractMode](./_static/imgs/contractMode.png)
#### Normal mode Click the startup button on the left to start the contract in normal mode.
#### Debug mode Click the Debug button on the right to start the contract in debug mode. The current convention returns an example of the return result from the normal mode contract document when the debug mode contract is invoked via executeContract.
### Call the contract
### # Generate document ![genReadme](./_static/imgs/genReadme.png)
After starting the contract, click the “Generate document” button to call the contract and return the Result through @description / @param / @result of each export function, so as to generate the contract Description document.
- - -
## Route access management interface
### Permission application and authorization
### The dashboard
The dashboard provides an overview of the number of users, contracts, and nodes in the admittance node.
### The overall view
![dashboard](./_static/imgs/dashboard.jpg) It is divided into four modules. One module is the overview of the number of users, contracts and nodes, and then the detailed statistics of the three quantities.
### The number of nodes
![node](./_static/imgs/node.jpg) Collect statistics about the current online and offline nodes
### User Type Distribution
![userAll](./_static/imgs/userAll.jpg) Number of node administrators and admission administrators in the network where the current admitted node resides, and number of nodes to be applied for
### Contract invocation condition
![contract](./_static/imgs/contract.jpg) Broken line statistics of events, multi-point execution, WS call, and Http call in all contracts in the network where the current access node resides.
### User management
User management allows login users to view the current user distribution and user active statistics.
### An overview of
![centerManager](./_static/imgs/centerManager.jpg) The user management page consists of four modules.
### User Type Distribution
Main Statistics on the number of node administrators in the network managed by the center administrator, the number of center administrators, and the number of applied node administrators ![userList](./_static/imgs/userList.jpg)
### Statistics of applications made within 30 days
![userApplyGraph](./_static/imgs/userApplyGraph.jpg) Calculates the number of node administrators who apply for and are authorized to become node administrators within 30 days
### Current User Information
![authNodeManager](./_static/imgs/authNodeManager.jpg)
* In this text box, you can view the public and private keys of the current user. If other users want to use their public and private keys to log in to the center administrator interface, they can copy their public and private keys to this text box.
* After copying your public and private keys, click **Import the public key** to add the public key to the central administrator
* The first five public keys are displayed in **Local public key**. If you select your own public key, the role of the selected public key is displayed in **My permission**. If you are a central administrator, you have all the rights of the central administrator.
* If you are not a center administrator or node administrator and want to join the network of the current center administrator, you can select the node administrator in the following box and run **Role of certification**.
### List of authorized and unauthorized users
After applying for the current user information of the center administrator, the center administrator will see the application information with the public key in the form. If you agree, click . If you disagree, click , and the application is invalid.
![authMan](./_static/imgs/authMan.jpg)
After authorization, you will see a list of authorized nodes in the **Authorized User Management** table. If the central administrator wants to remove a role of a node administrator, select the role in the authorized user management list and click **delete** to delete the selected role.
![authMana](./_static/imgs/authMana.jpg)
### Node management
![centerNodePage](./_static/imgs/centerNodePage.png)
Node management is a page on which the Manager manages the Cluster nodes connected to it, visible only to Manager administrators and contract managers. Manager Administrators and contract managers can view node information and manage trusted execution clusters.
### An overview of
![centerNodePreview](./_static/imgs/centerNodePreview.png)
The overview displays the statistics of all nodes managed by the Manager node, including the total number of nodes, the total number of contracts, the total number of subscription events, and the number of trusted execution clusters. The pie chart on the right shows the number of nodes that are Online and Offline respectively.
### The node list
![centerNodeList](./_static/imgs/centerNodeList.png)
The node list shows the node information that the user has the permission to view. (The Manager administrator can view all nodes, and the contract Manager can view the Online node that he is responsible for managing.) This includes the node name, status, number of contracts, number of subscribed events, PeerID for P2P communication between nodes, UDPID for UDP communication between nodes, and the node public key.
### List of trusted execution clusters
![centerNodeUnits](./_static/imgs/centerNodeUnits.png)
The trusted execution cluster list displays the trusted execution cluster information that the user has the permission to view. (The Manager administrator can view all the clusters, and the contract Manager can view the clusters created by himself.) This includes the creator of the cluster, the cluster ID, the number of nodes in the cluster, and information about the nodes in the cluster.
You can click the “Delete” button of the column entry to delete the cluster.
### Create a trusted execution cluster
![centerNodeUnitCreate](./_static/imgs/centerNodeUnitCreate.png)
You can create a new trusted execution cluster by selecting multiple nodes. The nodes that users can select are those they have permission to view, that is, the Manager administrator can select from all nodes, and the contract Manager can select from the Online node that they are responsible for managing). Select and click Submit. A message indicating that the cluster is created successfully will be displayed in the list of trusted execution clusters. The cluster name is selected by the creator and cannot contain double quotation marks. The cluster name is visible when the contract manager selects the cluster.
### Log management
Log management displays the log information of admission nodes and consists of six modules.
### An overview of
![log](./_static/imgs/log.jpg)
### Classified Statistics of Management Operations (2 days)
![operator](./_static/imgs/operator.jpg) Pie chart of all management operations in the last two days. Management operations are classified into login, log, maintenance, and user operations.
### Daily Statistics of Management Operations (2 days)
![everyLog](./_static/imgs/everyLog.jpg) Daily operation statistics of all management operations within two days
### Statistics on Contract Operations by Category (2 Days)
![contractLog](./_static/imgs/contractLog.jpg) Two day contract operation classification statistical pie chart, contract operation is mainly divided into connection class and status update class.
### Daily Statistics of Contract Operation (2 days)
![contracteveryLog](./_static/imgs/contracteveryLog.jpg) Chart of the broken line of the number of contract operations in two days.
### Manage the operation log list
![opList](./_static/imgs/opList.jpg) Manage the detailed information list of operation logs. The information includes log time, management operation name, and node public key corresponding to the operation. The default value is two days. You can customize the days for obtaining logs.
### List of contract operation logs
![contractList](./_static/imgs/contractList.jpg) Detailed information list of contract operation logs. This parameter includes log generation time, contract operation name, and public key of the contract operation node. The default value is two days. You can customize the days for obtaining logs.
### Set up the
The Settings page displays the status of node certificates and configures node certificates
### An overview of
![set](./_static/imgs/set.jpg)
### Certificate status
![licence](./_static/imgs/licence.jpg) The certificate status includes the license expiration time and the number of licensed nodes.
### Certificate of configuration
![plicence](./_static/imgs/plicence.jpg) Configure the certificate module. You can download the node ID file or enter the certificate information for submission.

View File

@ -0,0 +1,188 @@
# BDContract Installation instructions
- - -
## Environment-dependent installation
1.Install the Java1.8 environment.
For example, using apt-get to install Ubuntu:
```bash
apt-get install openjdk-8-jre
```
On Centos, install using yum:
```bash
yum install java-1.8.0-openjdk
```
In an offline environment, download the OpenJDK installation package and install it offline.
Under the Ubuntu
```bash
dpkg -i jdk-8uxxxxx.deb
```
On Centos, use yum for offline installation:
```bash
yum localinstall jdk-8u271-linux-xxx.rpm
```
2.Install wGET and unzip. For example, using apt-get to install Ubuntu:
```bash
apt-get install unzip
apt-get install wget
```
- - -
## Network Topology Description
Only one node is required to deploy the Surui smart contract engine, which can be used for debugging and testing. The multi-node mode cannot be used to achieve trusted computing. When a single node is deployed, the calculation of “anti-repudiation” can be implemented by configuring the ledger, but the calculation of “tamper-resistant” cannot be implemented.
In multi-node deployment, the following figure shows three types of logical nodes. One to three types of nodes can be installed on a VM.
1) Account node. That is, the number Rui schema ledger.
2) Contract node. Run code logic and implement highly responsive modules through memory caching. Form a trusted computing network with other contract nodes.
3) Routing node. Routing information of each contract node. Generally, a routing node can support a maximum of 1000 contract nodes. Deploy multiple routing nodes as required, and configure the routing nodes among them to implement a large-scale node network.
Generally, **Contract node and ledger node** is deployed on the same VM.
![deploytopology](_static/imgs/deploytopology.png)
- - -
## Smart contract node installation
Open the[安装包下载链接](https://public.internetapi.cn/?dir=releases/bdcontract/newest), download `bdserver-lite.zip` or `bdserver.zip`, among them, the `bdserver.zip` contains more examples and documentation. After downloading, unzip and launch.
```bash
unzip -d ./bdserver bdserver-lite.zip
cd bdserver
chmod +x *.sh
sh cmstart.sh
```
- - -
## Route admission nodes are installed
Open[安装包下载链接](https://public.internetapi.cn/?dir=releases/bdcontract/newest) Where, download `bdserver-cluster.zip`. After downloading, unzip and launch.
```bash
unzip -d ./bdcluster bdserver-cluster.zip
cd bdcluster
chmod +x *.sh
sh ncstart.sh
```
- - -
## Document describing
### Smart Contract node
![bdserver目录](_static/imgs/dirstructure.png)
Description of files in this directory:
1.Cmstart. sh This script is used to start the contract engine. The contract engine listens to port 8080 by default. You can modify the listening port by running the cmstart.sh command.
2.BDWareProjectDir This directory stores all contract projects for this node.
3.WebContent This directory stores the front-end code of this node.
4.Cp, which holds yjs.jar, the JAR needed to start the contract instance.
5.Bdserver. jar provides HTTP/webSocket server logic externally.
6.Updatecontract. sh Upgrade script.
### Route admission node
The installation script is automatically downloaded and decompressed to the bdCluster directory. Description of files in this directory:
1.Ncstart. sh This script is used to start the node access center. It listens on port 1718 by default. You can modify the listening port by modifying ncstart.sh.
2.WebContent This directory houses the front-end code for the access center.
3.Bdcluster. jar back-end of the access center.
- - -
## The upgrade process
### Contract node
On the command line, type:
```bash
sh updateContract.sh
```
Alternatively, go to [public.internetapi.cn](https://public.internetapi.cn/?dir=releases/bdcontract), download the latest file, and upgrade yjs.zip/bdserver-jar.zip/AgentWebContent separately.
### Route admission node
```bash
sh updateCluster.sh
```
Through the [public.internetapi.cn](https://public.internetapi.cn/?dir=releases/bdcontract), download the latest files, separate upgrade bdserver — cluster. Zip/ClusterWebContent. Zip to upgrade.
- - -
## Directions for use
### Use it on the reference page
If the WebContent directory is reserved, you can configure it using the browser. For more information, see the document [BDContract refer to the interface instructions](./IDEUsage.html) on the left.
#### BDWare OnlineIDE
Open [BDWare OnlineIDE](../OnlineIDE.html).
#### BDWare NodePortal
Open [BDWare NodePortal](../NodePortal.html).
If the cross-node function is required for networking, install the route access center. Perform the following steps to configure it. Two sets of public and private keys are involved. The first group of public and private keys is the public and private keys of the contract node that have NodeManager permission. The second group is the public and private keys of the route access node that have the CenterManager permission.
1.Open nodeportal. HTML and copy the public and private NodeManager keys of the node.
2.Open centerportal. HTML, click in the upper right corner, and import the public and private NodeManager keys. And select “NodeManager” for identity authentication.
3.In centerportal. HTML, switch the public and private keys of CenterManager, click User Management on the left, and pass the NodeManager authentication request.
4.Use the public and private keys of the NodeManager permission to open nodeportal. HTML, click the Node Management menu, and configure joining the network. The format of joining the network is WS :// IP address of Centerportal: port +1. ![配置示例](_static/imgs/config.png)
### Using the SDK
#### Basic knowledge of
[Websocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API)
[Sm2 encrypted using] (https://github.com/JuneAndGreen/sm-crypto)
#### Download the SDK
1. Java client download: [BDWareJavaClient](_static/BDWareJavaClient.zip). For details about how to use it, download it, decompress it, check readme.md, and see [ContractAPI](./ContractAPI.html).
2.Javascript version for client download :[BDWareWebClient](_static/BDWareWebClient.zip). For details about how to use it, download it, decompress it, check readme.md, and see [ContractAPI](./ContractAPI.html).
3.Configuration tool [BDWareConfigTool](_static/BDWareConfigTool.zip). For details, decompress the package and run the following command to view help information:
``` bash
java -jar java-client.jar -h
```

View File

@ -0,0 +1,219 @@
# BDContract introduction
- - -
## What is a BDContract?
Pku is a management and scheduling platform for data resources, IoT resources and cloud resources in big data scenarios. BDContract is a trusted computing framework where the computation logic is expressed as a smart contract. Through “random” and “redundant computation” to achieve the trusted execution of smart contract. BDContract focuses on improving execution efficiency and security while ensuring the availability and reliability of smart contracts.
- - -
## The characteristics of
0. Support multiple execution modes, balancing availability, reliability, correctness, and efficiency.
1. Access to various data sources.
2. Support for fine-grained monitoring of contracts.
3. Support the state of the contract.
4. Access control.
5. Support for cross-language invocation.
- - -
## Update log
* **v1.4.5** June 29, 2021
- Improvement of stability
- Optimize URIPath for the HTTP server
- Supports static resource file loading using Http
* **v1.4.4** June 15, 2021
- Fixed an issue with getContractMeta that does not prioritise RUNNING/HANGED contracts
- The logic of HomomorphicEncrypt is implemented
* **v1.4.3** June 9, 2021
- Fix the SSL Renegotiate Bug
- Implement automatic hangup-resume when memory is insufficient
- Implement hard disk persistence for Contract Meta
* **v1.4.1** May 26, 2021
- Implement event semantics in event mechanism, support “at least once”, “at most once” and “only once”
- Optimized contract templates
- Example Add a template configuration file
- Optimized the MockTemplate annotation
* **v1.4.0** May 9, 2021
- Optimize the ACTemplate
- Improved configuration linkage for DoRepo
* **v1.3.9** April 22, 2021
- Fixed a bug where doipConfig was not supported in updateConfig
- Test-tool supports SUdo
- Optimized the ACTemplate template in Contract-Template
* **v1.3.6** April 21, 2021
- Fixed an issue in Docker where CPUID could not be obtained
* **v1.3.6** April 16, 2021
- Fixed some bugs
- Fixed a bug that caused queuing due to insufficient GRPCPool threads
- Fixed a bug where the requestID assignment could duplicate under stress testing
* **v1.3.5** March 31, 2021
- Fixed some bugs
- Simple congestion control policies have been added to the contract invocation part of HTTP
- Improvement of stability
* **v1.3.0** February 1, 2021
- Optimizing heartbeat Mechanism
- Fixed some bugs
- SM2 update/SM3 library
- Update the front-end signature calculation method
* **v1.2.0** December 11, 2020
- Optimized multi-node execution mode
- Optimized the logic of the contract master route
- Fixed some bugs
- Fix file system related vulnerabilities
* **v1.1.0** September 2020
- Support for HTTPS, and updated this part of the documentation
* **v1.0.9** August 27, 2020
- Improve the documentation of IO related tools
- Optimize contract template: DAC persistence
* **v1.0.7** August 13, 2020
- Optimized the contract log and ledger interfaces
- Optimize documentation for interfaces
- Provides the WebSocket interface for the contract template
- Automatic compilation of bug fixes
* **v1.0.5** July 25, 2020
- Weaken the centralization of NC, and cluster point-to-point connection.
- Optimize bdwareclient
- TODO MemoryDurable
* **v1.0.2** July 22, 2020
- Fixed Bug in CentOS7 Too Many Opened Files
- Fix permissions bugs
- Adding a Permission
- Fixed bugs in MySQLUtil
- Upgrade the BDLedger version
* **v1.0.1** July 5, 2020
- Updated NodePortal/CenterPortal UI.
- The compilation process has been modified so that the compilation results can be viewed in NodePortal and compiled manually/startup in OnlineIDE
- Modified the contract distribution logic to use compiled YPk as the distribution file
- When YPK in the public directory is executed in multi-node mode, contract faults can be automatically recovered
* **v0.99** June 22, 2020
- Billing for custom contract methods
- Add GasExample, Incentives examples
- On the client side, “check multipoint result” is implemented, and the method of result return is optimized
- Repair Disconnection No permission prompt after reconnection
* **v0.97** May 25, 2020
- CPU metering: GAS mechanism
- Onlineide.html supports uploading multiple files
- Multi-point Execution in UDP Mode [Unordered messages]
- Bdwareclient.html, fixes a call example generation prefix error that contains only computational logic
* **v0.95** May 19, 2020
- Fixed bug where onlineide.html could not jump to Bdwareclient correctly when the pathname was prefixed.
- Fixed a bug where Bdwareclient automatically extracted urls when the pathname was prefixed.
- Permissions for contracts are enabled
- Increased NodePortal. HTML/OnlineIDE. HTML and bdwareclient. HTML has no right to limit the warning
* **v0.90** May 9, 2020
- Changed the way yjs.jar/bdserver.jar is packaged
- Updated the sh/update. Sh
- OnlineIDE post modification reminder
- OnlineIDE tag adaptive width
- File interface isolation
* **v0.8** April 26, 2020
- Improve the documentation interface and optimize the way SDK is provided
- Rui Web client, all the data processing in the client and how to render the processed data are from the contract call, to achieve a trusted Web application.
* **v0.78** April 13, 2020
- Contract call DAC example
- Supports dynamic change of I/O permissions
- Supports custom backup (periodic) policies for contract status
- Fixed some page bugs
- Log Display Optimization
- Optimized ledger log presentation
- Enable partial access control
* **v0.7** March 25, 2020
- Support access control for multiple roles
- Updated the UI
* **v0.6** February 14, 2020
- Optimized communication between contract processes
- Try to access a P2P network
* **v0.5** December 10, 2019
- Improved three smart contract state record-playback strategies
- Supports the simplest multi-point execution algorithm (unsynchronized)
* **v0.45** September 2, 2019
- Preliminary implementation of PBFT algorithm
* **v0.4** May 10, 2019
- Support the memory dump
* **v0.35** April 26, 2019
- Implement a static analysis framework for contracts
- Support for publish-subscribe events
* **v0.3** January 8, 2019
- Support ledger data access
- Contract status on the chain
* **v0.2** October 9, 2018
- Support for automatic Python package generation
- Contracts can be packaged as YPK
- Supports data access, such as files and databases
* **v0.1** August 6, 2018
- Defines the syntax for smart contracts
- Based on Nashorn engine, smart contract execution is realized
- - -
## Use open source project instructions
The BDWareContract project stands on the shoulders of many giants, thanks to these open source projects.
The smart contract backend of this project uses the following open source libraries.
| 名称 |Licence type| 说明 |
| ------ | ---------- | ---- |
| [Project Nashorn](https://openjdk.java.net/projects/nashorn/) |[GPLv2](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)| 使用了该项目的编译器可以将js函数编译为java字节码 |
| [ASM OW2](https://projects.ow2.org/view/asm/) |[BSD](https://en.wikipedia.org/wiki/BSD_licenses#4-clause_license_(original_%22BSD_License%22)) with attribution| 基于asm的TreeAPI与VisitorAPI实现合约的静态分析框架 |
| [Netty](https://netty.io/) |[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)| 使用netty作为Http/Websocket的服务端 |
| [gRPC](https://grpc.io/) |[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)| 使用gRPC与BDWareLedger通讯 |
| [RocksDB](https://github.com/facebook/rocksdb) |[GPLv2](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)| 后台数据库 |
| [ANTLR](https://github.com/antlr/antlr4) |[BSD](https://en.wikipedia.org/wiki/BSD_licenses#4-clause_license_(original_%22BSD_License%22))| 对合约脚本的词法分析与语法分析 |
| [SM2Java](https://github.com/PopezLotado/SM2Java) |[无](https://github.com/PopezLotado/SM2Java/blob/master/README.md)| 国密SM2 Java语言实现 |
The smart contract front-end of this project uses the following open source libraries.
| 名称 |Licence type| 说明 |
| ------ | ---------- | ---- |
| [Bootstrap](https://getbootstrap.com/) |[MIT](https://github.com/twbs/bootstrap/blob/master/LICENSE)| 前端的排版、样式 |
| [jQuery](https://jquery.org/) |[MIT](https://jquery.org/license/)| 用于操作DOM的javascript库 |
| [jQueryUI](https://jqueryui.com/) |[MIT](https://jquery.org/license/)| 前端UI构件库 |
| [DataTables](https://datatables.net/) |[MIT](https://datatables.net/license/mit)| 表格样式 |
|[CodeMirror](https://codemirror.net/)| [MIT](https://codemirror.net/LICENSE) | 代码编辑框样式 |
|[eCharts](https://echarts.apache.org/zh/index.html)| [ApacheV2](https://www.apache.org/licenses/) | 统计图表 |
| [sm-crypto](https://github.com/JuneAndGreen/sm-crypto) |[MIT](https://github.com/JuneAndGreen/sm-crypto/blob/master/LICENCE_MIT)| 国密SM2 javascript语言实现 |
The document for this project was generated using [Sphinx](https://www.sphinx-doc.org/en/master/), thanks to [readthedocs](https://readthedocs.org/) for providing the document style.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,290 @@
# YJS grammar
- - -
## An overview of the
YJS source files include any number of **The import declaration** and one **The contract is defined**.
- - -
## The import declaration
Like JavaScript (ES6), YJS also supports import statements. At the global level, developers can use the following import statements to import other files.
```
import "filename";
```
### content
The import statement imports all global symbols (units) contained in the “filename” file into the current file and is globally valid.
### The path
**filename** Usually **/** is used as the directory separator to indicate the file path. For example, to import the **x.yjs** file from the same directory to the current file, you can use the **import “x.yjs”** statement. Import **x.yjs** from another directory using the **import “lib/x.yjs”** statement.
- - -
## The Contract is defined
### The sample
Here is an example contract for JSON processing, with the YJS source file named after the contract name.
```
contract ScoreAdder{
//arg = {"action":"main","arg":"[{\"score\":20},{\"score\":20}]"}
export function main(arg){
//JSON is a build-in object.
var point = JSON.parse(arg);
var s = 0;
print(point[0].score);
print(point.length);
for (var i=0;i<point.length;i++){
s+=point[i].score/1.0;
}
print("total score= "+s);
return s;
}
}
```
### annotation
YJS source files support single-line comments represented by (**//**) and multi-line comments represented by (**/\*...\*/**), as shown below:
```
// 这是一个单行注释
/*
* 这是一个
* 多行注释
*/
```
### annotations
Like Java, YJS also supports annotations to declare contracts and functions.
In YJS, there are several built-in annotations: LogType, LogLocation, Access, Permission. Of course, you can customize your annotations. The detailed usage of the built-in annotations can be viewed through the YJS built-in API documentation. Developers can use the following annotations to declare contracts and functions.
```
@LogType("Arg","Result","Branch")
@SelfDefinedAnntation("dad",1)
@Access
function xxx(){}
```
### structure
Contracts in YJS are similar to classes in Java. Each contract defines a certain number of **variable**, **function** and **The event**.
#### variable
Variables in YJS are similar to those in JavaScript (ES6), which are divided into **The global variable** and **A local variable**.
Global variables:
```
judge = true;
```
Local variables:
```
var vs = "This is a string";
```
All variables are **Dynamic type** because the specific type of variable is determined by the value of the variable. In the example above, the global variable judge is of type bool and the local variable VS is of type string.
#### function
A function is an executable unit in a contract. There are two types of functions in YJS: ordinary functions and exported functions decorated with the **export** keyword.
The following is the difference between exported functions and ordinary functions:
1. Only the exported function can be called by other contracts.
2. Exported functions can only have one parameter and the parameter type must be String.
3. Exported functions return type must be String.
4. The built-in object requester (the requesters public key) can only exist in the exported function or the onCreate function, because onCreate(), although not modified by the **export** keyword, comes with a Requester object and the function can be executed automatically.
#### The event
Events in YJS are similar to events in Solidity.
**The publisher** Define an event that contains the event publisher function, and then publish the event by calling the event publisher function.
**The subscriber** Subscribe and process events.
The following is an example of an event:
EventPuber.yjs
```
contract EventPuber{
event abcEvent;
export function pub(arg){
abcEvent(arg);
return "done!";
}
}
```
EventSuber.yjs
```
contract EventSuber{
export function init(arg){
YancloudUtil.subscribe("EventPuber","abcEvent",handler);
print("Handler:"+handler);
}
function handler(e){
var ret = "ReceiveEvent:"+(e.type)+" "+(e.content);
print(ret);
}
}
```
- - -
## YJS project
In addition to the YJS source file that contains only a contract definition, the YJS engine also supports **YJS project**.
Each YJS project contains various files used by the execution of a contract, including YJS source file files and other resources, such as **“mainfest.json”**, **“.js”**, **“.txt”**, **“.jar”**,...
### Manifest.json
Each YJS project must have a **mainfest.json** file in the root directory of the project, which describes the necessary information required by the contract for the YJS compilation tool (YJS engine).
#### Structure of the Manifest
The manifest file must contain the following information:
1. **main**: contract document to be executed in the project.
2. **type**: type of contract, such as data contract/algorithm contract...
3. **builder**: Name of the developer who built the YJS project.
4. **insnLimit**: indicates the value consumed to run the contract.
5. **pyDependences**: Python dependencies required by the project.
#### The Manifest sample
```
{
"main": "contract.js",
"type": "Data",
"builder": "caihq",
"permissions": 0L,
"pyDependences": [
{
"name": "yjsexample",
"modules": [
{
"name": "sample"
}
]
}
]
}
```
### YJS-Java
Jar file implements **Calling across languages** between YJS and other programming languages, such as yjs-Java, yjs-Python,... The contract can call methods directly in Java by wrapping Java files into JAR packages.
Java class:
```java
package your.own.pkg;
public class HelloWorld {
public static int fun(String arg){
return arg.length;
}
public int fun2(String arg){
return arg.length;
}
}
```
InvokeJava.yjs
```javascript
contract InvokeJava{
export function main(arg){
var Hello = Java.type("your.own.package.HelloWorld");
var hello = new Hello();
return Hello.fun(arg)+hello.fun2(arg);
}
}
```
### YJS — front end
Using the Surui client to access smart contracts supports fetching resource files such as HTML/JS/CSS from smart contracts and rendering them in [BDWareWebClient](./_static/BDWareWebClient.zip). Start by importing the following modules into the contract.
```javascript
module Viewable{
export function loadResource(arg){
return Global.Resources.loadAsString(arg);
}
export function needRender(arg){
return true;
}
}
```
Also, after the import, define a getMainFrame method so that the mainframe can be recognized by the mainframe client:
```javascript
export function getMainFrame(arg){
return "/html/main.html";
}
```
The result of this method is the path to a resource file. The example resource file ”/ HTML /main.html” is as follows:
```html
<div>
<button onclick="queryDataFromContract()">Hello,</button> Data from contract:
<span id="resultText"></span>
<script fromContract="/html/hello.js"></script>
<link fromContract="/html/hello.css"/>
</div>
```
The example resource file ”/ HTML /hello.js” is as follows:
```javascript
var queryDataFromContract = function(){
//第一个参数为函数名,第二个为参数,第三个参数为回调。
var data = executeCurrentContract("query","abc",function(argg){
$("#resultText")[0].innerHTML = argg.result;
});
}
```
Reference example:
### YJS-Python
TODO

View File

@ -0,0 +1,100 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# -- Project information -----------------------------------------------------
project = '北大数瑞大数据区块链'
copyright = '2021, Peking University'
author = 'Peking University'
# The full version, including alpha/beta/rc tags
release = 'V1.0'
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
html_theme = "sphinx_rtd_theme"
html_logo="_static/imgs/logo.png"
html_theme_options = {
'logo_only': True
}
source_parsers = {
'.md': 'recommonmark.parser.CommonMarkParser',
}
source_suffix = ['.rst', '.md']
# source_suffix = {
# '.rst': 'restructuredtext',
# '.txt': 'markdown',
# '.md': 'markdown'
# }
extensions = [
'recommonmark',
'sphinx_rtd_theme',
'sphinx_markdown_tables'
]
html_favicon = "_static/imgs/favicon.ico"
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = 'zh_CN'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
#html_theme = 'alabaster'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
master_doc = 'index'
##latex_elements = {
## 'papersize': 'a4paper',
# Additional stuff for the LaTeX preamble.
## 'preamble': '''
##\usepackage{xeCJK}
##\usepackage{indentfirst}
##\setlength{\parindent}{2em}
##\setCJKmainfont[BoldFont=STFangsong, ItalicFont=STKaiti]{STSong}
##\setCJKsansfont[BoldFont=STHeiti]{STXihei}
##\setCJKmonofont{STFangsong}
##''',
##}

View File

@ -0,0 +1,10 @@
.. BDContract documentation master file, created bysphinx-quickstart on Mon Nov 25 16:23:38 2019.You can adapt this file completely to your liking, but it should at leastcontain the root `toctree` directive.
Zhirong Yunhe big data blockchain — Smart contract engine document
===================================================================
.. toctree::
:maxdepth: 3
:caption: directory
Introduction.rstInstallTips.rstIDEUsage.rstContractAPI.rstYJSInDepth.rstYJSAPI.rst

View File

@ -0,0 +1,246 @@
# Introduction to Peking University
- - -
## What is a BDContract?
BDContract is a trusted computing framework where the computation logic is expressed as a smart contract. Through “random” and “redundant computation” to achieve the trusted execution of smart contract. BDContract focuses on improving execution efficiency and security while ensuring the availability and reliability of smart contracts.
- - -
## The characteristics of
1. Support multiple execution modes, balancing availability, reliability, correctness, and efficiency.
2. Access to various data sources.
3. Support for fine-grained monitoring of contracts.
4. Support the state of the contract.
5. Access control.
6. Support for cross-language invocation.
- - -
## Update log
* **v1.7.5** April 29, 2022
- Updated some features of nodeportal.html
- Supports YPK deploy Tool
- Optimized the view keyword
- Optimized the startContract log output
- Docker image script support
* **v1.7.0** March 7, 2022
- The submission algorithm is plug-in
- Cp is stripped from the mirror image
- ArgSchema annotations are supported.
* **v1.6.7** January 6, 2022
- Cp supports MultiTagTimeIndexUtil
* **v1.6.6** January 4, 2022
- Update DOIP — SDK
* **v1.6.0** December 20, 2021
- Merge feature DS branch and support PBFT algorithm.
- Upgrade Log4j2 to 2.1.17
* **v1.5.0** October 1, 2021
- It is divided into two modules: cp-bundle and bdcontract-bundle
- Network optimization: NetworkManager is used to manage Agent-cluster/Agent-Agent connections.
* **v1.4.5** June 29, 2021
- Improvement of stability
- Optimize URIPath for the HTTP server
- Supports static resource file loading using Http
* **v1.4.4** June 15, 2021
- Fixed an issue with getContractMeta that does not prioritise RUNNING/HANGED contracts
- The logic of HomomorphicEncrypt is implemented
* **v1.4.3** June 9, 2021
- Fix the SSL Renegotiate Bug
- Implement automatic hangup-resume when memory is insufficient
- Implement hard disk persistence for Contract Meta
* **v1.4.1** May 26, 2021
- Implement event semantics in event mechanism, support “at least once”, “at most once” and “only once”
- Optimized contract templates
- Example Add a template configuration file
- Optimized the MockTemplate annotation
* **v1.4.0** May 9, 2021
- Optimize the ACTemplate
- Improved configuration linkage for DoRepo
* **v1.3.9** April 22, 2021
- Fixed a bug where doipConfig was not supported in updateConfig
- Test-tool supports SUdo
- Optimized the ACTemplate template in Contract-Template
* **v1.3.6** April 21, 2021
- Fixed an issue in Docker where CPUID could not be obtained
* **v1.3.6** April 16, 2021
- Fixed some bugs
- Fixed a bug that caused queuing due to insufficient GRPCPool threads
- Fixed a bug where the requestID assignment could duplicate under stress testing
* **v1.3.5** March 31, 2021
- Fixed some bugs
- Simple congestion control policies have been added to the contract invocation part of HTTP
- Improvement of stability
* **v1.3.0** February 1, 2021
- Optimizing heartbeat Mechanism
- Fixed some bugs
- SM2 update/SM3 library
- Update the front-end signature calculation method
* **v1.2.0** December 11, 2020
- Optimized multi-node execution mode
- Optimized the logic of the contract master route
- Fixed some bugs
- Fix file system related vulnerabilities
* **v1.1.0** September 2020
- Support for HTTPS, and updated this part of the documentation
* **v1.0.9** August 27, 2020
- Improve the documentation of IO related tools
- Optimize contract template: DAC persistence
* **v1.0.7** August 13, 2020
- Optimized the contract log and ledger interfaces
- Optimize documentation for interfaces
- Provides the WebSocket interface for the contract template
- Automatic compilation of bug fixes
* **v1.0.5** July 25, 2020
- Weaken the centralization of NC, and cluster point-to-point connection.
- Optimize bdwareclient
- TODO MemoryDurable
* **v1.0.2** July 22, 2020
- Fixed Bug in CentOS7 Too Many Opened Files
- Fix permissions bugs
- Adding a Permission
- Fixed bugs in MySQLUtil
- Upgrade the BDLedger version
* **v1.0.1** July 5, 2020
- Updated NodePortal/CenterPortal UI.
- The compilation process has been modified so that the compilation results can be viewed in NodePortal and compiled manually/startup in OnlineIDE
- Modified the contract distribution logic to use compiled YPk as the distribution file
- When YPK in the public directory is executed in multi-node mode, contract faults can be automatically recovered
* **v0.99** June 22, 2020
- Billing for custom contract methods
- Add GasExample, Incentives examples
- On the client side, “check multipoint result” is implemented, and the method of result return is optimized
- Repair Disconnection No permission prompt after reconnection
* **v0.97** May 25, 2020
- CPU metering: GAS mechanism
- Onlineide.html supports uploading multiple files
- Multi-point Execution in UDP Mode [Unordered messages]
- Bdwareclient.html, fixes a call example generation prefix error that contains only computational logic
* **v0.95** May 19, 2020
- Fixed bug where onlineide.html could not jump to Bdwareclient correctly when the pathname was prefixed.
- Fixed a bug where Bdwareclient automatically extracted urls when the pathname was prefixed.
- Permissions for contracts are enabled
- Increased NodePortal. HTML/OnlineIDE. HTML and bdwareclient. HTML has no right to limit the warning
* **v0.90** May 9, 2020
- Changed the way yjs.jar/bdserver.jar is packaged
- Updated the sh/update. Sh
- OnlineIDE post modification reminder
- OnlineIDE tag adaptive width
- File interface isolation
* **v0.8** April 26, 2020
- Improve the documentation interface and optimize the way SDK is provided
- Rui Web client, all the data processing in the client and how to render the processed data are from the contract call, to achieve a trusted Web application.
* **v0.78** April 13, 2020
- Contract call DAC example
- Supports dynamic change of I/O permissions
- Supports custom backup (periodic) policies for contract status
- Fixed some page bugs
- Log Display Optimization
- Optimized ledger log presentation
- Enable partial access control
* **v0.7** March 25, 2020
- Support access control for multiple roles
- Updated the UI
* **v0.6** February 14, 2020
- Optimized communication between contract processes
- Try to access a P2P network
* **v0.5** December 10, 2019
- Improved three smart contract state record-playback strategies
- Supports the simplest multi-point execution algorithm (unsynchronized)
* **v0.45** September 2, 2019
- Preliminary implementation of PBFT algorithm
* **v0.4** May 10, 2019
- Support the memory dump
* **v0.35** April 26, 2019
- Implement a static analysis framework for contracts
- Support for publish-subscribe events
* **v0.3** January 8, 2019
- Support ledger data access
- Contract status on the chain
* **v0.2** October 9, 2018
- Support for automatic Python package generation
- Contracts can be packaged as YPK
- Supports data access, such as files and databases
* **v0.1** August 6, 2018
- Defines the syntax for smart contracts
- Based on Nashorn engine, smart contract execution is realized
- - -
## Use open source project instructions
The BDWare project stands on the shoulders of many giants, thanks to these open source projects.
The smart contract backend of this project uses the following open source libraries.
| 名称 |Licence type| 说明 |
| ------ | ---------- | ---- |
| [Project Nashorn](https://openjdk.java.net/projects/nashorn/) |[GPLv2](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)| 使用了该项目的编译器可以将js函数编译为java字节码 |
| [ASM OW2](https://projects.ow2.org/view/asm/) |[BSD](https://en.wikipedia.org/wiki/BSD_licenses#4-clause_license_(original_%22BSD_License%22)) with attribution| 基于asm的TreeAPI与VisitorAPI实现合约的静态分析框架 |
| [Netty](https://netty.io/) |[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)| 使用netty作为Http/Websocket的服务端 |
| [gRPC](https://grpc.io/) |[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)| 使用gRPC与BDWareLedger通讯 |
| [RocksDB](https://github.com/facebook/rocksdb) |[GPLv2](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)| 后台数据库 |
| [ANTLR](https://github.com/antlr/antlr4) |[BSD](https://en.wikipedia.org/wiki/BSD_licenses#4-clause_license_(original_%22BSD_License%22))| 对合约脚本的词法分析与语法分析 |
| [SM2Java](https://github.com/PopezLotado/SM2Java) |[无](https://github.com/PopezLotado/SM2Java/blob/master/README.md)| 国密SM2 Java语言实现 |
The smart contract front-end of this project uses the following open source libraries.
| 名称 |Licence type| 说明 |
| ------ | ---------- | ---- |
| [Bootstrap](https://getbootstrap.com/) |[MIT](https://github.com/twbs/bootstrap/blob/master/LICENSE)| 前端的排版、样式 |
| [jQuery](https://jquery.org/) |[MIT](https://jquery.org/license/)| 用于操作DOM的javascript库 |
| [jQueryUI](https://jqueryui.com/) |[MIT](https://jquery.org/license/)| 前端UI构件库 |
| [DataTables](https://datatables.net/) |[MIT](https://datatables.net/license/mit)| 表格样式 |
|[CodeMirror](https://codemirror.net/)| [MIT](https://codemirror.net/LICENSE) | 代码编辑框样式 |
|[eCharts](https://echarts.apache.org/zh/index.html)| [ApacheV2](https://www.apache.org/licenses/) | 统计图表 |
| [sm-crypto](https://github.com/JuneAndGreen/sm-crypto) |[MIT](https://github.com/JuneAndGreen/sm-crypto/blob/master/LICENCE_MIT)| 国密SM2 javascript语言实现 |
The document for this project was generated using [Sphinx](https://www.sphinx-doc.org/en/master/), thanks to [readthedocs](https://readthedocs.org/) for providing the document style.

View File

@ -0,0 +1,188 @@
# Installation instructions
- - -
## Environment-dependent installation
1.Install the Java1.8 environment.
For example, using apt-get to install Ubuntu:
```bash
apt-get install openjdk-8-jre
```
On Centos, install using yum:
```bash
yum install java-1.8.0-openjdk
```
In an offline environment, download the OpenJDK installation package and install it offline.
Under the Ubuntu
```bash
dpkg -i jdk-8uxxxxx.deb
```
On Centos, use yum for offline installation:
```bash
yum localinstall jdk-8u271-linux-xxx.rpm
```
2.Install wGET and unzip. For example, using apt-get to install Ubuntu:
```bash
apt-get install unzip
apt-get install wget
```
- - -
## Network Topology Description
Only one node is required to deploy the Surui smart contract engine, which can be used for debugging and testing. The multi-node mode cannot be used to achieve trusted computing. When a single node is deployed, the calculation of “anti-repudiation” can be implemented by configuring the ledger, but the calculation of “tamper-resistant” cannot be implemented.
In multi-node deployment, the following figure shows three types of logical nodes. One to three types of nodes can be installed on a VM.
1) Account node. That is, the number Rui schema ledger.
2) Contract node. Run code logic and implement highly responsive modules through memory caching. Form a trusted computing network with other contract nodes.
3) Routing node. Routing information of each contract node. Generally, a routing node can support a maximum of 1000 contract nodes. Deploy multiple routing nodes as required, and configure the routing nodes among them to implement a large-scale node network.
Generally, **Contract node and ledger node** is deployed on the same VM.
![deploytopology](_static/imgs/deploytopology.png)
- - -
## Smart contract node installation
Open the[安装包下载链接](https://public.internetapi.cn/?dir=releases/bdcontract/newest), download `bdserver-lite.zip` or `bdserver.zip`, among them, the `bdserver.zip` contains more examples and documentation. After downloading, unzip and launch.
```bash
unzip -d ./bdserver bdserver-lite.zip
cd bdserver
chmod +x *.sh
sh cmstart.sh
```
- - -
## Route admission nodes are installed
Open[安装包下载链接](https://public.internetapi.cn/?dir=releases/bdcontract/newest) Where, download `bdserver-cluster.zip`. After downloading, unzip and launch.
```bash
unzip -d ./bdcluster bdserver-cluster.zip
cd bdcluster
chmod +x *.sh
sh ncstart.sh
```
- - -
## Document describing
### Smart Contract node
![bdserver目录](_static/imgs/dirstructure.png)
Description of files in this directory:
1.Cmstart. sh This script is used to start the contract engine. The contract engine listens to port 8080 by default. You can modify the listening port by running the cmstart.sh command.
2.BDWareProjectDir This directory stores all contract projects for this node.
3.WebContent This directory stores the front-end code of this node.
4.Cp, which holds yjs.jar, the JAR needed to start the contract instance.
5.Bdserver. jar provides HTTP/webSocket server logic externally.
6.Updatecontract. sh Upgrade script.
### Route admission node
The installation script is automatically downloaded and decompressed to the bdCluster directory. Description of files in this directory:
1.Ncstart. sh This script is used to start the node access center. It listens on port 1718 by default. You can modify the listening port by modifying ncstart.sh.
2.WebContent This directory houses the front-end code for the access center.
3.Bdcluster. jar back-end of the access center.
- - -
## The upgrade process
### Contract node
On the command line, type:
```bash
sh updateContract.sh
```
Alternatively, go to [public.internetapi.cn](https://public.internetapi.cn/?dir=releases/bdcontract), download the latest file, and upgrade yjs.zip/bdserver-jar.zip/AgentWebContent separately.
### Route admission node
```bash
sh updateCluster.sh
```
Through the [public.internetapi.cn](https://public.internetapi.cn/?dir=releases/bdcontract), download the latest files, separate upgrade bdserver — cluster. Zip/ClusterWebContent. Zip to upgrade.
- - -
## Directions for use
### Use it on the reference page
If the WebContent directory is reserved, you can configure it using the browser. For more information, see the document [BDContract refer to the interface instructions](./IDEUsage.html) on the left.
#### BDWare OnlineIDE
Open [BDWare OnlineIDE](../OnlineIDE.html).
#### BDWare NodePortal
Open [BDWare NodePortal](../NodePortal.html).
If the cross-node function is required for networking, install the route access center. Perform the following steps to configure it. Two sets of public and private keys are involved. The first group of public and private keys is the public and private keys of the contract node that have NodeManager permission. The second group is the public and private keys of the route access node that have the CenterManager permission.
1.Open nodeportal. HTML and copy the public and private NodeManager keys of the node.
2.Open centerportal. HTML, click in the upper right corner, and import the public and private NodeManager keys. And select “NodeManager” for identity authentication.
3.In centerportal. HTML, switch the public and private keys of CenterManager, click User Management on the left, and pass the NodeManager authentication request.
4.Use the public and private keys of the NodeManager permission to open nodeportal. HTML, click the Node Management menu, and configure joining the network. The format of joining the network is WS :// IP address of Centerportal: port +1. ![配置示例](_static/imgs/config.png)
### Using the SDK
#### Basic knowledge of
[Websocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API)
[Sm2 encrypted using] (https://github.com/JuneAndGreen/sm-crypto)
#### Download the SDK
1. Java client download: [BDWareJavaClient](_static/BDWareJavaClient.zip). For details about how to use it, download it, decompress it, check readme.md, and see [ContractAPI](./ContractAPI.html).
2.Javascript version for client download :[BDWareWebClient](_static/BDWareWebClient.zip). For details about how to use it, download it, decompress it, check readme.md, and see [ContractAPI](./ContractAPI.html).
3.Configuration tool [BDWareConfigTool](_static/BDWareConfigTool.zip). For details, decompress the package and run the following command to view help information:
``` bash
java -jar java-client.jar -h
```

View File

@ -0,0 +1,411 @@
# Management interface
- - -
## Contract node management interface
The address of this interface is: [NodePortal.html](/NodePortal.html)
### User Management Menu
User management allows login users to view the current user distribution and user active statistics.
#### An overview of
![nodeUserManager](./_static/imgs/nodeUserManager.jpg) The node user management page has four modules: user information, active user statistics, authorized user management, and unauthorized user management.
#### User Type Distribution
Calculate the number of four roles held by the current node administrator: contract provider, contract administrator, and contract user ![userList](./_static/imgs/userList.jpg)
#### Active User Statistics
![userActive](./_static/imgs/userActive.jpg) statistics 30 days **The login**, **authorization**, **To apply for** the number of times
#### Current User Information
![nodeInfo](./_static/imgs/nodeInfo.jpg)
* In this text box, you can view the public and private keys of the current user. If other users want to use their public and private keys to log in to the node administrator interface, they can copy their public and private keys to this text box.
* After copying your public and private keys, click **Import the public key** to add the public key to the local node administrator
* The first five public keys are displayed in **Local public key**. If you select your own public key, the role of the selected public key will be displayed in **My permission**. If the node has not been authenticated by the central administrator, the default value is **Anonymous**.
* If you are not a node administrator and want to join the network of a central administrator, use your own public and private keys to import the key to the user management where the central administrator resides for authentication.
* If you want to perform more operations on contracts, you need to authenticate different roles: contract administrator, contract consumer, contract provider, and then **Role of certification**
#### List of authorized and unauthorized users
![roleAuth](./_static/imgs/roleAuth.jpg)
After the node administrator authenticates the role, the node administrator will see the application information with the public key in the **Role management is not authorized** form. If yes, click . If no, click . After authorization, you will see a list of authorized nodes in the **Authorized Role Management** table. If the node administrator wants to remove a role from a node, enter **delete** in the entitlement role management list.
### Contract code management menu
![codeManageMenu](./_static/imgs/codeManageMenu.png)
#### The contract documents
![codeManage1](./_static/imgs/codeManage1.png)
In the Contract Code Management menu, users can see public contracts as well as individual private contracts. ![codeManage1-1](./_static/imgs/codeManage1-1.png)
For public contracts, node administrators can delete and upload files, and download and delete contract items. ![codeManage1-2](./_static/imgs/codeManage1-2.png)
For private contracts, the contract provider can delete and upload files, and download, delete and upload contract items to the public contract directory.
The following is an example of working with a contract file.
#### Upload a file
![codeManage6](./_static/imgs/codeManage6.png)
#### delete
![codeManage5](./_static/imgs/codeManage5.png)
#### To the public
![codeManage7](./_static/imgs/codeManage7.png)
#### A drop-down box
![codeManage2](./_static/imgs/codeManage2.png)
From the four drop-down boxes, you can select the contract status saving mode, started contract instance, cluster where the node resides, and result verification mode.
#### Button action
![codeManage3](./_static/imgs/codeManage3.png)
#### Start the
After selecting the contract file in the file list, select “Single Node Execution” in the contract operation mode and click the Start button to launch the specified file and display the return result in the result display box.
#### The P2P cluster contract is started
After selecting the contract file in the file list, select the contract cluster on which the trusted contract runs in the Contract Run mode and click the Start button to start the specified file on all nodes of the cluster and display the return result in the result display box.
#### Start all
Select “Single Node Execution” in the contract operation mode and click the “Start All” button to start all contracts in the contract file list.
#### Stop the P2P cluster contract
Select a contract instance from the drop-down box for started contract instances, select the contract cluster for which the trusted contract runs in Contract Run mode, and click the Stop button to terminate the contract process on all nodes in the cluster.
#### stop
Selecting a contract instance from the drop-down box for started contract instances and clicking the Stop button will terminate the contract process.
#### Stop all
Clicking the Stop All button stops all contract instances running on that node.
#### Static analysis
Select the contract file in the Contract file list, select the contract instance in the Contract instance drop-down box, click the static analysis button, the contract will be static analysis, and the result will be displayed in the result display box.
#### Distribution of the contract
Select a contract item in the contract file list, select a cluster in Contract operation mode, and click the Distribute contract button. The contract item will be packaged as YPK and distributed to all nodes in the cluster.
#### Returns the result
![codeManage4](./_static/imgs/codeManage4.png)
The Return Result display displays the return results of some operations.
#### Contract Permission Configuration
After starting the contract, if the current users role can view the started contract process, the IO permissions for the current contract will be displayed in the bottom right when the process is selected. ![permissionShow](./_static/imgs/permissionShow.png)
If the selected contract does not have I/O permission, the following message is displayed in the current permission display box: **The current contract does not have IO permission**![nullPermission](./_static/imgs/nullPermission.png)
If the current user is a contract administrator, you can modify the existing contract I/O permissions. The system will prompt that the contract may not run normally after modification. If you still want to cancel, click <GT R="34"/>, otherwise click <GT R="35"/><GT R="33"/>.
After clicking Close or open, the next time the process views the same contract code, it will display the IO permission after the last modification by default. ![closePermission](./_static/imgs/closePermission.png)
### Contract instance management menu
![nodeInstancesPage](./_static/imgs/nodeInstancesPage.png)
The contract instance management menu displays all the current contract instances of this node. Users can view the status of the contract instance and execute or migrate the status of the contract instance.
#### List of Contract instances
![nodeInstancesList](./_static/imgs/nodeInstancesList.png)
This list shows all the contract instance information of the current node, including the contract ID, contract name, contract type, contract status, contract process port, contract call times, contract traffic, and contract memory usage, and the result verification mode of the cluster contract.
#### Contract instance execution
![chooseInstance](./_static/imgs/chooseInstance.png)
Users can select a contract instance in the contract instance selection drop-down box to operate on the contract instance.
![intanceExecute](./_static/imgs/intanceExecute.png)
After selecting the contract instance, the user can select the method name of the contract from the “Methods” drop-down box, enter the method parameters in the “Parameters” input box, and click “Execute ”.
Users can also click on “Dynamic Analysis Execution” to perform an execution with dynamic analysis results.
If the contract is a single point contract, the contract is executed at a single point; If the contract is a cluster contract, the contract is executed on all nodes in the cluster.
#### Contract instance execution result
![executeResult](./_static/imgs/executeResult.png)
The execution result of the contract instance is displayed in the Execution Result area, including the execution ID, execution success/failure, execution time, and execution result.
![analysisExecuteResult](./_static/imgs/analysisExecuteResult.png)
If the execution mode of the contract is Dynamic Analysis execution, in addition to the execution result, the dynamic analysis result of the execution is displayed in the result box.
#### Contract status migration
![memoryDump](./_static/imgs/memoryDump.png)
For the contract instances that support manual migration, users can click “Local State Save” to save the state of the contract instance, or select the saved contract instance from the TimeTravel list of the contract to migrate the contract state to the corresponding time.
### Log Management Menu
![logMenu](./_static/imgs/logMenu.png)
This menu displays the statistics of local node logs and contract logs of the node.
Node administrators can view node log data. The contract manager and contract user can view the local contract log data of the node.
#### Log Statistics View
![log1](./_static/imgs/log1.png)
#### Operating percentage of various platforms
By default, this chart shows the pie chart of the proportion of various platform operations in the last two days, in which platform operations are divided into six categories: login, user, log, contract, maintenance and others. You can enter the desired log time range in the upper right corner of the node log details. After the time range is changed, the operation percentage of each platform is updated.
#### Operating percentage of each type of contract
Contract operations are divided into four categories: start, end, static analysis and execution. The pie chart shows the proportion of each type of contract operation in the last 2 days. You can enter the desired log time range in the upper right corner of the contract log details. After the time range is modified, the operation percentage of each contract is updated.
#### Daily platform usage statistics
The figure is a broken line chart of the number of platform operations in the last 2 days. You can enter the desired log time range in the time range box in the upper right corner of node log details. After the time range is changed, the daily platform usage statistics line chart is updated.
#### Daily contract usage statistics
The figure is a broken line chart of the number of operations performed on the node in the last two days. You can enter the desired log time range in the time range box in the upper right corner of the contract log details. After modification, the daily contract usage statistics line chart will be updated.
#### Log details
#### Node Log Details
![log2](./_static/imgs/log2.png)
The node log details table displays all data in node logs. You can click the relevant button in the table to sort the log data in different ways, and enter keywords in the upper right corner of the table to search for relevant logs. You can enter the desired log time range in the time range box in the upper right corner. After the log time range is modified, the operation percentage of each platform and daily platform usage statistics are updated simultaneously.
#### Contract Log Details
![log3](./_static/imgs/log3.png)
The contract log details table is a display of all the data in the contract log. You can click the relevant button in the table to sort the log data in different ways, and enter keywords in the upper right corner of the table to search for relevant logs. You can enter the desired log time range in the time range box at the upper right corner. After the change, the operation percentage of each type of contract and the daily contract usage statistics are updated simultaneously.
### Node Management Menu
![nodeConfig](./_static/imgs/nodeConfig.png)
The node management menu displays the configuration information about the node and its trusted execution cluster.
#### Node configuration
![nodeConfigChange](./_static/imgs/nodeConfigChange.png)
The node administrator can view the configuration information of the node, including the node name, YJS path, and network center node of the node. The node administrator can also modify the configurations.
If the node administrator changes the network center of the node, the node tries to change the connection again, and the entire page is refreshed and reloaded.
#### Node trusted execution cluster list
![nodeUnits](./_static/imgs/nodeUnits.png)
A node administrator can view information about the trusted execution cluster to which a node belongs, including the cluster creator, cluster ID, number of nodes in the cluster, and information about nodes in the cluster.
- - -
#### Node License Configuration
![nodeLicence](./_static/imgs/nodeLicence.png)
You can view the nodes license and expiration time, apply for and upload a license, and save the node UUID.
## Smart Contract online editor
### Users and Accounts
#### Create account
#### Apply for authorization
### Create a project
#### The new file
#### Upload a file
### Start the contract
![contractMode](./_static/imgs/contractMode.png)
#### Normal mode Click the startup button on the left to start the contract in normal mode.
#### Debug mode Click the Debug button on the right to start the contract in debug mode. The current convention returns an example of the return result from the normal mode contract document when the debug mode contract is invoked via executeContract.
### Call the contract
### # Generate document ![genReadme](./_static/imgs/genReadme.png)
After starting the contract, click the “Generate document” button to call the contract and return the Result through @description / @param / @result of each export function, so as to generate the contract Description document.
- - -
## Route access management interface
### Permission application and authorization
### The dashboard
The dashboard provides an overview of the number of users, contracts, and nodes in the admittance node.
### The overall view
![dashboard](./_static/imgs/dashboard.jpg) It is divided into four modules. One module is the overview of the number of users, contracts and nodes, and then the detailed statistics of the three quantities.
### The number of nodes
![node](./_static/imgs/node.jpg) Collect statistics about the current online and offline nodes
### User Type Distribution
![userAll](./_static/imgs/userAll.jpg) Number of node administrators and admission administrators in the network where the current admitted node resides, and number of nodes to be applied for
### Contract invocation condition
![contract](./_static/imgs/contract.jpg) Broken line statistics of events, multi-point execution, WS call, and Http call in all contracts in the network where the current access node resides.
### User management
User management allows login users to view the current user distribution and user active statistics.
### An overview of
![centerManager](./_static/imgs/centerManager.jpg) The user management page consists of four modules.
### User Type Distribution
Main Statistics on the number of node administrators in the network managed by the center administrator, the number of center administrators, and the number of applied node administrators ![userList](./_static/imgs/userList.jpg)
### Statistics of applications made within 30 days
![userApplyGraph](./_static/imgs/userApplyGraph.jpg) Calculates the number of node administrators who apply for and are authorized to become node administrators within 30 days
### Current User Information
![authNodeManager](./_static/imgs/authNodeManager.jpg)
* In this text box, you can view the public and private keys of the current user. If other users want to use their public and private keys to log in to the center administrator interface, they can copy their public and private keys to this text box.
* After copying your public and private keys, click **Import the public key** to add the public key to the central administrator
* The first five public keys are displayed in **Local public key**. If you select your own public key, the role of the selected public key is displayed in **My permission**. If you are a central administrator, you have all the rights of the central administrator.
* If you are not a center administrator or node administrator and want to join the network of the current center administrator, you can select the node administrator in the following box and run **Role of certification**.
### List of authorized and unauthorized users
After applying for the current user information of the center administrator, the center administrator will see the application information with the public key in the form. If you agree, click . If you disagree, click , and the application is invalid.
![authMan](./_static/imgs/authMan.jpg)
After authorization, you will see a list of authorized nodes in the **Authorized User Management** table. If the central administrator wants to remove a role of a node administrator, select the role in the authorized user management list and click **delete** to delete the selected role.
![authMana](./_static/imgs/authMana.jpg)
### Node management
![centerNodePage](./_static/imgs/centerNodePage.png)
Node management is a page on which the Manager manages the Cluster nodes connected to it, visible only to Manager administrators and contract managers. Manager Administrators and contract managers can view node information and manage trusted execution clusters.
### An overview of
![centerNodePreview](./_static/imgs/centerNodePreview.png)
The overview displays the statistics of all nodes managed by the Manager node, including the total number of nodes, the total number of contracts, the total number of subscription events, and the number of trusted execution clusters. The pie chart on the right shows the number of nodes that are Online and Offline respectively.
### The node list
![centerNodeList](./_static/imgs/centerNodeList.png)
The node list shows the node information that the user has the permission to view. (The Manager administrator can view all nodes, and the contract Manager can view the Online node that he is responsible for managing.) This includes the node name, status, number of contracts, number of subscribed events, PeerID for P2P communication between nodes, UDPID for UDP communication between nodes, and the node public key.
### List of trusted execution clusters
![centerNodeUnits](./_static/imgs/centerNodeUnits.png)
The trusted execution cluster list displays the trusted execution cluster information that the user has the permission to view. (The Manager administrator can view all the clusters, and the contract Manager can view the clusters created by himself.) This includes the creator of the cluster, the cluster ID, the number of nodes in the cluster, and information about the nodes in the cluster.
You can click the “Delete” button of the column entry to delete the cluster.
### Create a trusted execution cluster
![centerNodeUnitCreate](./_static/imgs/centerNodeUnitCreate.png)
You can create a new trusted execution cluster by selecting multiple nodes. The nodes that users can select are those they have permission to view, that is, the Manager administrator can select from all nodes, and the contract Manager can select from the Online node that they are responsible for managing). Select and click Submit. A message indicating that the cluster is created successfully will be displayed in the list of trusted execution clusters. The cluster name is selected by the creator and cannot contain double quotation marks. The cluster name is visible when the contract manager selects the cluster.
### Log management
Log management displays the log information of admission nodes and consists of six modules.
### An overview of
![log](./_static/imgs/log.jpg)
### Classified Statistics of Management Operations (2 days)
![operator](./_static/imgs/operator.jpg) Pie chart of all management operations in the last two days. Management operations are classified into login, log, maintenance, and user operations.
### Daily Statistics of Management Operations (2 days)
![everyLog](./_static/imgs/everyLog.jpg) Daily operation statistics of all management operations within two days
### Statistics on Contract Operations by Category (2 Days)
![contractLog](./_static/imgs/contractLog.jpg) Two day contract operation classification statistical pie chart, contract operation is mainly divided into connection class and status update class.
### Daily Statistics of Contract Operation (2 days)
![contracteveryLog](./_static/imgs/contracteveryLog.jpg) Chart of the broken line of the number of contract operations in two days.
### Manage the operation log list
![opList](./_static/imgs/opList.jpg) Manage the detailed information list of operation logs. The information includes log time, management operation name, and node public key corresponding to the operation. The default value is two days. You can customize the days for obtaining logs.
### List of contract operation logs
![contractList](./_static/imgs/contractList.jpg) Detailed information list of contract operation logs. This parameter includes log generation time, contract operation name, and public key of the contract operation node. The default value is two days. You can customize the days for obtaining logs.
### Set up the
The Settings page displays the status of node certificates and configures node certificates
### An overview of
![set](./_static/imgs/set.jpg)
### Certificate status
![licence](./_static/imgs/licence.jpg) The certificate status includes the license expiration time and the number of licensed nodes.
### Certificate of configuration
![plicence](./_static/imgs/plicence.jpg) Configure the certificate module. You can download the node ID file or enter the certificate information for submission.

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,290 @@
# YJS grammar
- - -
## An overview of the
YJS source files include any number of **The import declaration** and one **The contract is defined**.
- - -
## The import declaration
Like JavaScript (ES6), YJS also supports import statements. At the global level, developers can use the following import statements to import other files.
```
import "filename";
```
### content
The import statement imports all global symbols (units) contained in the “filename” file into the current file and is globally valid.
### The path
**filename** Usually **/** is used as the directory separator to indicate the file path. For example, to import the **x.yjs** file from the same directory to the current file, you can use the **import “x.yjs”** statement. Import **x.yjs** from another directory using the **import “lib/x.yjs”** statement.
- - -
## The Contract is defined
### The sample
Here is an example contract for JSON processing, with the YJS source file named after the contract name.
```
contract ScoreAdder{
//arg = {"action":"main","arg":"[{\"score\":20},{\"score\":20}]"}
export function main(arg){
//JSON is a build-in object.
var point = JSON.parse(arg);
var s = 0;
print(point[0].score);
print(point.length);
for (var i=0;i<point.length;i++){
s+=point[i].score/1.0;
}
print("total score= "+s);
return s;
}
}
```
### annotation
YJS source files support single-line comments represented by (**//**) and multi-line comments represented by (**/\*...\*/**), as shown below:
```
// 这是一个单行注释
/*
* 这是一个
* 多行注释
*/
```
### annotations
Like Java, YJS also supports annotations to declare contracts and functions.
In YJS, there are several built-in annotations: LogType, LogLocation, Access, Permission. Of course, you can customize your annotations. The detailed usage of the built-in annotations can be viewed through the YJS built-in API documentation. Developers can use the following annotations to declare contracts and functions.
```
@LogType("Arg","Result","Branch")
@SelfDefinedAnntation("dad",1)
@Access
function xxx(){}
```
### structure
Contracts in YJS are similar to classes in Java. Each contract defines a certain number of **variable**, **function** and **The event**.
#### variable
Variables in YJS are similar to those in JavaScript (ES6), which are divided into **The global variable** and **A local variable**.
Global variables:
```
judge = true;
```
Local variables:
```
var vs = "This is a string";
```
All variables are **Dynamic type** because the specific type of variable is determined by the value of the variable. In the example above, the global variable judge is of type bool and the local variable VS is of type string.
#### function
A function is an executable unit in a contract. There are two types of functions in YJS: ordinary functions and exported functions decorated with the **export** keyword.
The following is the difference between exported functions and ordinary functions:
1. Only the exported function can be called by other contracts.
2. Exported functions can only have one parameter and the parameter type must be String.
3. Exported functions return type must be String.
4. The built-in object requester (the requesters public key) can only exist in the exported function or the onCreate function, because onCreate(), although not modified by the **export** keyword, comes with a Requester object and the function can be executed automatically.
#### The event
Events in YJS are similar to events in Solidity.
**The publisher** Define an event that contains the event publisher function, and then publish the event by calling the event publisher function.
**The subscriber** Subscribe and process events.
The following is an example of an event:
EventPuber.yjs
```
contract EventPuber{
event abcEvent;
export function pub(arg){
abcEvent(arg);
return "done!";
}
}
```
EventSuber.yjs
```
contract EventSuber{
export function init(arg){
YancloudUtil.subscribe("EventPuber","abcEvent",handler);
print("Handler:"+handler);
}
function handler(e){
var ret = "ReceiveEvent:"+(e.type)+" "+(e.content);
print(ret);
}
}
```
- - -
## YJS project
In addition to the YJS source file that contains only a contract definition, the YJS engine also supports **YJS project**.
Each YJS project contains various files used by the execution of a contract, including YJS source file files and other resources, such as **“mainfest.json”**, **“.js”**, **“.txt”**, **“.jar”**,...
### Manifest.json
Each YJS project must have a **mainfest.json** file in the root directory of the project, which describes the necessary information required by the contract for the YJS compilation tool (YJS engine).
#### Structure of the Manifest
The manifest file must contain the following information:
1. **main**: contract document to be executed in the project.
2. **type**: type of contract, such as data contract/algorithm contract...
3. **builder**: Name of the developer who built the YJS project.
4. **insnLimit**: indicates the value consumed to run the contract.
5. **pyDependences**: Python dependencies required by the project.
#### The Manifest sample
```
{
"main": "contract.js",
"type": "Data",
"builder": "caihq",
"permissions": 0L,
"pyDependences": [
{
"name": "yjsexample",
"modules": [
{
"name": "sample"
}
]
}
]
}
```
### YJS-Java
Jar file implements **Calling across languages** between YJS and other programming languages, such as yjs-Java, yjs-Python,... The contract can call methods directly in Java by wrapping Java files into JAR packages.
Java class:
```java
package your.own.pkg;
public class HelloWorld {
public static int fun(String arg){
return arg.length;
}
public int fun2(String arg){
return arg.length;
}
}
```
InvokeJava.yjs
```javascript
contract InvokeJava{
export function main(arg){
var Hello = Java.type("your.own.package.HelloWorld");
var hello = new Hello();
return Hello.fun(arg)+hello.fun2(arg);
}
}
```
### YJS — front end
Using the Surui client to access smart contracts supports fetching resource files such as HTML/JS/CSS from smart contracts and rendering them in [BDWareWebClient](./_static/BDWareWebClient.zip). Start by importing the following modules into the contract.
```javascript
module Viewable{
export function loadResource(arg){
return Global.Resources.loadAsString(arg);
}
export function needRender(arg){
return true;
}
}
```
Also, after the import, define a getMainFrame method so that the mainframe can be recognized by the mainframe client:
```javascript
export function getMainFrame(arg){
return "/html/main.html";
}
```
The result of this method is the path to a resource file. The example resource file ”/ HTML /main.html” is as follows:
```html
<div>
<button onclick="queryDataFromContract()">Hello,</button> Data from contract:
<span id="resultText"></span>
<script fromContract="/html/hello.js"></script>
<link fromContract="/html/hello.css"/>
</div>
```
The example resource file ”/ HTML /hello.js” is as follows:
```javascript
var queryDataFromContract = function(){
//第一个参数为函数名,第二个为参数,第三个参数为回调。
var data = executeCurrentContract("query","abc",function(argg){
$("#resultText")[0].innerHTML = argg.result;
});
}
```
Reference example:
### YJS-Python
TODO

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 414 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Some files were not shown because too many files have changed in this diff Show More