Skip to content

Commit 62ca76f

Browse files
author
Jason Yellick
committed
FAB-16124 Kill IsSyccNotInvokableExternal
This is yet another case of superfluous API bloat. It's entirely possible for a chaincode to check itself whether it's being invoked 'externally' or via 'cc2cc', so, there's no need for Fabric to provide this as part of the sccprovider. Change-Id: If08d4605c26fe0bf7ebeb8372579882cafd9f40c Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
1 parent 5ef447d commit 62ca76f

File tree

8 files changed

+0
-206
lines changed

8 files changed

+0
-206
lines changed

core/common/sysccprovider/sysccprovider.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ type SystemChaincodeProvider interface {
3030
// IsSysCC returns true if the supplied chaincode is a system chaincode
3131
IsSysCC(name string) bool
3232

33-
// IsSysCCAndNotInvokable returns true if the supplied chaincode
34-
// is a system chaincode and is not invokable through a proposal
35-
IsSysCCAndNotInvokableExternal(name string) bool
36-
3733
// GetQueryExecutorForLedger returns a query executor for the
3834
// ledger of the supplied channel.
3935
// That's useful for system chaincodes that require unfettered

core/endorser/endorser.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ type privateDataDistributor func(channel string, txID string, privateData *trans
4040
// Support contains functions that the endorser requires to execute its tasks
4141
type Support interface {
4242
identity.SignerSerializer
43-
// IsSysCCAndNotInvokableExternal returns true if the supplied chaincode is
44-
// ia system chaincode and it NOT invokable
45-
IsSysCCAndNotInvokableExternal(name string) bool
46-
4743
// GetTxSimulator returns the transaction simulator for the specified ledger
4844
// a client may obtain more than one such simulator; they are made unique
4945
// by way of the supplied txid
@@ -370,14 +366,6 @@ func (e *Endorser) preProcess(signedProp *pb.SignedProposal) (*validateResult, e
370366
return vr, err
371367
}
372368

373-
// block invocations to security-sensitive system chaincodes
374-
if e.s.IsSysCCAndNotInvokableExternal(hdrExt.ChaincodeId.Name) {
375-
endorserLogger.Errorf("Error: an attempt was made by %#v to invoke system chaincode %s", shdr.Creator, hdrExt.ChaincodeId.Name)
376-
err = errors.Errorf("chaincode %s cannot be invoked through a proposal", hdrExt.ChaincodeId.Name)
377-
vr.resp = &pb.ProposalResponse{Response: &pb.Response{Status: 500, Message: err.Error()}}
378-
return vr, err
379-
}
380-
381369
chainID := chdr.ChannelId
382370
txid := chdr.TxId
383371
endorserLogger.Debugf("[%s][%s] processing txid: %s", chainID, shorttxid(txid), txid)

core/endorser/endorser_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -158,22 +158,6 @@ func TestEndorserNilProp(t *testing.T) {
158158
assert.EqualValues(t, 1, fakeMetrics.proposalValidationFailed.AddArgsForCall(0))
159159
}
160160

161-
func TestEndorserUninvokableSysCC(t *testing.T) {
162-
es := endorser.NewEndorserServer(pvtEmptyDistributor, &mocks.MockSupport{
163-
GetApplicationConfigBoolRv: true,
164-
GetApplicationConfigRv: &mc.MockApplication{CapabilitiesRv: &mc.MockApplicationCapabilities{}},
165-
GetTransactionByIDErr: errors.New(""),
166-
IsSysCCAndNotInvokableExternalRv: true,
167-
}, packaging.NewRegistry(&golang.Platform{}), &disabled.Provider{})
168-
169-
signedProp := getSignedProp("test-chaincode", "test-version", t)
170-
171-
pResp, err := es.ProcessProposal(context.Background(), signedProp)
172-
assert.Error(t, err)
173-
assert.EqualValues(t, 500, pResp.Response.Status)
174-
assert.Equal(t, "chaincode test-chaincode cannot be invoked through a proposal", pResp.Response.Message)
175-
}
176-
177161
func TestEndorserCCInvocationFailed(t *testing.T) {
178162
es := endorser.NewEndorserServer(pvtEmptyDistributor, &mocks.MockSupport{
179163
GetApplicationConfigBoolRv: true,

core/endorser/mocks/support.go

Lines changed: 0 additions & 73 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/endorser/support.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ func (s *SupportImpl) SigningIdentityForRequest(*pb.SignedProposal) (SigningIden
5555
return s.SignerSerializer, nil
5656
}
5757

58-
// IsSysCCAndNotInvokableExternal returns true if the supplied chaincode is
59-
// ia system chaincode and it NOT invokable
60-
func (s *SupportImpl) IsSysCCAndNotInvokableExternal(name string) bool {
61-
return s.SysCCProvider.IsSysCCAndNotInvokableExternal(name)
62-
}
63-
6458
// GetTxSimulator returns the transaction simulator for the specified ledger
6559
// a client may obtain more than one such simulator; they are made unique
6660
// by way of the supplied txid

core/scc/lscc/mock/sysccprovider.go

Lines changed: 0 additions & 73 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/scc/scc_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,6 @@ func TestIsSysCC(t *testing.T) {
8888
assert.True(t, (newTestProvider()).IsSysCC("disabled"))
8989
}
9090

91-
func TestIsSysCCAndNotInvokableExternal(t *testing.T) {
92-
assert.False(t, (newTestProvider()).IsSysCCAndNotInvokableExternal("invokableExternalButNotCC2CC"))
93-
assert.True(t, (newTestProvider()).IsSysCCAndNotInvokableExternal("invokableCC2CCButNotExternal"))
94-
}
95-
9691
func TestSccProviderImpl_GetQueryExecutorForLedger(t *testing.T) {
9792
p := &scc.Provider{
9893
Peer: &peer.Peer{},

core/scc/sccproviderimpl.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,6 @@ func (p *Provider) GetQueryExecutorForLedger(cid string) (ledger.QueryExecutor,
5757
return l.NewQueryExecutor()
5858
}
5959

60-
// IsSysCCAndNotInvokableExternal returns true if the chaincode
61-
// is a system chaincode and *CANNOT* be invoked through
62-
// a proposal to this peer
63-
func (p *Provider) IsSysCCAndNotInvokableExternal(name string) bool {
64-
for _, sysCC := range p.SysCCs {
65-
if sysCC.Name() == name {
66-
return !sysCC.InvokableExternal()
67-
}
68-
}
69-
70-
if isDeprecatedSysCC(name) {
71-
return true
72-
}
73-
74-
return false
75-
}
76-
7760
// GetApplicationConfig returns the configtxapplication.SharedConfig for the channel
7861
// and whether the Application config exists
7962
func (p *Provider) GetApplicationConfig(cid string) (channelconfig.Application, bool) {

0 commit comments

Comments
 (0)