Skip to content

Conversation

@DorKatzelnick
Copy link
Contributor

add config-puller delivery client to router, and pull config blocks for consensus

add test

issue: #199

ccp.logger.Panicf("Failed extracting header from decision: %s", err)
}

// if num := len(header.AvailableCommonBlocks); num > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

remove comments

common.HeaderType_DELIVER_SEEK_INFO,
"consensus",
nil,
NewestSeekInfo(),
Copy link
Contributor

Choose a reason for hiding this comment

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

This might need to change
At least put a TODO here so we remember to give this a second thought

Copy link
Contributor Author

@DorKatzelnick DorKatzelnick Nov 4, 2025

Choose a reason for hiding this comment

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

will change it with the last decision number in config store

res := make(chan *common.Block, configBlocksChanSize)

blockHandlerFunc := func(block *common.Block) {
ccp.logger.Infof("Received decision block %d from consensus", block.GetHeader().GetNumber())
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe debugf?
otherwise we will see a log for each and every decision

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i will just remove it, since we log it in pullAndProcessConfigBlocks method


blockHandlerFunc := func(block *common.Block) {
ccp.logger.Infof("Received decision block %d from consensus", block.GetHeader().GetNumber())
// check that the decision contains a config block. then extract the config block and send it on the res channel
Copy link
Contributor

Choose a reason for hiding this comment

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

check if

Stop()
}

//go:generate counterfeiter -o mocks/consensus_state_replicator_creator.go . ConsensusStateReplicatorCreator
Copy link
Contributor

Choose a reason for hiding this comment

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

this is used for mocking for testing
If not used then you can remove this

Copy link
Contributor

Choose a reason for hiding this comment

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

and just have the struct without and interface

Copy link
Contributor

Choose a reason for hiding this comment

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

or just call new without a struct
remove this file

err = sc.MakeDecisionFromHeader(&state.Header{Num: 1, DecisionNumOfLastConfigBlock: 1, AvailableCommonBlocks: acb})
require.NoError(t, err)

// check for config block is stored in router's config store
Copy link
Contributor

Choose a reason for hiding this comment

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

check if


// check for config block is stored in router's config store
require.Eventually(t, func() bool {
return testSetup.router.GetConfigStoreSize() == 1
Copy link
Contributor

Choose a reason for hiding this comment

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

what was the size before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will also check it is 0 before.

return fmt.Errorf("not implemented")
}

func (sc *StubConsenter) MakeDecisionFromHeader(header *state.Header) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Deliver Decision From Header?

server: server,
partyID: partyID,
decisions: make(chan *common.Block, 100),
logger: testutil.CreateLoggerForModule(t, "stucbconsenter", zapcore.DebugLevel),
Copy link
Contributor

Choose a reason for hiding this comment

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

why create logger here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

txs uint32 // Number of txs received from router
partyID types.PartyID
decisions chan *common.Block
decisionSentCh chan struct{} // decision sent signal
Copy link
Contributor

Choose a reason for hiding this comment

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

what is this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

return configPuller
}

func (ccp *ConsensusConfigPuller) PullConfigBlocks() <-chan *common.Block {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should keep in mind somewhere that we should pull config blocks from all consenters
Maybe add a TODO

func NextSeekInfoFromConfigStore(configStore *configstore.Store, logger types.Logger) *orderer.SeekInfo {
lastBlock, err := configStore.Last()
if err != nil {
// TODO - replace this with panic if genesis block is placed in config store during router initialization
Copy link
Contributor

Choose a reason for hiding this comment

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

please avoid this by changing the tests to start with a full config store (with genesis block)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@DorKatzelnick DorKatzelnick force-pushed the reconfigC2R branch 2 times, most recently from f8e5ac8 to 4764c16 Compare November 6, 2025 15:12
Comment on lines 413 to 414
r.logger.Errorf("Failed adding config block to config store: %s", err)
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a fatal error... better panic

stubConsenterInfo := config.ConsenterInfo{PartyID: partyID, Endpoint: consenter.GetConsenterEndpoint(), TLSCACerts: []config.RawBytes{ca.CertBytes()}}

configStorePath := t.TempDir()
cs, _ := configstore.NewStore(configStorePath)
Copy link
Contributor

Choose a reason for hiding this comment

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

require.NoError


configStorePath := t.TempDir()
cs, _ := configstore.NewStore(configStorePath)
cs.Add(&common.Block{Header: &common.BlockHeader{Number: 0}, Data: &common.BlockData{}}) // add dummy genesis block
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a block that at least passes protoutils.IsConfigBlock() as true

initialConfigStoreSize := testSetup.router.GetConfigStoreSize()

// create a decision with a config block
configBlock := common.Block{Header: &common.BlockHeader{Number: 999}, Data: &common.BlockData{}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a block that at least passes protoutils.IsConfigBlock() as true

sc := testSetup.consenter
defer testSetup.Close()

initialConfigStoreSize := testSetup.router.GetConfigStoreSize()
Copy link
Contributor

Choose a reason for hiding this comment

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

require something here, I assume ==1

bundle.ConfigtxValidatorReturns(configtxValidator)

configStorePath := t.TempDir()
cs, _ := configstore.NewStore(configStorePath)
Copy link
Contributor

Choose a reason for hiding this comment

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

require NoError


configStorePath := t.TempDir()
cs, _ := configstore.NewStore(configStorePath)
cs.Add(&common.Block{Header: &common.BlockHeader{Number: 0}, Data: &common.BlockData{}}) // add dummy genesis block
Copy link
Contributor

Choose a reason for hiding this comment

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

again should pass IsConfigBlock

return configPuller
}

func (ccp *ConsensusConfigPuller) PullConfigBlocks() <-chan *common.Block {
Copy link
Contributor

Choose a reason for hiding this comment

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

Document it. Doe it return only config blocks or is filtering required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also added the verification for the config block with protoutil.IsConfigBlock()

requestEnvelope, err := protoutil.CreateSignedEnvelopeWithTLSBinding(
common.HeaderType_DELIVER_SEEK_INFO,
"consensus",
nil,
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a TODO to use a signer here

return ccp.endpoint
}

requestEnvelopeFactoryFunc := func() *common.Envelope {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no point using a factory if the cpp.seekInfo is fixed...

The idea was to make the puller self update when new config blocks are met, i.e. update the endpoint and credentials on the fly. This is not the case here.

Copy link
Contributor Author

@DorKatzelnick DorKatzelnick Nov 9, 2025

Choose a reason for hiding this comment

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

I replaced the seekInfo with a function that returns the latest seekInfo when called. I am not sure if this is necessary. Because I don't see when it will be called again unless the router restarts and then the configPuller starts again (like it would before)

Did you mean to add an update method that the router can call and change the params? I can place it in TODO now and do it in next PR's (like in the config-submitter)

Copy link
Contributor

Choose a reason for hiding this comment

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

You can simply calculate once the seek info in advance and pass the value when you create the ConsensusConfigPuller
It doesn't need to be a function at all since as you put it the seek info does not change

Copy link
Contributor Author

@DorKatzelnick DorKatzelnick Nov 10, 2025

Choose a reason for hiding this comment

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

added an Update method with TODO comment

@DorKatzelnick DorKatzelnick force-pushed the reconfigC2R branch 2 times, most recently from 1ee689a to fdc1043 Compare November 10, 2025 14:09
…or consensus

add new config blocks to the config-store

add test

Signed-off-by: Dor.Katzelnick <Dor.Katzelnick@ibm.com>
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