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

Question about trusted_validator_set in detect_misbehavior #3697

Closed
beer-1 opened this issue Nov 16, 2023 · 0 comments · Fixed by #3727
Closed

Question about trusted_validator_set in detect_misbehavior #3697

beer-1 opened this issue Nov 16, 2023 · 0 comments · Fixed by #3727

Comments

@beer-1
Copy link
Contributor

beer-1 commented Nov 16, 2023

In detect_misbehavior, hermes is fetching trusted_validator_set at trusted_height not trusted_height+1 and check this result with trusted_validator_set in update_client ibc events.

let trusted_block = self.fetch(update_header.trusted_height)?;
if trusted_block.validators.hash() != update_header.trusted_validator_set.hash() {
return Err(Error::misbehaviour(format!(
"mismatch between the trusted validator set of the update \
header ({}) and that of the trusted block that was fetched ({}), \
aborting misbehaviour detection.",
trusted_block.validators.hash(),
update_header.trusted_validator_set.hash()
)));
}

But when hermes makes MsgUpdateClient, it is always fetching trusted_validator_set at trusted_height+1 like following. (see line 369, 388 and 401)

let trusted_validator_set = self.fetch(trusted_height.increment())?.validators;
let mut supporting_headers = Vec::with_capacity(supporting.len());
let mut current_trusted_height = trusted_height;
let mut current_trusted_validators = trusted_validator_set.clone();
for support in supporting {
let header = TmHeader {
signed_header: support.signed_header.clone(),
validator_set: support.validators,
trusted_height: current_trusted_height,
trusted_validator_set: current_trusted_validators,
};
// This header is now considered to be the currently trusted header
current_trusted_height = header.height();
// Therefore we can now trust the next validator set, see NOTE above.
current_trusted_validators = self.fetch(header.height().increment())?.validators;
supporting_headers.push(header);
}
// a) Set the trusted height of the target header to the height of the previous
// supporting header if any, or to the initial trusting height otherwise.
//
// b) Set the trusted validators of the target header to the validators of the successor to
// the last supporting header if any, or to the initial trusted validators otherwise.
let (latest_trusted_height, latest_trusted_validator_set) = match supporting_headers.last()
{
Some(prev_header) => {
let prev_succ = self.fetch(prev_header.height().increment())?;
(prev_header.height(), prev_succ.validators)
}
None => (trusted_height, trusted_validator_set),
};
let target_header = TmHeader {
signed_header: target.signed_header,
validator_set: target.validators,
trusted_height: latest_trusted_height,
trusted_validator_set: latest_trusted_validator_set,
};
Ok((target_header, supporting_headers))

Is it intended or bug?

@github-project-automation github-project-automation bot moved this to 🩹 Triage in Hermes Nov 16, 2023
@beer-1 beer-1 changed the title Question about trusted_validator in detect_misbehaviour Question about trusted_validator_set in detect_misbehaviour Nov 16, 2023
@beer-1 beer-1 changed the title Question about trusted_validator_set in detect_misbehaviour Question about trusted_validator_set in detect_misbehavior Nov 16, 2023
@github-project-automation github-project-automation bot moved this from 🩹 Triage to ✅ Done in Hermes Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
1 participant