MCPcopy Create free account
hub / github.com/tendermint/tendermint / ValidateBasic

Method ValidateBasic

types/light.go:129–157  ·  view source on GitHub ↗

ValidateBasic does basic consistency checks and makes sure the header and commit are consistent. NOTE: This does not actually check the cryptographic signatures. Make sure to use a Verifier to validate the signatures actually provide a significantly strong proof for this header's validity.

(chainID string)

Source from the content-addressed store, hash-verified

127// to use a Verifier to validate the signatures actually provide a
128// significantly strong proof for this header's validity.
129func (sh SignedHeader) ValidateBasic(chainID string) error {
130 if sh.Header == nil {
131 return errors.New("missing header")
132 }
133 if sh.Commit == nil {
134 return errors.New("missing commit")
135 }
136
137 if err := sh.Header.ValidateBasic(); err != nil {
138 return fmt.Errorf("invalid header: %w", err)
139 }
140 if err := sh.Commit.ValidateBasic(); err != nil {
141 return fmt.Errorf("invalid commit: %w", err)
142 }
143
144 if sh.ChainID != chainID {
145 return fmt.Errorf("header belongs to another chain %q, not %q", sh.ChainID, chainID)
146 }
147
148 // Make sure the header is consistent with the commit.
149 if sh.Commit.Height != sh.Height {
150 return fmt.Errorf("header and commit height mismatch: %d vs %d", sh.Height, sh.Commit.Height)
151 }
152 if hhash, chash := sh.Header.Hash(), sh.Commit.BlockID.Hash; !bytes.Equal(hhash, chash) {
153 return fmt.Errorf("commit signs block %X, header is block %X", chash, hhash)
154 }
155
156 return nil
157}
158
159// String returns a string representation of SignedHeader.
160func (sh SignedHeader) String() string {

Callers 1

Calls 3

ValidateBasicMethod · 0.65
HashMethod · 0.65
EqualMethod · 0.65

Tested by 1