当前位置:网站首页>Construction and use of Changan chain go language smart contract environment
Construction and use of Changan chain go language smart contract environment
2022-06-29 09:37:00 【Handsome Wutong】
Prerequisite
- Prepare a long safety chain environment
- At present, only support in Linux Deployment and operation under the system chainmaker-vm-docker-go
- Software dependency
| name | edition | describe | Whether must |
|---|---|---|---|
| docker | 18+ | Run the container independently | yes |
| 7zip | 16+ | Compress 、 Unzip the contract file | yes |
Installation and deployment
7zip install
wget http://101.34.22.188/7-zip/p7zip-16.02-10.el7.x86_64.rpm -P /opt
rpm -ivh /opt/p7zip-16.02-10.el7.x86_64.rpmmatters needing attention :
- Each long safety chain node server needs to be installed .
- After successful installation , stay centos The command used in the system is 7za, stay ubuntu Under the system is 7z.
- When using centos Deploy go When it comes to smart contracts , You will encounter the following problems :
fail to extract contract: exec: "7z": executable file not found in $PATHreason : Chang'an chain is deploying go Language contract , The default is “7z” Command decompression go Language intelligence contract compression package , Therefore, in centos A soft connection handle is required under the system 7za Change it to 7z.
ln -s /usr/bin/7za /usr/bin/7zstay chainmaker Enable Docker VM
- Each Chang'an chain node needs to be configured and started docker vm.
- Modify the node configuration config In the catalog chainmaker.yml file :
# Docker go virtual machine configuration
vm:
# Enable docker go virtual machine
enable_dockervm: true
# Mount point in chainmaker
dockervm_mount_path: ../data/org1/docker-go
# Specify log file path
dockervm_log_path: ../log/org1/docker-go
# Whether to print log at terminal
log_in_console: false
# Log level
log_level: INFO
# Unix domain socket open, used for chainmaker and docker manager communication
uds_open: true
# Grpc max send message size, Default size is 4, Unit: MB
max_send_msg_size: 20
# Grpc max receive message size, Default size is 4, Unit: MB
max_recv_msg_size: 20
# max number of connection created to connect docker vm service
max_connection: 5- Modify the node configuration bin In the catalog start.sh file :
Mainly add -e ENV_MAX_SEND_MSG_SIZE=20 -e ENV_MAX_RECV_MSG_SIZE=20 To avoid subsequent deployment of contracts , Unsuccessful deployment occurs because the request message is too large .
docker run -itd \
-e ENV_LOG_IN_CONSOLE="$log_in_console" -e ENV_LOG_LEVEL="$log_level" -e ENV_ENABLE_UDS=true \
-e ENV_USER_NUM=1000 -e ENV_MAX_CONCURRENCY=100 -e ENV_TX_TIME_LIMIT=8 \
-e ENV_MAX_SEND_MSG_SIZE=20 -e ENV_MAX_RECV_MSG_SIZE=20 \
-v "$mount_path":/mount \
-v "$log_path":/log \
--name DOCKERVM-ljh-org3.qianjinlian.com \
--privileged $image_namestart-up docker vm:
stay UNIX Domain Socket In the connection mode of ( The government also offers a TCP The way , It can be used without special requirements socket Pattern ), Node configuration
binUnder the table of contentsstart.shThe script will automatically pull up Docker VM Containers , In the environment that has been started , After the above steps are configured , have access to restart.sh Restart the node to start docker vm.stop it docker vm:
stay UNIX Domain Socket In the connection mode of , When stopping a node , Node configuration
binIn the catalogstop.shThe script stops automatically Docker VM Containers . You can also use docker Command to stop individually Docker VM Containers .
Use CMC Tool deployment and invocation GO Intelligent contract
Create a contract
The following is officially provided contract_fact For example, the deposit contract :
./cmc client contract user create \
--contract-name=contract_fact \
--runtime-type=DOCKER_GO \
--byte-code-path=./testdata/docker-go-demo/contract_fact.7z \
--version=1.0 \
--sdk-conf-path=./testdata/sdk_config.yml \
--admin-key-file-paths=./testdata/crypto-config/wx-org1.chainmaker.org/user/admin1/admin1.tls.key,./testdata/crypto-config/wx-org2.chainmaker.org/user/admin1/admin1.tls.key,./testdata/crypto-config/wx-org3.chainmaker.org/user/admin1/admin1.tls.key,./testdata/crypto-config/wx-org4.chainmaker.org/user/admin1/admin1.tls.key \
--admin-crt-file-paths=./testdata/crypto-config/wx-org1.chainmaker.org/user/admin1/admin1.tls.crt,./testdata/crypto-config/wx-org2.chainmaker.org/user/admin1/admin1.tls.crt,./testdata/crypto-config/wx-org3.chainmaker.org/user/admin1/admin1.tls.crt,./testdata/crypto-config/wx-org4.chainmaker.org/user/admin1/admin1.tls.crt \
--sync-result=true \
--params="{}"There may be a problem here : Request message too large , This leads to unsuccessful deployment . The error message is as follows
trying to send message larger than max (6153962 vs. 4194304)You need to modify the connection configuration :testdata/sdk_config.yml Inside rpc_client:
rpc_client:
max_receive_message_size: 1000
max_send_message_size: 1000
hold max_send_message_size Turn up some . One more thing to mention here is JAVA SDK 2.2.0 Version not supported max_send_message_size To configure , Count as a BUG, So if you try to use JAVA SDK When deploying the contract , The above error can only be changed to pass for the time being CMC To deploy .
Call contract
./cmc client contract user invoke \
--contract-name=contract_fact \
--method=invoke_contract \
--sdk-conf-path=./testdata/sdk_config.yml \
--params="{\"method\":\"save\",\"file_name\":\"name007\",\"file_hash\":\"ab3456df5799b87c77e7f88\",\"time\":\"6543234\"}" \
--sync-result=trueCheck the contract
./cmc client contract user get \
--contract-name=contract_fact \
--method=invoke_contract \
--sdk-conf-path=./testdata/sdk_config.yml \
--params="{\"method\":\"findByFileHash\",\"file_hash\":\"ab3456df5799b87c77e7f88\"}"边栏推荐
- GD32F4xx 以太網芯片(enc28j60)驅動移植
- UE4 在4.20-23版本安裝Datasmith插件
- 第十二章 信号(二)- 生产者消费者示例
- Lffd: a lightweight fast face detector for edge detection
- 【NOI模拟赛】为NOI加点料(重链剖分,线段树)
- Yotact real-time instance segmentation
- Pytorch summary learning series - data manipulation
- Find the most repeated element in the string
- SSD改进CFENet
- SSD Improvement cfenet
猜你喜欢

Simplicity Studio无法识别新买的JLink v9解决方法

UE4 material UV texture does not stretch with model scale

UE4 编译单个文件(VS与编辑器分别启动)

KiCad学习笔记--快捷键

Difference between factory mode and strategy mode

Wechat applet wx Navigateback returns the parameters carried on the previous page

1.4 regression of machine learning methods

基于stm32标准库独立按键的多按键状态机的实现

Wechat applet custom multi selector

UE4 去掉材质中Mask透明白边
随机推荐
深入RC、RS、DaemonSet、StatefulSet(七)
After aikuai is installed or reset, the PC or mobile terminal cannot obtain IP
UE4 动画重定向
数据治理:元数据管理(第二篇)
Pytorch Summary - Automatic gradient
UE4 去掉材质中Mask透明白边
Detecting and counting tiny faces
LeetCode刷题——泰波那契数列
Mac mysql数据库基本操作
Visual assist plug-in settings for UE4 vs
Training view (issue temporary storage)
Record the field name dynamically modified by SetData of wechat applet
Difference between factory mode and strategy mode
Pytorch summary learning series - operation
Hb5470 combustion test of non-metallic materials in civil aircraft cabin
c语言printf大家族系列
[noi Simulation Competition] add points for noi (heavy chain dissection, line segment tree)
UE4 插件报错 Cannot open include file: ‘ModuleManager.h‘解决
【NOI模拟赛】为NOI加点料(重链剖分,线段树)
Jar package and war package