diff --git a/common/configtx/manager.go b/common/configtx/manager.go index 8ad58a9265a..fcfc8ffaa54 100644 --- a/common/configtx/manager.go +++ b/common/configtx/manager.go @@ -98,8 +98,21 @@ func computeChainIDAndSequence(configtx *cb.ConfigurationEnvelope) (string, uint return "", 0, errors.New("Empty envelope unsupported") } - m := uint64(0) //configtx.Items[0].LastModified - var chainID string //:= configtx.Items[0].Header.ChainID + m := uint64(0) + + if configtx.Header == nil { + return "", 0, fmt.Errorf("Header not set") + } + + if configtx.Header.ChainID == "" { + return "", 0, fmt.Errorf("Header chainID was not set") + } + + chainID := configtx.Header.ChainID + + if err := validateChainID(chainID); err != nil { + return "", 0, err + } for _, signedItem := range configtx.Items { item := &cb.ConfigurationItem{} @@ -110,26 +123,6 @@ func computeChainIDAndSequence(configtx *cb.ConfigurationEnvelope) (string, uint if item.LastModified > m { m = item.LastModified } - - if item.Header == nil { - return "", 0, fmt.Errorf("Header not set: %v", item) - } - - if item.Header.ChainID == "" { - return "", 0, fmt.Errorf("Header chainID was not set: %v", item) - } - - if chainID == "" { - chainID = item.Header.ChainID - } else { - if chainID != item.Header.ChainID { - return "", 0, fmt.Errorf("Mismatched chainIDs in envelope %s != %s", chainID, item.Header.ChainID) - } - } - - if err := validateChainID(chainID); err != nil { - return "", 0, err - } } return chainID, m, nil diff --git a/common/configtx/manager_test.go b/common/configtx/manager_test.go index 6e694631870..0fff10ca4f9 100644 --- a/common/configtx/manager_test.go +++ b/common/configtx/manager_test.go @@ -68,9 +68,8 @@ func (mpm *mockPolicyManager) GetPolicy(id string) (policies.Policy, bool) { return mpm.policy, (mpm.policy != nil) } -func makeConfigurationItem(id, modificationPolicy string, lastModified uint64, data []byte, chainID string) *cb.ConfigurationItem { +func makeConfigurationItem(id, modificationPolicy string, lastModified uint64, data []byte) *cb.ConfigurationItem { return &cb.ConfigurationItem{ - Header: &cb.ChainHeader{ChainID: chainID}, ModificationPolicy: modificationPolicy, LastModified: lastModified, Key: id, @@ -78,8 +77,8 @@ func makeConfigurationItem(id, modificationPolicy string, lastModified uint64, d } } -func makeSignedConfigurationItem(id, modificationPolicy string, lastModified uint64, data []byte, chainID string) *cb.SignedConfigurationItem { - config := makeConfigurationItem(id, modificationPolicy, lastModified, data, chainID) +func makeSignedConfigurationItem(id, modificationPolicy string, lastModified uint64, data []byte) *cb.SignedConfigurationItem { + config := makeConfigurationItem(id, modificationPolicy, lastModified, data) marshaledConfig, err := proto.Marshal(config) if err != nil { panic(err) @@ -92,7 +91,8 @@ func makeSignedConfigurationItem(id, modificationPolicy string, lastModified uin // TestOmittedHandler tests that startup fails if not all configuration types have an associated handler func TestOmittedHandler(t *testing.T) { _, err := NewManagerImpl(&cb.ConfigurationEnvelope{ - Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"), defaultChain)}, + Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"))}, + Header: &cb.ChainHeader{ChainID: defaultChain}, }, &mockconfigtx.Initializer{PolicyManagerVal: &mockPolicyManager{&mockPolicy{}}, HandlersVal: map[cb.ConfigurationItem_ConfigurationType]Handler{}}, nil) if err == nil { @@ -107,7 +107,8 @@ func TestCallback(t *testing.T) { } cm, err := NewManagerImpl(&cb.ConfigurationEnvelope{ - Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"), defaultChain)}, + Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"))}, + Header: &cb.ChainHeader{ChainID: defaultChain}, }, &mockconfigtx.Initializer{PolicyManagerVal: &mockPolicyManager{&mockPolicy{}}, HandlersVal: defaultHandlers()}, []func(Manager){callback}) if err != nil { @@ -122,7 +123,8 @@ func TestCallback(t *testing.T) { // TestDifferentChainID tests that a configuration update for a different chain ID fails func TestDifferentChainID(t *testing.T) { cm, err := NewManagerImpl(&cb.ConfigurationEnvelope{ - Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"), defaultChain)}, + Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"))}, + Header: &cb.ChainHeader{ChainID: defaultChain}, }, &mockconfigtx.Initializer{PolicyManagerVal: &mockPolicyManager{&mockPolicy{}}, HandlersVal: defaultHandlers()}, nil) if err != nil { @@ -130,7 +132,8 @@ func TestDifferentChainID(t *testing.T) { } newConfig := &cb.ConfigurationEnvelope{ - Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 1, []byte("foo"), "wrongChain")}, + Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 1, []byte("foo"))}, + Header: &cb.ChainHeader{ChainID: "wrongChain"}, } err = cm.Validate(newConfig) @@ -147,7 +150,8 @@ func TestDifferentChainID(t *testing.T) { // TestOldConfigReplay tests that resubmitting a config for a sequence number which is not newer is ignored func TestOldConfigReplay(t *testing.T) { cm, err := NewManagerImpl(&cb.ConfigurationEnvelope{ - Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"), defaultChain)}, + Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"))}, + Header: &cb.ChainHeader{ChainID: defaultChain}, }, &mockconfigtx.Initializer{PolicyManagerVal: &mockPolicyManager{&mockPolicy{}}, HandlersVal: defaultHandlers()}, nil) if err != nil { @@ -155,7 +159,7 @@ func TestOldConfigReplay(t *testing.T) { } newConfig := &cb.ConfigurationEnvelope{ - Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"), defaultChain)}, + Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"))}, } err = cm.Validate(newConfig) @@ -171,10 +175,11 @@ func TestOldConfigReplay(t *testing.T) { // TestInvalidInitialConfigByStructure tests to make sure that if the config contains corrupted configuration that construction results in error func TestInvalidInitialConfigByStructure(t *testing.T) { - entries := []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"), defaultChain)} + entries := []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"))} entries[0].ConfigurationItem = []byte("Corrupted") _, err := NewManagerImpl(&cb.ConfigurationEnvelope{ - Items: entries, + Items: entries, + Header: &cb.ChainHeader{ChainID: defaultChain}, }, &mockconfigtx.Initializer{PolicyManagerVal: &mockPolicyManager{&mockPolicy{}}, HandlersVal: defaultHandlers()}, nil) if err == nil { @@ -185,7 +190,8 @@ func TestInvalidInitialConfigByStructure(t *testing.T) { // TestValidConfigChange tests the happy path of updating a configuration value with no defaultModificationPolicy func TestValidConfigChange(t *testing.T) { cm, err := NewManagerImpl(&cb.ConfigurationEnvelope{ - Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"), defaultChain)}, + Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"))}, + Header: &cb.ChainHeader{ChainID: defaultChain}, }, &mockconfigtx.Initializer{PolicyManagerVal: &mockPolicyManager{&mockPolicy{}}, HandlersVal: defaultHandlers()}, nil) if err != nil { @@ -193,7 +199,8 @@ func TestValidConfigChange(t *testing.T) { } newConfig := &cb.ConfigurationEnvelope{ - Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 1, []byte("foo"), defaultChain)}, + Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 1, []byte("foo"))}, + Header: &cb.ChainHeader{ChainID: defaultChain}, } err = cm.Validate(newConfig) @@ -211,7 +218,8 @@ func TestValidConfigChange(t *testing.T) { // config values while advancing another func TestConfigChangeRegressedSequence(t *testing.T) { cm, err := NewManagerImpl(&cb.ConfigurationEnvelope{ - Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 1, []byte("foo"), defaultChain)}, + Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 1, []byte("foo"))}, + Header: &cb.ChainHeader{ChainID: defaultChain}, }, &mockconfigtx.Initializer{PolicyManagerVal: &mockPolicyManager{&mockPolicy{}}, HandlersVal: defaultHandlers()}, nil) if err != nil { @@ -220,9 +228,10 @@ func TestConfigChangeRegressedSequence(t *testing.T) { newConfig := &cb.ConfigurationEnvelope{ Items: []*cb.SignedConfigurationItem{ - makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"), defaultChain), - makeSignedConfigurationItem("bar", "bar", 2, []byte("bar"), defaultChain), + makeSignedConfigurationItem("foo", "foo", 0, []byte("foo")), + makeSignedConfigurationItem("bar", "bar", 2, []byte("bar")), }, + Header: &cb.ChainHeader{ChainID: defaultChain}, } err = cm.Validate(newConfig) @@ -240,7 +249,8 @@ func TestConfigChangeRegressedSequence(t *testing.T) { // config values while advancing another func TestConfigChangeOldSequence(t *testing.T) { cm, err := NewManagerImpl(&cb.ConfigurationEnvelope{ - Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 1, []byte("foo"), defaultChain)}, + Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 1, []byte("foo"))}, + Header: &cb.ChainHeader{ChainID: defaultChain}, }, &mockconfigtx.Initializer{PolicyManagerVal: &mockPolicyManager{&mockPolicy{}}, HandlersVal: defaultHandlers()}, nil) if err != nil { @@ -249,9 +259,10 @@ func TestConfigChangeOldSequence(t *testing.T) { newConfig := &cb.ConfigurationEnvelope{ Items: []*cb.SignedConfigurationItem{ - makeSignedConfigurationItem("foo", "foo", 2, []byte("foo"), defaultChain), - makeSignedConfigurationItem("bar", "bar", 1, []byte("bar"), defaultChain), + makeSignedConfigurationItem("foo", "foo", 2, []byte("foo")), + makeSignedConfigurationItem("bar", "bar", 1, []byte("bar")), }, + Header: &cb.ChainHeader{ChainID: defaultChain}, } err = cm.Validate(newConfig) @@ -270,9 +281,10 @@ func TestConfigChangeOldSequence(t *testing.T) { func TestConfigImplicitDelete(t *testing.T) { cm, err := NewManagerImpl(&cb.ConfigurationEnvelope{ Items: []*cb.SignedConfigurationItem{ - makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"), defaultChain), - makeSignedConfigurationItem("bar", "bar", 0, []byte("bar"), defaultChain), + makeSignedConfigurationItem("foo", "foo", 0, []byte("foo")), + makeSignedConfigurationItem("bar", "bar", 0, []byte("bar")), }, + Header: &cb.ChainHeader{ChainID: defaultChain}, }, &mockconfigtx.Initializer{PolicyManagerVal: &mockPolicyManager{&mockPolicy{}}, HandlersVal: defaultHandlers()}, nil) if err != nil { @@ -281,8 +293,9 @@ func TestConfigImplicitDelete(t *testing.T) { newConfig := &cb.ConfigurationEnvelope{ Items: []*cb.SignedConfigurationItem{ - makeSignedConfigurationItem("bar", "bar", 1, []byte("bar"), defaultChain), + makeSignedConfigurationItem("bar", "bar", 1, []byte("bar")), }, + Header: &cb.ChainHeader{ChainID: defaultChain}, } err = cm.Validate(newConfig) @@ -299,7 +312,8 @@ func TestConfigImplicitDelete(t *testing.T) { // TestEmptyConfigUpdate tests to make sure that an empty config is rejected as an update func TestEmptyConfigUpdate(t *testing.T) { cm, err := NewManagerImpl(&cb.ConfigurationEnvelope{ - Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"), defaultChain)}, + Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"))}, + Header: &cb.ChainHeader{ChainID: defaultChain}, }, &mockconfigtx.Initializer{PolicyManagerVal: &mockPolicyManager{&mockPolicy{}}, HandlersVal: defaultHandlers()}, nil) if err != nil { @@ -325,9 +339,10 @@ func TestEmptyConfigUpdate(t *testing.T) { func TestSilentConfigModification(t *testing.T) { cm, err := NewManagerImpl(&cb.ConfigurationEnvelope{ Items: []*cb.SignedConfigurationItem{ - makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"), defaultChain), - makeSignedConfigurationItem("bar", "bar", 0, []byte("bar"), defaultChain), + makeSignedConfigurationItem("foo", "foo", 0, []byte("foo")), + makeSignedConfigurationItem("bar", "bar", 0, []byte("bar")), }, + Header: &cb.ChainHeader{ChainID: defaultChain}, }, &mockconfigtx.Initializer{PolicyManagerVal: &mockPolicyManager{&mockPolicy{}}, HandlersVal: defaultHandlers()}, nil) if err != nil { @@ -336,9 +351,10 @@ func TestSilentConfigModification(t *testing.T) { newConfig := &cb.ConfigurationEnvelope{ Items: []*cb.SignedConfigurationItem{ - makeSignedConfigurationItem("foo", "foo", 0, []byte("different"), defaultChain), - makeSignedConfigurationItem("bar", "bar", 1, []byte("bar"), defaultChain), + makeSignedConfigurationItem("foo", "foo", 0, []byte("different")), + makeSignedConfigurationItem("bar", "bar", 1, []byte("bar")), }, + Header: &cb.ChainHeader{ChainID: defaultChain}, } err = cm.Validate(newConfig) @@ -356,7 +372,8 @@ func TestSilentConfigModification(t *testing.T) { // even construction fails func TestInvalidInitialConfigByPolicy(t *testing.T) { _, err := NewManagerImpl(&cb.ConfigurationEnvelope{ - Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"), defaultChain)}, + Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"))}, + Header: &cb.ChainHeader{ChainID: defaultChain}, }, &mockconfigtx.Initializer{PolicyManagerVal: &mockPolicyManager{&mockPolicy{policyResult: fmt.Errorf("err")}}, HandlersVal: defaultHandlers()}, nil) if err == nil { @@ -369,7 +386,8 @@ func TestInvalidInitialConfigByPolicy(t *testing.T) { func TestConfigChangeViolatesPolicy(t *testing.T) { mpm := &mockPolicyManager{} cm, err := NewManagerImpl(&cb.ConfigurationEnvelope{ - Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"), defaultChain)}, + Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"))}, + Header: &cb.ChainHeader{ChainID: defaultChain}, }, &mockconfigtx.Initializer{PolicyManagerVal: mpm, HandlersVal: defaultHandlers()}, nil) if err != nil { @@ -379,7 +397,8 @@ func TestConfigChangeViolatesPolicy(t *testing.T) { mpm.policy = &mockPolicy{policyResult: fmt.Errorf("err")} newConfig := &cb.ConfigurationEnvelope{ - Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 1, []byte("foo"), defaultChain)}, + Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 1, []byte("foo"))}, + Header: &cb.ChainHeader{ChainID: defaultChain}, } err = cm.Validate(newConfig) @@ -398,7 +417,8 @@ func TestConfigChangeViolatesPolicy(t *testing.T) { func TestUnchangedConfigViolatesPolicy(t *testing.T) { mpm := &mockPolicyManager{} cm, err := NewManagerImpl(&cb.ConfigurationEnvelope{ - Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"), defaultChain)}, + Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"))}, + Header: &cb.ChainHeader{ChainID: defaultChain}, }, &mockconfigtx.Initializer{PolicyManagerVal: mpm, HandlersVal: defaultHandlers()}, nil) if err != nil { @@ -412,9 +432,10 @@ func TestUnchangedConfigViolatesPolicy(t *testing.T) { newConfig := &cb.ConfigurationEnvelope{ Items: []*cb.SignedConfigurationItem{ - makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"), defaultChain), - makeSignedConfigurationItem("bar", "bar", 1, []byte("foo"), defaultChain), + makeSignedConfigurationItem("foo", "foo", 0, []byte("foo")), + makeSignedConfigurationItem("bar", "bar", 1, []byte("foo")), }, + Header: &cb.ChainHeader{ChainID: defaultChain}, } err = cm.Validate(newConfig) @@ -443,7 +464,8 @@ func TestInvalidProposal(t *testing.T) { handlers := defaultHandlers() initializer := &mockconfigtx.Initializer{PolicyManagerVal: &mockPolicyManager{&mockPolicy{}}, HandlersVal: handlers} cm, err := NewManagerImpl(&cb.ConfigurationEnvelope{ - Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"), defaultChain)}, + Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"))}, + Header: &cb.ChainHeader{ChainID: defaultChain}, }, initializer, nil) if err != nil { @@ -453,7 +475,7 @@ func TestInvalidProposal(t *testing.T) { initializer.Handlers()[cb.ConfigurationItem_ConfigurationType(0)] = failHandler{} newConfig := &cb.ConfigurationEnvelope{ - Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 1, []byte("foo"), defaultChain)}, + Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 1, []byte("foo"))}, } err = cm.Validate(newConfig) @@ -470,8 +492,7 @@ func TestInvalidProposal(t *testing.T) { // TestMissingHeader checks that a configuration item with a missing header causes the config to be rejected func TestMissingHeader(t *testing.T) { handlers := defaultHandlers() - configItem := makeConfigurationItem("foo", "foo", 0, []byte("foo"), defaultChain) - configItem.Header = nil + configItem := makeConfigurationItem("foo", "foo", 0, []byte("foo")) data, _ := proto.Marshal(configItem) _, err := NewManagerImpl(&cb.ConfigurationEnvelope{ Items: []*cb.SignedConfigurationItem{&cb.SignedConfigurationItem{ConfigurationItem: data}}, @@ -486,22 +507,8 @@ func TestMissingHeader(t *testing.T) { func TestMissingChainID(t *testing.T) { handlers := defaultHandlers() _, err := NewManagerImpl(&cb.ConfigurationEnvelope{ - Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"), "")}, - }, &mockconfigtx.Initializer{PolicyManagerVal: &mockPolicyManager{&mockPolicy{}}, HandlersVal: handlers}, nil) - - if err == nil { - t.Error("Should have errored creating the configuration manager because of the missing header") - } -} - -// TestMismatchedChainID checks that a configuration envelope with items with mixed chainIDs causes the config to be rejected -func TestMismatchedChainID(t *testing.T) { - handlers := defaultHandlers() - _, err := NewManagerImpl(&cb.ConfigurationEnvelope{ - Items: []*cb.SignedConfigurationItem{ - makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"), "chain1"), - makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"), "chain2"), - }, + Items: []*cb.SignedConfigurationItem{makeSignedConfigurationItem("foo", "foo", 0, []byte("foo"))}, + Header: &cb.ChainHeader{}, }, &mockconfigtx.Initializer{PolicyManagerVal: &mockPolicyManager{&mockPolicy{}}, HandlersVal: handlers}, nil) if err == nil { diff --git a/common/configtx/template.go b/common/configtx/template.go index 04ea33fe94d..78e0f563fe3 100644 --- a/common/configtx/template.go +++ b/common/configtx/template.go @@ -53,7 +53,6 @@ func NewSimpleTemplate(items ...*cb.ConfigurationItem) Template { func (st *simpleTemplate) Items(chainID string) ([]*cb.SignedConfigurationItem, error) { signedItems := make([]*cb.SignedConfigurationItem, len(st.items)) for i := range st.items { - st.items[i].Header = &cb.ChainHeader{ChainID: chainID, Type: int32(cb.HeaderType_CONFIGURATION_ITEM)} mItem, err := proto.Marshal(st.items[i]) if err != nil { return nil, err @@ -113,9 +112,8 @@ func (nct *newChainTemplate) Items(chainID string) ([]*cb.SignedConfigurationIte creationPolicy := &cb.SignedConfigurationItem{ ConfigurationItem: utils.MarshalOrPanic(&cb.ConfigurationItem{ - Header: utils.MakeChainHeader(cb.HeaderType_CONFIGURATION_ITEM, msgVersion, chainID, epoch), - Type: cb.ConfigurationItem_Orderer, - Key: CreationPolicyKey, + Type: cb.ConfigurationItem_Orderer, + Key: CreationPolicyKey, Value: utils.MarshalOrPanic(&ab.CreationPolicy{ Policy: nct.creationPolicy, Digest: HashItems(items, nct.hash), @@ -162,7 +160,7 @@ func MakeChainCreationTransaction(creationPolicy string, chainID string, signer return nil, err } - manager, err := NewManagerImpl(&cb.ConfigurationEnvelope{Items: items}, NewInitializer(), nil) + manager, err := NewManagerImpl(&cb.ConfigurationEnvelope{Header: &cb.ChainHeader{ChainID: chainID, Type: int32(cb.HeaderType_CONFIGURATION_ITEM)}, Items: items}, NewInitializer(), nil) if err != nil { return nil, err } @@ -181,7 +179,10 @@ func MakeChainCreationTransaction(creationPolicy string, chainID string, signer payloadChainHeader := utils.MakeChainHeader(cb.HeaderType_CONFIGURATION_TRANSACTION, msgVersion, chainID, epoch) payloadSignatureHeader := utils.MakeSignatureHeader(sSigner, utils.CreateNonceOrPanic()) payloadHeader := utils.MakePayloadHeader(payloadChainHeader, payloadSignatureHeader) - payload := &cb.Payload{Header: payloadHeader, Data: utils.MarshalOrPanic(utils.MakeConfigurationEnvelope(signedConfigItems...))} + payload := &cb.Payload{Header: payloadHeader, Data: utils.MarshalOrPanic(&cb.ConfigurationEnvelope{ + Items: signedConfigItems, + Header: &cb.ChainHeader{ChainID: chainID, Type: int32(cb.HeaderType_CONFIGURATION_ITEM)}, + })} paylBytes := utils.MarshalOrPanic(payload) // sign the payload diff --git a/common/configtx/template_test.go b/common/configtx/template_test.go index 3c92e02dc7d..840f4b45ccc 100644 --- a/common/configtx/template_test.go +++ b/common/configtx/template_test.go @@ -40,21 +40,15 @@ func verifyItemsResult(t *testing.T, template Template, count int) { for i, signedItem := range result { item := utils.UnmarshalConfigurationItemOrPanic(signedItem.ConfigurationItem) - assert.Equal(t, newChainID, item.Header.ChainID, "Should have appropriately set new chainID") expected := fmt.Sprintf("%d", i) assert.Equal(t, expected, string(item.Value), "Expected %s but got %s", expected, item.Value) - assert.Equal(t, int32(cb.HeaderType_CONFIGURATION_ITEM), item.Header.Type) } } func TestSimpleTemplate(t *testing.T) { - hdr := &cb.ChainHeader{ - ChainID: "foo", - Type: int32(cb.HeaderType_CONFIGURATION_ITEM), - } simple := NewSimpleTemplate( - &cb.ConfigurationItem{Value: []byte("0"), Header: hdr}, - &cb.ConfigurationItem{Value: []byte("1"), Header: hdr}, + &cb.ConfigurationItem{Value: []byte("0")}, + &cb.ConfigurationItem{Value: []byte("1")}, ) verifyItemsResult(t, simple, 2) } @@ -94,9 +88,6 @@ func TestNewChainTemplate(t *testing.T) { for i, signedItem := range items { item := utils.UnmarshalConfigurationItemOrPanic(signedItem.ConfigurationItem) - if item.Header.ChainID != newChainID { - t.Errorf("Should have appropriately set new chainID") - } if i == 0 { if item.Key != CreationPolicyKey { t.Errorf("First item should have been the creation policy") diff --git a/common/configtx/test/orderer.template b/common/configtx/test/orderer.template index fc4aa2e0306..eb89bd5e0fa 100644 Binary files a/common/configtx/test/orderer.template and b/common/configtx/test/orderer.template differ diff --git a/common/genesis/genesis.go b/common/genesis/genesis.go index ad6277b3218..00170365942 100644 --- a/common/genesis/genesis.go +++ b/common/genesis/genesis.go @@ -51,7 +51,7 @@ func (f *factory) Block(chainID string) (*cb.Block, error) { payloadChainHeader := utils.MakeChainHeader(cb.HeaderType_CONFIGURATION_TRANSACTION, msgVersion, chainID, epoch) payloadSignatureHeader := utils.MakeSignatureHeader(nil, utils.CreateNonceOrPanic()) payloadHeader := utils.MakePayloadHeader(payloadChainHeader, payloadSignatureHeader) - payload := &cb.Payload{Header: payloadHeader, Data: utils.MarshalOrPanic(&cb.ConfigurationEnvelope{Items: items})} + payload := &cb.Payload{Header: payloadHeader, Data: utils.MarshalOrPanic(&cb.ConfigurationEnvelope{Header: &cb.ChainHeader{ChainID: chainID}, Items: items})} envelope := &cb.Envelope{Payload: utils.MarshalOrPanic(payload), Signature: nil} block := cb.NewBlock(0, nil) diff --git a/orderer/multichain/systemchain_test.go b/orderer/multichain/systemchain_test.go index 57380db623e..9b004c1f232 100644 --- a/orderer/multichain/systemchain_test.go +++ b/orderer/multichain/systemchain_test.go @@ -118,10 +118,6 @@ func TestGoodProposal(t *testing.T) { mcc.ms.mpm.mp = &mockPolicy{} chainCreateTx := &cb.ConfigurationItem{ - Header: &cb.ChainHeader{ - ChainID: newChainID, - Type: int32(cb.HeaderType_CONFIGURATION_ITEM), - }, Key: configtx.CreationPolicyKey, Type: cb.ConfigurationItem_Orderer, Value: utils.MarshalOrPanic(&ab.CreationPolicy{ diff --git a/orderer/multichain/util_test.go b/orderer/multichain/util_test.go index f72b63d5cdc..c219eb232dd 100644 --- a/orderer/multichain/util_test.go +++ b/orderer/multichain/util_test.go @@ -103,6 +103,10 @@ func makeConfigTxWithItems(chainID string, items ...*cb.ConfigurationItem) *cb.E }, Data: utils.MarshalOrPanic(&cb.ConfigurationEnvelope{ Items: signedItems, + Header: &cb.ChainHeader{ + Type: int32(cb.HeaderType_CONFIGURATION_ITEM), + ChainID: chainID, + }, }), } return &cb.Envelope{ diff --git a/protos/common/configtx.pb.go b/protos/common/configtx.pb.go index cec4b0ba2bd..5c82c2058d7 100644 --- a/protos/common/configtx.pb.go +++ b/protos/common/configtx.pb.go @@ -68,6 +68,8 @@ func (ConfigurationItem_ConfigurationType) EnumDescriptor() ([]byte, []int) { // 5. All configuration changes satisfy the corresponding modification policy type ConfigurationEnvelope struct { Items []*SignedConfigurationItem `protobuf:"bytes,1,rep,name=Items" json:"Items,omitempty"` + // XXX This needs to be signed over, purely temporary pending completion of https://jira.hyperledger.org/browse/FAB-1880 + Header *ChainHeader `protobuf:"bytes,2,opt,name=header" json:"header,omitempty"` } func (m *ConfigurationEnvelope) Reset() { *m = ConfigurationEnvelope{} } @@ -82,6 +84,13 @@ func (m *ConfigurationEnvelope) GetItems() []*SignedConfigurationItem { return nil } +func (m *ConfigurationEnvelope) GetHeader() *ChainHeader { + if m != nil { + return m.Header + } + return nil +} + // ConfigurationTemplate is used as a serialization format to share configuration templates // The orderer supplies a configuration template to the user to use when constructing a new // chain creation transaction, so this is used to facilitate that. @@ -120,12 +129,11 @@ func (m *SignedConfigurationItem) GetSignatures() []*ConfigurationSignature { } type ConfigurationItem struct { - Header *ChainHeader `protobuf:"bytes,1,opt,name=Header" json:"Header,omitempty"` - Type ConfigurationItem_ConfigurationType `protobuf:"varint,2,opt,name=Type,enum=common.ConfigurationItem_ConfigurationType" json:"Type,omitempty"` - LastModified uint64 `protobuf:"varint,3,opt,name=LastModified" json:"LastModified,omitempty"` - ModificationPolicy string `protobuf:"bytes,4,opt,name=ModificationPolicy" json:"ModificationPolicy,omitempty"` - Key string `protobuf:"bytes,5,opt,name=Key" json:"Key,omitempty"` - Value []byte `protobuf:"bytes,6,opt,name=Value,proto3" json:"Value,omitempty"` + Type ConfigurationItem_ConfigurationType `protobuf:"varint,1,opt,name=Type,enum=common.ConfigurationItem_ConfigurationType" json:"Type,omitempty"` + LastModified uint64 `protobuf:"varint,2,opt,name=LastModified" json:"LastModified,omitempty"` + ModificationPolicy string `protobuf:"bytes,3,opt,name=ModificationPolicy" json:"ModificationPolicy,omitempty"` + Key string `protobuf:"bytes,4,opt,name=Key" json:"Key,omitempty"` + Value []byte `protobuf:"bytes,5,opt,name=Value,proto3" json:"Value,omitempty"` } func (m *ConfigurationItem) Reset() { *m = ConfigurationItem{} } @@ -133,13 +141,6 @@ func (m *ConfigurationItem) String() string { return proto.CompactTex func (*ConfigurationItem) ProtoMessage() {} func (*ConfigurationItem) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{3} } -func (m *ConfigurationItem) GetHeader() *ChainHeader { - if m != nil { - return m.Header - } - return nil -} - type ConfigurationSignature struct { SignatureHeader []byte `protobuf:"bytes,1,opt,name=signatureHeader,proto3" json:"signatureHeader,omitempty"` Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` @@ -162,32 +163,32 @@ func init() { func init() { proto.RegisterFile("common/configtx.proto", fileDescriptor1) } var fileDescriptor1 = []byte{ - // 418 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x74, 0x53, 0xdd, 0x8e, 0xd2, 0x40, - 0x14, 0xb6, 0xb4, 0x74, 0xe5, 0x40, 0xb4, 0x9e, 0x75, 0x75, 0x34, 0x46, 0x9b, 0x5e, 0x35, 0x41, - 0x69, 0x82, 0xf1, 0x56, 0x13, 0x8d, 0xc9, 0xfa, 0xb3, 0x4a, 0x66, 0x37, 0x5e, 0x78, 0xe5, 0xd0, - 0x1e, 0x60, 0x92, 0xd2, 0x69, 0xa6, 0x83, 0x91, 0x27, 0xf0, 0xd9, 0x7c, 0x2b, 0xd3, 0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 0x0a, 0x31, 0x82, 0xc1, 0x57, 0x51, 0x99, 0x0b, 0x95, 0xc9, 0x99, 0xa4, 0x8c, - 0xb9, 0xa1, 0x13, 0x7b, 0x7c, 0x07, 0xc3, 0x11, 0x60, 0x73, 0x4e, 0xad, 0x7a, 0xa2, 0x72, 0x99, - 0xae, 0x99, 0x17, 0x3a, 0x71, 0x8f, 0xb7, 0x4c, 0x30, 0x00, 0xf7, 0x0b, 0xad, 0x59, 0xd7, 0x12, - 0xea, 0x23, 0x3e, 0x84, 0xee, 0x0f, 0x91, 0xaf, 0x88, 0xf9, 0xb6, 0xcb, 0xe6, 0x12, 0x7d, 0xde, - 0x5b, 0xdf, 0xbe, 0x10, 0x80, 0xdf, 0xd8, 0x04, 0x77, 0xb0, 0x07, 0x5d, 0xbb, 0x74, 0xe0, 0x60, - 0x1f, 0x4e, 0xbe, 0xeb, 0x8c, 0x34, 0xe9, 0xa0, 0x83, 0x77, 0xc1, 0x9b, 0x10, 0xe9, 0xc0, 0xc5, - 0x13, 0x70, 0x2f, 0x2e, 0x27, 0x81, 0x17, 0xfd, 0x82, 0x47, 0xed, 0x8d, 0x63, 0x0c, 0xf7, 0xab, - 0xeb, 0xcb, 0xad, 0x62, 0x07, 0x7c, 0x1f, 0xc6, 0x67, 0xd0, 0xdb, 0x42, 0xb6, 0xd1, 0x01, 0xbf, - 0x01, 0xde, 0xbf, 0xfa, 0x39, 0x9c, 0x4b, 0xb3, 0x58, 0x4d, 0xeb, 0x92, 0x93, 0xc5, 0xba, 0x24, - 0x9d, 0x53, 0x36, 0x27, 0x9d, 0xcc, 0xc4, 0x54, 0xcb, 0x34, 0xb1, 0x1f, 0x7e, 0xb5, 0xf9, 0x0d, - 0xa6, 0xbe, 0xbd, 0xbe, 0xfe, 0x1f, 0x00, 0x00, 0xff, 0xff, 0xc3, 0xe0, 0x32, 0x62, 0x3d, 0x03, - 0x00, 0x00, + // 422 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x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0x88, 0x31, 0xfb, 0x0f, 0xbc, 0x7f, 0xf5, 0x7d, 0xba, 0x16, 0x7a, 0xb3, 0x5b, 0x96, 0x21, + 0x87, 0x9b, 0x22, 0x23, 0x95, 0x50, 0xbc, 0x26, 0x15, 0xae, 0xf8, 0x52, 0x89, 0x28, 0x34, 0x0f, + 0x3f, 0xaf, 0x7f, 0x83, 0xe5, 0xc0, 0x94, 0xaf, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x6f, 0x31, + 0x52, 0xf2, 0x3d, 0x03, 0x00, 0x00, } diff --git a/protos/common/configtx.proto b/protos/common/configtx.proto index f37785bd432..1f96664312f 100644 --- a/protos/common/configtx.proto +++ b/protos/common/configtx.proto @@ -48,6 +48,9 @@ package common; // 5. All configuration changes satisfy the corresponding modification policy message ConfigurationEnvelope { repeated SignedConfigurationItem Items = 1; + + // XXX This needs to be signed over, purely temporary pending completion of https://jira.hyperledger.org/browse/FAB-1880 + ChainHeader header = 2; } // ConfigurationTemplate is used as a serialization format to share configuration templates @@ -71,12 +74,11 @@ message ConfigurationItem { Peer = 3; // Marshaled format for this type is yet to be determined MSP = 4; // Marshaled MSPConfig proto } - ChainHeader Header = 1; // The header which ties this configuration to a particular chain - ConfigurationType Type = 2; // The type of configuration this is. - uint64 LastModified = 3; // The Sequence number in the ConfigurationEnvelope this item was last modified - string ModificationPolicy = 4; // What policy to check before allowing modification - string Key = 5; // A unique ID, unique scoped by Type, to reference the value by - bytes Value = 6; // The byte representation of this configuration, usually a marshaled message + ConfigurationType Type = 1; // The type of configuration this is. + uint64 LastModified = 2; // The Sequence number in the ConfigurationEnvelope this item was last modified + string ModificationPolicy = 3; // What policy to check before allowing modification + string Key = 4; // A unique ID, unique scoped by Type, to reference the value by + bytes Value = 5; // The byte representation of this configuration, usually a marshaled message } message ConfigurationSignature { diff --git a/protos/orderer/configuration.pb.go b/protos/orderer/configuration.pb.go index c1dcda91411..67c220c1ef5 100644 --- a/protos/orderer/configuration.pb.go +++ b/protos/orderer/configuration.pb.go @@ -7,7 +7,6 @@ package orderer import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" -import _ "github.com/hyperledger/fabric/protos/common" // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal @@ -134,27 +133,26 @@ func init() { func init() { proto.RegisterFile("orderer/configuration.proto", fileDescriptor1) } var fileDescriptor1 = []byte{ - // 346 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x92, 0x5f, 0x6b, 0xa3, 0x40, - 0x14, 0xc5, 0x71, 0xb3, 0x9b, 0x90, 0x4b, 0xb2, 0xbb, 0x99, 0x5d, 0x16, 0xd9, 0xbe, 0x04, 0xfb, - 0x62, 0x43, 0x88, 0x85, 0x7e, 0x81, 0xa2, 0xf4, 0xa1, 0x94, 0x94, 0x62, 0xf3, 0xd4, 0xb7, 0x51, - 0xaf, 0x3a, 0x24, 0xce, 0xc8, 0x9d, 0x11, 0x62, 0xbf, 0x44, 0xbf, 0x72, 0xc9, 0x68, 0x0a, 0x6d, - 0xa0, 0xf4, 0xc9, 0x73, 0xee, 0xf9, 0x39, 0x9c, 0xf9, 0x03, 0x67, 0x8a, 0x32, 0x24, 0xa4, 0x20, - 0x55, 0x32, 0x17, 0x45, 0x43, 0xdc, 0x08, 0x25, 0x57, 0x35, 0x29, 0xa3, 0xd8, 0xa8, 0x0f, 0xff, - 0xff, 0x49, 0x55, 0x55, 0x29, 0x19, 0x74, 0x9f, 0x2e, 0xf5, 0xce, 0x61, 0x1a, 0x29, 0xa9, 0x51, - 0xea, 0x46, 0x6f, 0xda, 0x1a, 0x19, 0x83, 0xef, 0xa6, 0xad, 0xd1, 0x75, 0xe6, 0x8e, 0x3f, 0x8e, - 0xad, 0xf6, 0x5e, 0x1c, 0x18, 0x87, 0xdc, 0xa4, 0xe5, 0xa3, 0x78, 0x46, 0xe6, 0xc3, 0xaf, 0x8a, - 0xef,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f4, 0x4f, 0x23, 0x19, 0x5a, 0x7f, 0xf5, 0x1a, 0x00, 0x00, - 0xff, 0xff, 0x02, 0x01, 0xf1, 0xb0, 0x49, 0x02, 0x00, 0x00, + // 334 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x92, 0x41, 0x4b, 0xeb, 0x40, + 0x14, 0x85, 0xc9, 0xeb, 0x7b, 0x2d, 0xbd, 0xb4, 0xef, 0xbd, 0x0e, 0x22, 0x01, 0x37, 0x25, 0x6e, + 0x62, 0x29, 0x8d, 0xe0, 0x1f, 0x90, 0x04, 0x17, 0x22, 0x15, 0x89, 0x5d, 0xb9, 0x9b, 0x24, 0x37, + 0xc9, 0xd0, 0x66, 0x26, 0xdc, 0x99, 0x40, 0xe3, 0x9f, 0xf0, 0x2f, 0x4b, 0x27, 0xa9, 0xa0, 0x05, + 0x71, 0x77, 0xce, 0xb9, 0xdf, 0x0c, 0xe7, 0xc2, 0x85, 0x0b, 0x45, 0x19, 0x12, 0x52, 0x90, 0x2a, + 0x99, 0x8b, 0xa2, 0x21, 0x6e, 0x84, 0x92, 0xab, 0x9a, 0x94, 0x51, 0x6c, 0xd4, 0x0f, 0xbd, 0x4b, + 0x98, 0x46, 0x4a, 0x6a, 0x94, 0xba, 0xd1, 0x9b, 0xb6, 0x46, 0xc6, 0xe0, 0xb7, 0x69, 0x6b, 0x74, + 0x9d, 0xb9, 0xe3, 0x8f, 0x63, 0xab, 0xbd, 0x37, 0x07, 0xc6, 0x21, 0x37, 0x69, 0xf9, 0x2c, 0x5e, + 0x91, 0xf9, 0xf0, 0xaf, 0xe2, 0xfb, 0x35, 0x6a, 0xcd, 0x0b, 0x8c, 0x54, 0x23, 0x8d, 0x85, 0xa7, + 0xf1, 0xd7, 0x98, 0x2d, 0xe0, 0x3f, 0x4f, 0xb4, 0xda, 0x35, 0x06, 0xd7, 0x7c, 0x1f, 0xb6, 0x06, + 0xb5, 0xfb, 0xcb, 0xa2, 0x27, 0x39, 0x5b, 0xc2, 0xac, 0x26, 0xcc, 0x91, 0x08, 0xb3, 0x0f, 0x78, + 0x60, 0xe1, 0xd3, 0x81, 0xe7, 0xc3, 0xc4, 0x16, 0xda, 0x88, 0x0a, 0x55, 0x63, 0x98, 0x0b, 0x23, + 0xd3, 0xc9, 0xbe, 0xf8, 0xd1, 0x7a, 0xb7, 0xf0, 0x37, 0x22, 0xb4, 0xbb, 0x3f, 0xa9, 0x9d, 0x48, + 0x5b, 0x76, 0x0e, 0xc3, 0xda, 0xaa, 0x1e, 0xed, 0xdd, 0x21, 0xcf, 0x44, 0x81, 0xda, 0xd8, 0x8e, + 0x93, 0xb8, 0x77, 0xde, 0x02, 0xd8, 0xbd, 0x2c, 0x08, 0xb5, 0xee, 0x3e, 0x78, 0xe4, 0x15, 0x6a, + 0x76, 0x06, 0x7f, 0xe4, 0x41, 0xb8, 0xce, 0x7c, 0xe0, 0x8f, 0xe3, 0xce, 0x78, 0x57, 0x30, 0xbb, + 0xfb, 0x21, 0x7a, 0x0d, 0x6e, 0x54, 0x72, 0x21, 0x3f, 0xb7, 0xfb, 0xee, 0x85, 0x0f, 0x93, 0x07, + 0x9e, 0x6f, 0x79, 0x48, 0x6a, 0x8b, 0xa4, 0x0f, 0x4b, 0x27, 0x9d, 0xec, 0xb9, 0xa3, 0x0d, 0x57, + 0x2f, 0xcb, 0x42, 0x98, 0xb2, 0x49, 0x56, 0xa9, 0xaa, 0x82, 0xb2, 0xad, 0x91, 0x76, 0x98, 0x15, + 0x48, 0x41, 0xce, 0x13, 0x12, 0x69, 0x60, 0xaf, 0x40, 0x07, 0xfd, 0x15, 0x24, 0x43, 0xeb, 0x6f, + 0xde, 0x03, 0x00, 0x00, 0xff, 0xff, 0x3b, 0x56, 0x2c, 0x13, 0x34, 0x02, 0x00, 0x00, } diff --git a/protos/orderer/configuration.proto b/protos/orderer/configuration.proto index 8f36e03ec9c..159ea4811f8 100644 --- a/protos/orderer/configuration.proto +++ b/protos/orderer/configuration.proto @@ -16,8 +16,6 @@ limitations under the License. syntax = "proto3"; -import "common/common.proto"; - option go_package = "github.com/hyperledger/fabric/protos/orderer"; package orderer; diff --git a/protos/utils/configtxutils_test.go b/protos/utils/configtxutils_test.go index 76186db78da..0487aa0be77 100644 --- a/protos/utils/configtxutils_test.go +++ b/protos/utils/configtxutils_test.go @@ -98,9 +98,6 @@ func TestBreakOutConfigEnvelopeToConfigItems(t *testing.T) { if len(configItems) != 1 { t.Errorf("TestBreakOutPayloadDataToConfigurationEnvelope did not return array of 1 config item\n") } - if configItems[0].Header.Type != int32(pb.HeaderType_CONFIGURATION_TRANSACTION) || configItems[0].Header.ChainID != "test" { - t.Errorf("TestBreakOutConfigEnvelopeToConfigItems, configItem header does not match original %+v . Expected config_transaction and chainid 'test'\n", configItems[0].Header) - } if configItems[0].Type != pb.ConfigurationItem_Orderer || configItems[0].Key != "abc" || !bytes.Equal(configItems[0].Value, []byte("test")) { t.Errorf("TestBreakOutConfigEnvelopeToConfigItems configItem type,Key,Value do not match original %+v\n. Expected orderer, 'abc', 'test'", configItems[0]) } @@ -198,15 +195,13 @@ func testConfigurationBlock() *pb.Block { } func testConfigurationEnvelope() *pb.ConfigurationEnvelope { - chainHeader := testChainHeader() - configItem := makeConfigurationItem(chainHeader, pb.ConfigurationItem_Orderer, 0, "defaultPolicyID", "abc", []byte("test")) + configItem := makeConfigurationItem(pb.ConfigurationItem_Orderer, 0, "defaultPolicyID", "abc", []byte("test")) signedConfigItem, _ := makeSignedConfigurationItem(configItem, nil) return makeConfigurationEnvelope(signedConfigItem) } // testConfigurationEnvelope -func makeConfigurationItem(ch *pb.ChainHeader, configItemType pb.ConfigurationItem_ConfigurationType, lastModified uint64, modPolicyID string, key string, value []byte) *pb.ConfigurationItem { +func makeConfigurationItem(configItemType pb.ConfigurationItem_ConfigurationType, lastModified uint64, modPolicyID string, key string, value []byte) *pb.ConfigurationItem { return &pb.ConfigurationItem{ - Header: ch, Type: configItemType, LastModified: lastModified, ModificationPolicy: modPolicyID, diff --git a/protos/utils/configurationutils.go b/protos/utils/configurationutils.go index 965533c4f88..b23d794d16f 100644 --- a/protos/utils/configurationutils.go +++ b/protos/utils/configurationutils.go @@ -27,7 +27,6 @@ import ( // MakeConfigurationItem makes a ConfigurationItem. func MakeConfigurationItem(ch *cb.ChainHeader, configItemType cb.ConfigurationItem_ConfigurationType, lastModified uint64, modPolicyID string, key string, value []byte) *cb.ConfigurationItem { return &cb.ConfigurationItem{ - Header: ch, Type: configItemType, LastModified: lastModified, ModificationPolicy: modPolicyID,