-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
Migration from Raft to BFT test #4561
Conversation
Signed-off-by: Yacov Manevich <yacov.manevich@ibm.com>
58a7b1b
to
d27fd90
Compare
06ae680
to
e2f1c5e
Compare
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 test case that emulates what happens when a raft chain receives the config block that changes from raft to BFT
@@ -84,22 +86,32 @@ func MetadataHasDuplication(md *etcdraft.ConfigMetadata) error { | |||
} | |||
|
|||
// MetadataFromConfigValue reads and translates configuration updates from config value into raft metadata | |||
func MetadataFromConfigValue(configValue *common.ConfigValue) (*etcdraft.ConfigMetadata, error) { | |||
func MetadataFromConfigValue(configValue *common.ConfigValue) (*etcdraft.ConfigMetadata, *orderer.ConsensusType, 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.
add a unit test
orderer/consensus/etcdraft/chain.go
Outdated
c.logger.Panicf("illegal consensus type detected during consensus metadata validation: %s", newOrdererConfig.ConsensusType()) | ||
panic("illegal consensus type detected during consensus metadata validation") |
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 panic? return error
0207578
to
f2ad291
Compare
fa0db9d
to
b3d82c2
Compare
Signed-off-by: May Rosenbaum <mayro1595@gmail.com>
b3d82c2
to
6a21a90
Compare
} | ||
|
||
_, err := validateBFTMetadataOptions(1, updatedMetadata) | ||
if updatedMetadata.XXX_unrecognized != nil || err != 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.
what is this XXX field thing check? This is prorobuf implementation specific, isn't it?
Once we upgrade the protobuf version, we might not have this field anymore.
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.
That's right, we can skip this check, err check is enough.
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.
True, the XXX fields are not required to preserve backwards compatibility going forward, so we better not use them.
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.
verifying with validateBFTMetadataOptions
should be enough, but see comment on verifying the consenters map as well.
c.logger.Infof("Detected migration to %s", consensusType.Type) | ||
return nil | ||
} else { | ||
c.logger.Panicf("illegal consensus type detected: %s", consensusType.Type) |
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 post consensus. Do we have a validation check for this condition pre-consensus anywhere?
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.
otherwise, you know what will happen once we reach this point ;-)
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 have one more check in the maintenance filter.
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.
Yes, May is correct, we prevent it the maintenance filter.
} | ||
|
||
_, err := validateBFTMetadataOptions(1, updatedMetadata) | ||
if updatedMetadata.XXX_unrecognized != nil || err != 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.
True, the XXX fields are not required to preserve backwards compatibility going forward, so we better not use them.
} | ||
|
||
_, err := validateBFTMetadataOptions(1, updatedMetadata) | ||
if updatedMetadata.XXX_unrecognized != nil || err != 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.
verifying with validateBFTMetadataOptions
should be enough, but see comment on verifying the consenters map as well.
integration/raft/migration_test.go
Outdated
block := FetchBlock(network, o1, 1, "testchannel") | ||
Expect(block).NotTo(BeNil()) | ||
|
||
By("Change to maintenance mode") |
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.
before each step of the migration, add a numbered comment like:
// === Step 1: Config update, change to MAINTENANCE ===
By("1) ...")
as is done in the tests below. this helps keep track of what is going on in the logs.
be consistent about how these look.
orderer/consensus/etcdraft/util.go
Outdated
if consensusTypeValue.Type != "etcdraft" { | ||
if consensusTypeValue.Type == "BFT" { | ||
return nil, consensusTypeValue, 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.
In case it is not etcdraft just do return nil, consensusTypeValue, nil
if it is not BFT, the chain will panic
c.logger.Infof("Detected migration to %s", consensusType.Type) | ||
return nil | ||
} else { | ||
c.logger.Panicf("illegal consensus type detected: %s", consensusType.Type) |
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.
Yes, May is correct, we prevent it the maintenance filter.
c.logger.Infof("Detected configuration change: consensusType is: %s, configMetadata is: %v", consensusType, configMetadata) | ||
|
||
if consensusType == nil { | ||
c.logger.Infof("ConsensusType is %v", consensusType) |
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.
"ConsensusType is nil"
does this ever happen?
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.
In the absence of this check, one of the chain tests fails.
Anyway, to be safe, it is better to check it
1877849
to
29c35a4
Compare
Signed-off-by: May Rosenbaum <mayro1595@gmail.com>
29c35a4
to
7f404af
Compare
@tock-ibm what is left in your opinion so this can be merged? |
return errors.Wrap(err, "failed to unmarshal BFT metadata configuration") | ||
} | ||
|
||
_, err := validateBFTMetadataOptions(1, updatedMetadata) |
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.
Either
- remove the first return value, because it is not used here, and the id can be hard coded, or
- move the function
consensus/smartbft/configFromMetadataOptions
to a packageconsensus/smartbft/util
and make it public. This would break the import cycle. I prefer this option, this way we don't duplicate code.
8c9a62f
to
a78393f
Compare
Signed-off-by: May Rosenbaum <mayro1595@gmail.com>
a78393f
to
903f2ea
Compare
Type of change
Related Issue
#3773