Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve chaincode lifecycle peer log messages #530

Merged
merged 1 commit into from
Jan 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions core/chaincode/lifecycle/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func (ef *ExternalFunctions) CheckCommitReadiness(chname, ccname string, cd *Cha
return nil, err
}

logger.Infof("Successfully checked commit readiness of chaincode definition %s, name '%s' on channel '%s'", cd, ccname, chname)
logger.Infof("Successfully checked commit readiness of chaincode name '%s' on channel '%s' with definition {%s}", ccname, chname, cd)

return approvals, nil
}
Expand All @@ -305,8 +305,6 @@ func (ef *ExternalFunctions) CommitChaincodeDefinition(chname, ccname string, cd
return nil, errors.WithMessage(err, "could not serialize chaincode definition")
}

logger.Infof("Successfully committed definition %s, name '%s' on channel '%s'", cd, ccname, chname)

return approvals, nil
}

Expand Down Expand Up @@ -447,7 +445,7 @@ func (ef *ExternalFunctions) ApproveChaincodeDefinitionForOrg(chname, ccname str
return errors.WithMessage(err, "could not serialize chaincode package info to state")
}

logger.Infof("Successfully approved definition %s, name '%s', package ID '%s', on channel '%s'", cd, ccname, packageID, chname)
logger.Infof("Successfully endorsed chaincode approval with name '%s', package ID '%s', on channel '%s' with definition {%s}", ccname, packageID, chname, cd)

return nil
}
Expand Down Expand Up @@ -479,7 +477,7 @@ func (ef *ExternalFunctions) QueryChaincodeDefinition(name string, publicState R
return nil, errors.WithMessagef(err, "could not deserialize namespace %s as chaincode", name)
}

logger.Infof("Successfully queried definition %s, name '%s'", definedChaincode, name)
logger.Infof("Successfully queried chaincode name '%s' with definition {%s},", name, definedChaincode)

return definedChaincode, nil
}
Expand Down
14 changes: 10 additions & 4 deletions core/chaincode/lifecycle/lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,28 @@ var _ = Describe("Resources", func() {
BeforeEach(func() {
fakePublicState = map[string][]byte{}
err := resources.Serializer.Serialize(lifecycle.NamespacesName, "cc-name", &lifecycle.ChaincodeDefinition{
Sequence: 5,
EndorsementInfo: &lb.ChaincodeEndorsementInfo{
Version: "version",
Version: "version",
EndorsementPlugin: "my endorsement plugin",
},
ValidationInfo: &lb.ChaincodeValidationInfo{
ValidationPlugin: "my validation plugin",
ValidationParameter: []byte("some awesome policy"),
},
ValidationInfo: &lb.ChaincodeValidationInfo{},
Collections: &pb.CollectionConfigPackage{},
Collections: &pb.CollectionConfigPackage{},
}, fakePublicState)
Expect(err).NotTo(HaveOccurred())
fakeReadableState = &mock.ReadWritableState{}
fakeReadableState.GetStateStub = fakePublicState.GetState
})

It("returns that the chaincode is defined and the definition", func() {
It("returns that the chaincode is defined and that the chaincode definition can be converted to a string suitable for log messages", func() {
exists, definition, err := resources.ChaincodeDefinitionIfDefined("cc-name", fakeReadableState)
Expect(err).NotTo(HaveOccurred())
Expect(exists).To(BeTrue())
Expect(definition.EndorsementInfo.Version).To(Equal("version"))
Expect(fmt.Sprintf("{%s}", definition)).To(Equal("{sequence: 5, endorsement info: (version: 'version', plugin: 'my endorsement plugin', init required: false), validation info: (plugin: 'my validation plugin', policy: '736f6d6520617765736f6d6520706f6c696379'), collections: ()}"))
})

Context("when the requested chaincode is _lifecycle", func() {
Expand Down
2 changes: 2 additions & 0 deletions core/chaincode/lifecycle/scc.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,8 @@ func (i *Invocation) CommitChaincodeDefinition(input *lb.CommitChaincodeDefiniti
return nil, errors.Errorf("chaincode definition not agreed to by this org (%s)", i.SCC.OrgMSPID)
}

logger.Infof("Successfully endorsed commit for chaincode name '%s' on channel '%s' with definition {%s}", input.Name, i.Stub.GetChannelID(), cd)

return &lb.CommitChaincodeDefinitionResult{}, nil
}

Expand Down