Skip to content

add endpoint and consenter consistency validations to OrdererRules#657

Merged
moradna merged 4 commits intohyperledger:mainfrom
moradna:add-orderer-endpoints-validate
Mar 11, 2026
Merged

add endpoint and consenter consistency validations to OrdererRules#657
moradna merged 4 commits intohyperledger:mainfrom
moradna:add-orderer-endpoints-validate

Conversation

@moradna
Copy link
Contributor

@moradna moradna commented Mar 2, 2026

#94

@moradna moradna force-pushed the add-orderer-endpoints-validate branch 2 times, most recently from 2388d3e to 1c699b0 Compare March 2, 2026 17:22
@tock-ibm tock-ibm requested a review from Copilot March 5, 2026 15:56
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends DefaultOrdererRules.ValidateNewConfig to validate orderer-organization endpoints and to enforce consistency between the orderer consenter mapping and the shared (consensus-metadata) parties config, aligning with the “Validate params” work from Issue #94.

Changes:

  • Add validation that each orderer org has non-empty endpoints and includes both broadcast and deliver roles.
  • Add validation that Orderers.ConsenterMapping matches SharedConfig.PartiesConfig (host/port/identity/TLS certs).
  • Update config generation + config-update test utilities and add unit tests to exercise the new validations.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
config/verify/orderer_rules.go Adds endpoint-role and consenter-mapping consistency validations in ValidateNewConfig.
config/verify/orderer_rules_test.go Adds tests for invalid endpoints and consenter-mapping inconsistency.
config/generate/config_block_gen.go Fixes generated consenter identity to use the signing cert and generates endpoints in the new format.
testutil/configutil/config_update_utils.go Updates test config update builder to keep PartiesConfig, consenter_mapping, and org endpoints in sync.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@moradna moradna force-pushed the add-orderer-endpoints-validate branch from 99f88fc to 3e54507 Compare March 10, 2026 07:44
Policies: make(map[string]*configtxgen.Policy),
AnchorPeers: templateAppOrg.AnchorPeers,
OrdererEndpoints: templateAppOrg.OrdererEndpoints, // TODO: org.OrdererEndpoints in the new format
OrdererEndpoints: buildOrdererEndpoints(uint32(p.PartyID), p.RouterConfig.Host, int(p.RouterConfig.Port), p.AssemblerConfig.Host, int(p.AssemblerConfig.Port)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

profile.Application.Organizations do not have orderer endpoints

return errors.Errorf("party ID %d missing from shared config", consenter.Id)
}
if party.ConsenterConfig == nil {
return errors.Errorf("consenter config missing for party %d", consenter.Id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return errors.Errorf("consenter config missing in shared config for party %d", consenter.Id)

Comment on lines +370 to +372
if !slices.Equal(consenter.ServerTlsCert, nodeCfg.TlsCert) || !slices.Equal(consenter.ClientTlsCert, nodeCfg.TlsCert) {
return errors.Errorf("TLS certificate mismatch for party %d", consenter.Id)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to enforce this rule, as clients should not be using these TLS certs to connect to the consenters directly. In fact, they can remain empty in the consenters mapping.

I say that we can check like so:
If consenter.ServerTlsCert (or consenter.ClientTlsCert) is empty, it is ok (this is permitted for Arma).
However, if they do contain something, it must be equal to nodeCfg.TlsCert.

moradna added 3 commits March 11, 2026 09:20
Signed-off-by: Natalie Morad <natalie.morad@ibm.com>
Signed-off-by: Natalie Morad <natalie.morad@ibm.com>
Signed-off-by: Natalie Morad <natalie.morad@ibm.com>
@moradna moradna force-pushed the add-orderer-endpoints-validate branch from 3e54507 to 53b4a52 Compare March 11, 2026 07:21
Signed-off-by: Natalie Morad <natalie.morad@ibm.com>
@tock-ibm
Copy link
Contributor

By the way, it is perfectly fine to add unit tests in the verify package and directly test the internal functions for input validity, if it turns out difficult to create the "big" config objects that way. EG in a separate file orderer_rules_internal_test.go that resides in the verify package. In the next PR maybe, as this one is done.

@moradna moradna merged commit 5ea550b into hyperledger:main Mar 11, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants