Skip to content

Commit 42fec44

Browse files
authored
Merge pull request #139 from ComposableFi/rustnninja/fix-tm-validation-on-yui
fix tm verify header on solidity.
2 parents 438c6e7 + fbf62e6 commit 42fec44

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

light-clients/ics07-tendermint/src/client_message.rs

+19-14
Original file line numberDiff line numberDiff line change
@@ -332,14 +332,22 @@ impl Header {
332332

333333
let mut bitmask: u64 = 0;
334334

335-
for (index, (_, vote)) in non_absent_votes.enumerate() {
336-
let pub_key = &self
337-
.validator_set
338-
.validators()
339-
.iter()
340-
.find(|x| x.address == vote.validator_address)
341-
.unwrap()
342-
.pub_key;
335+
for (index, s) in signed_header.commit.signatures.iter().enumerate() {
336+
337+
let validator_address = match s {
338+
CommitSig::BlockIdFlagAbsent { .. } => None,
339+
CommitSig::BlockIdFlagCommit { validator_address, .. } =>
340+
Some(*validator_address),
341+
CommitSig::BlockIdFlagNil { validator_address, .. } =>
342+
Some(*validator_address),
343+
};
344+
345+
let vote = match validator_address {
346+
Some(vote) => vote,
347+
None => continue,
348+
};
349+
350+
let pub_key = &self.validator_set.validators().iter().find(|x| x.address == vote).unwrap().pub_key;
343351
let p = pub_key;
344352
let mut f_pub_key = None;
345353
match p {
@@ -352,16 +360,13 @@ impl Header {
352360
if ret.iter().any(|x| x.0 == f_pub_key.clone().unwrap_or(vec![])) { 1 } else { 0 };
353361

354362
if validator == 1 {
355-
let str_pub_key = hex::encode(vote.validator_address);
356-
log::info!(
357-
target: "hyperspace", "Validator when bitmask index: {} : address {:?} Voting Power: {:?}",
358-
index,str_pub_key,
359-
self.validator_set.validators()[index].power()
360-
);
363+
let str_pub_key = hex::encode(vote);
364+
log::info!(target: "hyperspace", "Validator when bitmask index: {} : address {:?} Voting Power: {:?}", index, str_pub_key, self.validator_set.validators()[index].power());
361365
bitmask |= 1 << index;
362366
}
363367
}
364368

369+
log::info!(target: "hyperspace", "Header Height: {:?} Bitmask : {} Validators : {:?}", self.height(), bitmask, ret);
365370
Ok((ret, bitmask))
366371
}
367372
}

0 commit comments

Comments
 (0)