Skip to content

Commit b12870d

Browse files
authored
Merge pull request #133 from scrtlabs/add-implicit-hash-to-header
remove ImplicitHash from the blockheader hash calculation
2 parents 020a790 + da747a4 commit b12870d

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

state/state.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,10 @@ func (state State) MakeBlock(
280280
panic("Failed to validate generated random")
281281
}
282282

283-
implicitHash, err := tmenclave.GetImplicitHash()
284-
if err != nil {
285-
panic("Failed to get implicit hash")
286-
}
283+
// implicitHash, err := tmenclave.GetImplicitHash()
284+
// if err != nil {
285+
// panic("Failed to get implicit hash")
286+
// }
287287
// ScrtLabs changes out <-
288288

289289
// Fill rest of header with state data.
@@ -292,7 +292,7 @@ func (state State) MakeBlock(
292292
timestamp, state.LastBlockID,
293293
state.Validators.Hash(), state.NextValidators.Hash(),
294294
state.ConsensusParams.Hash(), state.AppHash, state.LastResultsHash,
295-
proposerAddress, &encryptedRandom, implicitHash,
295+
proposerAddress, &encryptedRandom, nil,
296296
)
297297

298298
return block

state/validation.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,15 @@ func validateBlock(state State, block *types.Block) error {
121121
}
122122
}
123123

124-
expectedImplicitHash, err := tmenclave.GetImplicitHash() // hash from last block's scheduling
125-
if err != nil {
126-
return fmt.Errorf("failed to get implicit hash: %w", err)
127-
}
128-
if !bytes.Equal(block.Header.ImplicitHash, expectedImplicitHash) {
124+
// expectedImplicitHash, err := tmenclave.GetImplicitHash() // hash from last block's scheduling
125+
// if err != nil {
126+
// return fmt.Errorf("failed to get implicit hash: %w", err)
127+
// }
128+
if len(block.Header.ImplicitHash) > 0 {
129129
emptySha256 := sha256.Sum256([]byte{})
130-
if !(bytes.Equal(block.Header.ImplicitHash, []byte{}) && bytes.Equal(expectedImplicitHash, emptySha256[:])) {
131-
return fmt.Errorf("implicit_hash mismatch: expected %X, got %X", hex.EncodeToString(expectedImplicitHash), hex.EncodeToString(block.Header.ImplicitHash))
130+
if !bytes.Equal(block.Header.ImplicitHash, emptySha256[:]) {
131+
return fmt.Errorf("implicit_hash mismatch: expected nil or empty hash, got %s",
132+
block.Header.ImplicitHash.String())
132133
}
133134
}
134135

types/block.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ func (h *Header) Hash() cmtbytes.HexBytes {
489489
cdcEncode(h.LastResultsHash),
490490
cdcEncode(h.EvidenceHash),
491491
cdcEncode(h.ProposerAddress),
492-
cdcEncode(h.ImplicitHash),
492+
// cdcEncode(h.ImplicitHash),
493493
})
494494
}
495495

@@ -529,7 +529,7 @@ func (h *Header) StringIndented(indent string) string {
529529
indent, h.LastResultsHash,
530530
indent, h.EvidenceHash,
531531
indent, h.ProposerAddress,
532-
indent, h.ImplicitHash,
532+
// indent, h.ImplicitHash,
533533
indent, h.Hash(),
534534
)
535535
}

0 commit comments

Comments
 (0)