Skip to content
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

Re-add support for submitting misbehaviors #750

Closed
Tracked by #776
jtieri opened this issue May 23, 2022 · 3 comments
Closed
Tracked by #776

Re-add support for submitting misbehaviors #750

jtieri opened this issue May 23, 2022 · 3 comments
Assignees
Labels
C: Relayer COMPONENT: Relayer T: New Feature TYPE: New features to be added

Comments

@jtieri
Copy link
Member

jtieri commented May 23, 2022

This code used to be present but was removed when refactoring the codebase to account for the Provider abstraction.

We should get this added back and finalize the methods signature

SubmitMisbehavior( /*TODO TBD*/ ) (RelayerMessage, error)

Testing cases for this should be built out in the ibctest repo

@jtieri jtieri added C: Relayer COMPONENT: Relayer T: New Feature TYPE: New features to be added labels May 23, 2022
@jtieri
Copy link
Member Author

jtieri commented Jun 9, 2022

The code that used to be in place for submitting misbehaviors is here

// checkAndSubmitMisbehaviour check headers from update_client tx events
// against the associated light client. If the headers do not match, the emitted
// header and a reconstructed header are used in misbehaviour submission to
// the IBC client on the source chain.
func checkAndSubmitMisbehaviour(src, counterparty *Chain, events map[string][]string) error {
hdrs, ok := events[fmt.Sprintf("%s.%s", updateCliTag, headerTag)]
if !ok {
return nil
}
for i, hdr := range hdrs {
clientIDs := events[fmt.Sprintf("%s.%s", updateCliTag, clientIDTag)]
if len(clientIDs) <= i {
return fmt.Errorf("emitted client-ids count is less than emitted headers count")
}
emittedClientID := clientIDs[i]
if src.PathEnd.ClientID != emittedClientID {
continue
}
hdrBytes, err := hex.DecodeString(hdr)
if err != nil {
return sdkerrors.Wrapf(err, "failed decoding hexadecimal string of header with client-id: %s",
emittedClientID)
}
exportedHeader, err := clienttypes.UnmarshalHeader(src.Encoding.Marshaler, hdrBytes)
if err != nil {
return sdkerrors.Wrapf(err, "failed unmarshaling header with client-id: %s", emittedClientID)
}
emittedHeader, ok := exportedHeader.(*tmclient.Header)
if !ok {
return fmt.Errorf("emitted header is not tendermint type")
}
trustedHeader, err := counterparty.GetLightSignedHeaderAtHeight(emittedHeader.Header.Height)
if err != nil {
return err
}
if IsMatchingConsensusState(emittedHeader.ConsensusState(), trustedHeader.ConsensusState()) {
continue
}
trustedHeader.TrustedValidators = emittedHeader.TrustedValidators
trustedHeader.TrustedHeight = emittedHeader.TrustedHeight
misbehaviour := tmclient.NewMisbehaviour(emittedClientID, emittedHeader, trustedHeader)
msg, err := clienttypes.NewMsgSubmitMisbehaviour(emittedClientID, misbehaviour, src.MustGetAddress())
if err != nil {
return err
}
if err := msg.ValidateBasic(); err != nil {
return err
}
res, success, err := src.SendMsg(msg)
if err != nil {
return err
}
if !success {
return fmt.Errorf("submit misbehaviour tx failed: %s", res.RawLog)
}
src.Log(fmt.Sprintf("Submitted misbehaviour for emitted header with height: %d",
emittedHeader.Header.Height))
}
return nil
}

@boojamya boojamya assigned agouin and unassigned jtieri Jul 5, 2022
@ItsFunny
Copy link
Contributor

When will it be finished

@jtieri
Copy link
Member Author

jtieri commented Mar 14, 2023

Closed by #1121

@jtieri jtieri closed this as completed Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Relayer COMPONENT: Relayer T: New Feature TYPE: New features to be added
Projects
None yet
Development

No branches or pull requests

3 participants