Skip to content

Conversation

@moradna
Copy link
Contributor

@moradna moradna commented Oct 20, 2025

Pending []types.BatchAttestationFragment
Complaints []Complaint
AppContext []byte
LatestConfigRequest *ConfigRequest
Copy link
Contributor

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"
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 comment to add more info to this string

Copy link
Contributor

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()
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 comment to maybe use a different ID

Copy link
Contributor

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?

Copy link
Contributor

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

s2.AppContext = make([]byte, 0, len(s.AppContext))
s2.AppContext = append(s2.AppContext, s.AppContext...)
}
if s.LatestConfigRequest != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

also remove this

s.Complaints = append(s.Complaints, *ce.Complaint)
}
if ce.ConfigRequest != nil {
s.LatestConfigRequest = ce.ConfigRequest
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this

}

ce = consensus_state.ControlEvent{nil, &c}
ce = consensus_state.ControlEvent{nil, &c, 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 simple test with a non nil config request

@moradna moradna force-pushed the config-control-event branch from d6c7861 to 2a2f212 Compare October 21, 2025 09:48
return -1, false
}

func ExtractConfigRequests(ces []ControlEvent) *ConfigRequest {
Copy link
Contributor

Choose a reason for hiding this comment

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

request and not requests

Copy link
Contributor

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

@HagarMeir HagarMeir force-pushed the config-control-event branch 3 times, most recently from d2ed4f0 to 5573cf7 Compare October 26, 2025 06:51
Comment on lines +708 to +716
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
}
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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

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 remember there is a pending config change and not propose another before it is committed, correct?

Copy link
Contributor

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
Copy link
Contributor

@tock-ibm tock-ibm Oct 26, 2025

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).

Copy link
Contributor

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...

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 done with other CEs (if you look at the top of this function)
maybe we should change this there as well?

Copy link
Contributor

@tock-ibm tock-ibm Oct 27, 2025

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?

Copy link
Contributor

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()
Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Contributor

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"
Copy link
Contributor

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) {
Copy link
Contributor

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?

Copy link
Contributor

@HagarMeir HagarMeir Oct 26, 2025

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

@tock-ibm tock-ibm force-pushed the config-control-event branch from 5573cf7 to 2cf981d Compare October 27, 2025 14:20
Signed-off-by: Natalie Morad <natalie.morad@ibm.com>
Signed-off-by: Natalie Morad <natalie.morad@ibm.com>
@tock-ibm tock-ibm force-pushed the config-control-event branch from 2cf981d to 09be6c4 Compare October 28, 2025 12:23
Copy link
Contributor

@tock-ibm tock-ibm left a 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

@tock-ibm tock-ibm merged commit 0cf9d51 into hyperledger:main Oct 28, 2025
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