Skip to content

Incorrect parent-hash continuity check in incoming block validation #16

Description

@sueun-dev

Summary

Block parent continuity check compares against the wrong value in Blockchain.Run.

In the incoming block path, the code currently does:

if reflect.DeepEqual(b.PrevBlock, bl.CurrentBlock.Hash()) {
    fmt.Println("Missing blocks in between")
} else {
    // accept/add block
}

b.PrevBlock should point to the previous confirmed block hash, but bl.CurrentBlock.Hash() is the hash of the current candidate block template (not the expected parent hash). This makes the continuity check unreliable and can accept out-of-sequence blocks.

Location

  • core/blockchain.go (inside func (bl *Blockchain) Run())

Expected behavior

Compare b.PrevBlock to the expected parent hash for the current mining context (e.g. bl.CurrentBlock.PrevBlock) before accepting the block.

Why this matters

Chain continuity validation is a critical consensus safety check. Comparing to the candidate block hash instead of candidate parent hash can allow invalid chain progression logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions