starcoinorg / starcoin

Starcoin - A Move smart contract blockchain network that scales by layering
Apache License 2.0
1.38k stars 289 forks source link

[Bug Report] Block header hash value is not the same though the header is the same #4132

Open jackzhhuang opened 5 months ago

jackzhhuang commented 5 months ago
pub fn random() -> Self {
        let body = BlockBody::sample();
        let mut header = BlockHeader::random();
        header.body_hash = body.hash();

        Self { header, body }
    }

In struct Block, body hash is involved with the header id calculation but it is set after the calculation resulting in mismatch

nkysg commented 5 months ago

I don't understand it. Could you provide more information?

jackzhhuang commented 5 months ago

pseudo code:

header.body_hash = random()
header.id = hash(header)
header.body_hash = body.sample().hash

header.id is not consistent with header value after the line: header.body_hash = body.sample().hash