迁移到2.0生命周期,Hyperledger Fabric EVM

时间:2020-04-07 18:43:13

标签: hyperledger-fabric hyperledger ethereum

我很幸运,尝试从https://github.com/hyperledger/fabric-chaincode-evm编译Hyperledger Fabric打包的EVM链代码。

我们需要将其编译为分类帐的2.0.1版本,因为这是我们的网络所使用的,一切运行良好,我设法使用go.mod依赖文件中的fabric v2.0.0依赖项进行了编译,之后用

拉出了缺少的1.4.0依赖项(对等,填充)
go get github.com/hyperledger/fabric/protos/peer
go get github.com/hyperledger/fabric/core/chaincode/shim

还更改了integration / vendor / github.com / hyperledger / fabric / protos / common / configuration.proto 从1到2,就像这样:

message Capabilities {
    map<string, Capability> capabilities = 2;
}

但是,进行实例化时出现错误:

Error: could not assemble transaction, err proposal response was not successful, error code 500, msg Channel 'evm' has been migrated to the new lifecycle, LSCC is now read-only

我不确定在哪里可以更改该标志以在EVM链码中使用新的生命周期,我不是专家,所以我最好将其视为一个问题,并依赖更多的专家开发人员。

如何升级到新的生命周期?

我想我缺少批准网络内所有对等点的链码的命令参数,我正在尝试

peer lifecycle chaincode approveformyorg -o orderer.example.com:7050 --channelID evm --name evmcc --version ${EVM_VERSION} --init-required --package-id ${PACKAGE_ID} --sequence ${EVM_VERSION} --waitForEvent

但是我不知道如何从已安装的chaincode软件包中提取package-id。

先谢谢了。

1 个答案:

答案 0 :(得分:0)

通过使用invoke解决。

我们首先批准组织,而不是实例化,然后为网络中的每个对等方调用。像这样:


export PEER_CONN_PARMS="--peerAddresses $ORG1_PEER0_CORE_PEER_ADDRESS --peerAddresses $ORG1_PEER1_CORE_PEER_ADDRESS --peerAddresses $ORG2_PEER0_CORE_PEER_ADDRESS --peerAddresses $ORG2_PEER1_CORE_PEER_ADDRESS --tlsRootCertFiles $ORG1_PEER0_CORE_PEER_TLS_ROOTCERT_FILE --tlsRootCertFiles $ORG1_PEER1_CORE_PEER_TLS_ROOTCERT_FILE --tlsRootCertFiles $ORG2_PEER0_CORE_PEER_TLS_ROOTCERT_FILE --tlsRootCertFiles $ORG2_PEER1_CORE_PEER_TLS_ROOTCERT_FILE"

echo $PEER_CONN_PARMS

peer lifecycle chaincode package evmcc.tar.gz --path ${CC_SRC_PATH} --lang ${CC_RUNTIME_LANGUAGE} --label evmcc_${VERSION} >&log.txt
cat log.txt

setGlobals 1 0

peer lifecycle chaincode install evmcc.tar.gz --peerAddresses $ORG1_PEER0_CORE_PEER_ADDRESS  --tlsRootCertFiles $ORG1_PEER0_CORE_PEER_TLS_ROOTCERT_FILE >&log.txt
cat log.txt

setGlobals 1 1

peer lifecycle chaincode install evmcc.tar.gz --peerAddresses $ORG1_PEER1_CORE_PEER_ADDRESS --tlsRootCertFiles $ORG1_PEER1_CORE_PEER_TLS_ROOTCERT_FILE >&log.txt
cat log.txt

setGlobals 2 0

peer lifecycle chaincode install evmcc.tar.gz --peerAddresses $ORG2_PEER0_CORE_PEER_ADDRESS --tlsRootCertFiles $ORG2_PEER0_CORE_PEER_TLS_ROOTCERT_FILE >&log.txt
cat log.txt

setGlobals 2 1

peer lifecycle chaincode install evmcc.tar.gz --peerAddresses $ORG2_PEER1_CORE_PEER_ADDRESS --tlsRootCertFiles $ORG2_PEER1_CORE_PEER_TLS_ROOTCERT_FILE >&log.txt
cat log.txt

peer lifecycle chaincode queryinstalled >&log.txt
PACKAGE_ID=$(sed -n "/evmcc_${VERSION}/{s/^Package ID: //; s/, Label:.*$//; p;}" log.txt)

cat log.txt

echo $PACKAGE_ID

setGlobals 1 0

peer lifecycle chaincode approveformyorg -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name evmcc --version ${VERSION} --init-required --package-id ${PACKAGE_ID} --sequence ${SEQUENCE}  >&log.txt
cat log.txt 

setGlobals 2 0

peer lifecycle chaincode approveformyorg -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name evmcc --version ${VERSION} --init-required --package-id ${PACKAGE_ID} --sequence ${SEQUENCE}  >&log.txt
cat log.txt 


ORGAPPROVAL=$(peer lifecycle chaincode checkcommitreadiness -o orderer.example.com:7050 --channelID ${CHANNEL_NAME} --tls --cafile $ORDERER_CA --name evmcc --version ${VERSION} --init-required --sequence ${SEQUENCE} --output json | jq -r '.approvals') 


ORG1APPROVAL=$(echo $ORGAPPROVAL | jq -r --arg key "$ORG1_MSP" '.[$key]')
ORG2APPROVAL=$(echo $ORGAPPROVAL | jq -r --arg key "$ORG2_MSP" '.[$key]')

if [ "$ORG1APPROVAL" = true ] ; then
    if [ "$ORG2APPROVAL" = true ] ; then
        peer lifecycle chaincode commit -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA --channelID $CHANNEL_NAME --name evmcc $PEER_CONN_PARMS --version ${VERSION} --sequence ${SEQUENCE} --init-required >&log.txt
        cat log.txt

    fi

fi

setGlobals 1 0

#peer chaincode instantiate -o orderer.example.com:7050 --tls --cafile $ORDERER_CA -C ${CHANNEL_NAME} -n evmcc -v ${VERSION} -c '{"Args":["init"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')"

peer chaincode invoke -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n evmcc $PEER_CONN_PARMS --isInit -c '{"function":"Init","Args":[]}' >&log.txt
cat log.txt


setGlobals 1 1

peer chaincode invoke -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n evmcc $PEER_CONN_PARMS --isInit -c '{"function":"Init","Args":[]}' >&log.txt
cat log.txt

setGlobals 2 0

peer chaincode invoke -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n evmcc $PEER_CONN_PARMS --isInit -c '{"function":"Init","Args":[]}' >&log.txt
cat log.txt

setGlobals 2 1

peer chaincode invoke -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n evmcc $PEER_CONN_PARMS --isInit -c '{"function":"Init","Args":[]}' >&log.txt
cat log.txt