-
Couldn't load subscription status.
- Fork 9
add config request to control event #305
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
Conversation
node/consensus/state/state.go
Outdated
| Pending []types.BatchAttestationFragment | ||
| Complaints []Complaint | ||
| AppContext []byte | ||
| LatestConfigRequest *ConfigRequest |
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.
as we discussed this is not needed
| } | ||
|
|
||
| func (c *ConfigRequest) String() string { | ||
| return "Config Request" |
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 comment to add more info to this string
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.
Some hash, the config sequence sequence? better to have more than less, this is a rare event.
| copy(payloadToHash[22:], ce.BAF.Digest()) | ||
| } else if ce.ConfigRequest != nil { | ||
| ce.ConfigRequest.Envelope.Signature = nil | ||
| payloadToHash = ce.ConfigRequest.Bytes() |
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 comment to maybe use a different ID
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 the ID should hash both content and sig? i.e. the marshalled bytes?
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 we could do something like Fabric does
but again this can be done in another PR
there is a TODO here
node/consensus/state/state.go
Outdated
| s2.AppContext = make([]byte, 0, len(s.AppContext)) | ||
| s2.AppContext = append(s2.AppContext, s.AppContext...) | ||
| } | ||
| if s.LatestConfigRequest != 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.
also remove this
node/consensus/state/state.go
Outdated
| s.Complaints = append(s.Complaints, *ce.Complaint) | ||
| } | ||
| if ce.ConfigRequest != nil { | ||
| s.LatestConfigRequest = ce.ConfigRequest |
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 this
node/consensus/state/state_test.go
Outdated
| } | ||
|
|
||
| ce = consensus_state.ControlEvent{nil, &c} | ||
| ce = consensus_state.ControlEvent{nil, &c, 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 simple test with a non nil config request
d6c7861 to
2a2f212
Compare
node/consensus/state/state.go
Outdated
| return -1, false | ||
| } | ||
|
|
||
| func ExtractConfigRequests(ces []ControlEvent) *ConfigRequest { |
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.
request and not requests
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.
also add a TODO comment about what we should do if there are multiple config requests
d2ed4f0 to
5573cf7
Compare
| func ExtractConfigRequest(ces []ControlEvent) *ConfigRequest { | ||
| // TODO: decide how to handle multiple config requests | ||
| for _, ce := range ces { | ||
| if ce.ConfigRequest != nil { | ||
| return ce.ConfigRequest | ||
| } | ||
| } | ||
| return 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 the context here, extract all into a slice. The decision happens by the caller of this function.
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 general, the desired behavior is that the first valid config request goes through and is proposed, and the next ones are rejected, with feedback to the router.
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.
feedback to the router happens in an earlier stage I believe, when the request is sent by router
as for returning a slice I agree that can be done
if not right now then in the next PR
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 remember there is a pending config change and not propose another before it is committed, correct?
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.
No I am not sure we do
| copy(payloadToHash[22:], ce.BAF.Digest()) | ||
| } else if ce.ConfigRequest != nil { | ||
| // TODO: maybe use a different ID for ConfigRequest | ||
| ce.ConfigRequest.Envelope.Signature = 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.
Why set nil here? If this is the leader, it would contain its signature by this time.
(the second stage of verification changes the update envelope to a full config, with the leader consenter sig).
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.
A getter should never be destructive...
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 done with other CEs (if you look at the top of this function)
maybe we should change this there as well?
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 is it done on other CEs?
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 could fix it to all CEs
| copy(payloadToHash[22:], ce.BAF.Digest()) | ||
| } else if ce.ConfigRequest != nil { | ||
| ce.ConfigRequest.Envelope.Signature = nil | ||
| payloadToHash = ce.ConfigRequest.Bytes() |
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 the ID should hash both content and sig? i.e. the marshalled bytes?
| signerID = fmt.Sprintf("%d", ce.Complaint.Signer) | ||
| } else if ce.BAF != nil { | ||
| signerID = fmt.Sprintf("%d", ce.BAF.Signer()) | ||
| // TODO: add ConfigRequest SignerID |
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.
The signer will be the leader node
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.
the identity will be in the payload, in the sig header, as in a normal TX
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.
sure
can be added later in another PR
there is a TODO
|
|
||
| c.stateLock.Lock() | ||
| computedState, attestations := c.Arma.SimulateStateTransition(c.State, batch) | ||
| computedState, attestations, _ := c.Arma.SimulateStateTransition(c.State, batch) |
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.
Extract the config request and do a log.Info on it if it exists.
Log there it is not supported yet.
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.
But I will support it in the next PR
|
|
||
| c.stateLock.Lock() | ||
| _, bafs := c.Arma.SimulateStateTransition(c.State, requests) | ||
| _, bafs, _ := c.Arma.SimulateStateTransition(c.State, requests) |
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.
Extract the config request and do a log.Info on it if it exists.
Log there it is not supported yet.
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.
But I will support it in the next PR
| c.stateLock.Lock() | ||
| newState, attestations := c.Arma.SimulateStateTransition(c.State, requests) | ||
| // TODO: config request not handled yet | ||
| newState, attestations, _ := c.Arma.SimulateStateTransition(c.State, requests) |
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.
Extract the config request and do a log.Info on it if it exists.
Log there it is not supported yet.
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.
But I will support it in the next PR
| // TODO revise the recovery from failure or shutdown, specifically the order of Commit and Append. | ||
| func (c *Consenter) Commit(events [][]byte) { | ||
| state, batchAttestations := c.SimulateStateTransition(c.State, events) | ||
| state, batchAttestations, _ := c.SimulateStateTransition(c.State, events) |
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.
Extract the config request and do a log.Info on it if it exists.
Log there it is not supported yet.
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.
But I will support it in the next PR
| } | ||
|
|
||
| func (c *ConfigRequest) String() string { | ||
| return "Config Request" |
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.
Some hash, the config sequence sequence? better to have more than less, this is a rare event.
| } | ||
|
|
||
| func (s *State) Process(l types.Logger, ces ...ControlEvent) (*State, []types.BatchAttestationFragment) { | ||
| func (s *State) Process(l types.Logger, ces ...ControlEvent) (*State, []types.BatchAttestationFragment, *ConfigRequest) { |
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 a config request change the state?
Should a config be also handled by a rule?
Nit - rename s2 into something meaningful... nextState maybe?
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.
Right now it does not change the state
A rule may be added later
We can add here a TODO comment
5573cf7 to
2cf981d
Compare
Signed-off-by: Natalie Morad <natalie.morad@ibm.com>
Signed-off-by: Natalie Morad <natalie.morad@ibm.com>
2cf981d to
09be6c4
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.
Let take all the comments in the next PR
#193