forked from cosmos/ibc-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix multiple bugs for Ethermint (cosmos#305)
* fix: proper handling of last commit * fix: set ValidatorsHash in block header * fix: update validator set with ResponseInitChain data * feat: Aggregators hash in block headers * fix: set correct DataHash in ToABCIBlock * docs: update CHANGELOG-PENDING.md
- Loading branch information
Showing
15 changed files
with
193 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,42 @@ | ||
package types | ||
|
||
import ( | ||
"encoding" | ||
"time" | ||
|
||
"github.com/minio/sha256-simd" | ||
tmversion "github.com/tendermint/tendermint/proto/tendermint/version" | ||
tmtypes "github.com/tendermint/tendermint/types" | ||
) | ||
|
||
func (h *Header) Hash() [32]byte { | ||
return hash(h) | ||
func (header *Header) Hash() [32]byte { | ||
abciHeader := tmtypes.Header{ | ||
Version: tmversion.Consensus{ | ||
Block: header.Version.Block, | ||
App: header.Version.App, | ||
}, | ||
Height: int64(header.Height), | ||
Time: time.Unix(int64(header.Time), 0), | ||
LastBlockID: tmtypes.BlockID{ | ||
Hash: header.LastHeaderHash[:], | ||
PartSetHeader: tmtypes.PartSetHeader{ | ||
Total: 0, | ||
Hash: nil, | ||
}, | ||
}, | ||
LastCommitHash: header.LastCommitHash[:], | ||
DataHash: header.DataHash[:], | ||
ValidatorsHash: header.AggregatorsHash[:], | ||
NextValidatorsHash: nil, | ||
ConsensusHash: header.ConsensusHash[:], | ||
AppHash: header.AppHash[:], | ||
LastResultsHash: header.LastResultsHash[:], | ||
EvidenceHash: new(tmtypes.EvidenceData).Hash(), | ||
ProposerAddress: header.ProposerAddress, | ||
} | ||
var hash [32]byte | ||
copy(hash[:], abciHeader.Hash()) | ||
return hash | ||
} | ||
|
||
func (b *Block) Hash() [32]byte { | ||
return hash(b) | ||
} | ||
|
||
func hash(obj encoding.BinaryMarshaler) [32]byte { | ||
blob, err := obj.MarshalBinary() | ||
if err != nil { | ||
return [32]byte{} | ||
} | ||
return sha256.Sum256(blob) | ||
|
||
return b.Header.Hash() | ||
} |
Oops, something went wrong.