-
Notifications
You must be signed in to change notification settings - Fork 9
config pull delivery client in router #334
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
base: main
Are you sure you want to change the base?
Conversation
| ccp.logger.Panicf("Failed extracting header from decision: %s", err) | ||
| } | ||
|
|
||
| // if num := len(header.AvailableCommonBlocks); num > 0 { |
There was a problem hiding this comment.
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(), |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
node/router/router_test.go
Outdated
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check if
node/router/router_test.go
Outdated
|
|
||
| // check for config block is stored in router's config store | ||
| require.Eventually(t, func() bool { | ||
| return testSetup.router.GetConfigStoreSize() == 1 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
node/router/stub_consenter_test.go
Outdated
| return fmt.Errorf("not implemented") | ||
| } | ||
|
|
||
| func (sc *StubConsenter) MakeDecisionFromHeader(header *state.Header) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deliver Decision From Header?
node/router/stub_consenter_test.go
Outdated
| server: server, | ||
| partyID: partyID, | ||
| decisions: make(chan *common.Block, 100), | ||
| logger: testutil.CreateLoggerForModule(t, "stucbconsenter", zapcore.DebugLevel), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why create logger here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
node/router/stub_consenter_test.go
Outdated
| txs uint32 // Number of txs received from router | ||
| partyID types.PartyID | ||
| decisions chan *common.Block | ||
| decisionSentCh chan struct{} // decision sent signal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
2fcfac7 to
b8403c1
Compare
| return configPuller | ||
| } | ||
|
|
||
| func (ccp *ConsensusConfigPuller) PullConfigBlocks() <-chan *common.Block { |
There was a problem hiding this comment.
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
b8403c1 to
6ac8e80
Compare
6ac8e80 to
1b378ab
Compare
node/router/router.go
Outdated
| 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 |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
f8e5ac8 to
4764c16
Compare
4764c16 to
b889a4f
Compare
node/router/router.go
Outdated
| r.logger.Errorf("Failed adding config block to config store: %s", err) | ||
| continue |
There was a problem hiding this comment.
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
node/router/router_test.go
Outdated
| stubConsenterInfo := config.ConsenterInfo{PartyID: partyID, Endpoint: consenter.GetConsenterEndpoint(), TLSCACerts: []config.RawBytes{ca.CertBytes()}} | ||
|
|
||
| configStorePath := t.TempDir() | ||
| cs, _ := configstore.NewStore(configStorePath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
require.NoError
node/router/router_test.go
Outdated
|
|
||
| configStorePath := t.TempDir() | ||
| cs, _ := configstore.NewStore(configStorePath) | ||
| cs.Add(&common.Block{Header: &common.BlockHeader{Number: 0}, Data: &common.BlockData{}}) // add dummy genesis block |
There was a problem hiding this comment.
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
node/router/router_test.go
Outdated
| initialConfigStoreSize := testSetup.router.GetConfigStoreSize() | ||
|
|
||
| // create a decision with a config block | ||
| configBlock := common.Block{Header: &common.BlockHeader{Number: 999}, Data: &common.BlockData{}} |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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
test/utils_test.go
Outdated
| bundle.ConfigtxValidatorReturns(configtxValidator) | ||
|
|
||
| configStorePath := t.TempDir() | ||
| cs, _ := configstore.NewStore(configStorePath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
require NoError
test/utils_test.go
Outdated
|
|
||
| configStorePath := t.TempDir() | ||
| cs, _ := configstore.NewStore(configStorePath) | ||
| cs.Add(&common.Block{Header: &common.BlockHeader{Number: 0}, Data: &common.BlockData{}}) // add dummy genesis block |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
1ee689a to
fdc1043
Compare
…or consensus add new config blocks to the config-store add test Signed-off-by: Dor.Katzelnick <Dor.Katzelnick@ibm.com>
fdc1043 to
4888b66
Compare
add config-puller delivery client to router, and pull config blocks for consensus
add test
issue: #199