Skip to content

Commit

Permalink
Merge pull request #139 from ComposableFi/rustnninja/fix-tm-validatio…
Browse files Browse the repository at this point in the history
…n-on-yui

fix tm verify header on solidity.
  • Loading branch information
vmarkushin authored Mar 18, 2024
2 parents 438c6e7 + fbf62e6 commit 42fec44
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions light-clients/ics07-tendermint/src/client_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,22 @@ impl Header {

let mut bitmask: u64 = 0;

for (index, (_, vote)) in non_absent_votes.enumerate() {
let pub_key = &self
.validator_set
.validators()
.iter()
.find(|x| x.address == vote.validator_address)
.unwrap()
.pub_key;
for (index, s) in signed_header.commit.signatures.iter().enumerate() {

let validator_address = match s {
CommitSig::BlockIdFlagAbsent { .. } => None,
CommitSig::BlockIdFlagCommit { validator_address, .. } =>
Some(*validator_address),
CommitSig::BlockIdFlagNil { validator_address, .. } =>
Some(*validator_address),
};

let vote = match validator_address {
Some(vote) => vote,
None => continue,
};

let pub_key = &self.validator_set.validators().iter().find(|x| x.address == vote).unwrap().pub_key;
let p = pub_key;
let mut f_pub_key = None;
match p {
Expand All @@ -352,16 +360,13 @@ impl Header {
if ret.iter().any(|x| x.0 == f_pub_key.clone().unwrap_or(vec![])) { 1 } else { 0 };

if validator == 1 {
let str_pub_key = hex::encode(vote.validator_address);
log::info!(
target: "hyperspace", "Validator when bitmask index: {} : address {:?} Voting Power: {:?}",
index,str_pub_key,
self.validator_set.validators()[index].power()
);
let str_pub_key = hex::encode(vote);
log::info!(target: "hyperspace", "Validator when bitmask index: {} : address {:?} Voting Power: {:?}", index, str_pub_key, self.validator_set.validators()[index].power());
bitmask |= 1 << index;
}
}

log::info!(target: "hyperspace", "Header Height: {:?} Bitmask : {} Validators : {:?}", self.height(), bitmask, ret);
Ok((ret, bitmask))
}
}
Expand Down

0 comments on commit 42fec44

Please sign in to comment.