e2e: integrate light clients (bp #6196)

integrate light clients (#6196)
fix e2e app test (#6223)
fix light client generator (#6236)
This commit is contained in:
mergify[bot]
2021-03-18 13:02:05 +01:00
committed by GitHub
parent 4e25703d58
commit b2f01448be
16 changed files with 243 additions and 59 deletions

View File

@@ -5,6 +5,7 @@ import (
"context"
"errors"
"fmt"
"regexp"
"time"
"github.com/gogo/protobuf/proto"
@@ -61,6 +62,27 @@ func KeyPathFn(fn KeyPathFunc) Option {
}
}
// DefaultMerkleKeyPathFn creates a function used to generate merkle key paths
// from a path string and a key. This is the default used by the cosmos SDK.
// This merkle key paths are required when verifying /abci_query calls
func DefaultMerkleKeyPathFn() KeyPathFunc {
// regexp for extracting store name from /abci_query path
storeNameRegexp := regexp.MustCompile(`\/store\/(.+)\/key`)
return func(path string, key []byte) (merkle.KeyPath, error) {
matches := storeNameRegexp.FindStringSubmatch(path)
if len(matches) != 2 {
return nil, fmt.Errorf("can't find store name in %s using %s", path, storeNameRegexp)
}
storeName := matches[1]
kp := merkle.KeyPath{}
kp = kp.AppendKey([]byte(storeName), merkle.KeyEncodingURL)
kp = kp.AppendKey(key, merkle.KeyEncodingURL)
return kp, nil
}
}
// NewClient returns a new client.
func NewClient(next rpcclient.Client, lc LightClient, opts ...Option) *Client {
c := &Client{