mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-08 22:23:11 +00:00
light: Fix absence proof verification by light client (#7639)
- use the full key path to pass to the VerifyAbsence function
This commit is contained in:
committed by
GitHub
parent
557d86316b
commit
9b32346ebd
@@ -70,3 +70,5 @@ Special thanks to external contributors on this release:
|
||||
### BUG FIXES
|
||||
|
||||
- fix: assignment copies lock value in `BitArray.UnmarshalJSON()` (@lklimek)
|
||||
- [light] \#7640 Light Client: fix absence proof verification (@ashcherbakov)
|
||||
- [light] \#7641 Light Client: fix querying against the latest height (@ashcherbakov)
|
||||
|
||||
@@ -196,24 +196,25 @@ func (c *Client) ABCIQueryWithOptions(ctx context.Context, path string, data tmb
|
||||
}
|
||||
|
||||
// Validate the value proof against the trusted header.
|
||||
|
||||
// build a Merkle key path from path and resp.Key
|
||||
if c.keyPathFn == nil {
|
||||
return nil, errors.New("please configure Client with KeyPathFn option")
|
||||
}
|
||||
|
||||
kp, err := c.keyPathFn(path, resp.Key)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("can't build merkle key path: %w", err)
|
||||
}
|
||||
|
||||
// verify value
|
||||
if resp.Value != nil {
|
||||
// 1) build a Merkle key path from path and resp.Key
|
||||
if c.keyPathFn == nil {
|
||||
return nil, errors.New("please configure Client with KeyPathFn option")
|
||||
}
|
||||
|
||||
kp, err := c.keyPathFn(path, resp.Key)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("can't build merkle key path: %w", err)
|
||||
}
|
||||
|
||||
// 2) verify value
|
||||
err = c.prt.VerifyValue(resp.ProofOps, l.AppHash, kp.String(), resp.Value)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("verify value proof: %w", err)
|
||||
}
|
||||
} else { // OR validate the absence proof against the trusted header.
|
||||
err = c.prt.VerifyAbsence(resp.ProofOps, l.AppHash, string(resp.Key))
|
||||
err = c.prt.VerifyAbsence(resp.ProofOps, l.AppHash, kp.String())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("verify absence proof: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user