fedml-2.Docker多容器配置

Docker安装

1
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
  • 中间遇到输出,提示建议使用for windows
1
2
WSL DETECTED: We recommend using Docker Desktop for Windows.
Please get Docker Desktop from https://www.docker.com/products/docker-desktop

创建容器并配置环境

验证是否可以使用gpu

阅读更多

fabric-9.服务器配置

centos yum错误

1
错误:为 repo 'appstream' 下载元数据失败 : Cannot prepare internal mirrorlist: No URLs in mirrorlist
1
2
sudo sed -i -e "s|mirrorlist=|#mirrorlist=|g" /etc/yum.repos.d/CentOS-*
sudo sed -i -e "s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g" /etc/yum.repos.d/CentOS-*

查看显卡

1
lspci | grep -i vga
阅读更多

fabric-5.论文

需要实现

  1. 论文中的新的归一化算法
  2. 防止恶意模型更新
  3. 客户使用私钥签名模型
  4. fedml的节点作为mec服务器起训练作用,再对原始数据进行处理,模拟移动设备对数据添加噪声
  5. 智能合约中记录用户的有效交易,用于用户获取奖励
  6. 如何控制fabric的出块?
  7. 实现IPFS
  8. peer节点和fedml训练节点之间如何获取对方的公钥,如何避免中间人攻击

笔记

IPFS is a peer-to-peer distributed file system that enables distributed computing devices to connect with the same file system.

在IPFS上进行存储,区块链上存储Hash指针,用于找到文件(块大小限制)

在神经网络的中间层添加噪声(ε, δ)-differential,cnn全连接层作为噪声提取器

阅读更多

fabric-4.创建ca

官方教程

创建ca节点

第一次启动CA时,它查找fabric-ca-server-config.yaml文件,其中包含CA配置参数。

编写创建ca的docker-compose文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
version: '3.7'

networks:
fed_fab:
name: fabric_fedml

services:
ca_org1:
image: hyperledger/fabric-ca:latest
labels:
service: hyperledger-fabric
environment:
- FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
- FABRIC_CA_SERVER_CA_NAME=ca-org1
- FABRIC_CA_SERVER_TLS_ENABLED=true
- FABRIC_CA_SERVER_PORT=8050
- FABRIC_CA_SERVER_OPERATIONS_LISTENADDRESS=0.0.0.0:18050
ports:
- "8050:8050"
- "18050:18050"
command: sh -c 'fabric-ca-server start -b admin:adminpw -d'
volumes:
- ../crypto-config/fabric-ca/org1:/etc/hyperledger/fabric-ca-server
container_name: ca_org1
networks:
- fed_fab

ca_org2:
image: hyperledger/fabric-ca:latest
labels:
service: hyperledger-fabric
environment:
- FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
- FABRIC_CA_SERVER_CA_NAME=ca-org2
- FABRIC_CA_SERVER_TLS_ENABLED=true
- FABRIC_CA_SERVER_PORT=9050
- FABRIC_CA_SERVER_OPERATIONS_LISTENADDRESS=0.0.0.0:19050
ports:
- "9050:9050"
- "19050:19050"
command: sh -c 'fabric-ca-server start -b admin:adminpw -d'
volumes:
- ../crypto-config/fabric-ca/org2:/etc/hyperledger/fabric-ca-server
container_name: ca_org2
networks:
- fed_fab

ca_orderer:
image: hyperledger/fabric-ca:latest
labels:
service: hyperledger-fabric
environment:
- FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
- FABRIC_CA_SERVER_CA_NAME=ca-orderer
- FABRIC_CA_SERVER_TLS_ENABLED=true
- FABRIC_CA_SERVER_PORT=7051
- FABRIC_CA_SERVER_OPERATIONS_LISTENADDRESS=0.0.0.0:17051
ports:
- "7051:7051"
- "17051:17051"
command: sh -c 'fabric-ca-server start -b admin:adminpw -d'
volumes:
- ../crypto-config/fabric-ca/ordererOrg:/etc/hyperledger/fabric-ca-server
container_name: ca_orderer
networks:
- fed_fab

ca_tls:
image: hyperledger/fabric-ca:latest
labels:
service: hyperledger-fabric
environment:
- FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
- FABRIC_CA_SERVER_CA_NAME=ca-orderer
- FABRIC_CA_SERVER_TLS_ENABLED=true
- FABRIC_CA_SERVER_PORT=7054
- FABRIC_CA_SERVER_OPERATIONS_LISTENADDRESS=0.0.0.0:17054
ports:
- "7054:7054"
- "17054:17054"
command: sh -c 'fabric-ca-server start -b admin:adminpw -d'
volumes:
- ../crypto-config/fabric-ca/tls-ca:/etc/hyperledger/fabric-ca-server
container_name: ca_tls
networks:
- fed_fab
阅读更多

fabric-3.链码运行与Api调用

链码的打包

  • 之前已经完成了链码mod的初始化和编译,直接进行打包
1
2
3
4
peer lifecycle chaincode package fedfab.tar.gz \
--path ../../fabric-cluster/chaincode/go/fedfab \
--label fedfab_1 \
--lang golang

在当前目录生成了fedfab.tar.gz文件

将打包好的文件复制到其他cli中

阅读更多

fabric-2.fabric自定义与实践

计划配置一个4个节点的网络,三个节点模拟IOT设备,一个代表公司节点

主要工作

  1. 创建了一个拥有两个org的通道
  2. 自定义了一个网络,org1拥有三个节点,org2拥有1个节点
  3. 用go语言自定义了chaincode并编译
  4. 在网络上安装通道,执行链码

fabric环境变量

  • 为了使用cryptogen等工具
阅读更多