Skip to content

Commit 6d6b071

Browse files
authored
Merge pull request #4171 from yangby-cryptape/bugfix/no-mmr-for-fork-chains
fix(light-client): could not check MMR for fork chains
2 parents 922516e + f2cdacf commit 6d6b071

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

util/light-client-protocol-server/src/components/get_last_state_proof.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,17 @@ impl<'a> GetLastStateProofProcess<'a> {
204204
let snapshot = self.protocol.shared.snapshot();
205205

206206
let last_block_hash = self.message.last_hash().to_entity();
207-
let last_block = if let Some(block) = snapshot.get_block(&last_block_hash) {
208-
block
209-
} else {
207+
let last_block = if !snapshot.is_main_chain(&last_block_hash) {
210208
return self
211209
.protocol
212210
.reply_tip_state::<packed::SendLastStateProof>(self.peer, self.nc);
211+
} else if let Some(block) = snapshot.get_block(&last_block_hash) {
212+
block
213+
} else {
214+
let errmsg = format!(
215+
"the block is in the main chain but not found, its hash is {last_block_hash:#x}"
216+
);
217+
return StatusCode::InternalError.with_context(errmsg);
213218
};
214219

215220
let start_block_hash = self.message.start_hash().to_entity();

0 commit comments

Comments
 (0)