Skip to content

Commit

Permalink
Use 8 bytes to hash UpgradeConfig
Browse files Browse the repository at this point in the history
8 bytes is generally enough to fingerprint the UpgradeConfig changes, so nodes
can exchange the hash as part of the handshake[1]

[1] https://stackoverflow.com/questions/18134627/how-much-of-a-git-sha-is-generally-considered-necessary-to-uniquely-identify-a
  • Loading branch information
nytzuga committed Sep 8, 2023
1 parent be9f6b2 commit a3a6471
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions plugin/evm/message/handshake/upgrade_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ func (r *UpgradeConfig) Bytes() []byte {
return r.bytes
}

func (r *UpgradeConfig) Hash() [32]byte {
return sha256.Sum256(r.bytes)
func (r *UpgradeConfig) Hash() [8]byte {
hash := sha256.Sum256(r.bytes)
var firstBytes [8]byte
copy(firstBytes[:], hash[:8])
return firstBytes
}

0 comments on commit a3a6471

Please sign in to comment.