Skip to content

Commit c34f794

Browse files
committed
Invert chain selection arguments order
To maintain consistency.
1 parent f28978e commit c34f794

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

operator/mina/lib/src/consensus_state.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ pub enum LongerChainResult {
99
}
1010

1111
pub fn select_longer_chain(
12-
tip: &MinaStateProtocolStateValueStableV2,
1312
candidate: &MinaStateProtocolStateValueStableV2,
13+
tip: &MinaStateProtocolStateValueStableV2,
1414
) -> LongerChainResult {
15-
let tip_block_height = &tip.body.consensus_state.blockchain_length.as_u32();
1615
let candidate_block_height = &candidate.body.consensus_state.blockchain_length.as_u32();
16+
let tip_block_height = &tip.body.consensus_state.blockchain_length.as_u32();
1717

18-
if tip_block_height < candidate_block_height {
18+
if candidate_block_height > tip_block_height {
1919
return LongerChainResult::Candidate;
2020
}
2121
// tiebreak logic
22-
else if tip_block_height == candidate_block_height {
22+
else if candidate_block_height == tip_block_height {
2323
// compare last VRF digests lexicographically
24-
if hash_last_vrf(tip) < hash_last_vrf(candidate) {
24+
if hash_last_vrf(candidate) > hash_last_vrf(tip) {
2525
return LongerChainResult::Candidate;
26-
} else if hash_last_vrf(tip) == hash_last_vrf(candidate) {
26+
} else if hash_last_vrf(candidate) == hash_last_vrf(tip) {
2727
// compare consensus state hashes lexicographically
28-
if hash_state(tip) < hash_state(candidate) {
28+
if hash_state(candidate) > hash_state(tip) {
2929
return LongerChainResult::Candidate;
3030
}
3131
}

operator/mina/lib/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub extern "C" fn verify_protocol_state_proof_ffi(
8181
}
8282

8383
// Consensus check: Short fork rule
84-
let longer_chain = select_longer_chain(&tip_protocol_state, &candidate_protocol_state);
84+
let longer_chain = select_longer_chain(&candidate_protocol_state, &tip_protocol_state);
8585

8686
longer_chain == LongerChainResult::Candidate
8787
}

0 commit comments

Comments
 (0)