diff --git a/go.mod b/go.mod index 07d8a0f2..78ab6376 100644 --- a/go.mod +++ b/go.mod @@ -1,16 +1,15 @@ module github.com/filecoin-project/go-fil-markets -go 1.13 +go 1.16 require ( - github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/filecoin-project/dagstore v0.5.2 github.com/filecoin-project/go-address v0.0.6 github.com/filecoin-project/go-bitfield v0.2.4 // indirect github.com/filecoin-project/go-cbor-util v0.0.1 github.com/filecoin-project/go-commp-utils v0.1.3 github.com/filecoin-project/go-crypto v0.0.1 // indirect - github.com/filecoin-project/go-data-transfer/v2 v2.0.0-20220511223325-5253bfe075cd + github.com/filecoin-project/go-data-transfer/v2 v2.0.0-20220603004528-681bfedccef1 github.com/filecoin-project/go-ds-versioning v0.1.1 github.com/filecoin-project/go-fil-commcid v0.1.0 github.com/filecoin-project/go-fil-commp-hashhash v0.1.0 @@ -28,8 +27,8 @@ require ( github.com/hashicorp/go-multierror v1.1.1 github.com/ipfs/go-block-format v0.0.3 github.com/ipfs/go-blockservice v0.2.1 - github.com/ipfs/go-cid v0.1.0 - github.com/ipfs/go-cidutil v0.0.2 + github.com/ipfs/go-cid v0.2.0 + github.com/ipfs/go-cidutil v0.1.0 github.com/ipfs/go-datastore v0.5.1 github.com/ipfs/go-filestore v1.1.0 github.com/ipfs/go-graphsync v0.13.1 @@ -41,19 +40,19 @@ require ( github.com/ipfs/go-ipfs-files v0.0.9 github.com/ipfs/go-ipld-cbor v0.0.6-0.20211211231443-5d9b9e1f6fa8 github.com/ipfs/go-ipld-format v0.2.0 - github.com/ipfs/go-log/v2 v2.5.0 + github.com/ipfs/go-log/v2 v2.5.1 github.com/ipfs/go-merkledag v0.5.1 github.com/ipfs/go-unixfs v0.3.1 github.com/ipld/go-car v0.3.3 github.com/ipld/go-car/v2 v2.1.1 - github.com/ipld/go-ipld-prime v0.16.0 + github.com/ipld/go-ipld-prime v0.17.1-0.20220624062450-534ccf82237d github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c github.com/jpillora/backoff v1.0.0 - github.com/libp2p/go-libp2p v0.18.0 - github.com/libp2p/go-libp2p-core v0.14.0 + github.com/libp2p/go-libp2p v0.19.4 + github.com/libp2p/go-libp2p-core v0.15.1 github.com/multiformats/go-multiaddr v0.5.0 github.com/multiformats/go-multibase v0.0.3 - github.com/multiformats/go-multicodec v0.4.1 + github.com/multiformats/go-multicodec v0.5.0 github.com/multiformats/go-multihash v0.1.0 github.com/multiformats/go-varint v0.0.6 github.com/petar/GoLLRB v0.0.0-20210522233825-ae3b015fd3e9 @@ -61,12 +60,9 @@ require ( github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11 github.com/whyrusleeping/cbor-gen v0.0.0-20220302191723-37c43cae8e14 github.com/xorcare/golden v0.6.1-0.20191112154924-b87f686d7542 // indirect - golang.org/x/crypto v0.0.0-20211209193657-4570a0811e8b // indirect golang.org/x/exp v0.0.0-20210715201039-d37aa40e8013 - golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 - golang.org/x/sys v0.0.0-20211209171907-798191bca915 // indirect - golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 - lukechampine.com/blake3 v1.1.7 // indirect + golang.org/x/net v0.0.0-20220418201149-a630d4f3e7a2 + golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f ) replace github.com/filecoin-project/filecoin-ffi => ./extern/filecoin-ffi diff --git a/go.sum b/go.sum index a14d64d1..aaa4dbc8 100644 --- a/go.sum +++ b/go.sum @@ -79,8 +79,9 @@ github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/benbjohnson/clock v1.0.2/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= -github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= +github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -127,15 +128,21 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWR github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/cilium/ebpf v0.2.0/go.mod h1:To2CFviqOWL/M0gIMsvSMlqe7em/l1ALkX1PyjrX2Qs= +github.com/cilium/ebpf v0.4.0/go.mod h1:4tRaxcgiL706VnOzHOdBlY8IEAIdxINsQBcU4xJJXRs= github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/containerd/cgroups v0.0.0-20201119153540-4cbc285b3327 h1:7grrpcfCtbZLsjtB0DgMuzs1umsJmpzaHMZ6cO6iAWw= github.com/containerd/cgroups v0.0.0-20201119153540-4cbc285b3327/go.mod h1:ZJeTFisyysqgcCdecO57Dj79RfL0LNeGiFUqLYQRYLE= +github.com/containerd/cgroups v1.0.3 h1:ADZftAkglvCiD44c77s5YmMqaP2pzVCFZvBmAlBdAP4= +github.com/containerd/cgroups v1.0.3/go.mod h1:/ofk34relqNjSGyqPrmEULrO4Sc8LJhvJmWbUCUKqj8= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= @@ -187,8 +194,9 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/elastic/gosigar v0.12.0 h1:AsdhYCJlTudhfOYQyFNgx+fIVTfrDO0V1ST0vHgiapU= github.com/elastic/gosigar v0.12.0/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= +github.com/elastic/gosigar v0.14.2 h1:Dg80n8cr90OZ7x+bAax/QjoW/XqTI11RmA79ZwIm9/4= +github.com/elastic/gosigar v0.14.2/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= github.com/elgris/jsondiff v0.0.0-20160530203242-765b5c24c302/go.mod h1:qBlWZqWeVx9BjvqBsnC/8RUlAYpIFmPvgROcw0n1scE= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -196,6 +204,7 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= +github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5/go.mod h1:JpoxHjuQauoxiFMl1ie8Xc/7TfLuMZ5eOCONd1sUBHg= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= @@ -229,8 +238,8 @@ github.com/filecoin-project/go-crypto v0.0.1/go.mod h1:+viYnvGtUTgJRdy6oaeF4MTFK github.com/filecoin-project/go-dagaggregator-unixfs v0.2.0/go.mod h1:WTuJWgBQY0omnQqa8kRPT9O0Uj5wQOgslVMUuTeHdJ8= github.com/filecoin-project/go-data-transfer v1.14.0 h1:4pnfJk8FYtqcdAg+QRGzaz57seUC/Tz+HJgPuGB7zdg= github.com/filecoin-project/go-data-transfer v1.14.0/go.mod h1:wNJKhaLLYBJDM3VFvgvYi4iUjPa69pz/1Q5Q4HzX2wE= -github.com/filecoin-project/go-data-transfer/v2 v2.0.0-20220511223325-5253bfe075cd h1:kTMV9ZzuuNpThVEqzCrM1DGWwoSnORX0rHVlCTzOY7g= -github.com/filecoin-project/go-data-transfer/v2 v2.0.0-20220511223325-5253bfe075cd/go.mod h1:ORcs+LQ/6hRNYn+hBNcEaca5WPfnBaHO1ZbzccQFsso= +github.com/filecoin-project/go-data-transfer/v2 v2.0.0-20220603004528-681bfedccef1 h1:OeqAIz4wyLdkmjQbxSEEmj3tUA6fcH4vwmCXLMm50Mg= +github.com/filecoin-project/go-data-transfer/v2 v2.0.0-20220603004528-681bfedccef1/go.mod h1:CKpMVsGd15In1HPfW24jFK/TIf+98iFPQ0qh1LcxyB8= github.com/filecoin-project/go-ds-versioning v0.0.0-20211206185234-508abd7c2aff/go.mod h1:C9/l9PnB1+mwPa26BBVpCjG/XQCB0yj/q5CK2J8X1I4= github.com/filecoin-project/go-ds-versioning v0.1.1 h1:JiyBqaQlwC+UM0WhcBtVEeT3XrX59mQhT8U3p7nu86o= github.com/filecoin-project/go-ds-versioning v0.1.1/go.mod h1:C9/l9PnB1+mwPa26BBVpCjG/XQCB0yj/q5CK2J8X1I4= @@ -300,8 +309,9 @@ github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVB github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= github.com/frankban/quicktest v1.14.0/go.mod h1:NeW+ay9A/U67EYXNFA1nPE8e/tnQv/09mUdL/ijj8og= -github.com/frankban/quicktest v1.14.2 h1:SPb1KFFmM+ybpEjPUhCCkZOM5xlovT5UbrMvWnXyBns= github.com/frankban/quicktest v1.14.2/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= +github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= +github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= @@ -321,9 +331,11 @@ github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.1 h1:DX7uPQ4WgAWfoh+NGGlbJQswnYIVvz0SRlLS3rPZQDA= @@ -335,8 +347,9 @@ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/me github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= +github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -397,8 +410,9 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -437,8 +451,9 @@ github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB7 github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= @@ -481,8 +496,9 @@ github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/J github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= github.com/huin/goupnp v1.0.0/go.mod h1:n9v9KO1tAxYH82qOn+UTIFQDmx5n1Zxd/ClZDMX7Bnc= -github.com/huin/goupnp v1.0.2 h1:RfGLP+h3mvisuWEyybxNq5Eft3NWhHLPeUN72kpKZoI= github.com/huin/goupnp v1.0.2/go.mod h1:0dxJBVBHqTMjIUMkESDTNgOOx/Mw5wYIfyFmdzSamkM= +github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ= +github.com/huin/goupnp v1.0.3/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y= github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= @@ -518,10 +534,12 @@ github.com/ipfs/go-cid v0.0.5/go.mod h1:plgt+Y5MnOey4vO4UlUazGqdbEXuFYitED67Fexh github.com/ipfs/go-cid v0.0.6-0.20200501230655-7c82f3b81c00/go.mod h1:plgt+Y5MnOey4vO4UlUazGqdbEXuFYitED67FexhXog= github.com/ipfs/go-cid v0.0.6/go.mod h1:6Ux9z5e+HpkQdckYoX1PG/6xqKspzlEIR5SDmgqgC/I= github.com/ipfs/go-cid v0.0.7/go.mod h1:6Ux9z5e+HpkQdckYoX1PG/6xqKspzlEIR5SDmgqgC/I= -github.com/ipfs/go-cid v0.1.0 h1:YN33LQulcRHjfom/i25yoOZR4Telp1Hr/2RU3d0PnC0= github.com/ipfs/go-cid v0.1.0/go.mod h1:rH5/Xv83Rfy8Rw6xG+id3DYAMUVmem1MowoKwdXmN2o= -github.com/ipfs/go-cidutil v0.0.2 h1:CNOboQf1t7Qp0nuNh8QMmhJs0+Q//bRL1axtCnIB1Yo= +github.com/ipfs/go-cid v0.2.0 h1:01JTiihFq9en9Vz0lc0VDWvZe/uBonGpzo4THP0vcQ0= +github.com/ipfs/go-cid v0.2.0/go.mod h1:P+HXFDF4CVhaVayiEb4wkAy7zBHxBwsJyt0Y5U6MLro= github.com/ipfs/go-cidutil v0.0.2/go.mod h1:ewllrvrxG6AMYStla3GD7Cqn+XYSLqjK0vc+086tB6s= +github.com/ipfs/go-cidutil v0.1.0 h1:RW5hO7Vcf16dplUU60Hs0AKDkQAVPVplr7lk97CFL+Q= +github.com/ipfs/go-cidutil v0.1.0/go.mod h1:e7OEVBMIv9JaOxt9zaGEmAoSlXW9jdFZ5lP/0PwcfpA= github.com/ipfs/go-datastore v0.0.1/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE= github.com/ipfs/go-datastore v0.0.5/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE= github.com/ipfs/go-datastore v0.1.0/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE= @@ -645,8 +663,9 @@ github.com/ipfs/go-log/v2 v2.1.1/go.mod h1:2v2nsGfZsvvAJz13SyFzf9ObaqwHiHxsPLEHn github.com/ipfs/go-log/v2 v2.1.2-0.20200626104915-0016c0b4b3e4/go.mod h1:2v2nsGfZsvvAJz13SyFzf9ObaqwHiHxsPLEHntrv9KM= github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g= github.com/ipfs/go-log/v2 v2.3.0/go.mod h1:QqGoj30OTpnKaG/LKTGTxoP2mmQtjVMEnK72gynbe/g= -github.com/ipfs/go-log/v2 v2.5.0 h1:+MhAooFd9XZNvR0i9FriKW6HB0ql7HNXUuflWtc0dd4= github.com/ipfs/go-log/v2 v2.5.0/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI= +github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY= +github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI= github.com/ipfs/go-merkledag v0.0.6/go.mod h1:QYPdnlvkOg7GnQRofu9XZimC5ZW5Wi3bKys/4GQQfto= github.com/ipfs/go-merkledag v0.2.3/go.mod h1:SQiXrtSts3KGNmgOzMICy5c0POOpUNQLvB3ClKnBAlk= github.com/ipfs/go-merkledag v0.2.4/go.mod h1:SQiXrtSts3KGNmgOzMICy5c0POOpUNQLvB3ClKnBAlk= @@ -706,8 +725,10 @@ github.com/ipld/go-ipld-prime v0.14.1/go.mod h1:QcE4Y9n/ZZr8Ijg5bGPT0GqYWgZ1704n github.com/ipld/go-ipld-prime v0.14.2/go.mod h1:QcE4Y9n/ZZr8Ijg5bGPT0GqYWgZ1704nH0RDcQtgTP0= github.com/ipld/go-ipld-prime v0.14.3-0.20211207234443-319145880958/go.mod h1:QcE4Y9n/ZZr8Ijg5bGPT0GqYWgZ1704nH0RDcQtgTP0= github.com/ipld/go-ipld-prime v0.14.4/go.mod h1:QcE4Y9n/ZZr8Ijg5bGPT0GqYWgZ1704nH0RDcQtgTP0= -github.com/ipld/go-ipld-prime v0.16.0 h1:RS5hhjB/mcpeEPJvfyj0qbOj/QL+/j05heZ0qa97dVo= github.com/ipld/go-ipld-prime v0.16.0/go.mod h1:axSCuOCBPqrH+gvXr2w9uAOulJqBPhHPT2PjoiiU1qA= +github.com/ipld/go-ipld-prime v0.16.1-0.20220519105356-1f1151b69dba/go.mod h1:/bZAYlzT7SJS4UV0al4q67xgKvenm5hKrPCa2wNGN1U= +github.com/ipld/go-ipld-prime v0.17.1-0.20220624062450-534ccf82237d h1:aY4pwcHVHonF+edc4gzRr3HA7vAaindLXz7InFIUgiY= +github.com/ipld/go-ipld-prime v0.17.1-0.20220624062450-534ccf82237d/go.mod h1:aYcKm5TIvGfY8P3QBKz/2gKcLxzJ1zDaD+o0bOowhgs= github.com/ipld/go-ipld-prime-proto v0.0.0-20191113031812-e32bd156a1e5/go.mod h1:gcvzoEDBjwycpXt3LBE061wT9f46szXGHAmj9uoP6fU= github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20211210234204-ce2a1c70cd73 h1:TsyATB2ZRRQGTwafJdgEUQkmjOExRV0DNokcihZxbnQ= github.com/ipld/go-ipld-prime/storage/bsadapter v0.0.0-20211210234204-ce2a1c70cd73/go.mod h1:2PJ0JgxyB08t0b2WKrcuqI3di0V+5n6RS/LTUJhkoxY= @@ -742,6 +763,7 @@ github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= @@ -756,12 +778,14 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= +github.com/klauspost/compress v1.15.1 h1:y9FcTHGyrebwfP0ZZqFiaxTaiDnUrGkJkI+f583BL1A= +github.com/klauspost/compress v1.15.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.0.6/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.0.12 h1:p9dKCg8i4gmOxtv35DvrYoWqYzQrvEVdjQ762Y0OqZE= +github.com/klauspost/cpuid/v2 v2.0.12/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/koron/go-ssdp v0.0.0-20180514024734-4a0ed625a78b/go.mod h1:5Ky9EC2xfoUKUor0Hjgi2BJhCSXJfMOFlmyYrVKGQMk= @@ -817,8 +841,8 @@ github.com/libp2p/go-libp2p v0.14.4/go.mod h1:EIRU0Of4J5S8rkockZM7eJp2S0UrCyi55m github.com/libp2p/go-libp2p v0.16.0/go.mod h1:ump42BsirwAWxKzsCiFnTtN1Yc+DuPu76fyMX364/O4= github.com/libp2p/go-libp2p v0.18.0-rc1/go.mod h1:RgYlH7IIWHXREimC92bw5Lg1V2R5XmSzuLHb5fTnr+8= github.com/libp2p/go-libp2p v0.18.0-rc5/go.mod h1:aZPS5l84bDvCvP4jkyEUT/J6YOpUq33Fgqrs3K59mpI= -github.com/libp2p/go-libp2p v0.18.0 h1:moKKKG875KNGsCjZxTIFB75ihHiVjFeWg5I4aR1pDLk= -github.com/libp2p/go-libp2p v0.18.0/go.mod h1:+veaZ9z1SZQhmc5PW78jvnnxZ89Mgvmh4cggO11ETmw= +github.com/libp2p/go-libp2p v0.19.4 h1:50YL0YwPhWKDd+qbZQDEdnsmVAAkaCQrWUjpdHv4hNA= +github.com/libp2p/go-libp2p v0.19.4/go.mod h1:MIt8y481VDhUe4ErWi1a4bvt/CjjFfOq6kZTothWIXY= github.com/libp2p/go-libp2p-asn-util v0.0.0-20200825225859-85005c6cf052/go.mod h1:nRMRTab+kZuk0LnKZpxhOVH/ndsdr2Nr//Zltc/vwgo= github.com/libp2p/go-libp2p-asn-util v0.1.0 h1:rABPCO77SjdbJ/eJ/ynIo8vWICy1VEnL5JAxJbQLo1E= github.com/libp2p/go-libp2p-asn-util v0.1.0/go.mod h1:wu+AnM9Ii2KgO5jMmS1rz9dvzTdj8BXqsPR9HR0XB7I= @@ -844,7 +868,6 @@ github.com/libp2p/go-libp2p-circuit v0.2.1/go.mod h1:BXPwYDN5A8z4OEY9sOfr2DUQMLQ github.com/libp2p/go-libp2p-circuit v0.4.0/go.mod h1:t/ktoFIUzM6uLQ+o1G6NuBl2ANhBKN9Bc8jRIk31MoA= github.com/libp2p/go-libp2p-circuit v0.6.0 h1:rw/HlhmUB3OktS/Ygz6+2XABOmHKzZpPUuMNUMosj8w= github.com/libp2p/go-libp2p-circuit v0.6.0/go.mod h1:kB8hY+zCpMeScyvFrKrGicRdid6vNXbunKE4rXATZ0M= -github.com/libp2p/go-libp2p-connmgr v0.2.4 h1:TMS0vc0TCBomtQJyWr7fYxcVYYhx+q/2gF++G5Jkl/w= github.com/libp2p/go-libp2p-connmgr v0.2.4/go.mod h1:YV0b/RIm8NGPnnNWM7hG9Q38OeQiQfKhHCCs1++ufn0= github.com/libp2p/go-libp2p-core v0.0.1/go.mod h1:g/VxnTZ/1ygHxH3dKok7Vno1VfpvGcGip57wjTU4fco= github.com/libp2p/go-libp2p-core v0.0.2/go.mod h1:9dAcntw/n46XycV4RnlBq3BpgrmyUi9LuoTNdPrbUco= @@ -876,8 +899,9 @@ github.com/libp2p/go-libp2p-core v0.9.0/go.mod h1:ESsbz31oC3C1AvMJoGx26RTuCkNhmk github.com/libp2p/go-libp2p-core v0.10.0/go.mod h1:ECdxehoYosLYHgDDFa2N4yE8Y7aQRAMf0sX9mf2sbGg= github.com/libp2p/go-libp2p-core v0.11.0/go.mod h1:ECdxehoYosLYHgDDFa2N4yE8Y7aQRAMf0sX9mf2sbGg= github.com/libp2p/go-libp2p-core v0.12.0/go.mod h1:ECdxehoYosLYHgDDFa2N4yE8Y7aQRAMf0sX9mf2sbGg= -github.com/libp2p/go-libp2p-core v0.14.0 h1:0kYSgiK/D7Eo28GTuRXo5YHsWwAisVpFCqCVPUd/vJs= github.com/libp2p/go-libp2p-core v0.14.0/go.mod h1:tLasfcVdTXnixsLB0QYaT1syJOhsbrhG7q6pGrHtBg8= +github.com/libp2p/go-libp2p-core v0.15.1 h1:0RY+Mi/ARK9DgG1g9xVQLb8dDaaU8tCePMtGALEfBnM= +github.com/libp2p/go-libp2p-core v0.15.1/go.mod h1:agSaboYM4hzB1cWekgVReqV5M4g5M+2eNNejV+1EEhs= github.com/libp2p/go-libp2p-crypto v0.0.1/go.mod h1:yJkNyDmO341d5wwXxDUGO0LykUVT72ImHNUqh5D/dBE= github.com/libp2p/go-libp2p-crypto v0.0.2/go.mod h1:eETI5OUfBnvARGOHrJz2eWNyTUxEGZnBxMcbUjfIj4I= github.com/libp2p/go-libp2p-crypto v0.1.0/go.mod h1:sPUokVISZiy+nNuTTH/TY+leRSxnFj/2GLjtOTW90hI= @@ -914,8 +938,6 @@ github.com/libp2p/go-libp2p-mplex v0.3.0/go.mod h1:l9QWxRbbb5/hQMECEb908GbS9Sm2U github.com/libp2p/go-libp2p-mplex v0.4.0/go.mod h1:yCyWJE2sc6TBTnFpjvLuEJgTSw/u+MamvzILKdX7asw= github.com/libp2p/go-libp2p-mplex v0.4.1/go.mod h1:cmy+3GfqfM1PceHTLL7zQzAAYaryDu6iPSC+CIb094g= github.com/libp2p/go-libp2p-mplex v0.5.0/go.mod h1:eLImPJLkj3iG5t5lq68w3Vm5NAQ5BcKwrrb2VmOYb3M= -github.com/libp2p/go-libp2p-mplex v0.6.0 h1:5ubK4/vLE2JkogKlJ2JLeXcSfA6qY6mE2HMJV9ve/Sk= -github.com/libp2p/go-libp2p-mplex v0.6.0/go.mod h1:i3usuPrBbh9FD2fLZjGpotyNkwr42KStYZQY7BeTiu4= github.com/libp2p/go-libp2p-nat v0.0.4/go.mod h1:N9Js/zVtAXqaeT99cXgTV9e75KpnWCvVOiGzlcHmBbY= github.com/libp2p/go-libp2p-nat v0.0.5/go.mod h1:1qubaE5bTZMJE+E/uu2URroMbzdubFz1ChgiN79yKPE= github.com/libp2p/go-libp2p-nat v0.0.6/go.mod h1:iV59LVhB3IkFvS6S6sauVTSOrNEANnINbI/fkaLimiw= @@ -928,8 +950,9 @@ github.com/libp2p/go-libp2p-netutil v0.1.0 h1:zscYDNVEcGxyUpMd0JReUZTrpMfia8PmLK github.com/libp2p/go-libp2p-netutil v0.1.0/go.mod h1:3Qv/aDqtMLTUyQeundkKsA+YCThNdbQD54k3TqjpbFU= github.com/libp2p/go-libp2p-noise v0.1.1/go.mod h1:QDFLdKX7nluB7DEnlVPbz7xlLHdwHFA9HiohJRr3vwM= github.com/libp2p/go-libp2p-noise v0.2.0/go.mod h1:IEbYhBBzGyvdLBoxxULL/SGbJARhUeqlO8lVSREYu2Q= -github.com/libp2p/go-libp2p-noise v0.3.0 h1:NCVH7evhVt9njbTQshzT7N1S3Q6fjj9M11FCgfH5+cA= github.com/libp2p/go-libp2p-noise v0.3.0/go.mod h1:JNjHbociDJKHD64KTkzGnzqJ0FEV5gHJa6AB00kbCNQ= +github.com/libp2p/go-libp2p-noise v0.4.0 h1:khcMsGhHNdGqKE5LDLrnHwZvdGVMsrnD4GTkTWkwmLU= +github.com/libp2p/go-libp2p-noise v0.4.0/go.mod h1:BzzY5pyzCYSyJbQy9oD8z5oP2idsafjt4/X42h9DjZU= github.com/libp2p/go-libp2p-peer v0.0.1/go.mod h1:nXQvOBbwVqoP+T5Y5nCjeH4sP9IX/J0AMzcDUVruVoo= github.com/libp2p/go-libp2p-peer v0.1.1/go.mod h1:jkF12jGB4Gk/IOo+yomm+7oLWxF278F7UnrYUQ1Q8es= github.com/libp2p/go-libp2p-peer v0.2.0/go.mod h1:RCffaCvUyW2CJmG2gAWVqwePwW7JMgxjsHm7+J5kjWY= @@ -960,8 +983,9 @@ github.com/libp2p/go-libp2p-quic-transport v0.11.2/go.mod h1:wlanzKtIh6pHrq+0U3p github.com/libp2p/go-libp2p-quic-transport v0.13.0/go.mod h1:39/ZWJ1TW/jx1iFkKzzUg00W6tDJh73FC0xYudjr7Hc= github.com/libp2p/go-libp2p-quic-transport v0.15.0/go.mod h1:wv4uGwjcqe8Mhjj7N/Ic0aKjA+/10UnMlSzLO0yRpYQ= github.com/libp2p/go-libp2p-quic-transport v0.16.0/go.mod h1:1BXjVMzr+w7EkPfiHkKnwsWjPjtfaNT0q8RS3tGDvEQ= -github.com/libp2p/go-libp2p-quic-transport v0.16.1 h1:N/XqYXHurphPLDfXYhll8NyqzdZYQqAF4GIr7+SmLV8= github.com/libp2p/go-libp2p-quic-transport v0.16.1/go.mod h1:1BXjVMzr+w7EkPfiHkKnwsWjPjtfaNT0q8RS3tGDvEQ= +github.com/libp2p/go-libp2p-quic-transport v0.17.0 h1:yFh4Gf5MlToAYLuw/dRvuzYd1EnE2pX3Lq1N6KDiWRQ= +github.com/libp2p/go-libp2p-quic-transport v0.17.0/go.mod h1:x4pw61P3/GRCcSLypcQJE/Q2+E9f4X+5aRcZLXf20LM= github.com/libp2p/go-libp2p-record v0.0.1/go.mod h1:grzqg263Rug/sRex85QrDOLntdFAymLDLm7lxMgU79Q= github.com/libp2p/go-libp2p-record v0.1.0/go.mod h1:ujNc8iuE5dlKWVy6wuL6dd58t0n7xI4hAIl8pE6wu5Q= github.com/libp2p/go-libp2p-record v0.1.1/go.mod h1:VRgKajOyMVgP/F0L5g3kH7SVskp17vFi2xheb5uMJtg= @@ -970,8 +994,8 @@ github.com/libp2p/go-libp2p-record v0.1.3 h1:R27hoScIhQf/A8XJZ8lYpnqh9LatJ5YbHs2 github.com/libp2p/go-libp2p-record v0.1.3/go.mod h1:yNUff/adKIfPnYQXgp6FQmNu3gLJ6EMg7+/vv2+9pY4= github.com/libp2p/go-libp2p-resource-manager v0.1.0/go.mod h1:wJPNjeE4XQlxeidwqVY5G6DLOKqFK33u2n8blpl0I6Y= github.com/libp2p/go-libp2p-resource-manager v0.1.3/go.mod h1:wJPNjeE4XQlxeidwqVY5G6DLOKqFK33u2n8blpl0I6Y= -github.com/libp2p/go-libp2p-resource-manager v0.1.5 h1:7J6t9KLFS0MxXDTfqA6rwfVCZl/yLQnXW5LpZjHAANI= -github.com/libp2p/go-libp2p-resource-manager v0.1.5/go.mod h1:wJPNjeE4XQlxeidwqVY5G6DLOKqFK33u2n8blpl0I6Y= +github.com/libp2p/go-libp2p-resource-manager v0.2.1 h1:/0yqQQ4oT+3fEhUGGP2PhuIhdv10+pu5jLhvFNfUx/w= +github.com/libp2p/go-libp2p-resource-manager v0.2.1/go.mod h1:K+eCkiapf+ey/LADO4TaMpMTP9/Qde/uLlrnRqV4PLQ= github.com/libp2p/go-libp2p-routing v0.0.1/go.mod h1:N51q3yTr4Zdr7V8Jt2JIktVU+3xBBylx1MZeVA6t1Ys= github.com/libp2p/go-libp2p-routing-helpers v0.2.3/go.mod h1:795bh+9YeoFl99rMASoiVgHdi5bjack0N1+AFAdbvBw= github.com/libp2p/go-libp2p-secio v0.0.3/go.mod h1:hS7HQ00MgLhRO/Wyu1bTX6ctJKhVpm+j2/S2A5UqYb0= @@ -1005,12 +1029,14 @@ github.com/libp2p/go-libp2p-testing v0.4.0/go.mod h1:Q+PFXYoiYFN5CAEG2w3gLPEzotl github.com/libp2p/go-libp2p-testing v0.4.2/go.mod h1:Q+PFXYoiYFN5CAEG2w3gLPEzotlKsNSbKQ/lImlOWF0= github.com/libp2p/go-libp2p-testing v0.5.0/go.mod h1:QBk8fqIL1XNcno/l3/hhaIEn4aLRijpYOR+zVjjlh+A= github.com/libp2p/go-libp2p-testing v0.7.0/go.mod h1:OLbdn9DbgdMwv00v+tlp1l3oe2Cl+FAjoWIA2pa0X6E= -github.com/libp2p/go-libp2p-testing v0.8.0 h1:/te8SOIyj5sGH5Jr1Uoo+qYB00aK8O4+yHGzLgfE3kc= -github.com/libp2p/go-libp2p-testing v0.8.0/go.mod h1:gRdsNxQSxAZowTgcLY7CC33xPmleZzoBpqSYbWenqPc= +github.com/libp2p/go-libp2p-testing v0.9.0/go.mod h1:Td7kbdkWqYTJYQGTwzlgXwaqldraIanyjuRiAbK/XQU= +github.com/libp2p/go-libp2p-testing v0.9.2 h1:dCpODRtRaDZKF8HXT9qqqgON+OMEB423Knrgeod8j84= +github.com/libp2p/go-libp2p-testing v0.9.2/go.mod h1:Td7kbdkWqYTJYQGTwzlgXwaqldraIanyjuRiAbK/XQU= github.com/libp2p/go-libp2p-tls v0.1.3/go.mod h1:wZfuewxOndz5RTnCAxFliGjvYSDA40sKitV4c50uI1M= github.com/libp2p/go-libp2p-tls v0.3.0/go.mod h1:fwF5X6PWGxm6IDRwF3V8AVCCj/hOd5oFlg+wo2FxJDY= -github.com/libp2p/go-libp2p-tls v0.3.1 h1:lsE2zYte+rZCEOHF72J1Fg3XK3dGQyKvI6i5ehJfEp0= github.com/libp2p/go-libp2p-tls v0.3.1/go.mod h1:fwF5X6PWGxm6IDRwF3V8AVCCj/hOd5oFlg+wo2FxJDY= +github.com/libp2p/go-libp2p-tls v0.4.1 h1:1ByJUbyoMXvYXDoW6lLsMxqMViQNXmt+CfQqlnCpY+M= +github.com/libp2p/go-libp2p-tls v0.4.1/go.mod h1:EKCixHEysLNDlLUoKxv+3f/Lp90O2EXNjTr0UQDnrIw= github.com/libp2p/go-libp2p-transport v0.0.1/go.mod h1:UzbUs9X+PHOSw7S3ZmeOxfnwaQY5vGDzZmKPod3N3tk= github.com/libp2p/go-libp2p-transport v0.0.5/go.mod h1:StoY3sx6IqsP6XKoabsPnHCwqKXWUMWU7Rfcsubee/A= github.com/libp2p/go-libp2p-transport-upgrader v0.0.4/go.mod h1:RGq+tupk+oj7PzL2kn/m1w6YXxcIAYJYeI90h6BGgUc= @@ -1042,8 +1068,9 @@ github.com/libp2p/go-libp2p-yamux v0.5.4/go.mod h1:tfrXbyaTqqSU654GTvK3ocnSZL3Bu github.com/libp2p/go-libp2p-yamux v0.6.0/go.mod h1:MRhd6mAYnFRnSISp4M8i0ClV/j+mWHo2mYLifWGw33k= github.com/libp2p/go-libp2p-yamux v0.8.0/go.mod h1:yTkPgN2ib8FHyU1ZcVD7aelzyAqXXwEPbyx+aSKm9h8= github.com/libp2p/go-libp2p-yamux v0.8.1/go.mod h1:rUozF8Jah2dL9LLGyBaBeTQeARdwhefMCTQVQt6QobE= -github.com/libp2p/go-libp2p-yamux v0.8.2 h1:6GKWntresp0TFxMP/oSoH96nV8XKJRdynXsdp43dn0Y= github.com/libp2p/go-libp2p-yamux v0.8.2/go.mod h1:rUozF8Jah2dL9LLGyBaBeTQeARdwhefMCTQVQt6QobE= +github.com/libp2p/go-libp2p-yamux v0.9.1 h1:oplewiRix8s45SOrI30rCPZG5mM087YZp+VYhXAh4+c= +github.com/libp2p/go-libp2p-yamux v0.9.1/go.mod h1:wRc6wvyxQINFcKe7daL4BeQ02Iyp+wxyC8WCNfngBrA= github.com/libp2p/go-maddr-filter v0.0.1/go.mod h1:6eT12kSQMA9x2pvFQa+xesMKUBlj9VImZbj3B9FBH/Q= github.com/libp2p/go-maddr-filter v0.0.4/go.mod h1:6eT12kSQMA9x2pvFQa+xesMKUBlj9VImZbj3B9FBH/Q= github.com/libp2p/go-maddr-filter v0.0.5/go.mod h1:Jk+36PMfIqCJhAnaASRH83bdAvfDRp/w6ENFaC9bG+M= @@ -1056,14 +1083,13 @@ github.com/libp2p/go-mplex v0.1.2/go.mod h1:Xgz2RDCi3co0LeZfgjm4OgUF15+sVR8SRcu3 github.com/libp2p/go-mplex v0.2.0/go.mod h1:0Oy/A9PQlwBytDRp4wSkFnzHYDKcpLot35JQ6msjvYQ= github.com/libp2p/go-mplex v0.3.0/go.mod h1:0Oy/A9PQlwBytDRp4wSkFnzHYDKcpLot35JQ6msjvYQ= github.com/libp2p/go-mplex v0.4.0/go.mod h1:y26Lx+wNVtMYMaPu300Cbot5LkEZ4tJaNYeHeT9dh6E= -github.com/libp2p/go-mplex v0.6.0 h1:5kKp029zrsLVJT5q6ASt4LwuZFxj3B13wXXaGmFrWg0= -github.com/libp2p/go-mplex v0.6.0/go.mod h1:y26Lx+wNVtMYMaPu300Cbot5LkEZ4tJaNYeHeT9dh6E= github.com/libp2p/go-msgio v0.0.2/go.mod h1:63lBBgOTDKQL6EWazRMCwXsEeEeK9O2Cd+0+6OOuipQ= github.com/libp2p/go-msgio v0.0.3/go.mod h1:63lBBgOTDKQL6EWazRMCwXsEeEeK9O2Cd+0+6OOuipQ= github.com/libp2p/go-msgio v0.0.4/go.mod h1:63lBBgOTDKQL6EWazRMCwXsEeEeK9O2Cd+0+6OOuipQ= github.com/libp2p/go-msgio v0.0.6/go.mod h1:4ecVB6d9f4BDSL5fqvPiC4A3KivjWn+Venn/1ALLMWA= -github.com/libp2p/go-msgio v0.1.0 h1:8Q7g/528ivAlfXTFWvWhVjTE8XG8sDTkRUKPYh9+5Q8= github.com/libp2p/go-msgio v0.1.0/go.mod h1:eNlv2vy9V2X/kNldcZ+SShFE++o2Yjxwx6RAYsmgJnE= +github.com/libp2p/go-msgio v0.2.0 h1:W6shmB+FeynDrUVl2dgFQvzfBZcXiyqY4VmpQLu9FqU= +github.com/libp2p/go-msgio v0.2.0/go.mod h1:dBVM1gW3Jk9XqHkU4eKdGvVHdLa51hoGfll6jMJMSlY= github.com/libp2p/go-nat v0.0.3/go.mod h1:88nUEt0k0JD45Bk93NIwDqjlhiOwOoV36GchpcVc1yI= github.com/libp2p/go-nat v0.0.4/go.mod h1:Nmw50VAvKuk38jUBcmNh6p9lUJLoODbJRvYAa/+KSDo= github.com/libp2p/go-nat v0.0.5/go.mod h1:B7NxsVNPZmRLvMOwiEO1scOSyjA56zxYAGv1yQgRkEU= @@ -1140,8 +1166,10 @@ github.com/libp2p/go-yamux/v2 v2.1.1/go.mod h1:3So6P6TV6r75R9jiBpiIKgU/66lOarCZj github.com/libp2p/go-yamux/v2 v2.2.0/go.mod h1:3So6P6TV6r75R9jiBpiIKgU/66lOarCZjqROGxzPpPQ= github.com/libp2p/go-yamux/v2 v2.3.0/go.mod h1:iTU+lOIn/2h0AgKcL49clNTwfEw+WSfDYrXe05EyKIs= github.com/libp2p/go-yamux/v3 v3.0.1/go.mod h1:s2LsDhHbh+RfCsQoICSYt58U2f8ijtPANFD8BmE74Bo= -github.com/libp2p/go-yamux/v3 v3.0.2 h1:LW0q5+A1Wy0npEsPJP9wmare2NH4ohNluN5EWVwv2mE= github.com/libp2p/go-yamux/v3 v3.0.2/go.mod h1:s2LsDhHbh+RfCsQoICSYt58U2f8ijtPANFD8BmE74Bo= +github.com/libp2p/go-yamux/v3 v3.1.1/go.mod h1:jeLEQgLXqE2YqX1ilAClIfCMDY+0uXQUKmmb/qp0gT4= +github.com/libp2p/go-yamux/v3 v3.1.2 h1:lNEy28MBk1HavUAlzKgShp+F6mn/ea1nDYWftZhFW9Q= +github.com/libp2p/go-yamux/v3 v3.1.2/go.mod h1:jeLEQgLXqE2YqX1ilAClIfCMDY+0uXQUKmmb/qp0gT4= github.com/libp2p/zeroconf/v2 v2.1.1/go.mod h1:fuJqLnUwZTshS3U/bMRJ3+ow/v9oid1n0DmyYyNO1Xs= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= @@ -1149,8 +1177,10 @@ github.com/lucas-clemente/quic-go v0.19.3/go.mod h1:ADXpNbTQjq1hIzCpB+y/k5iz4n4z github.com/lucas-clemente/quic-go v0.21.2/go.mod h1:vF5M1XqhBAHgbjKcJOXY3JZz3GP0T3FQhz/uyOUS38Q= github.com/lucas-clemente/quic-go v0.23.0/go.mod h1:paZuzjXCE5mj6sikVLMvqXk8lJV2AsqtJ6bDhjEfxx0= github.com/lucas-clemente/quic-go v0.24.0/go.mod h1:paZuzjXCE5mj6sikVLMvqXk8lJV2AsqtJ6bDhjEfxx0= -github.com/lucas-clemente/quic-go v0.25.0 h1:K+X9Gvd7JXsOHtU0N2icZ2Nw3rx82uBej3mP4CLgibc= github.com/lucas-clemente/quic-go v0.25.0/go.mod h1:YtzP8bxRVCBlO77yRanE264+fY/T2U9ZlW1AaHOsMOg= +github.com/lucas-clemente/quic-go v0.27.0/go.mod h1:AzgQoPda7N+3IqMMMkywBKggIFo2KT6pfnlrQ2QieeI= +github.com/lucas-clemente/quic-go v0.27.1 h1:sOw+4kFSVrdWOYmUjufQ9GBVPqZ+tu+jMtXxXNmRJyk= +github.com/lucas-clemente/quic-go v0.27.1/go.mod h1:AzgQoPda7N+3IqMMMkywBKggIFo2KT6pfnlrQ2QieeI= github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= @@ -1161,13 +1191,16 @@ github.com/marten-seemann/qtls v0.10.0/go.mod h1:UvMd1oaYDACI99/oZUYLzMCkBXQVT0a github.com/marten-seemann/qtls-go1-15 v0.1.1/go.mod h1:GyFwywLKkRt+6mfU99csTEY1joMZz5vmB1WNZH3P81I= github.com/marten-seemann/qtls-go1-15 v0.1.4/go.mod h1:GyFwywLKkRt+6mfU99csTEY1joMZz5vmB1WNZH3P81I= github.com/marten-seemann/qtls-go1-15 v0.1.5/go.mod h1:GyFwywLKkRt+6mfU99csTEY1joMZz5vmB1WNZH3P81I= -github.com/marten-seemann/qtls-go1-16 v0.1.4 h1:xbHbOGGhrenVtII6Co8akhLEdrawwB2iHl5yhJRpnco= github.com/marten-seemann/qtls-go1-16 v0.1.4/go.mod h1:gNpI2Ol+lRS3WwSOtIUUtRwZEQMXjYK+dQSBFbethAk= +github.com/marten-seemann/qtls-go1-16 v0.1.5 h1:o9JrYPPco/Nukd/HpOHMHZoBDXQqoNtUCmny98/1uqQ= +github.com/marten-seemann/qtls-go1-16 v0.1.5/go.mod h1:gNpI2Ol+lRS3WwSOtIUUtRwZEQMXjYK+dQSBFbethAk= github.com/marten-seemann/qtls-go1-17 v0.1.0-rc.1/go.mod h1:fz4HIxByo+LlWcreM4CZOYNuz3taBQ8rN2X6FqvaWo8= -github.com/marten-seemann/qtls-go1-17 v0.1.0 h1:P9ggrs5xtwiqXv/FHNwntmuLMNq3KaSIG93AtAZ48xk= github.com/marten-seemann/qtls-go1-17 v0.1.0/go.mod h1:fz4HIxByo+LlWcreM4CZOYNuz3taBQ8rN2X6FqvaWo8= -github.com/marten-seemann/qtls-go1-18 v0.1.0-beta.1 h1:EnzzN9fPUkUck/1CuY1FlzBaIYMoiBsdwTNmNGkwUUM= +github.com/marten-seemann/qtls-go1-17 v0.1.1 h1:DQjHPq+aOzUeh9/lixAGunn6rIOQyWChPSI4+hgW7jc= +github.com/marten-seemann/qtls-go1-17 v0.1.1/go.mod h1:C2ekUKcDdz9SDWxec1N/MvcXBpaX9l3Nx67XaR84L5s= github.com/marten-seemann/qtls-go1-18 v0.1.0-beta.1/go.mod h1:PUhIQk19LoFt2174H4+an8TYvWOGjb/hHwphBeaDHwI= +github.com/marten-seemann/qtls-go1-18 v0.1.1 h1:qp7p7XXUFL7fpBvSS1sWD+uSqPvzNQK43DH+/qEkj0Y= +github.com/marten-seemann/qtls-go1-18 v0.1.1/go.mod h1:mJttiymBAByA49mhlNZZGrH5u1uXYZJ+RW28Py7f4m4= github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd h1:br0buuQ854V8u83wA0rVZ8ttrq5CpaPZdvrK0LP2lOk= github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd/go.mod h1:QuCEs1Nt24+FYQEqAAncTDPJIuGs+LxK1MCiFL25pMU= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= @@ -1193,9 +1226,9 @@ github.com/miekg/dns v1.1.12/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3N github.com/miekg/dns v1.1.28/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= github.com/miekg/dns v1.1.31/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= -github.com/miekg/dns v1.1.43 h1:JKfpVSCB84vrAmHzyrsxB5NAr5kLoMXZArPSw7Qlgyg= github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4= -github.com/mikioh/tcp v0.0.0-20190314235350-803a9b46060c h1:bzE/A84HN25pxAuk9Eej1Kz9OUelF97nAc82bDquQI8= +github.com/miekg/dns v1.1.48 h1:Ucfr7IIVyMBz4lRE8qmGUuZ4Wt3/ZGu9hmcMT3Uu4tQ= +github.com/miekg/dns v1.1.48/go.mod h1:e3IlAVfNqAllflbibAZEWOXOQ+Ynzk/dDozDxY7XnME= github.com/mikioh/tcp v0.0.0-20190314235350-803a9b46060c/go.mod h1:0SQS9kMwD2VsyFEB++InYyBJroV/FRmBgcydeSUcJms= github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b h1:z78hV3sbSMAUoyUMM0I83AUIT6Hu17AWfgjzIbtrYFc= github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b/go.mod h1:lxPUiZwKoFL8DUUmalo2yJJUCxbPKtm8OKfqr2/FTNU= @@ -1222,14 +1255,16 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= github.com/mr-tron/base58 v1.1.1/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mr-tron/base58 v1.1.3/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= -github.com/multiformats/go-base32 v0.0.3 h1:tw5+NhuwaOjJCC5Pp82QuXbrmLzWg7uxlMFp8Nq/kkI= github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL8NSQj0zQ5Nz/AA= +github.com/multiformats/go-base32 v0.0.4 h1:+qMh4a2f37b4xTNs6mqitDinryCI+tfO2dRVMN9mjSE= +github.com/multiformats/go-base32 v0.0.4/go.mod h1:jNLFzjPZtp3aIARHbJRZIaPuspdH0J6q39uUM5pnABM= github.com/multiformats/go-base36 v0.1.0 h1:JR6TyF7JjGd3m6FbLU2cOxhC0Li8z8dLNGQ89tUg4F4= github.com/multiformats/go-base36 v0.1.0/go.mod h1:kFGE83c6s80PklsHO9sRn2NCoffoRdUUOENyW/Vv6sM= github.com/multiformats/go-multiaddr v0.0.1/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lgmoS58qz/pzqmAxV44= @@ -1272,8 +1307,9 @@ github.com/multiformats/go-multicodec v0.3.0/go.mod h1:qGGaQmioCDh+TeFOnxrbU0DaI github.com/multiformats/go-multicodec v0.3.1-0.20210902112759-1539a079fd61/go.mod h1:1Hj/eHRaVWSXiSNNfcEPcwZleTmdNP81xlxDLnWU9GQ= github.com/multiformats/go-multicodec v0.3.1-0.20211210143421-a526f306ed2c/go.mod h1:1Hj/eHRaVWSXiSNNfcEPcwZleTmdNP81xlxDLnWU9GQ= github.com/multiformats/go-multicodec v0.4.0/go.mod h1:1Hj/eHRaVWSXiSNNfcEPcwZleTmdNP81xlxDLnWU9GQ= -github.com/multiformats/go-multicodec v0.4.1 h1:BSJbf+zpghcZMZrwTYBGwy0CPcVZGWiC72Cp8bBd4R4= github.com/multiformats/go-multicodec v0.4.1/go.mod h1:1Hj/eHRaVWSXiSNNfcEPcwZleTmdNP81xlxDLnWU9GQ= +github.com/multiformats/go-multicodec v0.5.0 h1:EgU6cBe/D7WRwQb1KmnBvU7lrcFGMggZVTPtOW9dDHs= +github.com/multiformats/go-multicodec v0.5.0/go.mod h1:DiY2HFaEp5EhEXb/iYzVAunmyX/aSFMxq2KMKfWEues= github.com/multiformats/go-multihash v0.0.1/go.mod h1:w/5tugSrLEbWqlcgJabL3oHFKTwfvkofsjW2Qa1ct4U= github.com/multiformats/go-multihash v0.0.5/go.mod h1:lt/HCbqlQwlPBz7lv0sQCdtfcMtlJvakRUn/0Ual8po= github.com/multiformats/go-multihash v0.0.8/go.mod h1:YSLudS+Pi8NHE7o6tb3D8vrpKa63epEDmG8nTduyAew= @@ -1291,8 +1327,9 @@ github.com/multiformats/go-multistream v0.1.0/go.mod h1:fJTiDfXJVmItycydCnNx4+wS github.com/multiformats/go-multistream v0.1.1/go.mod h1:KmHZ40hzVxiaiwlj3MEbYgK9JFk2/9UktWZAF54Du38= github.com/multiformats/go-multistream v0.2.0/go.mod h1:5GZPQZbkWOLOn3J2y4Y99vVW7vOfsAflxARk3x14o6k= github.com/multiformats/go-multistream v0.2.1/go.mod h1:5GZPQZbkWOLOn3J2y4Y99vVW7vOfsAflxARk3x14o6k= -github.com/multiformats/go-multistream v0.2.2 h1:TCYu1BHTDr1F/Qm75qwYISQdzGcRdC21nFgQW7l7GBo= github.com/multiformats/go-multistream v0.2.2/go.mod h1:UIcnm7Zuo8HKG+HkWgfQsGL+/MIEhyTqbODbIUwSXKs= +github.com/multiformats/go-multistream v0.3.0 h1:yX1v4IWseLPmr0rmnDo148wWJbNx40JxBZGmQb5fUP4= +github.com/multiformats/go-multistream v0.3.0/go.mod h1:ODRoqamLUsETKS9BNcII4gcRsJBU5VAwRIv7O39cEXg= github.com/multiformats/go-varint v0.0.1/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= github.com/multiformats/go-varint v0.0.2/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= github.com/multiformats/go-varint v0.0.5/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= @@ -1322,15 +1359,15 @@ github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0 github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E= -github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= +github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.13.0 h1:7lLHu94wT9Ij0o6EWWclhu0aOh32VxhkwEJvzuWPeak= github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/runtime-spec v1.0.2 h1:UfAcuLBJB9Coz72x1hgl8O5RVzTdNiaglX6v2DM6FI0= @@ -1380,8 +1417,9 @@ github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeD github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.9.0/go.mod h1:FqZLKOZnGdFAhOK4nqGHa7D66IdsO+O441Eve7ptJDU= github.com/prometheus/client_golang v1.10.0/go.mod h1:WJM3cc3yu7XKBKa/I8WeZm+V3eltZnBwfENSU7mdogU= -github.com/prometheus/client_golang v1.11.0 h1:HNkLOAEQMIDv/K+04rukrLx6ch7msSRwf3/SASFAGtQ= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= +github.com/prometheus/client_golang v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk= +github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -1399,8 +1437,10 @@ github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16 github.com/prometheus/common v0.18.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= github.com/prometheus/common v0.28.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.30.0 h1:JEkYlQnpzrzQFxi6gnukFPdQ+ac82oRhzMcIduJu/Ug= github.com/prometheus/common v0.30.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common v0.33.0 h1:rHgav/0a6+uYgGdNt3jwz8FNSesO/Hsang3O0T9A5SE= +github.com/prometheus/common v0.33.0/go.mod h1:gB3sOl7P0TvJabZpLY5uQMpUqRCPPCyRLCZYc7JZTNE= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= @@ -1528,8 +1568,9 @@ github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49u github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= github.com/wangjia184/sortedset v0.0.0-20160527075905-f5d03557ba30/go.mod h1:YkocrP2K2tcw938x9gCOmT5G5eCD6jsTz0SZuyAqwIE= github.com/warpfork/go-testmark v0.3.0/go.mod h1:jhEf8FVxd+F17juRubpmut64NEG6I2rgkUhlcqqXwE0= -github.com/warpfork/go-testmark v0.9.0 h1:nc+uaCiv5lFQLYjhuC2LTYeJ7JaC+gdDmsz9r0ISy0Y= github.com/warpfork/go-testmark v0.9.0/go.mod h1:jhEf8FVxd+F17juRubpmut64NEG6I2rgkUhlcqqXwE0= +github.com/warpfork/go-testmark v0.10.0 h1:E86YlUMYfwIacEsQGlnTvjk1IgYkyTGjPhF0RnwTCmw= +github.com/warpfork/go-testmark v0.10.0/go.mod h1:jhEf8FVxd+F17juRubpmut64NEG6I2rgkUhlcqqXwE0= github.com/warpfork/go-wish v0.0.0-20180510122957-5ad1f5abf436/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= github.com/warpfork/go-wish v0.0.0-20190328234359-8b3e70f8e830/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a h1:G++j5e0OC488te356JvdhaM8YS6nMsjLAYF7JxCv07w= @@ -1583,6 +1624,7 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= @@ -1629,8 +1671,9 @@ go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+ go.uber.org/multierr v1.4.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec= go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= +go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= +go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= @@ -1639,8 +1682,9 @@ go.uber.org/zap v1.15.0/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= -go.uber.org/zap v1.19.1 h1:ue41HOKd1vGURxrmeKIgELGb3jPW9DMUDGtsinblHwI= go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= +go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= +go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= go4.org v0.0.0-20200411211856-f5505b9728dd h1:BNJlw5kRTzdmyfh5U8F93HA2OwkP7ZGwA51eJ/0wKOU= go4.org v0.0.0-20200411211856-f5505b9728dd/go.mod h1:CIiUVy99QCPfoE13bO4EZaz5GZMZXMSBGhxRdsvzbkg= @@ -1679,8 +1723,8 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210813211128-0a44fdfbc16e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20211209193657-4570a0811e8b h1:QAqMVf3pSa6eeTsuklijukjXBlj7Es2QQplab+/RbQ4= -golang.org/x/crypto v0.0.0-20211209193657-4570a0811e8b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrbV5NY0liEs/Jg2pv5f+bBA= +golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20181106170214-d68db9428509/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1709,7 +1753,6 @@ golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= @@ -1721,8 +1764,9 @@ golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1778,9 +1822,14 @@ golang.org/x/net v0.0.0-20210423184538-5f58ad60dda6/go.mod h1:OJAsFXCWl8Ukc7SiCT golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220418201149-a630d4f3e7a2 h1:6mzvA99KwZxbOrxww4EvWVQUnN1+xEu9tafK5ZxkYeA= +golang.org/x/net v0.0.0-20220418201149-a630d4f3e7a2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1789,6 +1838,7 @@ golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852/go.mod h1:JLpeXjPJfIyPr5TlbXLkXWLhP8nz10XfvxElABhCtcw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1887,18 +1937,21 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210903071746-97244b99971b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211025112917-711f33c9992c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211209171907-798191bca915 h1:P+8mCzuEpyszAT6T42q0sxU+eveBAF/cJ2Kp0x6/8+0= -golang.org/x/sys v0.0.0-20211209171907-798191bca915/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1964,13 +2017,16 @@ golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.10 h1:QjFRCZxdOhBJ/UNgnBZLbNV13DlbnK0quyivTnXJM20= +golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f h1:GGU+dLjvlC3qDwqYgL6UgRmHXhOOgns0bZu2Ty5mm6U= +golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y= @@ -2058,8 +2114,9 @@ google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.40.0 h1:AGJ0Ih4mHjSeibYkFGh1dD9KJ/eOtZ93I6hoHhukQ5Q= google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/grpc v1.45.0 h1:NEpgUqV3Z+ZjkqMsxMg11IaDrXY4RY6CQukSGK0uI1M= +google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -2072,8 +2129,9 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/retrievalmarket/bindnodeoptions.go b/retrievalmarket/bindnodeoptions.go new file mode 100644 index 00000000..73c81d07 --- /dev/null +++ b/retrievalmarket/bindnodeoptions.go @@ -0,0 +1,165 @@ +package retrievalmarket + +import ( + "bytes" + "fmt" + "io" + + "github.com/ipld/go-ipld-prime/codec/dagcbor" + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/node/basicnode" + "github.com/ipld/go-ipld-prime/node/bindnode" + "github.com/ipld/go-ipld-prime/schema" + cbg "github.com/whyrusleeping/cbor-gen" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/big" + "github.com/filecoin-project/go-state-types/crypto" +) + +// go type converter functions for bindnode for common Filecoin data types + +// CborGenCompatibleNodeBindnodeOption converts a CborGenCompatibleNode type to +// and from an Any field in a schema +var CborGenCompatibleNodeBindnodeOption = bindnode.TypedAnyConverter(&CborGenCompatibleNode{}, cborGenCompatibleNodeFromAny, cborGenCompatibleNodeToAny) + +// BigIntBindnodeOption converts a big.Int type to and from a Bytes field in a +// schema +var BigIntBindnodeOption = bindnode.TypedBytesConverter(&big.Int{}, bigIntFromBytes, bigIntToBytes) + +// TokenAmountBindnodeOption converts a filecoin abi.TokenAmount type to and +// from a Bytes field in a schema +var TokenAmountBindnodeOption = bindnode.TypedBytesConverter(&abi.TokenAmount{}, tokenAmountFromBytes, tokenAmountToBytes) + +// AddressBindnodeOption converts a filecoin Address type to and from a Bytes +// field in a schema +var AddressBindnodeOption = bindnode.TypedBytesConverter(&address.Address{}, addressFromBytes, addressToBytes) + +// SignatureBindnodeOption converts a filecoin Signature type to and from a +// Bytes field in a schema +var SignatureBindnodeOption = bindnode.TypedBytesConverter(&crypto.Signature{}, signatureFromBytes, signatureToBytes) + +// CborGenCompatibleNode is for cbor-gen / go-ipld-prime compatibility, to +// replace Deferred types that are used to represent datamodel.Nodes. +// This shouldn't be used as a pointer (nullable/optional) as it can consume +// "Null" tokens and therefore be a Null. Instead, use +// CborGenCompatibleNode#IsNull to check for null status. +type CborGenCompatibleNode struct { + Node datamodel.Node +} + +func (sn CborGenCompatibleNode) IsNull() bool { + return sn.Node == nil || sn.Node == datamodel.Null +} + +// UnmarshalCBOR is for cbor-gen compatibility +func (sn *CborGenCompatibleNode) UnmarshalCBOR(r io.Reader) error { + // use cbg.Deferred.UnmarshalCBOR to figure out how much to pull + def := cbg.Deferred{} + if err := def.UnmarshalCBOR(r); err != nil { + return err + } + // convert it to a Node + na := basicnode.Prototype.Any.NewBuilder() + if err := dagcbor.Decode(na, bytes.NewReader(def.Raw)); err != nil { + return err + } + sn.Node = na.Build() + return nil +} + +// MarshalCBOR is for cbor-gen compatibility +func (sn *CborGenCompatibleNode) MarshalCBOR(w io.Writer) error { + node := datamodel.Null + if sn != nil && sn.Node != nil { + node = sn.Node + if tn, ok := node.(schema.TypedNode); ok { + node = tn.Representation() + } + } + return dagcbor.Encode(node, w) +} + +func cborGenCompatibleNodeFromAny(node datamodel.Node) (interface{}, error) { + return &CborGenCompatibleNode{Node: node}, nil +} + +func cborGenCompatibleNodeToAny(iface interface{}) (datamodel.Node, error) { + sn, ok := iface.(*CborGenCompatibleNode) + if !ok { + return nil, fmt.Errorf("expected *CborGenCompatibleNode value") + } + if sn.Node == nil { + return datamodel.Null, nil + } + return sn.Node, nil +} + +func tokenAmountFromBytes(b []byte) (interface{}, error) { + return bigIntFromBytes(b) +} + +func bigIntFromBytes(b []byte) (interface{}, error) { + if len(b) == 0 { + return big.NewInt(0), nil + } + return big.FromBytes(b) +} + +func tokenAmountToBytes(iface interface{}) ([]byte, error) { + return bigIntToBytes(iface) +} + +func bigIntToBytes(iface interface{}) ([]byte, error) { + bi, ok := iface.(*big.Int) + if !ok { + return nil, fmt.Errorf("expected *big.Int value") + } + if bi == nil || bi.Int == nil { + *bi = big.Zero() + } + return bi.Bytes() +} + +func addressFromBytes(b []byte) (interface{}, error) { + return address.NewFromBytes(b) +} + +func addressToBytes(iface interface{}) ([]byte, error) { + addr, ok := iface.(*address.Address) + if !ok { + return nil, fmt.Errorf("expected *Address value") + } + return addr.Bytes(), nil +} + +// Signature is a byteprefix union +func signatureFromBytes(b []byte) (interface{}, error) { + if len(b) > crypto.SignatureMaxLength { + return nil, fmt.Errorf("string too long") + } + if len(b) == 0 { + return nil, fmt.Errorf("string empty") + } + var s crypto.Signature + switch crypto.SigType(b[0]) { + default: + return nil, fmt.Errorf("invalid signature type in cbor input: %d", b[0]) + case crypto.SigTypeSecp256k1: + s.Type = crypto.SigTypeSecp256k1 + case crypto.SigTypeBLS: + s.Type = crypto.SigTypeBLS + } + s.Data = b[1:] + return &s, nil +} + +func signatureToBytes(iface interface{}) ([]byte, error) { + s, ok := iface.(*crypto.Signature) + if !ok { + return nil, fmt.Errorf("expected *Signature value") + } + ba := append([]byte{byte(s.Type)}, s.Data...) + return ba, nil +} diff --git a/retrievalmarket/common.go b/retrievalmarket/common.go deleted file mode 100644 index fc2c8e05..00000000 --- a/retrievalmarket/common.go +++ /dev/null @@ -1,22 +0,0 @@ -package retrievalmarket - -import ( - "bytes" - - "github.com/ipld/go-ipld-prime" - "github.com/ipld/go-ipld-prime/codec/dagcbor" - basicnode "github.com/ipld/go-ipld-prime/node/basic" - cbg "github.com/whyrusleeping/cbor-gen" -) - -// DecodeNode validates and computes a decoded ipld.Node selector from the -// provided cbor-encoded selector -func DecodeNode(defnode *cbg.Deferred) (ipld.Node, error) { - reader := bytes.NewReader(defnode.Raw) - nb := basicnode.Prototype.Any.NewBuilder() - err := dagcbor.Decode(nb, reader) - if err != nil { - return nil, err - } - return nb.Build(), nil -} diff --git a/retrievalmarket/impl/client.go b/retrievalmarket/impl/client.go index 439977e4..8b23fbae 100644 --- a/retrievalmarket/impl/client.go +++ b/retrievalmarket/impl/client.go @@ -108,21 +108,17 @@ func NewClient( if err != nil { return nil, err } - err = dataTransfer.RegisterVoucherResultType(&retrievalmarket.DealResponse{}) + err = dataTransfer.RegisterVoucherType(retrievalmarket.DealProposalType, nil) if err != nil { return nil, err } - err = dataTransfer.RegisterVoucherType(&retrievalmarket.DealProposal{}, nil) - if err != nil { - return nil, err - } - err = dataTransfer.RegisterVoucherType(&retrievalmarket.DealPayment{}, nil) + err = dataTransfer.RegisterVoucherType(retrievalmarket.DealPaymentType, nil) if err != nil { return nil, err } dataTransfer.SubscribeToEvents(dtutils.ClientDataTransferSubscriber(c.stateMachines)) transportConfigurer := dtutils.TransportConfigurer(network.ID(), &clientStoreGetter{c}) - err = dataTransfer.RegisterTransportConfigurer(&retrievalmarket.DealProposal{}, transportConfigurer) + err = dataTransfer.RegisterTransportConfigurer(retrievalmarket.DealProposalType, transportConfigurer) if err != nil { return nil, err } @@ -406,20 +402,15 @@ func (c *clientDealEnvironment) Node() retrievalmarket.RetrievalClientNode { func (c *clientDealEnvironment) OpenDataTransfer(ctx context.Context, to peer.ID, proposal *retrievalmarket.DealProposal) (datatransfer.ChannelID, error) { sel := selectorparse.CommonSelector_ExploreAllRecursively if proposal.SelectorSpecified() { - var err error - sel, err = retrievalmarket.DecodeNode(proposal.Selector) - if err != nil { - return datatransfer.ChannelID{}, xerrors.Errorf("selector is invalid: %w", err) - } + sel = proposal.Selector.Node } - - var vouch datatransfer.Voucher = proposal - return c.c.dataTransfer.OpenPullDataChannel(ctx, to, vouch, proposal.PayloadCID, sel) + vouch := retrievalmarket.BindnodeRegistry.TypeToNode(proposal) + return c.c.dataTransfer.OpenPullDataChannel(ctx, to, datatransfer.TypedVoucher{Voucher: vouch, Type: retrievalmarket.DealProposalType}, proposal.PayloadCID, sel) } func (c *clientDealEnvironment) SendDataTransferVoucher(ctx context.Context, channelID datatransfer.ChannelID, payment *retrievalmarket.DealPayment) error { - var vouch datatransfer.Voucher = payment - return c.c.dataTransfer.SendVoucher(ctx, channelID, vouch) + vouch := retrievalmarket.BindnodeRegistry.TypeToNode(payment) + return c.c.dataTransfer.SendVoucher(ctx, channelID, datatransfer.TypedVoucher{Voucher: vouch, Type: retrievalmarket.DealPaymentType}) } func (c *clientDealEnvironment) CloseDataTransfer(ctx context.Context, channelID datatransfer.ChannelID) error { diff --git a/retrievalmarket/impl/client_test.go b/retrievalmarket/impl/client_test.go index 8af46e0d..ac984841 100644 --- a/retrievalmarket/impl/client_test.go +++ b/retrievalmarket/impl/client_test.go @@ -13,12 +13,10 @@ import ( "github.com/ipfs/go-datastore" "github.com/ipfs/go-datastore/namespace" dss "github.com/ipfs/go-datastore/sync" - "github.com/ipld/go-ipld-prime/codec/dagcbor" selectorparse "github.com/ipld/go-ipld-prime/traversal/selector/parse" "github.com/libp2p/go-libp2p-core/peer" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - cbg "github.com/whyrusleeping/cbor-gen" "github.com/filecoin-project/go-address" datatransfer "github.com/filecoin-project/go-data-transfer/v2" @@ -47,17 +45,11 @@ func TestClient_Construction(t *testing.T) { require.NoError(t, err) require.Len(t, dt.Subscribers, 1) - require.Len(t, dt.RegisteredVoucherResultTypes, 1) - _, ok := dt.RegisteredVoucherResultTypes[0].(*retrievalmarket.DealResponse) - require.True(t, ok) require.Len(t, dt.RegisteredVoucherTypes, 2) - _, ok = dt.RegisteredVoucherTypes[0].VoucherType.(*retrievalmarket.DealProposal) - require.True(t, ok) - _, ok = dt.RegisteredVoucherTypes[1].VoucherType.(*retrievalmarket.DealPayment) - require.True(t, ok) + require.Equal(t, dt.RegisteredVoucherTypes[0].VoucherType, retrievalmarket.DealProposalType) + require.Equal(t, dt.RegisteredVoucherTypes[1].VoucherType, retrievalmarket.DealPaymentType) require.Len(t, dt.RegisteredTransportConfigurers, 1) - _, ok = dt.RegisteredTransportConfigurers[0].VoucherType.(*retrievalmarket.DealProposal) - require.True(t, ok) + require.Equal(t, dt.RegisteredTransportConfigurers[0].VoucherType, retrievalmarket.DealProposalType) } func TestClient_Query(t *testing.T) { @@ -304,7 +296,7 @@ func TestClient_DuplicateRetrieve(t *testing.T) { // Retrieve first payload CID from first peer params := retrievalmarket.Params{ - Selector: nil, + Selector: retrievalmarket.CborGenCompatibleNode{}, PieceCID: &tut.GenerateCids(1)[0], PricePerByte: abi.NewTokenAmount(1), PaymentInterval: 1, @@ -382,10 +374,6 @@ func TestMigrations(t *testing.T) { voucherShortfalls := make([]abi.TokenAmount, numDeals) selfPeer := tut.GeneratePeers(1)[0] - allSelectorBuf := new(bytes.Buffer) - err := dagcbor.Encode(selectorparse.CommonSelector_ExploreAllRecursively, allSelectorBuf) - require.NoError(t, err) - allSelectorBytes := allSelectorBuf.Bytes() emptyList, err := versioned.BuilderList{}.Build() require.NoError(t, err) oldDs, migrate := versionedds.NewVersionedDatastore(retrievalDs, emptyList, "1") @@ -425,8 +413,8 @@ func TestMigrations(t *testing.T) { PayloadCID: payloadCIDs[i], ID: iDs[i], Params: retrievalmarket.Params{ - Selector: &cbg.Deferred{ - Raw: allSelectorBytes, + Selector: retrievalmarket.CborGenCompatibleNode{ + Node: selectorparse.CommonSelector_ExploreAllRecursively, }, PieceCID: pieceCIDs[i], PricePerByte: pricePerBytes[i], @@ -477,8 +465,8 @@ func TestMigrations(t *testing.T) { PayloadCID: payloadCIDs[i], ID: iDs[i], Params: retrievalmarket.Params{ - Selector: &cbg.Deferred{ - Raw: allSelectorBytes, + Selector: retrievalmarket.CborGenCompatibleNode{ + Node: selectorparse.CommonSelector_ExploreAllRecursively, }, PieceCID: pieceCIDs[i], PricePerByte: pricePerBytes[i], diff --git a/retrievalmarket/impl/dtutils/dtutils.go b/retrievalmarket/impl/dtutils/dtutils.go index abb012dd..8c02c2b3 100644 --- a/retrievalmarket/impl/dtutils/dtutils.go +++ b/retrievalmarket/impl/dtutils/dtutils.go @@ -65,9 +65,18 @@ func providerEvent(event datatransfer.Event, channelState datatransfer.ChannelSt // event or moving to error if a data transfer error occurs func ProviderDataTransferSubscriber(deals EventReceiver) datatransfer.Subscriber { return func(event datatransfer.Event, channelState datatransfer.ChannelState) { - dealProposal, ok := dealProposalFromVoucher(channelState.Voucher()) + voucher, err := channelState.Voucher() + if err != nil { + log.Errorf("received bad voucher: %s", err.Error()) + return + } + if voucher.Voucher == nil { + log.Errorf("received empty voucher") + return + } + dealProposal, err := rm.DealProposalFromNode(voucher.Voucher) // if this event is for a transfer not related to storage, ignore - if !ok { + if err != nil { return } dealID := rm.ProviderDealIdentifier{DealID: dealProposal.ID, Receiver: channelState.Recipient()} @@ -77,7 +86,7 @@ func ProviderDataTransferSubscriber(deals EventReceiver) datatransfer.Subscriber } log.Debugw("processing retrieval provider dt event", "event", datatransfer.Events[event.Code], "dealID", dealProposal.ID, "peer", channelState.OtherPeer(), "retrievalEvent", rm.ProviderEvents[retrievalEvent]) - err := deals.Send(dealID, retrievalEvent, params...) + err = deals.Send(dealID, retrievalEvent, params...) if err != nil { log.Errorf("processing dt event: %s", err) } @@ -117,9 +126,14 @@ func clientEvent(event datatransfer.Event, channelState datatransfer.ChannelStat case datatransfer.Cancel: return rm.ClientEventProviderCancelled, nil case datatransfer.NewVoucherResult: - response, ok := dealResponseFromVoucherResult(channelState.LastVoucherResult()) - if !ok { - log.Errorf("unexpected voucher result received: %s", channelState.LastVoucher().Type()) + voucher, err := channelState.LastVoucherResult() + if err != nil { + log.Errorf("received bad voucher result: %s", err.Error()) + return noEvent, nil + } + response, err := rm.DealResponseFromNode(voucher.Voucher) + if err != nil { + log.Errorf("unexpected voucher result received: %s", err.Error()) return noEvent, nil } @@ -143,10 +157,14 @@ func clientEvent(event datatransfer.Event, channelState datatransfer.ChannelStat // an event to the appropriate state machine func ClientDataTransferSubscriber(deals EventReceiver) datatransfer.Subscriber { return func(event datatransfer.Event, channelState datatransfer.ChannelState) { - dealProposal, ok := dealProposalFromVoucher(channelState.Voucher()) - + voucher, err := channelState.Voucher() + if err != nil { + log.Errorf("received bad voucher: %s", err.Error()) + return + } + dealProposal, err := rm.DealProposalFromNode(voucher.Voucher) // if this event is for a transfer not related to retrieval, ignore - if !ok { + if err != nil { return } @@ -158,7 +176,7 @@ func ClientDataTransferSubscriber(deals EventReceiver) datatransfer.Subscriber { log.Debugw("processing retrieval client dt event", "event", datatransfer.Events[event.Code], "dealID", dealProposal.ID, "peer", channelState.OtherPeer(), "retrievalEvent", rm.ClientEvents[retrievalEvent]) // data transfer events for progress do not affect deal state - err := deals.Send(dealProposal.ID, retrievalEvent, params...) + err = deals.Send(dealProposal.ID, retrievalEvent, params...) if err != nil { log.Errorf("processing dt event %s for state %s: %s", datatransfer.Events[event.Code], datatransfer.Statuses[channelState.Status()], err) @@ -179,9 +197,10 @@ type StoreConfigurableTransport interface { // TransportConfigurer configurers the graphsync transport to use a custom blockstore per deal func TransportConfigurer(thisPeer peer.ID, storeGetter StoreGetter) datatransfer.TransportConfigurer { - return func(channelID datatransfer.ChannelID, voucher datatransfer.Voucher, transport datatransfer.Transport) { - dealProposal, ok := dealProposalFromVoucher(voucher) - if !ok { + return func(channelID datatransfer.ChannelID, voucher datatransfer.TypedVoucher, transport datatransfer.Transport) { + dealProposal, err := rm.DealProposalFromNode(voucher.Voucher) + if err != nil { + log.Debugf("not a deal proposal voucher: %s", err.Error()) return } gsTransport, ok := transport.(StoreConfigurableTransport) @@ -203,22 +222,3 @@ func TransportConfigurer(thisPeer peer.ID, storeGetter StoreGetter) datatransfer } } } - -func dealProposalFromVoucher(voucher datatransfer.Voucher) (*rm.DealProposal, bool) { - dealProposal, ok := voucher.(*rm.DealProposal) - // if this event is for a transfer not related to storage, ignore - if ok { - return dealProposal, true - } - - return nil, false -} - -func dealResponseFromVoucherResult(vres datatransfer.VoucherResult) (*rm.DealResponse, bool) { - dealResponse, ok := vres.(*rm.DealResponse) - // if this event is for a transfer not related to storage, ignore - if ok { - return dealResponse, true - } - return nil, false -} diff --git a/retrievalmarket/impl/dtutils/dtutils_test.go b/retrievalmarket/impl/dtutils/dtutils_test.go index b0eab5c7..2e6e1389 100644 --- a/retrievalmarket/impl/dtutils/dtutils_test.go +++ b/retrievalmarket/impl/dtutils/dtutils_test.go @@ -9,6 +9,7 @@ import ( ds "github.com/ipfs/go-datastore" bstore "github.com/ipfs/go-ipfs-blockstore" "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" peer "github.com/libp2p/go-libp2p-core/peer" "github.com/stretchr/testify/require" @@ -23,6 +24,8 @@ import ( func TestProviderDataTransferSubscriber(t *testing.T) { dealProposal := shared_testutil.MakeTestDealProposal() + node := rm.BindnodeRegistry.TypeToNode(dealProposal) + dealProposalVoucher := datatransfer.TypedVoucher{Voucher: node, Type: rm.DealProposalType} testPeers := shared_testutil.GeneratePeers(2) transferID := datatransfer.TransferID(rand.Uint64()) tests := map[string]struct { @@ -92,7 +95,7 @@ func TestProviderDataTransferSubscriber(t *testing.T) { TransferID: transferID, Sender: testPeers[0], Recipient: testPeers[1], - Vouchers: []datatransfer.Voucher{&dealProposal}, + Vouchers: []datatransfer.TypedVoucher{dealProposalVoucher}, Status: data.status})) require.True(t, fdg.called) require.Equal(t, fdg.lastID, rm.ProviderDealIdentifier{DealID: dealProposal.ID, Receiver: testPeers[1]}) @@ -108,6 +111,12 @@ func TestProviderDataTransferSubscriber(t *testing.T) { } func TestClientDataTransferSubscriber(t *testing.T) { dealProposal := shared_testutil.MakeTestDealProposal() + node := rm.BindnodeRegistry.TypeToNode(dealProposal) + dealProposalVoucher := datatransfer.TypedVoucher{Voucher: node, Type: retrievalmarket.DealProposalType} + dealResponseVoucher := func(dealResponse retrievalmarket.DealResponse) datatransfer.TypedVoucher { + node := rm.BindnodeRegistry.TypeToNode(&dealResponse) + return datatransfer.TypedVoucher{Voucher: node, Type: retrievalmarket.DealResponseType} + } paymentOwed := shared_testutil.MakeTestTokenAmount() tests := map[string]struct { code datatransfer.EventCode @@ -124,7 +133,7 @@ func TestClientDataTransferSubscriber(t *testing.T) { "progress": { code: datatransfer.DataReceivedProgress, state: shared_testutil.TestChannelParams{ - Vouchers: []datatransfer.Voucher{&dealProposal}, + Vouchers: []datatransfer.TypedVoucher{dealProposalVoucher}, Status: datatransfer.Ongoing, Received: 1000}, expectedID: dealProposal.ID, @@ -134,7 +143,7 @@ func TestClientDataTransferSubscriber(t *testing.T) { "finish transfer": { code: datatransfer.FinishTransfer, state: shared_testutil.TestChannelParams{ - Vouchers: []datatransfer.Voucher{&dealProposal}, + Vouchers: []datatransfer.TypedVoucher{dealProposalVoucher}, Status: datatransfer.TransferFinished}, expectedID: dealProposal.ID, expectedEvent: rm.ClientEventAllBlocksReceived, @@ -142,7 +151,7 @@ func TestClientDataTransferSubscriber(t *testing.T) { "cancel": { code: datatransfer.Cancel, state: shared_testutil.TestChannelParams{ - Vouchers: []datatransfer.Voucher{&dealProposal}, + Vouchers: []datatransfer.TypedVoucher{dealProposalVoucher}, Status: datatransfer.Ongoing}, expectedID: dealProposal.ID, expectedEvent: rm.ClientEventProviderCancelled, @@ -150,12 +159,12 @@ func TestClientDataTransferSubscriber(t *testing.T) { "new voucher result - rejected": { code: datatransfer.NewVoucherResult, state: shared_testutil.TestChannelParams{ - Vouchers: []datatransfer.Voucher{&dealProposal}, - VoucherResults: []datatransfer.VoucherResult{&retrievalmarket.DealResponse{ + Vouchers: []datatransfer.TypedVoucher{dealProposalVoucher}, + VoucherResults: []datatransfer.TypedVoucher{dealResponseVoucher(retrievalmarket.DealResponse{ Status: retrievalmarket.DealStatusRejected, ID: dealProposal.ID, Message: "something went wrong", - }}, + })}, Status: datatransfer.Ongoing}, expectedID: dealProposal.ID, expectedEvent: rm.ClientEventDealRejected, @@ -164,12 +173,12 @@ func TestClientDataTransferSubscriber(t *testing.T) { "new voucher result - not found": { code: datatransfer.NewVoucherResult, state: shared_testutil.TestChannelParams{ - Vouchers: []datatransfer.Voucher{&dealProposal}, - VoucherResults: []datatransfer.VoucherResult{&retrievalmarket.DealResponse{ + Vouchers: []datatransfer.TypedVoucher{dealProposalVoucher}, + VoucherResults: []datatransfer.TypedVoucher{dealResponseVoucher(retrievalmarket.DealResponse{ Status: retrievalmarket.DealStatusDealNotFound, ID: dealProposal.ID, Message: "something went wrong", - }}, + })}, Status: datatransfer.Ongoing}, expectedID: dealProposal.ID, expectedEvent: rm.ClientEventDealNotFound, @@ -178,11 +187,11 @@ func TestClientDataTransferSubscriber(t *testing.T) { "new voucher result - accepted": { code: datatransfer.NewVoucherResult, state: shared_testutil.TestChannelParams{ - Vouchers: []datatransfer.Voucher{&dealProposal}, - VoucherResults: []datatransfer.VoucherResult{&retrievalmarket.DealResponse{ + Vouchers: []datatransfer.TypedVoucher{dealProposalVoucher}, + VoucherResults: []datatransfer.TypedVoucher{dealResponseVoucher(retrievalmarket.DealResponse{ Status: retrievalmarket.DealStatusAccepted, ID: dealProposal.ID, - }}, + })}, Status: datatransfer.Ongoing}, expectedID: dealProposal.ID, expectedEvent: rm.ClientEventDealAccepted, @@ -190,12 +199,12 @@ func TestClientDataTransferSubscriber(t *testing.T) { "new voucher result - funds needed last payment": { code: datatransfer.NewVoucherResult, state: shared_testutil.TestChannelParams{ - Vouchers: []datatransfer.Voucher{&dealProposal}, - VoucherResults: []datatransfer.VoucherResult{&retrievalmarket.DealResponse{ + Vouchers: []datatransfer.TypedVoucher{dealProposalVoucher}, + VoucherResults: []datatransfer.TypedVoucher{dealResponseVoucher(retrievalmarket.DealResponse{ Status: retrievalmarket.DealStatusFundsNeededLastPayment, ID: dealProposal.ID, PaymentOwed: paymentOwed, - }}, + })}, Status: datatransfer.Ongoing}, expectedID: dealProposal.ID, expectedEvent: rm.ClientEventLastPaymentRequested, @@ -204,11 +213,11 @@ func TestClientDataTransferSubscriber(t *testing.T) { "new voucher result - completed": { code: datatransfer.NewVoucherResult, state: shared_testutil.TestChannelParams{ - Vouchers: []datatransfer.Voucher{&dealProposal}, - VoucherResults: []datatransfer.VoucherResult{&retrievalmarket.DealResponse{ + Vouchers: []datatransfer.TypedVoucher{dealProposalVoucher}, + VoucherResults: []datatransfer.TypedVoucher{dealResponseVoucher(retrievalmarket.DealResponse{ Status: retrievalmarket.DealStatusCompleted, ID: dealProposal.ID, - }}, + })}, Status: datatransfer.ResponderCompleted}, expectedID: dealProposal.ID, expectedEvent: rm.ClientEventComplete, @@ -216,12 +225,12 @@ func TestClientDataTransferSubscriber(t *testing.T) { "new voucher result - funds needed": { code: datatransfer.NewVoucherResult, state: shared_testutil.TestChannelParams{ - Vouchers: []datatransfer.Voucher{&dealProposal}, - VoucherResults: []datatransfer.VoucherResult{&retrievalmarket.DealResponse{ + Vouchers: []datatransfer.TypedVoucher{dealProposalVoucher}, + VoucherResults: []datatransfer.TypedVoucher{dealResponseVoucher(retrievalmarket.DealResponse{ Status: retrievalmarket.DealStatusFundsNeeded, ID: dealProposal.ID, PaymentOwed: paymentOwed, - }}, + })}, Status: datatransfer.Ongoing}, expectedID: dealProposal.ID, expectedEvent: rm.ClientEventPaymentRequested, @@ -230,11 +239,11 @@ func TestClientDataTransferSubscriber(t *testing.T) { "new voucher result - unexpected response": { code: datatransfer.NewVoucherResult, state: shared_testutil.TestChannelParams{ - Vouchers: []datatransfer.Voucher{&dealProposal}, - VoucherResults: []datatransfer.VoucherResult{&retrievalmarket.DealResponse{ + Vouchers: []datatransfer.TypedVoucher{dealProposalVoucher}, + VoucherResults: []datatransfer.TypedVoucher{dealResponseVoucher(retrievalmarket.DealResponse{ Status: retrievalmarket.DealStatusPaymentChannelAddingFunds, ID: dealProposal.ID, - }}, + })}, Status: datatransfer.Ongoing}, expectedID: dealProposal.ID, expectedEvent: rm.ClientEventUnknownResponseReceived, @@ -244,7 +253,7 @@ func TestClientDataTransferSubscriber(t *testing.T) { code: datatransfer.Error, message: "something went wrong", state: shared_testutil.TestChannelParams{ - Vouchers: []datatransfer.Voucher{&dealProposal}, + Vouchers: []datatransfer.TypedVoucher{dealProposalVoucher}, Status: datatransfer.Ongoing}, expectedID: dealProposal.ID, expectedEvent: rm.ClientEventDataTransferError, @@ -254,7 +263,7 @@ func TestClientDataTransferSubscriber(t *testing.T) { code: datatransfer.Disconnected, message: "something went wrong", state: shared_testutil.TestChannelParams{ - Vouchers: []datatransfer.Voucher{&dealProposal}, + Vouchers: []datatransfer.TypedVoucher{dealProposalVoucher}, Status: datatransfer.Ongoing}, expectedID: dealProposal.ID, expectedEvent: rm.ClientEventDataTransferError, @@ -264,7 +273,7 @@ func TestClientDataTransferSubscriber(t *testing.T) { code: datatransfer.Error, message: datatransfer.ErrRejected.Error(), state: shared_testutil.TestChannelParams{ - Vouchers: []datatransfer.Voucher{&dealProposal}, + Vouchers: []datatransfer.TypedVoucher{dealProposalVoucher}, Status: datatransfer.Ongoing, Message: datatransfer.ErrRejected.Error()}, expectedID: dealProposal.ID, @@ -311,9 +320,13 @@ func TestTransportConfigurer(t *testing.T) { expectedDealID := rm.DealID(rand.Uint64()) thisPeer := expectedChannelID.Initiator expectedPeer := expectedChannelID.Responder + dealProposalVoucher := func(proposal rm.DealProposal) datatransfer.TypedVoucher { + node := rm.BindnodeRegistry.TypeToNode(&proposal) + return datatransfer.TypedVoucher{Voucher: node, Type: rm.DealProposalType} + } testCases := map[string]struct { - voucher datatransfer.Voucher + voucher datatransfer.TypedVoucher transport datatransfer.Transport returnedStore bstore.Blockstore returnedStoreErr error @@ -321,22 +334,22 @@ func TestTransportConfigurer(t *testing.T) { useStoreCalled bool }{ "non-storage voucher": { - voucher: nil, + voucher: datatransfer.TypedVoucher{}, getterCalled: false, }, "non-configurable transport": { - voucher: &rm.DealProposal{ + voucher: dealProposalVoucher(rm.DealProposal{ PayloadCID: payloadCID, ID: expectedDealID, - }, + }), transport: &fakeTransport{}, getterCalled: false, }, "store getter errors": { - voucher: &rm.DealProposal{ + voucher: dealProposalVoucher(rm.DealProposal{ PayloadCID: payloadCID, ID: expectedDealID, - }, + }), transport: &fakeGsTransport{Transport: &fakeTransport{}}, getterCalled: true, useStoreCalled: false, @@ -344,10 +357,10 @@ func TestTransportConfigurer(t *testing.T) { returnedStoreErr: errors.New("something went wrong"), }, "store getter succeeds": { - voucher: &rm.DealProposal{ + voucher: dealProposalVoucher(rm.DealProposal{ PayloadCID: payloadCID, ID: expectedDealID, - }, + }), transport: &fakeGsTransport{Transport: &fakeTransport{}}, getterCalled: true, useStoreCalled: true, @@ -398,7 +411,7 @@ type fakeTransport struct{} var _ datatransfer.Transport = (*fakeTransport)(nil) -func (ft *fakeTransport) OpenChannel(ctx context.Context, dataSender peer.ID, channelID datatransfer.ChannelID, root ipld.Link, stor ipld.Node, channel datatransfer.ChannelState, msg datatransfer.Message) error { +func (ft *fakeTransport) OpenChannel(ctx context.Context, dataSender peer.ID, channelID datatransfer.ChannelID, root datamodel.Link, stor datamodel.Node, channel datatransfer.ChannelState, msg datatransfer.Message) error { return nil } diff --git a/retrievalmarket/impl/integration_test.go b/retrievalmarket/impl/integration_test.go index 0f8d8280..fed3b419 100644 --- a/retrievalmarket/impl/integration_test.go +++ b/retrievalmarket/impl/integration_test.go @@ -15,7 +15,7 @@ import ( graphsyncimpl "github.com/ipfs/go-graphsync/impl" "github.com/ipfs/go-graphsync/network" "github.com/ipld/go-car" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" cidlink "github.com/ipld/go-ipld-prime/linking/cid" basicnode "github.com/ipld/go-ipld-prime/node/basic" "github.com/ipld/go-ipld-prime/traversal/selector/builder" @@ -214,7 +214,7 @@ func TestClientCanMakeDealWithProvider(t *testing.T) { filename string filesize uint64 voucherAmts []abi.TokenAmount - selector ipld.Node + selector datamodel.Node unsealPrice abi.TokenAmount zeroPricePerByte bool paramsV1, addFunds bool diff --git a/retrievalmarket/impl/ipld_compat_test.go b/retrievalmarket/impl/ipld_compat_test.go new file mode 100644 index 00000000..d486a226 --- /dev/null +++ b/retrievalmarket/impl/ipld_compat_test.go @@ -0,0 +1,334 @@ +package retrievalimpl_test + +// TODO(rvagg): this is a transitional package to test compatibility between +// cbor-gen and bindnode - it can be removed if/when cbor-gen is also removed + +import ( + "bytes" + "encoding/hex" + "testing" + + "github.com/ipfs/go-cid" + "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/codec/dagcbor" + "github.com/ipld/go-ipld-prime/node/basicnode" + "github.com/ipld/go-ipld-prime/schema" + selectorparse "github.com/ipld/go-ipld-prime/traversal/selector/parse" + "github.com/stretchr/testify/assert" + + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/go-state-types/big" + "github.com/filecoin-project/go-state-types/crypto" + "github.com/filecoin-project/specs-actors/actors/builtin/paych" + + "github.com/filecoin-project/go-fil-markets/retrievalmarket" +) + +func TestIpldCompat_DealResponse(t *testing.T) { + compareDealResponse := func(t *testing.T, drExpected retrievalmarket.DealResponse, drActual retrievalmarket.DealResponse) { + assert.Equal(t, drExpected.ID, drActual.ID) + assert.Equal(t, drExpected.Message, drActual.Message) + compareBigInt(t, drExpected.PaymentOwed, drActual.PaymentOwed, "PaymentOwed") + assert.Equal(t, drExpected.Status, drActual.Status) + } + + for _, testCase := range []struct { + label string + dr retrievalmarket.DealResponse + }{ + {"empty", retrievalmarket.DealResponse{}}, + {"full", retrievalmarket.DealResponse{ + Status: 2, + ID: 3, + PaymentOwed: big.NewInt(10001), + Message: "bip bop", + }}, + {"negPayment", retrievalmarket.DealResponse{ // maybe nonsense, but worth a test + Status: 2, + ID: 3, + PaymentOwed: big.NewInt(-10001), + Message: "bip bop", + }}, + } { + t.Run(testCase.label, func(t *testing.T) { + // encode the DealResponse with cbor-gen to bytes + var originalBuf bytes.Buffer + assert.Nil(t, testCase.dr.MarshalCBOR(&originalBuf)) + originalBytes := originalBuf.Bytes() + + // decode the bytes to DealResponse with bindnode + nb := basicnode.Prototype.Any.NewBuilder() + assert.Nil(t, dagcbor.Decode(nb, &originalBuf)) + node := nb.Build() + drBindnodeIface, err := retrievalmarket.BindnodeRegistry.TypeFromNode(node, &retrievalmarket.DealResponse{}) + assert.Nil(t, err) + drBindnode, ok := drBindnodeIface.(*retrievalmarket.DealResponse) + assert.True(t, ok) + + // compare objects + compareDealResponse(t, testCase.dr, *drBindnode) + + // encode the new DealResponse with bindnode to bytes + node = retrievalmarket.BindnodeRegistry.TypeToNode(drBindnode) + var bindnodeBuf bytes.Buffer + dagcbor.Encode(node.(schema.TypedNode).Representation(), &bindnodeBuf) + bindnodeBytes := bindnodeBuf.Bytes() + + compareCbor(t, originalBytes, bindnodeBytes) + + // decode the new bytes to DealResponse with cbor-gen + var roundtripdr retrievalmarket.DealResponse + assert.Nil(t, roundtripdr.UnmarshalCBOR(&bindnodeBuf)) + + // compare objects + compareDealResponse(t, testCase.dr, *drBindnode) + }) + } +} + +func TestIpldCompat_DealProposal(t *testing.T) { + acid, err := cid.Decode("bafy2bzaceashdsqgbnisdg76gdhupvkpop4br5rs3veuy4whuxagnoco6px6e") + assert.Nil(t, err) + aselector := selectorparse.CommonSelector_MatchChildren + + compareDealProposal := func(t *testing.T, drExpected retrievalmarket.DealProposal, drActual retrievalmarket.DealProposal) { + // for cbor-gen we get the selector as a deferred bytes, but an datamodel.Node for bindnode, + // so we make them both bytes and compare those + assert.Equal(t, drExpected.PayloadCID, drActual.PayloadCID, "PayloadCID") + assert.Equal(t, drExpected.ID, drActual.ID, "ID") + if !drExpected.Selector.IsNull() || !drActual.Selector.IsNull() { + assert.True(t, ipld.DeepEqual(drExpected.Selector.Node, drActual.Selector.Node), "Selector") + } + assert.Equal(t, drExpected.Params.PieceCID, drActual.Params.PieceCID, "PieceCID") + compareBigInt(t, drExpected.Params.PricePerByte, drActual.Params.PricePerByte, "PricePerByte") + assert.Equal(t, drExpected.Params.PaymentInterval, drActual.Params.PaymentInterval, "PaymentInterval") + assert.Equal(t, drExpected.Params.PaymentIntervalIncrease, drActual.Params.PaymentIntervalIncrease, "PaymentIntervalIncrease") + compareBigInt(t, drExpected.Params.UnsealPrice, drActual.Params.UnsealPrice, "UnsealPrice") + } + + for _, testCase := range []struct { + label string + dp retrievalmarket.DealProposal + }{ + {"empty", retrievalmarket.DealProposal{PayloadCID: acid}}, // PayloadCID is a required field + {"optional", retrievalmarket.DealProposal{ + PayloadCID: acid, + ID: 1010, + Params: retrievalmarket.Params{ + Selector: retrievalmarket.CborGenCompatibleNode{}, + PieceCID: nil, + PricePerByte: abi.NewTokenAmount(1001), + PaymentInterval: 20, + PaymentIntervalIncrease: 30, + UnsealPrice: abi.NewTokenAmount(2002), + }, + }}, + {"full", retrievalmarket.DealProposal{ + PayloadCID: acid, + ID: 1010, + Params: retrievalmarket.Params{ + Selector: retrievalmarket.CborGenCompatibleNode{Node: aselector}, + PieceCID: &acid, + PricePerByte: abi.NewTokenAmount(1001), + PaymentInterval: 20, + PaymentIntervalIncrease: 30, + UnsealPrice: abi.NewTokenAmount(2002), + }, + }}, + } { + t.Run(testCase.label, func(t *testing.T) { + // encode the DealProposal with cbor-gen to bytes + var originalBuf bytes.Buffer + assert.Nil(t, testCase.dp.MarshalCBOR(&originalBuf)) + originalBytes := originalBuf.Bytes() + + // roundtrip the original DealProposal using cbor-gen so we can compare + // decoded forms + var roundtripdr retrievalmarket.DealProposal + assert.Nil(t, roundtripdr.UnmarshalCBOR(bytes.NewReader(originalBytes))) + + // decode the bytes to DealProposal with bindnode + nb := basicnode.Prototype.Any.NewBuilder() + assert.Nil(t, dagcbor.Decode(nb, &originalBuf)) + node := nb.Build() + dpBindnodeIface, err := retrievalmarket.BindnodeRegistry.TypeFromNode(node, &retrievalmarket.DealProposal{}) + assert.Nil(t, err) + dpBindnode, ok := dpBindnodeIface.(*retrievalmarket.DealProposal) + assert.True(t, ok) + + // compare objects + compareDealProposal(t, testCase.dp, *dpBindnode) + + // encode the new DealProposal with bindnode to bytes + node = retrievalmarket.BindnodeRegistry.TypeToNode(dpBindnode) + var bindnodeBuf bytes.Buffer + dagcbor.Encode(node.(schema.TypedNode).Representation(), &bindnodeBuf) + bindnodeBytes := bindnodeBuf.Bytes() + + compareCbor(t, originalBytes, bindnodeBytes) + + // decode the new bytes to DealProposal with cbor-gen + var roundtripFromBindnodeDr retrievalmarket.DealProposal + assert.Nil(t, roundtripFromBindnodeDr.UnmarshalCBOR(&bindnodeBuf)) + + // compare objects + compareDealProposal(t, roundtripdr, *dpBindnode) + // compareDealProposal(t, roundtripFromBindnodeDr, *dpBindnode) + }) + } +} + +func TestIpldCompat_DealPayment(t *testing.T) { + compareDealPayment := func(t *testing.T, dpExpected retrievalmarket.DealPayment, dpActual retrievalmarket.DealPayment) { + assert.Equal(t, dpExpected.ID, dpActual.ID, "ID") + assert.Equal(t, dpExpected.PaymentChannel.String(), dpActual.PaymentChannel.String(), "PaymentChannel") + assert.Equal(t, dpExpected.PaymentVoucher == nil, dpActual.PaymentVoucher == nil, "PaymentVoucher") + } + + for _, testCase := range []struct { + label string + dp retrievalmarket.DealPayment + }{ + // addresses can't be null, and they're not marked nullable or optional, so we have to insert them + {"empty", retrievalmarket.DealPayment{PaymentChannel: address.TestAddress}}, + {"empty voucher", retrievalmarket.DealPayment{ + ID: 1001, + PaymentChannel: address.TestAddress, + PaymentVoucher: &paych.SignedVoucher{ + ChannelAddr: address.TestAddress2, + }, + }}, + {"mostly full voucher", retrievalmarket.DealPayment{ + ID: 1001, + PaymentChannel: address.TestAddress, + PaymentVoucher: &paych.SignedVoucher{ + ChannelAddr: address.TestAddress2, + TimeLockMin: abi.ChainEpoch(2222), + TimeLockMax: abi.ChainEpoch(333333), + SecretPreimage: []byte("1234567890abcdef"), + Extra: nil, + Lane: 100, + Nonce: 200, + Amount: big.MustFromString("12345678901234567891234567890123456789012345678901234567890"), + MinSettleHeight: abi.ChainEpoch(444444444), + Signature: nil, + }, + }}, + {"full", retrievalmarket.DealPayment{ + ID: 1001, + PaymentChannel: address.TestAddress, + PaymentVoucher: &paych.SignedVoucher{ + ChannelAddr: address.TestAddress2, + TimeLockMin: abi.ChainEpoch(2222), + TimeLockMax: abi.ChainEpoch(333333), + SecretPreimage: []byte("1234567890abcdef"), + Extra: &paych.ModVerifyParams{ + Actor: address.TestAddress, + Method: abi.MethodNum(50), + Data: []byte("doo-bee-doo"), + }, + Lane: 100, + Nonce: 200, + Amount: big.MustFromString("12345678901234567891234567890123456789012345678901234567890"), + MinSettleHeight: abi.ChainEpoch(444444444), + Signature: &crypto.Signature{ + Type: crypto.SigTypeBLS, + Data: []byte("beep-boop-beep"), + }, + }, + }}, + {"full secp256k1", retrievalmarket.DealPayment{ + ID: 1001, + PaymentChannel: address.TestAddress, + PaymentVoucher: &paych.SignedVoucher{ + ChannelAddr: address.TestAddress2, + TimeLockMin: abi.ChainEpoch(2222), + TimeLockMax: abi.ChainEpoch(333333), + SecretPreimage: []byte("1234567890abcdef"), + Extra: &paych.ModVerifyParams{ + Actor: address.TestAddress, + Method: abi.MethodNum(50), + Data: []byte("doo-bee-doo"), + }, + Lane: 100, + Nonce: 200, + Amount: big.MustFromString("12345678901234567891234567890123456789012345678901234567890"), + MinSettleHeight: abi.ChainEpoch(444444444), + Signature: &crypto.Signature{ + Type: crypto.SigTypeSecp256k1, + Data: []byte("bop-bee-bop"), + }, + }, + }}, + } { + t.Run(testCase.label, func(t *testing.T) { + // encode the DealPayment with cbor-gen to bytes + var originalBuf bytes.Buffer + assert.Nil(t, testCase.dp.MarshalCBOR(&originalBuf)) + originalBytes := originalBuf.Bytes() + + // decode the bytes to DealPayment with bindnode + nb := basicnode.Prototype.Any.NewBuilder() + assert.Nil(t, dagcbor.Decode(nb, &originalBuf)) + node := nb.Build() + dpBindnodeIface, err := retrievalmarket.BindnodeRegistry.TypeFromNode(node, &retrievalmarket.DealPayment{}) + assert.Nil(t, err) + dpBindnode, ok := dpBindnodeIface.(*retrievalmarket.DealPayment) + assert.True(t, ok) + + // compare objects + compareDealPayment(t, testCase.dp, *dpBindnode) + + // encode the new DealPayment with bindnode to bytes + node = retrievalmarket.BindnodeRegistry.TypeToNode(dpBindnode) + var bindnodeBuf bytes.Buffer + dagcbor.Encode(node.(schema.TypedNode).Representation(), &bindnodeBuf) + bindnodeBytes := bindnodeBuf.Bytes() + + compareCbor(t, originalBytes, bindnodeBytes) + + // decode the new bytes to DealPayment with cbor-gen + var roundtripdp retrievalmarket.DealPayment + assert.Nil(t, roundtripdp.UnmarshalCBOR(&bindnodeBuf)) + + // compare objects + compareDealPayment(t, testCase.dp, *dpBindnode) + }) + } +} + +// this exists not because the encoding bytes are different but the unitialized +// form may be different in the empty case; functionally they should be the same +func compareBigInt(t *testing.T, expected big.Int, actual big.Int, msg string) { + // special case `nil` because it ends up being an empty bytes (0x40) which is + // big.Int(0) in a round-trip according to cbor-gen encoding + if expected.Int == nil { + expected = big.Zero() + } + assert.Equal(t, expected, actual, msg) +} + +// needed because cbor-gen sorts maps differently, so we can't compare bytes +// so instead we round-trip them, untyped, through go-ipld-prime and compare the +// output bytes +func compareCbor(t *testing.T, cb1 []byte, cb2 []byte) { + assert.Equal(t, len(cb1), len(cb2)) + rt := func(cb []byte) []byte { + na := basicnode.Prototype.Any.NewBuilder() + err := dagcbor.Decode(na, bytes.NewReader(cb)) + assert.Nil(t, err) + n := na.Build() + var buf bytes.Buffer + err = dagcbor.Encode(n, &buf) + assert.Nil(t, err) + return buf.Bytes() + } + if !bytes.Equal(rt(cb1), rt(cb2)) { + t.Logf( + "Round-tripped node forms of CBOR are not equal:\n\tExpected: %s\n\tActual: %s", + hex.EncodeToString(cb1), + hex.EncodeToString(cb2)) + assert.Fail(t, "decoded cbor different") + } +} diff --git a/retrievalmarket/impl/provider.go b/retrievalmarket/impl/provider.go index b3c15856..51ab67aa 100644 --- a/retrievalmarket/impl/provider.go +++ b/retrievalmarket/impl/provider.go @@ -150,21 +150,17 @@ func NewProvider(minerAddress address.Address, p.requestValidator = requestvalidation.NewProviderRequestValidator(&providerValidationEnvironment{p}) transportConfigurer := dtutils.TransportConfigurer(network.ID(), &providerStoreGetter{p}) - err = p.dataTransfer.RegisterVoucherType(&retrievalmarket.DealProposal{}, p.requestValidator) + err = p.dataTransfer.RegisterVoucherType(retrievalmarket.DealProposalType, p.requestValidator) if err != nil { return nil, err } - err = p.dataTransfer.RegisterVoucherType(&retrievalmarket.DealPayment{}, p.requestValidator) - if err != nil { - return nil, err - } - err = p.dataTransfer.RegisterVoucherResultType(&retrievalmarket.DealResponse{}) + err = p.dataTransfer.RegisterVoucherType(retrievalmarket.DealPaymentType, p.requestValidator) if err != nil { return nil, err } - err = p.dataTransfer.RegisterTransportConfigurer(&retrievalmarket.DealProposal{}, transportConfigurer) + err = p.dataTransfer.RegisterTransportConfigurer(retrievalmarket.DealProposalType, transportConfigurer) if err != nil { return nil, err } diff --git a/retrievalmarket/impl/provider_test.go b/retrievalmarket/impl/provider_test.go index 5f9e9c60..38a35840 100644 --- a/retrievalmarket/impl/provider_test.go +++ b/retrievalmarket/impl/provider_test.go @@ -12,12 +12,10 @@ import ( "github.com/ipfs/go-datastore" "github.com/ipfs/go-datastore/namespace" dss "github.com/ipfs/go-datastore/sync" - "github.com/ipld/go-ipld-prime/codec/dagcbor" selectorparse "github.com/ipld/go-ipld-prime/traversal/selector/parse" "github.com/libp2p/go-libp2p-core/peer" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - cbg "github.com/whyrusleeping/cbor-gen" "github.com/filecoin-project/go-address" datatransfer "github.com/filecoin-project/go-data-transfer/v2" @@ -959,22 +957,16 @@ func TestProvider_Construct(t *testing.T) { ) require.NoError(t, err) require.Len(t, dt.Subscribers, 1) - require.Len(t, dt.RegisteredVoucherResultTypes, 1) - _, ok := dt.RegisteredVoucherResultTypes[0].(*retrievalmarket.DealResponse) - require.True(t, ok) require.Len(t, dt.RegisteredVoucherTypes, 2) - _, ok = dt.RegisteredVoucherTypes[0].VoucherType.(*retrievalmarket.DealProposal) - require.True(t, ok) - _, ok = dt.RegisteredVoucherTypes[0].Validator.(*requestvalidation.ProviderRequestValidator) - require.True(t, ok) - _, ok = dt.RegisteredVoucherTypes[1].VoucherType.(*retrievalmarket.DealPayment) + require.Equal(t, dt.RegisteredVoucherTypes[0].VoucherType, retrievalmarket.DealProposalType) + _, ok := dt.RegisteredVoucherTypes[0].Validator.(*requestvalidation.ProviderRequestValidator) require.True(t, ok) + require.Equal(t, dt.RegisteredVoucherTypes[1].VoucherType, retrievalmarket.DealPaymentType) _, ok = dt.RegisteredVoucherTypes[1].Validator.(*requestvalidation.ProviderRequestValidator) require.True(t, ok) require.Len(t, dt.RegisteredTransportConfigurers, 1) - _, ok = dt.RegisteredTransportConfigurers[0].VoucherType.(*retrievalmarket.DealProposal) + require.Equal(t, dt.RegisteredTransportConfigurers[0].VoucherType, retrievalmarket.DealProposalType) - require.True(t, ok) } func TestProviderConfigOpts(t *testing.T) { @@ -1085,10 +1077,6 @@ func TestProviderMigrations(t *testing.T) { sectorIDs := make([]abi.SectorNumber, numDeals) offsets := make([]abi.PaddedPieceSize, numDeals) lengths := make([]abi.PaddedPieceSize, numDeals) - allSelectorBuf := new(bytes.Buffer) - err := dagcbor.Encode(selectorparse.CommonSelector_ExploreAllRecursively, allSelectorBuf) - require.NoError(t, err) - allSelectorBytes := allSelectorBuf.Bytes() for i := 0; i < numDeals; i++ { payloadCIDs[i] = tut.GenerateCids(1)[0] @@ -1117,8 +1105,8 @@ func TestProviderMigrations(t *testing.T) { PayloadCID: payloadCIDs[i], ID: iDs[i], Params: retrievalmarket.Params{ - Selector: &cbg.Deferred{ - Raw: allSelectorBytes, + Selector: retrievalmarket.CborGenCompatibleNode{ + Node: selectorparse.CommonSelector_ExploreAllRecursively, }, PieceCID: pieceCIDs[i], PricePerByte: pricePerBytes[i], @@ -1180,8 +1168,8 @@ func TestProviderMigrations(t *testing.T) { PayloadCID: payloadCIDs[i], ID: iDs[i], Params: retrievalmarket.Params{ - Selector: &cbg.Deferred{ - Raw: allSelectorBytes, + Selector: retrievalmarket.CborGenCompatibleNode{ + Node: selectorparse.CommonSelector_ExploreAllRecursively, }, PieceCID: pieceCIDs[i], PricePerByte: pricePerBytes[i], diff --git a/retrievalmarket/impl/providerstates/provider_states.go b/retrievalmarket/impl/providerstates/provider_states.go index a5ffbce4..4ad9d430 100644 --- a/retrievalmarket/impl/providerstates/provider_states.go +++ b/retrievalmarket/impl/providerstates/provider_states.go @@ -99,7 +99,7 @@ func updateFunding(ctx fsm.Context, log.Debugf("provider: owed %d, total received %d = received so far %d + newly received %d, unseal price %d, price per byte %d, bytes sent: %d, in finalization: %v", owed, totalPaid, deal.FundsReceived, received, deal.UnsealPrice, deal.PricePerByte, channelState.Queued(), channelState.Status().InFinalization()) - var voucherResult datatransfer.VoucherResult + var voucherResult *rm.DealResponse if owed.GreaterThan(big.Zero()) { // if payment is still owed but we received funds, send a partial payment received event if received.GreaterThan(big.Zero()) { @@ -130,13 +130,17 @@ func updateFunding(ctx fsm.Context, } } } - return datatransfer.ValidationResult{ + vr := datatransfer.ValidationResult{ Accepted: true, - VoucherResult: voucherResult, ForcePause: deal.Status == rm.DealStatusUnsealing || deal.Status == rm.DealStatusFundsNeededUnseal, RequiresFinalization: owed.GreaterThan(big.Zero()) || deal.Status != rm.DealStatusFundsNeededLastPayment, DataLimit: deal.Params.NextInterval(totalPaid), } + if voucherResult != nil { + node := rm.BindnodeRegistry.TypeToNode(voucherResult) + vr.VoucherResult = &datatransfer.TypedVoucher{Voucher: node, Type: rm.DealResponseType} + } + return vr } func savePayment(ctx fsm.Context, env ProviderDealEnvironment, payment *rm.DealPayment) (abi.TokenAmount, error) { @@ -155,26 +159,33 @@ func savePayment(ctx fsm.Context, env ProviderDealEnvironment, payment *rm.DealP } func processLastVoucher(ctx fsm.Context, env ProviderDealEnvironment, channelState datatransfer.ChannelState) (abi.TokenAmount, error) { - voucher := channelState.LastVoucher() + voucher, err := channelState.LastVoucher() + if err != nil { + return abi.TokenAmount{}, err + } + // read payment and return response if present - if payment, isPayment := voucher.(*rm.DealPayment); isPayment { + if payment, err := rm.DealPaymentFromNode(voucher.Voucher); err == nil { return savePayment(ctx, env, payment) } - if _, isProposal := voucher.(*rm.DealProposal); isProposal { + if _, err := rm.DealProposalFromNode(voucher.Voucher); err == nil { return big.Zero(), nil } + return big.Zero(), errors.New("wrong voucher type") } -func errorDealResponse(dealID rm.ProviderDealIdentifier, err error) datatransfer.ValidationResult { +func errorDealResponse(dealID rm.ProviderDealIdentifier, errMsg error) datatransfer.ValidationResult { + dr := rm.DealResponse{ + ID: dealID.DealID, + Message: errMsg.Error(), + Status: rm.DealStatusErrored, + } + node := rm.BindnodeRegistry.TypeToNode(&dr) return datatransfer.ValidationResult{ - Accepted: false, - VoucherResult: &rm.DealResponse{ - ID: dealID.DealID, - Message: err.Error(), - Status: rm.DealStatusErrored, - }, + Accepted: false, + VoucherResult: &datatransfer.TypedVoucher{Voucher: node, Type: rm.DealResponseType}, } } diff --git a/retrievalmarket/impl/providerstates/provider_states_test.go b/retrievalmarket/impl/providerstates/provider_states_test.go index 740faada..dbca900c 100644 --- a/retrievalmarket/impl/providerstates/provider_states_test.go +++ b/retrievalmarket/impl/providerstates/provider_states_test.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/ipfs/go-cid" + "github.com/ipld/go-ipld-prime/node/basicnode" selectorparse "github.com/ipld/go-ipld-prime/traversal/selector/parse" "github.com/stretchr/testify/require" @@ -148,13 +149,23 @@ func TestUnpauseDeal(t *testing.T) { func TestUpdateFunding(t *testing.T) { ctx := context.Background() + emptyDealPayment := rm.DealPayment{} + emptyDealPaymentNode := rm.BindnodeRegistry.TypeToNode(&emptyDealPayment) + emptyDealPaymentVoucher := datatransfer.TypedVoucher{Voucher: emptyDealPaymentNode, Type: rm.DealPaymentType} + emptyDealProposal := rm.DealProposal{} + emptyDealProposalNode := rm.BindnodeRegistry.TypeToNode(&emptyDealProposal) + emptyDealProposalVoucher := datatransfer.TypedVoucher{Voucher: emptyDealProposalNode, Type: rm.DealProposalType} + dealResponseVoucher := func(resp rm.DealResponse) *datatransfer.TypedVoucher { + node := rm.BindnodeRegistry.TypeToNode(&resp) + return &datatransfer.TypedVoucher{Voucher: node, Type: rm.DealResponseType} + } eventMachine, err := fsm.NewEventProcessor(rm.ProviderDealState{}, "Status", providerstates.ProviderEvents) require.NoError(t, err) testCases := map[string]struct { status rm.DealStatus emptyChannelID bool fundReceived abi.TokenAmount - lastVoucher datatransfer.Voucher + lastVoucher datatransfer.TypedVoucher queued uint64 dtStatus datatransfer.Status channelStateErr error @@ -180,20 +191,20 @@ func TestUpdateFunding(t *testing.T) { }, "when last voucher incorrect type, sends response": { status: rm.DealStatusFundsNeededUnseal, - lastVoucher: &testnet.FakeDTType{}, + lastVoucher: datatransfer.TypedVoucher{Voucher: basicnode.NewString("Fake Voucher"), Type: datatransfer.TypeIdentifier("Fake")}, expectedFinalStatus: rm.DealStatusFundsNeededUnseal, expectedReceivedValidation: datatransfer.ValidationResult{ Accepted: false, - VoucherResult: &rm.DealResponse{ + VoucherResult: dealResponseVoucher(rm.DealResponse{ ID: dealID, Message: "wrong voucher type", Status: rm.DealStatusErrored, - }, + }), }, }, "when received payment with nothing owed on unseal, updates status, forces pause": { status: rm.DealStatusFundsNeededUnseal, - lastVoucher: &rm.DealPayment{}, + lastVoucher: emptyDealPaymentVoucher, queued: 0, dtStatus: datatransfer.ResponderPaused, savePaymentAmount: defaultUnsealPrice, @@ -209,7 +220,7 @@ func TestUpdateFunding(t *testing.T) { "when received payment with nothing owed, updates data limits, funds, and status": { status: rm.DealStatusFundsNeeded, fundReceived: defaultUnsealPrice, - lastVoucher: &rm.DealPayment{}, + lastVoucher: emptyDealPaymentVoucher, queued: defaultCurrentInterval, dtStatus: datatransfer.ResponderPaused, savePaymentAmount: defaultPaymentPerInterval, @@ -224,7 +235,7 @@ func TestUpdateFunding(t *testing.T) { "when received payment with nothing owed on last payment, sends response, sets finalization false, updates status": { status: rm.DealStatusFundsNeededLastPayment, fundReceived: big.Add(defaultUnsealPrice, defaultPaymentPerInterval), - lastVoucher: &rm.DealPayment{}, + lastVoucher: emptyDealPaymentVoucher, queued: defaultCurrentInterval + defaultCurrentInterval, dtStatus: datatransfer.Finalizing, savePaymentAmount: defaultPaymentPerInterval, @@ -232,17 +243,17 @@ func TestUpdateFunding(t *testing.T) { expectedFundsReceived: big.Add(defaultUnsealPrice, big.Add(defaultPaymentPerInterval, defaultPaymentPerInterval)), expectedReceivedValidation: datatransfer.ValidationResult{ Accepted: true, - VoucherResult: &rm.DealResponse{ + VoucherResult: dealResponseVoucher(rm.DealResponse{ ID: dealID, Status: rm.DealStatusCompleted, - }, + }), RequiresFinalization: false, DataLimit: defaultCurrentInterval + defaultCurrentInterval + defaultIntervalIncrease, }, }, "when received payment with more owed on unseal, sends response, stays paused": { status: rm.DealStatusFundsNeededUnseal, - lastVoucher: &rm.DealPayment{}, + lastVoucher: emptyDealPaymentVoucher, queued: 0, dtStatus: datatransfer.ResponderPaused, savePaymentAmount: big.Div(defaultUnsealPrice, big.NewInt(2)), @@ -250,11 +261,11 @@ func TestUpdateFunding(t *testing.T) { expectedFundsReceived: big.Div(defaultUnsealPrice, big.NewInt(2)), expectedReceivedValidation: datatransfer.ValidationResult{ Accepted: true, - VoucherResult: &rm.DealResponse{ + VoucherResult: dealResponseVoucher(rm.DealResponse{ ID: dealID, Status: rm.DealStatusFundsNeededUnseal, PaymentOwed: big.Div(defaultUnsealPrice, big.NewInt(2)), - }, + }), RequiresFinalization: true, ForcePause: true, DataLimit: defaultCurrentInterval, @@ -263,7 +274,7 @@ func TestUpdateFunding(t *testing.T) { "when received payment with more owed, sends response and does not change data limit": { status: rm.DealStatusFundsNeeded, fundReceived: defaultUnsealPrice, - lastVoucher: &rm.DealPayment{}, + lastVoucher: emptyDealPaymentVoucher, queued: defaultCurrentInterval, dtStatus: datatransfer.ResponderPaused, savePaymentAmount: big.Div(defaultPaymentPerInterval, big.NewInt(2)), @@ -271,11 +282,11 @@ func TestUpdateFunding(t *testing.T) { expectedFundsReceived: big.Add(defaultUnsealPrice, big.Div(defaultPaymentPerInterval, big.NewInt(2))), expectedReceivedValidation: datatransfer.ValidationResult{ Accepted: true, - VoucherResult: &rm.DealResponse{ + VoucherResult: dealResponseVoucher(rm.DealResponse{ ID: dealID, Status: rm.DealStatusFundsNeeded, PaymentOwed: big.Div(defaultPaymentPerInterval, big.NewInt(2)), - }, + }), RequiresFinalization: true, DataLimit: defaultCurrentInterval, }, @@ -283,7 +294,7 @@ func TestUpdateFunding(t *testing.T) { "when received payment with more owed on last payment, sends response and does not change finalization status": { status: rm.DealStatusFundsNeededLastPayment, fundReceived: big.Add(defaultUnsealPrice, defaultPaymentPerInterval), - lastVoucher: &rm.DealPayment{}, + lastVoucher: emptyDealPaymentVoucher, queued: defaultCurrentInterval + defaultCurrentInterval, dtStatus: datatransfer.Finalizing, savePaymentAmount: big.Div(defaultPaymentPerInterval, big.NewInt(2)), @@ -291,18 +302,18 @@ func TestUpdateFunding(t *testing.T) { expectedFundsReceived: big.Add(defaultUnsealPrice, big.Add(defaultPaymentPerInterval, big.Div(defaultPaymentPerInterval, big.NewInt(2)))), expectedReceivedValidation: datatransfer.ValidationResult{ Accepted: true, - VoucherResult: &rm.DealResponse{ + VoucherResult: dealResponseVoucher(rm.DealResponse{ ID: dealID, Status: rm.DealStatusFundsNeededLastPayment, PaymentOwed: big.Div(defaultPaymentPerInterval, big.NewInt(2)), - }, + }), RequiresFinalization: true, DataLimit: defaultCurrentInterval + defaultCurrentInterval + defaultIntervalIncrease, }, }, "when money owed with no payment on unseal, leaves request paused": { status: rm.DealStatusFundsNeededUnseal, - lastVoucher: &rm.DealProposal{}, + lastVoucher: emptyDealProposalVoucher, queued: 0, dtStatus: datatransfer.ResponderPaused, expectedFinalStatus: rm.DealStatusFundsNeededUnseal, @@ -316,18 +327,18 @@ func TestUpdateFunding(t *testing.T) { "when money owed with no payment, sends response and does not change data limit": { status: rm.DealStatusFundsNeeded, fundReceived: defaultUnsealPrice, - lastVoucher: &rm.DealPayment{}, + lastVoucher: emptyDealPaymentVoucher, queued: defaultCurrentInterval, dtStatus: datatransfer.ResponderPaused, expectedFinalStatus: rm.DealStatusFundsNeeded, expectedFundsReceived: defaultUnsealPrice, expectedReceivedValidation: datatransfer.ValidationResult{ Accepted: true, - VoucherResult: &rm.DealResponse{ + VoucherResult: dealResponseVoucher(rm.DealResponse{ ID: dealID, Status: rm.DealStatusFundsNeeded, PaymentOwed: defaultPaymentPerInterval, - }, + }), RequiresFinalization: true, DataLimit: defaultCurrentInterval, }, @@ -335,18 +346,18 @@ func TestUpdateFunding(t *testing.T) { "when no payment and money owed for last payment, sends response and does not change finalization status": { status: rm.DealStatusFundsNeededLastPayment, fundReceived: big.Add(defaultUnsealPrice, defaultPaymentPerInterval), - lastVoucher: &rm.DealPayment{}, + lastVoucher: emptyDealPaymentVoucher, queued: defaultCurrentInterval + defaultCurrentInterval, dtStatus: datatransfer.Finalizing, expectedFinalStatus: rm.DealStatusFundsNeededLastPayment, expectedFundsReceived: big.Add(defaultUnsealPrice, defaultPaymentPerInterval), expectedReceivedValidation: datatransfer.ValidationResult{ Accepted: true, - VoucherResult: &rm.DealResponse{ + VoucherResult: dealResponseVoucher(rm.DealResponse{ ID: dealID, Status: rm.DealStatusFundsNeededLastPayment, PaymentOwed: defaultPaymentPerInterval, - }, + }), RequiresFinalization: true, DataLimit: defaultCurrentInterval + defaultCurrentInterval + defaultIntervalIncrease, }, @@ -354,7 +365,7 @@ func TestUpdateFunding(t *testing.T) { "when surplus payment with nothing owed, updates data limits accordingly": { status: rm.DealStatusFundsNeeded, fundReceived: defaultUnsealPrice, - lastVoucher: &rm.DealPayment{}, + lastVoucher: emptyDealPaymentVoucher, queued: defaultCurrentInterval, dtStatus: datatransfer.ResponderPaused, savePaymentAmount: big.Mul(defaultPricePerByte, big.NewIntUnsigned(defaultCurrentInterval+defaultCurrentInterval+defaultIntervalIncrease)), @@ -371,7 +382,7 @@ func TestUpdateFunding(t *testing.T) { "when no money owed and no payment, updates data limits and status": { status: rm.DealStatusFundsNeeded, fundReceived: big.Add(defaultUnsealPrice, defaultPaymentPerInterval), - lastVoucher: &rm.DealPayment{}, + lastVoucher: emptyDealPaymentVoucher, queued: defaultCurrentInterval, dtStatus: datatransfer.ResponderPaused, expectedFinalStatus: rm.DealStatusOngoing, @@ -385,55 +396,55 @@ func TestUpdateFunding(t *testing.T) { "when no money owed and no payment on last payment, sends response, sets finalization false, updates status": { status: rm.DealStatusFundsNeededLastPayment, fundReceived: big.Add(defaultUnsealPrice, big.Add(defaultPaymentPerInterval, defaultPaymentPerInterval)), - lastVoucher: &rm.DealPayment{}, + lastVoucher: emptyDealPaymentVoucher, queued: defaultCurrentInterval + defaultCurrentInterval, dtStatus: datatransfer.Finalizing, expectedFinalStatus: rm.DealStatusFinalizing, expectedFundsReceived: big.Add(defaultUnsealPrice, big.Add(defaultPaymentPerInterval, defaultPaymentPerInterval)), expectedReceivedValidation: datatransfer.ValidationResult{ Accepted: true, - VoucherResult: &rm.DealResponse{ + VoucherResult: dealResponseVoucher(rm.DealResponse{ ID: dealID, Status: rm.DealStatusCompleted, - }, + }), RequiresFinalization: false, DataLimit: defaultCurrentInterval + defaultCurrentInterval + defaultIntervalIncrease, }, }, "get chain head error": { status: rm.DealStatusFundsNeededUnseal, - lastVoucher: &rm.DealPayment{}, + lastVoucher: emptyDealPaymentVoucher, chainHeadErr: errors.New("something went wrong"), expectedFinalStatus: rm.DealStatusFailing, expectedMessage: "something went wrong", expectedReceivedValidation: datatransfer.ValidationResult{ Accepted: false, - VoucherResult: &rm.DealResponse{ + VoucherResult: dealResponseVoucher(rm.DealResponse{ ID: dealID, Message: "something went wrong", Status: rm.DealStatusErrored, - }, + }), }, }, "save payment voucher error": { status: rm.DealStatusFundsNeededUnseal, - lastVoucher: &rm.DealPayment{}, + lastVoucher: emptyDealPaymentVoucher, savePaymentErr: errors.New("something went wrong"), expectedFinalStatus: rm.DealStatusFailing, expectedMessage: "something went wrong", expectedReceivedValidation: datatransfer.ValidationResult{ Accepted: false, - VoucherResult: &rm.DealResponse{ + VoucherResult: dealResponseVoucher(rm.DealResponse{ ID: dealID, Message: "something went wrong", Status: rm.DealStatusErrored, - }, + }), }, }, "update validation status error": { status: rm.DealStatusFundsNeeded, fundReceived: big.Add(defaultUnsealPrice, defaultPaymentPerInterval), - lastVoucher: &rm.DealPayment{}, + lastVoucher: emptyDealPaymentVoucher, queued: defaultCurrentInterval, dtStatus: datatransfer.ResponderPaused, updateValidationStatusErr: errors.New("something went wrong"), @@ -480,7 +491,7 @@ func TestUpdateFunding(t *testing.T) { } } chst := testnet.NewTestChannel(testnet.TestChannelParams{ - Vouchers: []datatransfer.Voucher{ + Vouchers: []datatransfer.TypedVoucher{ data.lastVoucher, }, Status: data.dtStatus, @@ -502,7 +513,7 @@ func TestUpdateFunding(t *testing.T) { require.Equal(t, data.expectedFinalStatus, dealState.Status) require.True(t, data.expectedFundsReceived.Equals(dealState.FundsReceived)) require.Equal(t, data.expectedMessage, dealState.Message) - require.Equal(t, data.expectedReceivedValidation, environment.NewValidationStatus) + require.True(t, data.expectedReceivedValidation.Equals(environment.NewValidationStatus)) }) } } diff --git a/retrievalmarket/impl/requestvalidation/requestvalidation.go b/retrievalmarket/impl/requestvalidation/requestvalidation.go index e7b66d4c..5c4f6194 100644 --- a/retrievalmarket/impl/requestvalidation/requestvalidation.go +++ b/retrievalmarket/impl/requestvalidation/requestvalidation.go @@ -1,15 +1,13 @@ package requestvalidation import ( - "bytes" "context" "errors" "time" "github.com/ipfs/go-cid" - logging "github.com/ipfs/go-log/v2" "github.com/ipld/go-ipld-prime" - "github.com/ipld/go-ipld-prime/codec/dagcbor" + "github.com/ipld/go-ipld-prime/datamodel" selectorparse "github.com/ipld/go-ipld-prime/traversal/selector/parse" peer "github.com/libp2p/go-libp2p-core/peer" @@ -21,18 +19,10 @@ import ( rm "github.com/filecoin-project/go-fil-markets/retrievalmarket" ) -var log = logging.Logger("markets-rtvl-reval") - -var allSelectorBytes []byte +var allSelector = selectorparse.CommonSelector_ExploreAllRecursively var askTimeout = 5 * time.Second -func init() { - buf := new(bytes.Buffer) - _ = dagcbor.Encode(selectorparse.CommonSelector_ExploreAllRecursively, buf) - allSelectorBytes = buf.Bytes() -} - // ValidationEnvironment contains the dependencies needed to validate deals type ValidationEnvironment interface { GetAsk(ctx context.Context, payloadCid cid.Cid, pieceCid *cid.Cid, piece piecestore.PieceInfo, isUnsealed bool, client peer.ID) (rm.Ask, error) @@ -58,30 +48,32 @@ func NewProviderRequestValidator(env ValidationEnvironment) *ProviderRequestVali } // ValidatePush validates a push request received from the peer that will send data -func (rv *ProviderRequestValidator) ValidatePush(_ datatransfer.ChannelID, sender peer.ID, voucher datatransfer.Voucher, baseCid cid.Cid, selector ipld.Node) (datatransfer.ValidationResult, error) { +func (rv *ProviderRequestValidator) ValidatePush(_ datatransfer.ChannelID, sender peer.ID, voucher datamodel.Node, baseCid cid.Cid, selector datamodel.Node) (datatransfer.ValidationResult, error) { return datatransfer.ValidationResult{}, errors.New("No pushes accepted") } // ValidatePull validates a pull request received from the peer that will receive data -func (rv *ProviderRequestValidator) ValidatePull(_ datatransfer.ChannelID, receiver peer.ID, voucher datatransfer.Voucher, baseCid cid.Cid, selector ipld.Node) (datatransfer.ValidationResult, error) { - proposal, ok := voucher.(*rm.DealProposal) - if !ok { - return datatransfer.ValidationResult{}, errors.New("wrong voucher type") +func (rv *ProviderRequestValidator) ValidatePull(_ datatransfer.ChannelID, receiver peer.ID, voucher datamodel.Node, baseCid cid.Cid, selector datamodel.Node) (datatransfer.ValidationResult, error) { + proposal, err := rm.DealProposalFromNode(voucher) + if err != nil { + return datatransfer.ValidationResult{}, err } response, err := rv.validatePull(receiver, proposal, baseCid, selector) return response, err } -func rejectProposal(proposal *rm.DealProposal, status rm.DealStatus, reason string) datatransfer.ValidationResult { - return datatransfer.ValidationResult{ - Accepted: false, - VoucherResult: &rm.DealResponse{ - ID: proposal.ID, - Status: status, - Message: reason, - }, +func rejectProposal(proposal *rm.DealProposal, status rm.DealStatus, reason string) (datatransfer.ValidationResult, error) { + dr := rm.DealResponse{ + ID: proposal.ID, + Status: status, + Message: reason, } + node := rm.BindnodeRegistry.TypeToNode(&dr) + return datatransfer.ValidationResult{ + Accepted: false, + VoucherResult: &datatransfer.TypedVoucher{Voucher: node, Type: rm.DealResponseType}, + }, nil } // validatePull is called by the data provider when a new graphsync pull @@ -90,24 +82,19 @@ func rejectProposal(proposal *rm.DealProposal, status rm.DealStatus, reason stri // By default the graphsync request starts immediately sending data, unless // validatePull returns ErrPause or the data-transfer has not yet started // (because the provider is still unsealing the data). -func (rv *ProviderRequestValidator) validatePull(receiver peer.ID, proposal *rm.DealProposal, baseCid cid.Cid, selector ipld.Node) (datatransfer.ValidationResult, error) { +func (rv *ProviderRequestValidator) validatePull(receiver peer.ID, proposal *rm.DealProposal, baseCid cid.Cid, selector datamodel.Node) (datatransfer.ValidationResult, error) { // Check the proposal CID matches if proposal.PayloadCID != baseCid { - return rejectProposal(proposal, rm.DealStatusRejected, "incorrect CID for this proposal"), nil + return rejectProposal(proposal, rm.DealStatusRejected, "incorrect CID for this proposal") } // Check the proposal selector matches - buf := new(bytes.Buffer) - err := dagcbor.Encode(selector, buf) - if err != nil { - return rejectProposal(proposal, rm.DealStatusRejected, err.Error()), nil - } - bytesCompare := allSelectorBytes + sel := allSelector if proposal.SelectorSpecified() { - bytesCompare = proposal.Selector.Raw + sel = proposal.Selector.Node } - if !bytes.Equal(buf.Bytes(), bytesCompare) { - return rejectProposal(proposal, rm.DealStatusRejected, "incorrect selector specified for this proposal"), nil + if !ipld.DeepEqual(sel, selector) { + return rejectProposal(proposal, rm.DealStatusRejected, "incorrect selector specified for this proposal") } // This is a new graphsync request (not a restart) @@ -119,9 +106,9 @@ func (rv *ProviderRequestValidator) validatePull(receiver peer.ID, proposal *rm. pieceInfo, isUnsealed, err := rv.env.GetPiece(deal.PayloadCID, deal.PieceCID) if err != nil { if err == rm.ErrNotFound { - return rejectProposal(proposal, rm.DealStatusDealNotFound, err.Error()), nil + return rejectProposal(proposal, rm.DealStatusDealNotFound, err.Error()) } - return rejectProposal(proposal, rm.DealStatusErrored, err.Error()), nil + return rejectProposal(proposal, rm.DealStatusErrored, err.Error()) } ctx, cancel := context.WithTimeout(context.TODO(), askTimeout) @@ -129,22 +116,22 @@ func (rv *ProviderRequestValidator) validatePull(receiver peer.ID, proposal *rm. ask, err := rv.env.GetAsk(ctx, deal.PayloadCID, deal.PieceCID, pieceInfo, isUnsealed, deal.Receiver) if err != nil { - return rejectProposal(proposal, rm.DealStatusErrored, err.Error()), nil + return rejectProposal(proposal, rm.DealStatusErrored, err.Error()) } // check that the deal parameters match our required parameters or // reject outright err = rv.env.CheckDealParams(ask, deal.PricePerByte, deal.PaymentInterval, deal.PaymentIntervalIncrease, deal.UnsealPrice) if err != nil { - return rejectProposal(proposal, rm.DealStatusRejected, err.Error()), nil + return rejectProposal(proposal, rm.DealStatusRejected, err.Error()) } accepted, reason, err := rv.env.RunDealDecisioningLogic(context.TODO(), deal) if err != nil { - return rejectProposal(proposal, rm.DealStatusErrored, err.Error()), nil + return rejectProposal(proposal, rm.DealStatusErrored, err.Error()) } if !accepted { - return rejectProposal(proposal, rm.DealStatusRejected, reason), nil + return rejectProposal(proposal, rm.DealStatusRejected, reason) } deal.PieceInfo = &pieceInfo @@ -160,13 +147,15 @@ func (rv *ProviderRequestValidator) validatePull(receiver peer.ID, proposal *rm. } // Pause the data transfer while unsealing the data. // The state machine will unpause the transfer when unsealing completes. + dr := rm.DealResponse{ + ID: proposal.ID, + Status: status, + PaymentOwed: deal.Params.OutstandingBalance(big.Zero(), 0, false), + } + node := rm.BindnodeRegistry.TypeToNode(&dr) result := datatransfer.ValidationResult{ - Accepted: true, - VoucherResult: &rm.DealResponse{ - ID: proposal.ID, - Status: status, - PaymentOwed: deal.Params.OutstandingBalance(big.Zero(), 0, false), - }, + Accepted: true, + VoucherResult: &datatransfer.TypedVoucher{Voucher: node, Type: rm.DealResponseType}, ForcePause: true, DataLimit: deal.Params.NextInterval(big.Zero()), RequiresFinalization: true, @@ -176,8 +165,12 @@ func (rv *ProviderRequestValidator) validatePull(receiver peer.ID, proposal *rm. // ValidateRestart validates a request on restart, based on its current state func (rv *ProviderRequestValidator) ValidateRestart(channelID datatransfer.ChannelID, channelState datatransfer.ChannelState) (datatransfer.ValidationResult, error) { - proposal, ok := channelState.Voucher().(*rm.DealProposal) - if !ok { + voucher, err := channelState.Voucher() + if err != nil { + return datatransfer.ValidationResult{}, err + } + proposal, err := rm.DealProposalFromNode(voucher.Voucher) + if err != nil { return datatransfer.ValidationResult{}, errors.New("wrong voucher type") } @@ -186,7 +179,7 @@ func (rv *ProviderRequestValidator) ValidateRestart(channelID datatransfer.Chann // read the deal state deal, err := rv.env.Get(dealID) if err != nil { - return errorDealResponse(dealID, err), nil + return errorDealResponse(dealID, err) } // produce validation based on current deal state and channel state @@ -207,13 +200,15 @@ func requiresFinalization(deal rm.ProviderDealState, channelState datatransfer.C return owed.GreaterThan(big.Zero()) } -func errorDealResponse(dealID rm.ProviderDealIdentifier, err error) datatransfer.ValidationResult { - return datatransfer.ValidationResult{ - Accepted: false, - VoucherResult: &rm.DealResponse{ - ID: dealID.DealID, - Message: err.Error(), - Status: rm.DealStatusErrored, - }, +func errorDealResponse(dealID rm.ProviderDealIdentifier, err error) (datatransfer.ValidationResult, error) { + dr := rm.DealResponse{ + ID: dealID.DealID, + Message: err.Error(), + Status: rm.DealStatusErrored, } + node := rm.BindnodeRegistry.TypeToNode(&dr) + return datatransfer.ValidationResult{ + Accepted: false, + VoucherResult: &datatransfer.TypedVoucher{Voucher: node, Type: rm.DealResponseType}, + }, nil } diff --git a/retrievalmarket/impl/requestvalidation/requestvalidation_test.go b/retrievalmarket/impl/requestvalidation/requestvalidation_test.go index 6bbe47af..c708b232 100644 --- a/retrievalmarket/impl/requestvalidation/requestvalidation_test.go +++ b/retrievalmarket/impl/requestvalidation/requestvalidation_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/ipfs/go-cid" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" basicnode "github.com/ipld/go-ipld-prime/node/basic" "github.com/ipld/go-ipld-prime/traversal/selector/builder" selectorparse "github.com/ipld/go-ipld-prime/traversal/selector/parse" @@ -26,23 +26,40 @@ import ( func TestValidatePush(t *testing.T) { fve := &fakeValidationEnvironment{} sender := shared_testutil.GeneratePeers(1)[0] - voucher := shared_testutil.MakeTestDealProposal() + testDp := shared_testutil.MakeTestDealProposal() + voucher := rm.BindnodeRegistry.TypeToNode(testDp) requestValidator := requestvalidation.NewProviderRequestValidator(fve) - validationResult, err := requestValidator.ValidatePush(datatransfer.ChannelID{}, sender, &voucher, voucher.PayloadCID, selectorparse.CommonSelector_ExploreAllRecursively) - require.Equal(t, nil, validationResult.VoucherResult) + validationResult, err := requestValidator.ValidatePush(datatransfer.ChannelID{}, sender, voucher, testDp.PayloadCID, selectorparse.CommonSelector_ExploreAllRecursively) + require.Nil(t, validationResult.VoucherResult) require.Error(t, err) } +func dealResponseToVoucher(t *testing.T, status rm.DealStatus, id rm.DealID, message string, owed *abi.TokenAmount) *datatransfer.TypedVoucher { + dr := rm.DealResponse{ + Status: status, + ID: id, + Message: message, + } + if owed != nil { + dr.PaymentOwed = *owed + } + node := rm.BindnodeRegistry.TypeToNode(&dr) + return &datatransfer.TypedVoucher{Voucher: node, Type: rm.DealResponseType} +} + func TestValidatePull(t *testing.T) { proposal := shared_testutil.MakeTestDealProposal() + node := rm.BindnodeRegistry.TypeToNode(proposal) + proposalVoucher := datatransfer.TypedVoucher{Voucher: node, Type: rm.DealProposalType} + zero := big.Zero() testCases := map[string]struct { fve fakeValidationEnvironment sender peer.ID - voucher datatransfer.Voucher + voucher datatransfer.TypedVoucher baseCid cid.Cid - selector ipld.Node - expectedVoucherResult datatransfer.VoucherResult + selector datamodel.Node + expectedVoucherResult *datatransfer.TypedVoucher expectedError error expectAccepted bool expectForcePause bool @@ -50,93 +67,65 @@ func TestValidatePull(t *testing.T) { expectRequiresFinalization bool }{ "not a retrieval voucher": { - expectedError: errors.New("wrong voucher type"), + expectedError: errors.New("empty voucher"), }, "proposal and base cid do not match": { - baseCid: shared_testutil.GenerateCids(1)[0], - voucher: &proposal, - expectedVoucherResult: &rm.DealResponse{ - Status: rm.DealStatusRejected, - ID: proposal.ID, - Message: "incorrect CID for this proposal", - }, + baseCid: shared_testutil.GenerateCids(1)[0], + voucher: proposalVoucher, + expectedVoucherResult: dealResponseToVoucher(t, rm.DealStatusRejected, proposal.ID, "incorrect CID for this proposal", nil), }, "proposal and selector do not match": { - baseCid: proposal.PayloadCID, - selector: builder.NewSelectorSpecBuilder(basicnode.Prototype.Any).Matcher().Node(), - voucher: &proposal, - expectedVoucherResult: &rm.DealResponse{ - Status: rm.DealStatusRejected, - ID: proposal.ID, - Message: "incorrect selector specified for this proposal", - }, + baseCid: proposal.PayloadCID, + selector: builder.NewSelectorSpecBuilder(basicnode.Prototype.Any).Matcher().Node(), + voucher: proposalVoucher, + expectedVoucherResult: dealResponseToVoucher(t, rm.DealStatusRejected, proposal.ID, "incorrect selector specified for this proposal", nil), }, "get piece other err": { fve: fakeValidationEnvironment{ RunDealDecisioningLogicAccepted: true, GetPieceErr: errors.New("something went wrong"), }, - baseCid: proposal.PayloadCID, - selector: selectorparse.CommonSelector_ExploreAllRecursively, - voucher: &proposal, - expectedVoucherResult: &rm.DealResponse{ - Status: rm.DealStatusErrored, - ID: proposal.ID, - Message: "something went wrong", - }, + baseCid: proposal.PayloadCID, + selector: selectorparse.CommonSelector_ExploreAllRecursively, + voucher: proposalVoucher, + expectedVoucherResult: dealResponseToVoucher(t, rm.DealStatusErrored, proposal.ID, "something went wrong", nil), }, "get piece not found err": { fve: fakeValidationEnvironment{ RunDealDecisioningLogicAccepted: true, GetPieceErr: rm.ErrNotFound, }, - baseCid: proposal.PayloadCID, - selector: selectorparse.CommonSelector_ExploreAllRecursively, - voucher: &proposal, - expectedVoucherResult: &rm.DealResponse{ - Status: rm.DealStatusDealNotFound, - ID: proposal.ID, - Message: rm.ErrNotFound.Error(), - }, + baseCid: proposal.PayloadCID, + selector: selectorparse.CommonSelector_ExploreAllRecursively, + voucher: proposalVoucher, + expectedVoucherResult: dealResponseToVoucher(t, rm.DealStatusDealNotFound, proposal.ID, rm.ErrNotFound.Error(), nil), }, "check deal params err": { fve: fakeValidationEnvironment{ CheckDealParamsError: errors.New("something went wrong"), }, - baseCid: proposal.PayloadCID, - selector: selectorparse.CommonSelector_ExploreAllRecursively, - voucher: &proposal, - expectedVoucherResult: &rm.DealResponse{ - Status: rm.DealStatusRejected, - ID: proposal.ID, - Message: "something went wrong", - }, + baseCid: proposal.PayloadCID, + selector: selectorparse.CommonSelector_ExploreAllRecursively, + voucher: proposalVoucher, + expectedVoucherResult: dealResponseToVoucher(t, rm.DealStatusRejected, proposal.ID, "something went wrong", nil), }, "run deal decioning error": { fve: fakeValidationEnvironment{ RunDealDecisioningLogicError: errors.New("something went wrong"), }, - baseCid: proposal.PayloadCID, - selector: selectorparse.CommonSelector_ExploreAllRecursively, - voucher: &proposal, - expectedVoucherResult: &rm.DealResponse{ - Status: rm.DealStatusErrored, - ID: proposal.ID, - Message: "something went wrong", - }, + baseCid: proposal.PayloadCID, + selector: selectorparse.CommonSelector_ExploreAllRecursively, + voucher: proposalVoucher, + expectedVoucherResult: dealResponseToVoucher(t, rm.DealStatusErrored, proposal.ID, "something went wrong", nil), }, "run deal decioning rejected": { fve: fakeValidationEnvironment{ RunDealDecisioningLogicFailReason: "something went wrong", }, - baseCid: proposal.PayloadCID, - selector: selectorparse.CommonSelector_ExploreAllRecursively, - voucher: &proposal, - expectedVoucherResult: &rm.DealResponse{ - Status: rm.DealStatusRejected, - ID: proposal.ID, - Message: "something went wrong", - }, + baseCid: proposal.PayloadCID, + selector: selectorparse.CommonSelector_ExploreAllRecursively, + voucher: proposalVoucher, + expectedVoucherResult: dealResponseToVoucher(t, rm.DealStatusRejected, proposal.ID, "something went wrong", nil), }, "begin tracking error": { fve: fakeValidationEnvironment{ @@ -145,21 +134,17 @@ func TestValidatePull(t *testing.T) { }, baseCid: proposal.PayloadCID, selector: selectorparse.CommonSelector_ExploreAllRecursively, - voucher: &proposal, + voucher: proposalVoucher, expectedError: errors.New("everything is awful"), }, "success": { fve: fakeValidationEnvironment{ RunDealDecisioningLogicAccepted: true, }, - baseCid: proposal.PayloadCID, - selector: selectorparse.CommonSelector_ExploreAllRecursively, - voucher: &proposal, - expectedVoucherResult: &rm.DealResponse{ - Status: rm.DealStatusAccepted, - ID: proposal.ID, - PaymentOwed: big.Zero(), - }, + baseCid: proposal.PayloadCID, + selector: selectorparse.CommonSelector_ExploreAllRecursively, + voucher: proposalVoucher, + expectedVoucherResult: dealResponseToVoucher(t, rm.DealStatusAccepted, proposal.ID, "", &zero), expectAccepted: true, expectForcePause: true, expectDataLimit: proposal.PaymentInterval, @@ -169,8 +154,12 @@ func TestValidatePull(t *testing.T) { for testCase, data := range testCases { t.Run(testCase, func(t *testing.T) { requestValidator := requestvalidation.NewProviderRequestValidator(&data.fve) - validationResult, err := requestValidator.ValidatePull(datatransfer.ChannelID{}, data.sender, data.voucher, data.baseCid, data.selector) - require.Equal(t, data.expectedVoucherResult, validationResult.VoucherResult) + validationResult, err := requestValidator.ValidatePull(datatransfer.ChannelID{}, data.sender, data.voucher.Voucher, data.baseCid, data.selector) + if data.expectedVoucherResult == nil { + require.Nil(t, validationResult.VoucherResult) + } else { + require.True(t, data.expectedVoucherResult.Equals(*validationResult.VoucherResult)) + } require.Equal(t, data.expectAccepted, validationResult.Accepted) require.Equal(t, data.expectForcePause, validationResult.ForcePause) require.Equal(t, data.expectDataLimit, validationResult.DataLimit) @@ -206,11 +195,13 @@ func TestValidateRestart(t *testing.T) { ID: dealID, Params: params, } + node := rm.BindnodeRegistry.TypeToNode(&proposal) + proposalVoucher := datatransfer.TypedVoucher{Voucher: node, Type: rm.DealProposalType} testCases := map[string]struct { status rm.DealStatus fundReceived abi.TokenAmount - voucher datatransfer.Voucher + voucher datatransfer.TypedVoucher queued uint64 dtStatus datatransfer.Status dealErr error @@ -220,7 +211,7 @@ func TestValidateRestart(t *testing.T) { "normal operation": { status: rm.DealStatusOngoing, fundReceived: big.Add(defaultUnsealPrice, defaultPaymentPerInterval), - voucher: &proposal, + voucher: proposalVoucher, queued: defaultCurrentInterval, dtStatus: datatransfer.Ongoing, expectedValidation: datatransfer.ValidationResult{ @@ -232,7 +223,7 @@ func TestValidateRestart(t *testing.T) { "unsealing": { status: rm.DealStatusUnsealing, fundReceived: defaultUnsealPrice, - voucher: &proposal, + voucher: proposalVoucher, queued: 0, dtStatus: datatransfer.ResponderPaused, expectedValidation: datatransfer.ValidationResult{ @@ -245,7 +236,7 @@ func TestValidateRestart(t *testing.T) { "last payment, no money owed": { status: rm.DealStatusFinalizing, fundReceived: big.Add(defaultUnsealPrice, big.Add(defaultPaymentPerInterval, defaultPaymentPerInterval)), - voucher: &proposal, + voucher: proposalVoucher, queued: defaultCurrentInterval + defaultCurrentInterval, dtStatus: datatransfer.Finalizing, expectedValidation: datatransfer.ValidationResult{ @@ -257,7 +248,7 @@ func TestValidateRestart(t *testing.T) { "last payment, money owed": { status: rm.DealStatusFundsNeededLastPayment, fundReceived: big.Add(defaultUnsealPrice, defaultPaymentPerInterval), - voucher: &proposal, + voucher: proposalVoucher, queued: defaultCurrentInterval + defaultCurrentInterval, dtStatus: datatransfer.Finalizing, expectedValidation: datatransfer.ValidationResult{ @@ -267,19 +258,15 @@ func TestValidateRestart(t *testing.T) { }, }, "get deal error": { - voucher: &proposal, + voucher: proposalVoucher, dealErr: errors.New("something went wrong"), expectedValidation: datatransfer.ValidationResult{ - Accepted: false, - VoucherResult: &rm.DealResponse{ - ID: dealID, - Message: "something went wrong", - Status: rm.DealStatusErrored, - }, + Accepted: false, + VoucherResult: dealResponseToVoucher(t, rm.DealStatusErrored, dealID, "something went wrong", nil), }, }, "wrong voucher type": { - voucher: &shared_testutil.FakeDTType{}, + voucher: datatransfer.TypedVoucher{Voucher: basicnode.NewString("bad voucher"), Type: datatransfer.TypeIdentifier("bad")}, expectedValidationErr: errors.New("wrong voucher type"), }, } @@ -296,14 +283,14 @@ func TestValidateRestart(t *testing.T) { fve := &fakeValidationEnvironment{GetDeal: *dealState, GetError: data.dealErr} requestValidator := requestvalidation.NewProviderRequestValidator(fve) chst := shared_testutil.NewTestChannel(shared_testutil.TestChannelParams{ - Vouchers: []datatransfer.Voucher{ + Vouchers: []datatransfer.TypedVoucher{ data.voucher, }, Status: data.dtStatus, Queued: data.queued, }) validationResult, err := requestValidator.ValidateRestart(datatransfer.ChannelID{}, chst) - require.Equal(t, data.expectedValidation, validationResult) + require.True(t, data.expectedValidation.Equals(validationResult)) if data.expectedValidationErr == nil { require.NoError(t, err) } else { diff --git a/retrievalmarket/storage_retrieval_integration_test.go b/retrievalmarket/storage_retrieval_integration_test.go index a428092d..951d700f 100644 --- a/retrievalmarket/storage_retrieval_integration_test.go +++ b/retrievalmarket/storage_retrieval_integration_test.go @@ -12,7 +12,7 @@ import ( "github.com/ipfs/go-datastore" "github.com/ipfs/go-datastore/namespace" "github.com/ipld/go-car" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" cidlink "github.com/ipld/go-ipld-prime/linking/cid" selectorparse "github.com/ipld/go-ipld-prime/traversal/selector/parse" "github.com/libp2p/go-libp2p-core/peer" @@ -503,11 +503,11 @@ func newRetrievalHarnessWithDeps( type fakeDTValidator struct{} -func (v *fakeDTValidator) ValidatePush(_ datatransfer.ChannelID, sender peer.ID, voucher datatransfer.Voucher, baseCid cid.Cid, selector ipld.Node) (datatransfer.ValidationResult, error) { +func (v *fakeDTValidator) ValidatePush(_ datatransfer.ChannelID, sender peer.ID, voucher datamodel.Node, baseCid cid.Cid, selector datamodel.Node) (datatransfer.ValidationResult, error) { return datatransfer.ValidationResult{Accepted: true}, nil } -func (v *fakeDTValidator) ValidatePull(_ datatransfer.ChannelID, receiver peer.ID, voucher datatransfer.Voucher, baseCid cid.Cid, selector ipld.Node) (datatransfer.ValidationResult, error) { +func (v *fakeDTValidator) ValidatePull(_ datatransfer.ChannelID, receiver peer.ID, voucher datamodel.Node, baseCid cid.Cid, selector datamodel.Node) (datatransfer.ValidationResult, error) { return datatransfer.ValidationResult{Accepted: true}, nil } diff --git a/retrievalmarket/types.go b/retrievalmarket/types.go index 9160dcc5..09aca12c 100644 --- a/retrievalmarket/types.go +++ b/retrievalmarket/types.go @@ -1,16 +1,16 @@ package retrievalmarket import ( - "bytes" + _ "embed" "errors" "fmt" "github.com/ipfs/go-cid" - "github.com/ipld/go-ipld-prime" - "github.com/ipld/go-ipld-prime/codec/dagcbor" + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/node/bindnode" + bindnoderegistry "github.com/ipld/go-ipld-prime/node/bindnode/registry" "github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/protocol" - cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" @@ -24,6 +24,9 @@ import ( //go:generate cbor-gen-for --map-encoding Query QueryResponse DealProposal DealResponse Params QueryParams DealPayment ClientDealState ProviderDealState PaymentInfo RetrievalPeer Ask +//go:embed types.ipldsch +var embedSchema []byte + // QueryProtocolID is the protocol for querying information about retrieval // deal parameters const QueryProtocolID = protocol.ID("/fil/retrieval/qry/1.0.0") @@ -146,7 +149,7 @@ const ( // for the retrieval deal type QueryParams struct { PieceCID *cid.Cid // optional, query if miner has this cid in this piece. some miners may not be able to respond. - //Selector ipld.Node // optional, query if miner has this cid in this piece. some miners may not be able to respond. + //Selector datamodel.Node // optional, query if miner has this cid in this piece. some miners may not be able to respond. //MaxPricePerByte abi.TokenAmount // optional, tell miner uninterested if more expensive than this //MinPaymentInterval uint64 // optional, tell miner uninterested unless payment interval is greater than this //MinPaymentIntervalIncrease uint64 // optional, tell miner uninterested unless payment interval increase is greater than this @@ -230,7 +233,7 @@ func IsTerminalStatus(status DealStatus) bool { // Params are the parameters requested for a retrieval deal proposal type Params struct { - Selector *cbg.Deferred // V1 + Selector CborGenCompatibleNode // V1 PieceCID *cid.Cid PricePerByte abi.TokenAmount PaymentInterval uint64 // when to request payment @@ -238,8 +241,15 @@ type Params struct { UnsealPrice abi.TokenAmount } +// paramsBindnodeOptions is the bindnode options required to convert custom +// types used by the Param type +var paramsBindnodeOptions = []bindnode.Option{ + CborGenCompatibleNodeBindnodeOption, + TokenAmountBindnodeOption, +} + func (p Params) SelectorSpecified() bool { - return p.Selector != nil && !bytes.Equal(p.Selector.Raw, cbg.CborNull) + return !p.Selector.IsNull() } func (p Params) IntervalLowerBound(currentInterval uint64) uint64 { @@ -330,20 +340,13 @@ func NewParamsV0(pricePerByte abi.TokenAmount, paymentInterval uint64, paymentIn } // NewParamsV1 generates parameters for a retrieval deal, including a selector -func NewParamsV1(pricePerByte abi.TokenAmount, paymentInterval uint64, paymentIntervalIncrease uint64, sel ipld.Node, pieceCid *cid.Cid, unsealPrice abi.TokenAmount) (Params, error) { - var buffer bytes.Buffer - +func NewParamsV1(pricePerByte abi.TokenAmount, paymentInterval uint64, paymentIntervalIncrease uint64, sel datamodel.Node, pieceCid *cid.Cid, unsealPrice abi.TokenAmount) (Params, error) { if sel == nil { return Params{}, xerrors.New("selector required for NewParamsV1") } - err := dagcbor.Encode(sel, &buffer) - if err != nil { - return Params{}, xerrors.Errorf("error encoding selector: %w", err) - } - return Params{ - Selector: &cbg.Deferred{Raw: buffer.Bytes()}, + Selector: CborGenCompatibleNode{Node: sel}, PieceCID: pieceCid, PricePerByte: pricePerByte, PaymentInterval: paymentInterval, @@ -366,9 +369,24 @@ type DealProposal struct { Params } -// Type method makes DealProposal usable as a voucher -func (dp *DealProposal) Type() datatransfer.TypeIdentifier { - return "RetrievalDealProposal/1" +// DealProposalType is the DealProposal voucher type +const DealProposalType = datatransfer.TypeIdentifier("RetrievalDealProposal/1") + +// dealProposalBindnodeOptions is the bindnode options required to convert +// custom types used by the DealProposal type; the only custom types involved +// are for Params so we can reuse those options. +var dealProposalBindnodeOptions = paramsBindnodeOptions + +func DealProposalFromNode(node datamodel.Node) (*DealProposal, error) { + if node == nil { + return nil, fmt.Errorf("empty voucher") + } + dpIface, err := BindnodeRegistry.TypeFromNode(node, &DealProposal{}) + if err != nil { + return nil, xerrors.Errorf("invalid DealProposal: %w", err) + } + dp, _ := dpIface.(*DealProposal) // safe to assume type + return dp, nil } // DealProposalUndefined is an undefined deal proposal @@ -385,14 +403,28 @@ type DealResponse struct { Message string } -// Type method makes DealResponse usable as a voucher result -func (dr *DealResponse) Type() datatransfer.TypeIdentifier { - return "RetrievalDealResponse/1" -} +// DealResponseType is the DealResponse usable as a voucher type +const DealResponseType = datatransfer.TypeIdentifier("RetrievalDealResponse/1") + +// dealResponseBindnodeOptions is the bindnode options required to convert custom +// types used by the DealResponse type +var dealResponseBindnodeOptions = []bindnode.Option{TokenAmountBindnodeOption} // DealResponseUndefined is an undefined deal response var DealResponseUndefined = DealResponse{} +func DealResponseFromNode(node datamodel.Node) (*DealResponse, error) { + if node == nil { + return nil, fmt.Errorf("empty voucher") + } + dpIface, err := BindnodeRegistry.TypeFromNode(node, &DealResponse{}) + if err != nil { + return nil, xerrors.Errorf("invalid DealResponse: %w", err) + } + dp, _ := dpIface.(*DealResponse) // safe to assume type + return dp, nil +} + // DealPayment is a payment for an in progress retrieval deal type DealPayment struct { ID DealID @@ -400,14 +432,33 @@ type DealPayment struct { PaymentVoucher *paych.SignedVoucher } -// Type method makes DealPayment usable as a voucher -func (dr *DealPayment) Type() datatransfer.TypeIdentifier { - return "RetrievalDealPayment/1" +// DealPaymentType is the DealPayment voucher type +const DealPaymentType = datatransfer.TypeIdentifier("RetrievalDealPayment/1") + +// dealPaymentBindnodeOptions is the bindnode options required to convert custom +// types used by the DealPayment type +var dealPaymentBindnodeOptions = []bindnode.Option{ + SignatureBindnodeOption, + AddressBindnodeOption, + BigIntBindnodeOption, + TokenAmountBindnodeOption, } // DealPaymentUndefined is an undefined deal payment var DealPaymentUndefined = DealPayment{} +func DealPaymentFromNode(node datamodel.Node) (*DealPayment, error) { + if node == nil { + return nil, fmt.Errorf("empty voucher") + } + dpIface, err := BindnodeRegistry.TypeFromNode(node, &DealPayment{}) + if err != nil { + return nil, xerrors.Errorf("invalid DealPayment: %w", err) + } + dp, _ := dpIface.(*DealPayment) // safe to assume type + return dp, nil +} + var ( // ErrNotFound means a piece was not found during retrieval ErrNotFound = errors.New("not found") @@ -475,3 +526,22 @@ type PricingInput struct { // CurrentAsk is the current configured ask in the ask-store. CurrentAsk Ask } + +var BindnodeRegistry = bindnoderegistry.NewRegistry() + +func init() { + for _, r := range []struct { + typ interface{} + typName string + opts []bindnode.Option + }{ + {(*Params)(nil), "Params", paramsBindnodeOptions}, + {(*DealProposal)(nil), "DealProposal", dealProposalBindnodeOptions}, + {(*DealResponse)(nil), "DealResponse", dealResponseBindnodeOptions}, + {(*DealPayment)(nil), "DealPayment", dealPaymentBindnodeOptions}, + } { + if err := BindnodeRegistry.RegisterType(r.typ, string(embedSchema), r.typName, r.opts...); err != nil { + panic(err.Error()) + } + } +} diff --git a/retrievalmarket/types.ipldsch b/retrievalmarket/types.ipldsch new file mode 100644 index 00000000..d9609cae --- /dev/null +++ b/retrievalmarket/types.ipldsch @@ -0,0 +1,52 @@ +type Params struct { + Selector nullable Any # CborGenCompatibleNode + PieceCID nullable &Any + PricePerByte Bytes # abi.TokenAmount + PaymentInterval Int + PaymentIntervalIncrease Int + UnsealPrice Bytes # abi.TokenAmount +} + +type DealProposal struct { + PayloadCID &Any + ID Int # DealID + Params Params +} + +type DealResponse struct { + Status Int + ID Int + PaymentOwed Bytes + Message String +} + +type DealPayment struct { + ID Int # DealID + PaymentChannel Bytes # address.Address + PaymentVoucher nullable SignedVoucher +} + +type SignedVoucher struct { + ChannelAddr Bytes # addr.Address + TimeLockMin Int # abi.ChainEpoch + TimeLockMax Int # abi.ChainEpoch + SecretPreimage Bytes + Extra nullable ModVerifyParams + Lane Int + Nonce Int + Amount Bytes # big.Int + MinSettleHeight Int # abi.ChainEpoch + Merges [Merge] + Signature nullable Bytes # crypto.Signature +} representation tuple + +type ModVerifyParams struct { + Actor Bytes # addr.Address + Method Int # abi.MethodNum + Data Bytes +} representation tuple + +type Merge struct { + Lane Int + Nonce Int +} representation tuple diff --git a/retrievalmarket/types_cbor_gen.go b/retrievalmarket/types_cbor_gen.go index 304a0d59..3f1e5f31 100644 --- a/retrievalmarket/types_cbor_gen.go +++ b/retrievalmarket/types_cbor_gen.go @@ -783,7 +783,7 @@ func (t *Params) MarshalCBOR(w io.Writer) error { scratch := make([]byte, 9) - // t.Selector (typegen.Deferred) (struct) + // t.Selector (retrievalmarket.CborGenCompatibleNode) (struct) if len("Selector") > cbg.MaxLength { return xerrors.Errorf("Value in field \"Selector\" was too long") } @@ -920,16 +920,15 @@ func (t *Params) UnmarshalCBOR(r io.Reader) error { } switch name { - // t.Selector (typegen.Deferred) (struct) + // t.Selector (retrievalmarket.CborGenCompatibleNode) (struct) case "Selector": { - t.Selector = new(cbg.Deferred) - if err := t.Selector.UnmarshalCBOR(br); err != nil { - return xerrors.Errorf("failed to read deferred field: %w", err) + return xerrors.Errorf("unmarshaling t.Selector: %w", err) } + } // t.PieceCID (cid.Cid) (struct) case "PieceCID": diff --git a/retrievalmarket/types_test.go b/retrievalmarket/types_test.go index cffb5b32..200a7a7b 100644 --- a/retrievalmarket/types_test.go +++ b/retrievalmarket/types_test.go @@ -5,8 +5,6 @@ import ( "encoding/json" "testing" - "github.com/ipld/go-ipld-prime/codec/dagcbor" - basicnode "github.com/ipld/go-ipld-prime/node/basic" selectorparse "github.com/ipld/go-ipld-prime/traversal/selector/parse" "github.com/libp2p/go-libp2p-core/test" "github.com/stretchr/testify/assert" @@ -36,11 +34,7 @@ func TestParamsMarshalUnmarshal(t *testing.T) { assert.Equal(t, params, *unmarshalled) - nb := basicnode.Prototype.Any.NewBuilder() - err = dagcbor.Decode(nb, bytes.NewBuffer(unmarshalled.Selector.Raw)) - assert.NoError(t, err) - sel := nb.Build() - assert.Equal(t, sel, allSelector) + assert.Equal(t, unmarshalled.Selector.Node, allSelector) } func TestPricingInputMarshalUnmarshalJSON(t *testing.T) { diff --git a/shared/selectors.go b/shared/selectors.go index 9422d29f..7bd07772 100644 --- a/shared/selectors.go +++ b/shared/selectors.go @@ -1,10 +1,10 @@ package shared import ( - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" selectorparse "github.com/ipld/go-ipld-prime/traversal/selector/parse" ) // Deprecated: AllSelector is a compatibility alias for an entire DAG non-matching-selector. // Use github.com/ipld/go-ipld-prime/traversal/selector/parse.CommonSelector_ExploreAllRecursively instead. -func AllSelector() ipld.Node { return selectorparse.CommonSelector_ExploreAllRecursively } +func AllSelector() datamodel.Node { return selectorparse.CommonSelector_ExploreAllRecursively } diff --git a/shared_testutil/generators.go b/shared_testutil/generators.go index 3a69e74e..2ef374bf 100644 --- a/shared_testutil/generators.go +++ b/shared_testutil/generators.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/ipfs/go-cid" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/test" "github.com/stretchr/testify/require" @@ -84,9 +84,9 @@ func MakeTestQueryResponse() retrievalmarket.QueryResponse { } // MakeTestDealProposal generates a valid, random DealProposal -func MakeTestDealProposal() retrievalmarket.DealProposal { +func MakeTestDealProposal() *retrievalmarket.DealProposal { cid := GenerateCids(1)[0] - return retrievalmarket.DealProposal{ + return &retrievalmarket.DealProposal{ PayloadCID: cid, ID: retrievalmarket.DealID(rand.Uint64()), Params: retrievalmarket.NewParamsV0(MakeTestTokenAmount(), rand.Uint64(), rand.Uint64()), @@ -293,11 +293,11 @@ func RequireGenerateRetrievalPeers(t *testing.T, numPeers int) []retrievalmarket type FakeDTValidator struct{} -func (v *FakeDTValidator) ValidatePush(_ datatransfer.ChannelID, sender peer.ID, voucher datatransfer.Voucher, baseCid cid.Cid, selector ipld.Node) (datatransfer.ValidationResult, error) { +func (v *FakeDTValidator) ValidatePush(_ datatransfer.ChannelID, sender peer.ID, voucher datamodel.Node, baseCid cid.Cid, selector datamodel.Node) (datatransfer.ValidationResult, error) { return datatransfer.ValidationResult{Accepted: true}, nil } -func (v *FakeDTValidator) ValidatePull(_ datatransfer.ChannelID, receiver peer.ID, voucher datatransfer.Voucher, baseCid cid.Cid, selector ipld.Node) (datatransfer.ValidationResult, error) { +func (v *FakeDTValidator) ValidatePull(_ datatransfer.ChannelID, receiver peer.ID, voucher datamodel.Node, baseCid cid.Cid, selector datamodel.Node) (datatransfer.ValidationResult, error) { return datatransfer.ValidationResult{Accepted: true}, nil } diff --git a/shared_testutil/mocknet.go b/shared_testutil/mocknet.go index 427279fb..f885dffb 100644 --- a/shared_testutil/mocknet.go +++ b/shared_testutil/mocknet.go @@ -17,6 +17,7 @@ import ( "github.com/ipfs/go-merkledag" unixfile "github.com/ipfs/go-unixfs/file" "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" cidlink "github.com/ipld/go-ipld-prime/linking/cid" "github.com/libp2p/go-libp2p-core/host" mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" @@ -108,7 +109,7 @@ func NewLibp2pTestData(ctx context.Context, t *testing.T) *Libp2pTestData { // LoadUnixFSFile injects the fixture `src` into the given blockstore from the // fixtures directory. If useSecondNode is true, fixture is injected to the second node; // otherwise the first node gets it -func (ltd *Libp2pTestData) LoadUnixFSFile(t *testing.T, src string, useSecondNode bool) (ipld.Link, string) { +func (ltd *Libp2pTestData) LoadUnixFSFile(t *testing.T, src string, useSecondNode bool) (datamodel.Link, string) { var dagService ipldformat.DAGService if useSecondNode { dagService = ltd.DagService2 @@ -119,7 +120,7 @@ func (ltd *Libp2pTestData) LoadUnixFSFile(t *testing.T, src string, useSecondNod } // LoadUnixFSFileToStore creates a CAR file from the fixture at `src` -func (ltd *Libp2pTestData) LoadUnixFSFileToStore(t *testing.T, src string) (ipld.Link, string) { +func (ltd *Libp2pTestData) LoadUnixFSFileToStore(t *testing.T, src string) (datamodel.Link, string) { dstore := dss.MutexWrap(datastore.NewMapDatastore()) bs := bstore.NewBlockstore(dstore) dagService := merkledag.NewDAGService(blockservice.New(bs, offline.Exchange(bs))) @@ -127,7 +128,7 @@ func (ltd *Libp2pTestData) LoadUnixFSFileToStore(t *testing.T, src string) (ipld return ltd.loadUnixFSFile(t, src, dagService) } -func (ltd *Libp2pTestData) loadUnixFSFile(t *testing.T, src string, dagService ipldformat.DAGService) (ipld.Link, string) { +func (ltd *Libp2pTestData) loadUnixFSFile(t *testing.T, src string, dagService ipldformat.DAGService) (datamodel.Link, string) { f, err := os.Open(src) require.NoError(t, err) @@ -144,7 +145,7 @@ func (ltd *Libp2pTestData) loadUnixFSFile(t *testing.T, src string, dagService i } // VerifyFileTransferred checks that the fixture file was sent from one node to the other. -func (ltd *Libp2pTestData) VerifyFileTransferred(t *testing.T, link ipld.Link, useSecondNode bool, readLen uint64) { +func (ltd *Libp2pTestData) VerifyFileTransferred(t *testing.T, link datamodel.Link, useSecondNode bool, readLen uint64) { var dagService ipldformat.DAGService if useSecondNode { dagService = ltd.DagService2 @@ -156,13 +157,13 @@ func (ltd *Libp2pTestData) VerifyFileTransferred(t *testing.T, link ipld.Link, u // VerifyFileTransferredIntoStore checks that the fixture file was sent from // one node to the other, and stored in the given CAR file -func (ltd *Libp2pTestData) VerifyFileTransferredIntoStore(t *testing.T, link ipld.Link, bs bstore.Blockstore, readLen uint64) { +func (ltd *Libp2pTestData) VerifyFileTransferredIntoStore(t *testing.T, link datamodel.Link, bs bstore.Blockstore, readLen uint64) { bsvc := blockservice.New(bs, offline.Exchange(bs)) dagService := merkledag.NewDAGService(bsvc) ltd.verifyFileTransferred(t, link, dagService, readLen) } -func (ltd *Libp2pTestData) verifyFileTransferred(t *testing.T, link ipld.Link, dagService ipldformat.DAGService, readLen uint64) { +func (ltd *Libp2pTestData) verifyFileTransferred(t *testing.T, link datamodel.Link, dagService ipldformat.DAGService, readLen uint64) { c := link.(cidlink.Link).Cid // load the root of the UnixFS DAG from the new blockstore diff --git a/shared_testutil/test_datatransfer.go b/shared_testutil/test_datatransfer.go index c2d5699a..22015a46 100644 --- a/shared_testutil/test_datatransfer.go +++ b/shared_testutil/test_datatransfer.go @@ -4,7 +4,7 @@ import ( "context" "github.com/ipfs/go-cid" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/libp2p/go-libp2p-core/peer" datatransfer "github.com/filecoin-project/go-data-transfer/v2" @@ -12,13 +12,13 @@ import ( // RegisteredVoucherType records a voucher typed that was registered type RegisteredVoucherType struct { - VoucherType datatransfer.Voucher + VoucherType datatransfer.TypeIdentifier Validator datatransfer.RequestValidator } // RegisteredTransportConfigurer records transport configurer registered for a voucher type type RegisteredTransportConfigurer struct { - VoucherType datatransfer.Voucher + VoucherType datatransfer.TypeIdentifier Configurer datatransfer.TransportConfigurer } @@ -26,7 +26,6 @@ type RegisteredTransportConfigurer struct { // Most of its functions have no effect type TestDataTransfer struct { RegisteredVoucherTypes []RegisteredVoucherType - RegisteredVoucherResultTypes []datatransfer.VoucherResult RegisteredTransportConfigurers []RegisteredTransportConfigurer Subscribers []datatransfer.Subscriber } @@ -47,25 +46,19 @@ func (tdt *TestDataTransfer) Stop(context.Context) error { } // RegisterVoucherType records the registred voucher type -func (tdt *TestDataTransfer) RegisterVoucherType(voucherType datatransfer.Voucher, validator datatransfer.RequestValidator) error { +func (tdt *TestDataTransfer) RegisterVoucherType(voucherType datatransfer.TypeIdentifier, validator datatransfer.RequestValidator) error { tdt.RegisteredVoucherTypes = append(tdt.RegisteredVoucherTypes, RegisteredVoucherType{voucherType, validator}) return nil } -// RegisterVoucherResultType records the registered result type -func (tdt *TestDataTransfer) RegisterVoucherResultType(resultType datatransfer.VoucherResult) error { - tdt.RegisteredVoucherResultTypes = append(tdt.RegisteredVoucherResultTypes, resultType) - return nil -} - // RegisterTransportConfigurer records the registered transport configurer -func (tdt *TestDataTransfer) RegisterTransportConfigurer(voucherType datatransfer.Voucher, configurer datatransfer.TransportConfigurer) error { +func (tdt *TestDataTransfer) RegisterTransportConfigurer(voucherType datatransfer.TypeIdentifier, configurer datatransfer.TransportConfigurer) error { tdt.RegisteredTransportConfigurers = append(tdt.RegisteredTransportConfigurers, RegisteredTransportConfigurer{voucherType, configurer}) return nil } // OpenPushDataChannel does nothing -func (tdt *TestDataTransfer) OpenPushDataChannel(ctx context.Context, to peer.ID, voucher datatransfer.Voucher, baseCid cid.Cid, selector ipld.Node) (datatransfer.ChannelID, error) { +func (tdt *TestDataTransfer) OpenPushDataChannel(ctx context.Context, to peer.ID, voucher datatransfer.TypedVoucher, baseCid cid.Cid, selector datamodel.Node) (datatransfer.ChannelID, error) { return datatransfer.ChannelID{}, nil } @@ -74,17 +67,17 @@ func (tdt *TestDataTransfer) RestartDataTransferChannel(ctx context.Context, chI } // OpenPullDataChannel does nothing -func (tdt *TestDataTransfer) OpenPullDataChannel(ctx context.Context, to peer.ID, voucher datatransfer.Voucher, baseCid cid.Cid, selector ipld.Node) (datatransfer.ChannelID, error) { +func (tdt *TestDataTransfer) OpenPullDataChannel(ctx context.Context, to peer.ID, voucher datatransfer.TypedVoucher, baseCid cid.Cid, selector datamodel.Node) (datatransfer.ChannelID, error) { return datatransfer.ChannelID{}, nil } // SendVoucher does nothing -func (tdt *TestDataTransfer) SendVoucher(ctx context.Context, chid datatransfer.ChannelID, voucher datatransfer.Voucher) error { +func (tdt *TestDataTransfer) SendVoucher(ctx context.Context, chid datatransfer.ChannelID, voucher datatransfer.TypedVoucher) error { return nil } // SendVoucherResult does nothing -func (tdt *TestDataTransfer) SendVoucherResult(ctx context.Context, chid datatransfer.ChannelID, voucherResult datatransfer.VoucherResult) error { +func (tdt *TestDataTransfer) SendVoucherResult(ctx context.Context, chid datatransfer.ChannelID, voucherResult datatransfer.TypedVoucher) error { return nil } diff --git a/shared_testutil/test_ipld_tree.go b/shared_testutil/test_ipld_tree.go index eb59f6a4..ce92fd5a 100644 --- a/shared_testutil/test_ipld_tree.go +++ b/shared_testutil/test_ipld_tree.go @@ -13,6 +13,7 @@ import ( // to register multicodec _ "github.com/ipld/go-ipld-prime/codec/dagjson" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/ipld/go-ipld-prime/fluent" cidlink "github.com/ipld/go-ipld-prime/linking/cid" basicnode "github.com/ipld/go-ipld-prime/node/basic" @@ -22,28 +23,28 @@ import ( // TestIPLDTree is a set of IPLD Data that forms a tree spread across some blocks // with a serialized in memory representation type TestIPLDTree struct { - Storage map[ipld.Link][]byte - LeafAlpha ipld.Node - LeafAlphaLnk ipld.Link + Storage map[datamodel.Link][]byte + LeafAlpha datamodel.Node + LeafAlphaLnk datamodel.Link LeafAlphaBlock blocks.Block - LeafBeta ipld.Node - LeafBetaLnk ipld.Link + LeafBeta datamodel.Node + LeafBetaLnk datamodel.Link LeafBetaBlock blocks.Block - MiddleMapNode ipld.Node - MiddleMapNodeLnk ipld.Link + MiddleMapNode datamodel.Node + MiddleMapNodeLnk datamodel.Link MiddleMapBlock blocks.Block - MiddleListNode ipld.Node - MiddleListNodeLnk ipld.Link + MiddleListNode datamodel.Node + MiddleListNodeLnk datamodel.Link MiddleListBlock blocks.Block - RootNode ipld.Node - RootNodeLnk ipld.Link + RootNode datamodel.Node + RootNodeLnk datamodel.Link RootBlock blocks.Block } // NewTestIPLDTree returns a fake tree of nodes, spread across 5 blocks func NewTestIPLDTree() TestIPLDTree { - var storage = make(map[ipld.Link][]byte) - encode := func(n ipld.Node) (ipld.Node, ipld.Link) { + var storage = make(map[datamodel.Link][]byte) + encode := func(n datamodel.Node) (datamodel.Node, datamodel.Link) { lb := cidlink.LinkPrototype{Prefix: cid.Prefix{ Version: 1, Codec: 0x0129, @@ -53,7 +54,7 @@ func NewTestIPLDTree() TestIPLDTree { lsys := cidlink.DefaultLinkSystem() lsys.StorageWriteOpener = func(ipld.LinkContext) (io.Writer, ipld.BlockWriteCommitter, error) { buf := bytes.Buffer{} - return &buf, func(lnk ipld.Link) error { + return &buf, func(lnk datamodel.Link) error { storage[lnk] = buf.Bytes() return nil }, nil diff --git a/shared_testutil/testchannel.go b/shared_testutil/testchannel.go index 6973a4b2..dd17592b 100644 --- a/shared_testutil/testchannel.go +++ b/shared_testutil/testchannel.go @@ -2,7 +2,8 @@ package shared_testutil import ( "github.com/ipfs/go-cid" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/node/basicnode" selectorparse "github.com/ipld/go-ipld-prime/traversal/selector/parse" "github.com/libp2p/go-libp2p-core/peer" "golang.org/x/exp/rand" @@ -14,7 +15,7 @@ import ( type TestChannelParams struct { TransferID datatransfer.TransferID BaseCID cid.Cid - Selector ipld.Node + Selector datamodel.Node SelfPeer peer.ID Sender peer.ID Recipient peer.ID @@ -25,8 +26,8 @@ type TestChannelParams struct { Received uint64 Queued uint64 Status datatransfer.Status - Vouchers []datatransfer.Voucher - VoucherResults []datatransfer.VoucherResult + Vouchers []datatransfer.TypedVoucher + VoucherResults []datatransfer.TypedVoucher ReceivedCids []cid.Cid } @@ -35,7 +36,7 @@ type TestChannel struct { selfPeer peer.ID transferID datatransfer.TransferID baseCID cid.Cid - selector ipld.Node + selector datamodel.Node sender peer.ID recipient peer.ID totalSize uint64 @@ -45,36 +46,34 @@ type TestChannel struct { received uint64 queued uint64 status datatransfer.Status - vouchers []datatransfer.Voucher - voucherResults []datatransfer.VoucherResult + vouchers []datatransfer.TypedVoucher + voucherResults []datatransfer.TypedVoucher receivedCids []cid.Cid } -// FakeDTType is a fake voucher type -type FakeDTType struct{} - -// Type returns an identifier -func (f FakeDTType) Type() datatransfer.TypeIdentifier { return "Fake" } - // NewTestChannel makes a test channel with default params plus non-zero // values for TestChannelParams func NewTestChannel(params TestChannelParams) datatransfer.ChannelState { peers := GeneratePeers(2) tc := &TestChannel{ - selfPeer: peers[0], - transferID: datatransfer.TransferID(rand.Uint64()), - baseCID: GenerateCids(1)[0], - selector: selectorparse.CommonSelector_ExploreAllRecursively, - sender: peers[0], - recipient: peers[1], - totalSize: rand.Uint64(), - isPull: params.IsPull, - status: params.Status, - sent: params.Sent, - received: params.Received, - queued: params.Queued, - vouchers: []datatransfer.Voucher{FakeDTType{}}, - voucherResults: []datatransfer.VoucherResult{FakeDTType{}}, + selfPeer: peers[0], + transferID: datatransfer.TransferID(rand.Uint64()), + baseCID: GenerateCids(1)[0], + selector: selectorparse.CommonSelector_ExploreAllRecursively, + sender: peers[0], + recipient: peers[1], + totalSize: rand.Uint64(), + isPull: params.IsPull, + status: params.Status, + sent: params.Sent, + received: params.Received, + queued: params.Queued, + vouchers: []datatransfer.TypedVoucher{ + {Voucher: basicnode.NewString("Fake DT Voucher"), Type: datatransfer.TypeIdentifier("Fake")}, + }, + voucherResults: []datatransfer.TypedVoucher{ + {Voucher: basicnode.NewString("Fake DT Voucher"), Type: datatransfer.TypeIdentifier("Fake")}, + }, } tc.receivedCids = params.ReceivedCids @@ -133,7 +132,7 @@ func (tc *TestChannel) BaseCID() cid.Cid { // Selector returns the IPLD selector for this data transfer (represented as // an IPLD node) -func (tc *TestChannel) Selector() ipld.Node { +func (tc *TestChannel) Selector() datamodel.Node { return tc.selector } @@ -156,8 +155,8 @@ func (tc *TestChannel) SentCidsTotal() int64 { } // Voucher returns the voucher for this data transfer -func (tc *TestChannel) Voucher() datatransfer.Voucher { - return tc.vouchers[0] +func (tc *TestChannel) Voucher() (datatransfer.TypedVoucher, error) { + return tc.vouchers[0], nil } // Sender returns the peer id for the node that is sending data @@ -236,23 +235,23 @@ func (tc *TestChannel) Message() string { } // Vouchers returns all vouchers sent on this channel -func (tc *TestChannel) Vouchers() []datatransfer.Voucher { - return tc.vouchers +func (tc *TestChannel) Vouchers() ([]datatransfer.TypedVoucher, error) { + return tc.vouchers, nil } // VoucherResults are results of vouchers sent on the channel -func (tc *TestChannel) VoucherResults() []datatransfer.VoucherResult { - return tc.voucherResults +func (tc *TestChannel) VoucherResults() ([]datatransfer.TypedVoucher, error) { + return tc.voucherResults, nil } // LastVoucher returns the last voucher sent on the channel -func (tc *TestChannel) LastVoucher() datatransfer.Voucher { - return tc.vouchers[len(tc.vouchers)-1] +func (tc *TestChannel) LastVoucher() (datatransfer.TypedVoucher, error) { + return tc.vouchers[len(tc.vouchers)-1], nil } // LastVoucherResult returns the last voucher result sent on the channel -func (tc *TestChannel) LastVoucherResult() datatransfer.VoucherResult { - return tc.voucherResults[len(tc.voucherResults)-1] +func (tc *TestChannel) LastVoucherResult() (datatransfer.TypedVoucher, error) { + return tc.voucherResults[len(tc.voucherResults)-1], nil } func (tc *TestChannel) Stages() *datatransfer.ChannelStages { diff --git a/storagemarket/impl/client.go b/storagemarket/impl/client.go index 461998de..496805b4 100644 --- a/storagemarket/impl/client.go +++ b/storagemarket/impl/client.go @@ -125,12 +125,12 @@ func NewClient( // register a data transfer event handler -- this will send events to the state machines based on DT events c.unsubDataTransfer = dataTransfer.SubscribeToEvents(dtutils.ClientDataTransferSubscriber(c.statemachines)) - err = dataTransfer.RegisterVoucherType(&requestvalidation.StorageDataTransferVoucher{}, requestvalidation.NewUnifiedRequestValidator(nil, &clientPullDeals{c})) + err = dataTransfer.RegisterVoucherType(requestvalidation.StorageDataTransferVoucherType, requestvalidation.NewUnifiedRequestValidator(nil, &clientPullDeals{c})) if err != nil { return nil, err } - err = dataTransfer.RegisterTransportConfigurer(&requestvalidation.StorageDataTransferVoucher{}, dtutils.TransportConfigurer(&clientStoreGetter{c})) + err = dataTransfer.RegisterTransportConfigurer(requestvalidation.StorageDataTransferVoucherType, dtutils.TransportConfigurer(&clientStoreGetter{c})) if err != nil { return nil, err } diff --git a/storagemarket/impl/client_environments.go b/storagemarket/impl/client_environments.go index 262364c3..5508ce85 100644 --- a/storagemarket/impl/client_environments.go +++ b/storagemarket/impl/client_environments.go @@ -6,7 +6,7 @@ import ( "github.com/ipfs/go-cid" bstore "github.com/ipfs/go-ipfs-blockstore" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/libp2p/go-libp2p-core/peer" "golang.org/x/xerrors" @@ -36,7 +36,7 @@ func (c *clientDealEnvironment) CleanBlockstore(payloadCid cid.Cid) error { return c.c.bstores.Done(payloadCid) } -func (c *clientDealEnvironment) StartDataTransfer(ctx context.Context, to peer.ID, voucher datatransfer.Voucher, baseCid cid.Cid, selector ipld.Node) (datatransfer.ChannelID, +func (c *clientDealEnvironment) StartDataTransfer(ctx context.Context, to peer.ID, voucher datatransfer.TypedVoucher, baseCid cid.Cid, selector datamodel.Node) (datatransfer.ChannelID, error) { chid, err := c.c.dataTransfer.OpenPushDataChannel(ctx, to, voucher, baseCid, selector) return chid, err diff --git a/storagemarket/impl/clientstates/client_states.go b/storagemarket/impl/clientstates/client_states.go index 17f6da10..5494f718 100644 --- a/storagemarket/impl/clientstates/client_states.go +++ b/storagemarket/impl/clientstates/client_states.go @@ -6,7 +6,7 @@ import ( "github.com/ipfs/go-cid" logging "github.com/ipfs/go-log/v2" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" selectorparse "github.com/ipld/go-ipld-prime/traversal/selector/parse" "github.com/libp2p/go-libp2p-core/peer" "golang.org/x/xerrors" @@ -35,7 +35,7 @@ type ClientDealEnvironment interface { CleanBlockstore(rootCid cid.Cid) error Node() storagemarket.StorageClientNode NewDealStream(ctx context.Context, p peer.ID) (network.StorageDealStream, error) - StartDataTransfer(ctx context.Context, to peer.ID, voucher datatransfer.Voucher, baseCid cid.Cid, selector ipld.Node) (datatransfer.ChannelID, error) + StartDataTransfer(ctx context.Context, to peer.ID, voucher datatransfer.TypedVoucher, baseCid cid.Cid, selector datamodel.Node) (datatransfer.ChannelID, error) RestartDataTransfer(ctx context.Context, chid datatransfer.ChannelID) error GetProviderDealState(ctx context.Context, proposalCid cid.Cid) (*storagemarket.ProviderDealState, error) PollingInterval() time.Duration @@ -159,11 +159,14 @@ func InitiateDataTransfer(ctx fsm.Context, environment ClientDealEnvironment, de log.Infof("sending data for a deal %s", deal.ProposalCid) + voucher := requestvalidation.StorageDataTransferVoucher{Proposal: deal.ProposalCid} + node := requestvalidation.BindnodeRegistry.TypeToNode(&voucher) + // initiate a push data transfer. This will complete asynchronously and the // completion of the data transfer will trigger a change in deal state _, err := environment.StartDataTransfer(ctx.Context(), deal.Miner, - &requestvalidation.StorageDataTransferVoucher{Proposal: deal.ProposalCid}, + datatransfer.TypedVoucher{Voucher: node, Type: requestvalidation.StorageDataTransferVoucherType}, deal.DataRef.Root, selectorparse.CommonSelector_ExploreAllRecursively, ) diff --git a/storagemarket/impl/clientstates/client_states_test.go b/storagemarket/impl/clientstates/client_states_test.go index c4006c64..7a5bbaf7 100644 --- a/storagemarket/impl/clientstates/client_states_test.go +++ b/storagemarket/impl/clientstates/client_states_test.go @@ -7,7 +7,7 @@ import ( "time" "github.com/ipfs/go-cid" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/libp2p/go-libp2p-core/peer" "github.com/stretchr/testify/assert" "golang.org/x/xerrors" @@ -729,16 +729,16 @@ type fakeEnvironment struct { type dataTransferParams struct { to peer.ID - voucher datatransfer.Voucher + voucher datatransfer.TypedVoucher baseCid cid.Cid - selector ipld.Node + selector datamodel.Node } type restartDataTransferParams struct { channelId datatransfer.ChannelID } -func (fe *fakeEnvironment) StartDataTransfer(_ context.Context, to peer.ID, voucher datatransfer.Voucher, baseCid cid.Cid, selector ipld.Node) (datatransfer.ChannelID, error) { +func (fe *fakeEnvironment) StartDataTransfer(_ context.Context, to peer.ID, voucher datatransfer.TypedVoucher, baseCid cid.Cid, selector datamodel.Node) (datatransfer.ChannelID, error) { fe.startDataTransferCalls = append(fe.startDataTransferCalls, dataTransferParams{ to: to, voucher: voucher, diff --git a/storagemarket/impl/dtutils/dtutils.go b/storagemarket/impl/dtutils/dtutils.go index 5e312246..e53a6a84 100644 --- a/storagemarket/impl/dtutils/dtutils.go +++ b/storagemarket/impl/dtutils/dtutils.go @@ -32,13 +32,25 @@ type EventReceiver interface { // event or moving to error if a data transfer error occurs func ProviderDataTransferSubscriber(deals EventReceiver) datatransfer.Subscriber { return func(event datatransfer.Event, channelState datatransfer.ChannelState) { - voucher, ok := channelState.Voucher().(*requestvalidation.StorageDataTransferVoucher) + node, err := channelState.Voucher() + if err != nil { + log.Errorf("ignoring data-transfer event as the voucher is invalid, event=%s, channelID=%s: %s", datatransfer.Events[event.Code], "channelID", + channelState.ChannelID().String(), err.Error()) + return + } + if node.Voucher == nil { + log.Debugw("ignoring data-transfer event as it's not storage related", "event", datatransfer.Events[event.Code], "channelID", + channelState.ChannelID()) + return + } + voucherIface, err := requestvalidation.BindnodeRegistry.TypeFromNode(node.Voucher, &requestvalidation.StorageDataTransferVoucher{}) // if this event is for a transfer not related to storage, ignore - if !ok { + if err != nil { log.Debugw("ignoring data-transfer event as it's not storage related", "event", datatransfer.Events[event.Code], "channelID", channelState.ChannelID()) return } + voucher, _ := voucherIface.(*requestvalidation.StorageDataTransferVoucher) // safe to assume type log.Debugw("processing storage provider dt event", "event", datatransfer.Events[event.Code], "proposalCid", voucher.Proposal, "channelID", channelState.ChannelID(), "channelState", datatransfer.Statuses[channelState.Status()]) @@ -47,12 +59,13 @@ func ProviderDataTransferSubscriber(deals EventReceiver) datatransfer.Subscriber err := deals.Send(voucher.Proposal, storagemarket.ProviderEventDataTransferCompleted) if err != nil { log.Errorf("processing dt event: %s", err) + return } } // Translate from data transfer events to provider FSM events // Note: We ignore data transfer progress events (they do not affect deal state) - err := func() error { + err = func() error { switch event.Code { case datatransfer.Cancel: return deals.Send(voucher.Proposal, storagemarket.ProviderEventDataTransferCancelled) @@ -81,11 +94,26 @@ func ProviderDataTransferSubscriber(deals EventReceiver) datatransfer.Subscriber // an event to the appropriate state machine func ClientDataTransferSubscriber(deals EventReceiver) datatransfer.Subscriber { return func(event datatransfer.Event, channelState datatransfer.ChannelState) { - voucher, ok := channelState.Voucher().(*requestvalidation.StorageDataTransferVoucher) + // TODO: are these log messages valid for Client? + node, err := channelState.Voucher() + if err != nil { + log.Errorf("ignoring data-transfer event as the voucher is invalid, event=%s, channelID=%s: %s", datatransfer.Events[event.Code], "channelID", + channelState.ChannelID().String(), err.Error()) + return + } + if node.Voucher == nil { + log.Debugw("ignoring data-transfer event as it's not storage related", "event", datatransfer.Events[event.Code], "channelID", + channelState.ChannelID()) + return + } + voucherIface, err := requestvalidation.BindnodeRegistry.TypeFromNode(node.Voucher, &requestvalidation.StorageDataTransferVoucher{}) // if this event is for a transfer not related to storage, ignore - if !ok { + if err != nil { + log.Debugw("ignoring data-transfer event as it's not storage related", "event", datatransfer.Events[event.Code], "channelID", + channelState.ChannelID()) return } + voucher, _ := voucherIface.(*requestvalidation.StorageDataTransferVoucher) // safe to assume type // Note: We ignore data transfer progress events (they do not affect deal state) log.Debugw("processing storage client dt event", "event", datatransfer.Events[event.Code], "proposalCid", voucher.Proposal, "channelID", @@ -95,10 +123,11 @@ func ClientDataTransferSubscriber(deals EventReceiver) datatransfer.Subscriber { err := deals.Send(voucher.Proposal, storagemarket.ClientEventDataTransferComplete) if err != nil { log.Errorf("processing dt event: %s", err) + return } } - err := func() error { + err = func() error { switch event.Code { case datatransfer.Cancel: return deals.Send(voucher.Proposal, storagemarket.ClientEventDataTransferCancelled) @@ -136,11 +165,18 @@ type StoreConfigurableTransport interface { // TransportConfigurer configurers the graphsync transport to use a custom blockstore per deal func TransportConfigurer(storeGetter StoreGetter) datatransfer.TransportConfigurer { - return func(channelID datatransfer.ChannelID, voucher datatransfer.Voucher, transport datatransfer.Transport) { - storageVoucher, ok := voucher.(*requestvalidation.StorageDataTransferVoucher) - if !ok { + return func(channelID datatransfer.ChannelID, voucher datatransfer.TypedVoucher, transport datatransfer.Transport) { + if voucher.Voucher == nil { + log.Errorf("attempting to configure data store, empty voucher") + return + } + voucherIface, err := requestvalidation.BindnodeRegistry.TypeFromNode(voucher.Voucher, &requestvalidation.StorageDataTransferVoucher{}) + // if this event is for a transfer not related to storage, ignore + if err != nil { + log.Errorf("attempting to configure data store, bad voucher: %s", err) return } + storageVoucher, _ := voucherIface.(*requestvalidation.StorageDataTransferVoucher) // safe to assume type gsTransport, ok := transport.(StoreConfigurableTransport) if !ok { return diff --git a/storagemarket/impl/dtutils/dtutils_test.go b/storagemarket/impl/dtutils/dtutils_test.go index 6db959f8..fa784725 100644 --- a/storagemarket/impl/dtutils/dtutils_test.go +++ b/storagemarket/impl/dtutils/dtutils_test.go @@ -9,6 +9,8 @@ import ( ds "github.com/ipfs/go-datastore" bs "github.com/ipfs/go-ipfs-blockstore" "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/node/basicnode" peer "github.com/libp2p/go-libp2p-core/peer" "github.com/stretchr/testify/require" @@ -21,6 +23,14 @@ import ( "github.com/filecoin-project/go-fil-markets/storagemarket/impl/requestvalidation" ) +func storageDataTransferVoucher(t *testing.T, proposalCid cid.Cid) datatransfer.TypedVoucher { + sdtv := requestvalidation.StorageDataTransferVoucher{ + Proposal: proposalCid, + } + node := requestvalidation.BindnodeRegistry.TypeToNode(&sdtv) + return datatransfer.TypedVoucher{Voucher: node, Type: requestvalidation.StorageDataTransferVoucherType} +} + func TestProviderDataTransferSubscriber(t *testing.T) { ps := shared_testutil.GeneratePeers(2) init := ps[0] @@ -32,85 +42,71 @@ func TestProviderDataTransferSubscriber(t *testing.T) { message string status datatransfer.Status called bool - voucher datatransfer.Voucher + voucher datatransfer.TypedVoucher expectedID interface{} expectedEvent fsm.EventName expectedArgs []interface{} }{ "not a storage voucher": { called: false, - voucher: nil, + voucher: datatransfer.TypedVoucher{Voucher: basicnode.NewString("Nope"), Type: datatransfer.TypeIdentifier("Nope")}, }, "open event": { - code: datatransfer.Open, - status: datatransfer.Requested, - called: true, - voucher: &requestvalidation.StorageDataTransferVoucher{ - Proposal: expectedProposalCID, - }, + code: datatransfer.Open, + status: datatransfer.Requested, + called: true, + voucher: storageDataTransferVoucher(t, expectedProposalCID), expectedID: expectedProposalCID, expectedEvent: storagemarket.ProviderEventDataTransferInitiated, expectedArgs: []interface{}{datatransfer.ChannelID{Initiator: init, Responder: resp, ID: tid}}, }, "restart event": { - code: datatransfer.Restart, - status: datatransfer.Ongoing, - called: true, - voucher: &requestvalidation.StorageDataTransferVoucher{ - Proposal: expectedProposalCID, - }, + code: datatransfer.Restart, + status: datatransfer.Ongoing, + called: true, + voucher: storageDataTransferVoucher(t, expectedProposalCID), expectedID: expectedProposalCID, expectedEvent: storagemarket.ProviderEventDataTransferRestarted, expectedArgs: []interface{}{datatransfer.ChannelID{Initiator: init, Responder: resp, ID: tid}}, }, "disconnected event": { - code: datatransfer.Disconnected, - status: datatransfer.Ongoing, - called: true, - voucher: &requestvalidation.StorageDataTransferVoucher{ - Proposal: expectedProposalCID, - }, + code: datatransfer.Disconnected, + status: datatransfer.Ongoing, + called: true, + voucher: storageDataTransferVoucher(t, expectedProposalCID), expectedID: expectedProposalCID, expectedEvent: storagemarket.ProviderEventDataTransferStalled, }, "completion status": { - code: datatransfer.Complete, - status: datatransfer.Completed, - called: true, - voucher: &requestvalidation.StorageDataTransferVoucher{ - Proposal: expectedProposalCID, - }, + code: datatransfer.Complete, + status: datatransfer.Completed, + called: true, + voucher: storageDataTransferVoucher(t, expectedProposalCID), expectedID: expectedProposalCID, expectedEvent: storagemarket.ProviderEventDataTransferCompleted, }, "data received": { - code: datatransfer.DataReceived, - status: datatransfer.Ongoing, - called: false, - voucher: &requestvalidation.StorageDataTransferVoucher{ - Proposal: expectedProposalCID, - }, + code: datatransfer.DataReceived, + status: datatransfer.Ongoing, + called: false, + voucher: storageDataTransferVoucher(t, expectedProposalCID), expectedID: expectedProposalCID, }, "error event": { - code: datatransfer.Error, - message: "something went wrong", - status: datatransfer.Failed, - called: true, - voucher: &requestvalidation.StorageDataTransferVoucher{ - Proposal: expectedProposalCID, - }, + code: datatransfer.Error, + message: "something went wrong", + status: datatransfer.Failed, + called: true, + voucher: storageDataTransferVoucher(t, expectedProposalCID), expectedID: expectedProposalCID, expectedEvent: storagemarket.ProviderEventDataTransferFailed, expectedArgs: []interface{}{errors.New("deal data transfer failed: something went wrong")}, }, "other event": { - code: datatransfer.DataSent, - status: datatransfer.Ongoing, - called: false, - voucher: &requestvalidation.StorageDataTransferVoucher{ - Proposal: expectedProposalCID, - }, + code: datatransfer.DataSent, + status: datatransfer.Ongoing, + called: false, + voucher: storageDataTransferVoucher(t, expectedProposalCID), }, } for test, data := range tests { @@ -118,7 +114,7 @@ func TestProviderDataTransferSubscriber(t *testing.T) { fdg := &fakeDealGroup{} subscriber := dtutils.ProviderDataTransferSubscriber(fdg) subscriber(datatransfer.Event{Code: data.code, Message: data.message}, shared_testutil.NewTestChannel( - shared_testutil.TestChannelParams{Vouchers: []datatransfer.Voucher{data.voucher}, Status: data.status, + shared_testutil.TestChannelParams{Vouchers: []datatransfer.TypedVoucher{data.voucher}, Status: data.status, Sender: init, Recipient: resp, TransferID: tid, IsPull: false}, )) if data.called { @@ -145,76 +141,64 @@ func TestClientDataTransferSubscriber(t *testing.T) { message string status datatransfer.Status called bool - voucher datatransfer.Voucher + voucher datatransfer.TypedVoucher expectedID interface{} expectedEvent fsm.EventName expectedArgs []interface{} }{ "not a storage voucher": { called: false, - voucher: nil, + voucher: datatransfer.TypedVoucher{Voucher: basicnode.NewString("Nope"), Type: datatransfer.TypeIdentifier("Nope")}, }, "completion event": { - code: datatransfer.Complete, - status: datatransfer.Completed, - called: true, - voucher: &requestvalidation.StorageDataTransferVoucher{ - Proposal: expectedProposalCID, - }, + code: datatransfer.Complete, + status: datatransfer.Completed, + called: true, + voucher: storageDataTransferVoucher(t, expectedProposalCID), expectedID: expectedProposalCID, expectedEvent: storagemarket.ClientEventDataTransferComplete, }, "restart event": { - code: datatransfer.Restart, - status: datatransfer.Ongoing, - called: true, - voucher: &requestvalidation.StorageDataTransferVoucher{ - Proposal: expectedProposalCID, - }, + code: datatransfer.Restart, + status: datatransfer.Ongoing, + called: true, + voucher: storageDataTransferVoucher(t, expectedProposalCID), expectedID: expectedProposalCID, expectedEvent: storagemarket.ClientEventDataTransferRestarted, expectedArgs: []interface{}{datatransfer.ChannelID{Initiator: init, Responder: resp, ID: tid}}, }, "disconnected event": { - code: datatransfer.Disconnected, - status: datatransfer.Ongoing, - called: true, - voucher: &requestvalidation.StorageDataTransferVoucher{ - Proposal: expectedProposalCID, - }, + code: datatransfer.Disconnected, + status: datatransfer.Ongoing, + called: true, + voucher: storageDataTransferVoucher(t, expectedProposalCID), expectedID: expectedProposalCID, expectedEvent: storagemarket.ClientEventDataTransferStalled, }, "accept event": { - code: datatransfer.Accept, - status: datatransfer.Requested, - called: true, - voucher: &requestvalidation.StorageDataTransferVoucher{ - Proposal: expectedProposalCID, - }, + code: datatransfer.Accept, + status: datatransfer.Requested, + called: true, + voucher: storageDataTransferVoucher(t, expectedProposalCID), expectedID: expectedProposalCID, expectedEvent: storagemarket.ClientEventDataTransferInitiated, expectedArgs: []interface{}{datatransfer.ChannelID{Initiator: init, Responder: resp, ID: tid}}, }, "error event": { - code: datatransfer.Error, - message: "something went wrong", - status: datatransfer.Failed, - called: true, - voucher: &requestvalidation.StorageDataTransferVoucher{ - Proposal: expectedProposalCID, - }, + code: datatransfer.Error, + message: "something went wrong", + status: datatransfer.Failed, + called: true, + voucher: storageDataTransferVoucher(t, expectedProposalCID), expectedID: expectedProposalCID, expectedEvent: storagemarket.ClientEventDataTransferFailed, expectedArgs: []interface{}{errors.New("deal data transfer failed: something went wrong")}, }, "other event": { - code: datatransfer.DataReceived, - status: datatransfer.Ongoing, - called: false, - voucher: &requestvalidation.StorageDataTransferVoucher{ - Proposal: expectedProposalCID, - }, + code: datatransfer.DataReceived, + status: datatransfer.Ongoing, + called: false, + voucher: storageDataTransferVoucher(t, expectedProposalCID), }, } @@ -223,7 +207,7 @@ func TestClientDataTransferSubscriber(t *testing.T) { fdg := &fakeDealGroup{} subscriber := dtutils.ClientDataTransferSubscriber(fdg) subscriber(datatransfer.Event{Code: data.code, Message: data.message}, shared_testutil.NewTestChannel( - shared_testutil.TestChannelParams{Vouchers: []datatransfer.Voucher{data.voucher}, Status: data.status, + shared_testutil.TestChannelParams{Vouchers: []datatransfer.TypedVoucher{data.voucher}, Status: data.status, Sender: init, Recipient: resp, TransferID: tid, IsPull: false}, )) if data.called { @@ -243,7 +227,7 @@ func TestTransportConfigurer(t *testing.T) { expectedChannelID := shared_testutil.MakeTestChannelID() testCases := map[string]struct { - voucher datatransfer.Voucher + voucher datatransfer.TypedVoucher transport datatransfer.Transport returnedStore bs.Blockstore returnedStoreErr error @@ -251,20 +235,16 @@ func TestTransportConfigurer(t *testing.T) { useStoreCalled bool }{ "non-storage voucher": { - voucher: nil, + voucher: datatransfer.TypedVoucher{Voucher: basicnode.NewString("Nope"), Type: datatransfer.TypeIdentifier("Nope")}, getterCalled: false, }, "non-configurable transport": { - voucher: &requestvalidation.StorageDataTransferVoucher{ - Proposal: expectedProposalCID, - }, + voucher: storageDataTransferVoucher(t, expectedProposalCID), transport: &fakeTransport{}, getterCalled: false, }, "store getter errors": { - voucher: &requestvalidation.StorageDataTransferVoucher{ - Proposal: expectedProposalCID, - }, + voucher: storageDataTransferVoucher(t, expectedProposalCID), transport: &fakeGsTransport{Transport: &fakeTransport{}}, getterCalled: true, useStoreCalled: false, @@ -272,9 +252,7 @@ func TestTransportConfigurer(t *testing.T) { returnedStoreErr: errors.New("something went wrong"), }, "store getter succeeds": { - voucher: &requestvalidation.StorageDataTransferVoucher{ - Proposal: expectedProposalCID, - }, + voucher: storageDataTransferVoucher(t, expectedProposalCID), transport: &fakeGsTransport{Transport: &fakeTransport{}}, getterCalled: true, useStoreCalled: true, @@ -336,7 +314,7 @@ func (fsg *fakeStoreGetter) Get(proposalCid cid.Cid) (bs.Blockstore, error) { type fakeTransport struct{} -func (ft *fakeTransport) OpenChannel(ctx context.Context, dataSender peer.ID, channelID datatransfer.ChannelID, root ipld.Link, stor ipld.Node, channel datatransfer.ChannelState, msg datatransfer.Message) error { +func (ft *fakeTransport) OpenChannel(ctx context.Context, dataSender peer.ID, channelID datatransfer.ChannelID, root datamodel.Link, stor datamodel.Node, channel datatransfer.ChannelState, msg datatransfer.Message) error { return nil } diff --git a/storagemarket/impl/ipld_compat_test.go b/storagemarket/impl/ipld_compat_test.go new file mode 100644 index 00000000..182f70b1 --- /dev/null +++ b/storagemarket/impl/ipld_compat_test.go @@ -0,0 +1,64 @@ +package storageimpl_test + +// TODO(rvagg): this is a transitional package to test compatibility between +// cbor-gen and bindnode - it can be removed if/when cbor-gen is also removed + +import ( + "bytes" + "fmt" + "testing" + + "github.com/ipfs/go-cid" + "github.com/ipld/go-ipld-prime/codec/dagcbor" + "github.com/ipld/go-ipld-prime/node/basicnode" + "github.com/ipld/go-ipld-prime/schema" + "github.com/stretchr/testify/assert" + + "github.com/filecoin-project/go-fil-markets/storagemarket/impl/requestvalidation" +) + +func TestIpldCompat_StorageDataTransferVoucher(t *testing.T) { + acid, err := cid.Decode("bafy2bzaceashdsqgbnisdg76gdhupvkpop4br5rs3veuy4whuxagnoco6px6e") + assert.Nil(t, err) + + for _, sdtv := range []requestvalidation.StorageDataTransferVoucher{ + {Proposal: acid}, + // {}, - we can't test this because cbor-gen generates an invalid byte repr for empty CID + } { + t.Run(fmt.Sprintf("with Proposal: %s", sdtv.Proposal), func(t *testing.T) { + // encode the StorageDataTransferVoucher with cbor-gen to bytes + var originalBuf bytes.Buffer + sdtv.MarshalCBOR(&originalBuf) + originalBytes := originalBuf.Bytes() + + // decode the bytes to StorageDataTransferVoucher with bindnode + nb := basicnode.Prototype.Any.NewBuilder() + dagcbor.Decode(nb, &originalBuf) + node := nb.Build() + sdtvBindnodeIface, err := requestvalidation.BindnodeRegistry.TypeFromNode(node, &requestvalidation.StorageDataTransferVoucher{}) + assert.Nil(t, err) + sdtvBindnode, ok := sdtvBindnodeIface.(*requestvalidation.StorageDataTransferVoucher) + assert.True(t, ok) + + // compare objects + assert.Equal(t, sdtv.Proposal, sdtvBindnode.Proposal) + + // encode the new StorageDataTransferVoucher with bindnode to bytes + node = requestvalidation.BindnodeRegistry.TypeToNode(sdtvBindnode) + var bindnodeBuf bytes.Buffer + dagcbor.Encode(node.(schema.TypedNode).Representation(), &bindnodeBuf) + bindnodeBytes := bindnodeBuf.Bytes() + + // compare bytes + assert.Equal(t, originalBytes, bindnodeBytes) + + // decode the new bytes to StorageDataTransferVoucher with cbor-gen + var roundtripSdtv requestvalidation.StorageDataTransferVoucher + err = roundtripSdtv.UnmarshalCBOR(&bindnodeBuf) + assert.Nil(t, err) + + // compare objects + assert.Equal(t, sdtv.Proposal, roundtripSdtv.Proposal) + }) + } +} diff --git a/storagemarket/impl/provider.go b/storagemarket/impl/provider.go index 1646377f..8d9ff7be 100644 --- a/storagemarket/impl/provider.go +++ b/storagemarket/impl/provider.go @@ -164,12 +164,12 @@ func NewProvider(net network.StorageMarketNetwork, h.unsubDataTransfer = dataTransfer.SubscribeToEvents(dtutils.ProviderDataTransferSubscriber(h.deals)) pph := &providerPushDeals{h} - err = dataTransfer.RegisterVoucherType(&requestvalidation.StorageDataTransferVoucher{}, requestvalidation.NewUnifiedRequestValidator(pph, nil)) + err = dataTransfer.RegisterVoucherType(requestvalidation.StorageDataTransferVoucherType, requestvalidation.NewUnifiedRequestValidator(pph, nil)) if err != nil { return nil, err } - err = dataTransfer.RegisterTransportConfigurer(&requestvalidation.StorageDataTransferVoucher{}, dtutils.TransportConfigurer(&providerStoreGetter{h})) + err = dataTransfer.RegisterTransportConfigurer(requestvalidation.StorageDataTransferVoucherType, dtutils.TransportConfigurer(&providerStoreGetter{h})) if err != nil { return nil, err } diff --git a/storagemarket/impl/requestvalidation/common.go b/storagemarket/impl/requestvalidation/common.go index d13d98ab..63bfae28 100644 --- a/storagemarket/impl/requestvalidation/common.go +++ b/storagemarket/impl/requestvalidation/common.go @@ -2,12 +2,10 @@ package requestvalidation import ( "github.com/ipfs/go-cid" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/libp2p/go-libp2p-core/peer" "golang.org/x/xerrors" - datatransfer "github.com/filecoin-project/go-data-transfer/v2" - "github.com/filecoin-project/go-fil-markets/storagemarket" ) @@ -20,15 +18,16 @@ import ( func ValidatePush( deals PushDeals, sender peer.ID, - voucher datatransfer.Voucher, + voucher datamodel.Node, baseCid cid.Cid, - Selector ipld.Node) error { - dealVoucher, ok := voucher.(*StorageDataTransferVoucher) - if !ok { - return xerrors.Errorf("voucher type %s: %w", voucher.Type(), ErrWrongVoucherType) + Selector datamodel.Node) error { + + dealVoucherIface, err := BindnodeRegistry.TypeFromNode(voucher, &StorageDataTransferVoucher{}) + if err != nil { + return xerrors.Errorf("could not decode StorageDataTransferVoucher: %w", err) } + dealVoucher, _ := dealVoucherIface.(*StorageDataTransferVoucher) // safe to assume type - var deal storagemarket.MinerDeal deal, err := deals.Get(dealVoucher.Proposal) if err != nil { return xerrors.Errorf("Proposal CID %s: %w", dealVoucher.Proposal.String(), ErrNoDeal) @@ -54,13 +53,15 @@ func ValidatePush( func ValidatePull( deals PullDeals, receiver peer.ID, - voucher datatransfer.Voucher, + voucher datamodel.Node, baseCid cid.Cid, - Selector ipld.Node) error { - dealVoucher, ok := voucher.(*StorageDataTransferVoucher) - if !ok { - return xerrors.Errorf("voucher type %s: %w", voucher.Type(), ErrWrongVoucherType) + Selector datamodel.Node) error { + + dealVoucherIface, err := BindnodeRegistry.TypeFromNode(voucher, &StorageDataTransferVoucher{}) + if err != nil { + return xerrors.Errorf("could not decode StorageDataTransferVoucher: %w", err) } + dealVoucher, _ := dealVoucherIface.(*StorageDataTransferVoucher) // safe to assume type deal, err := deals.Get(dealVoucher.Proposal) if err != nil { return xerrors.Errorf("Proposal CID %s: %w", dealVoucher.Proposal.String(), ErrNoDeal) diff --git a/storagemarket/impl/requestvalidation/request_validation_test.go b/storagemarket/impl/requestvalidation/request_validation_test.go index 4577d524..42d3bd51 100644 --- a/storagemarket/impl/requestvalidation/request_validation_test.go +++ b/storagemarket/impl/requestvalidation/request_validation_test.go @@ -9,7 +9,8 @@ import ( "github.com/ipfs/go-datastore/namespace" dss "github.com/ipfs/go-datastore/sync" blocksutil "github.com/ipfs/go-ipfs-blocksutil" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" + "github.com/ipld/go-ipld-prime/node/basicnode" "github.com/libp2p/go-libp2p-core/peer" xerrors "golang.org/x/xerrors" @@ -22,18 +23,12 @@ import ( tut "github.com/filecoin-project/go-fil-markets/shared_testutil" "github.com/filecoin-project/go-fil-markets/storagemarket" + "github.com/filecoin-project/go-fil-markets/storagemarket/impl/requestvalidation" rv "github.com/filecoin-project/go-fil-markets/storagemarket/impl/requestvalidation" ) var blockGenerator = blocksutil.NewBlockGenerator() -type wrongDTType struct { -} - -func (wrongDTType) Type() datatransfer.TypeIdentifier { - return "WrongDTTYPE" -} - func uniqueStorageDealProposal() (market.ClientDealProposal, error) { clientAddr, err := address.NewIDAddress(uint64(rand.Int())) if err != nil { @@ -133,7 +128,7 @@ func TestUnifiedRequestValidator(t *testing.T) { urv := rv.NewUnifiedRequestValidator(nil, &pullDeals{state}) t.Run("ValidatePush fails", func(t *testing.T) { - _, err := urv.ValidatePush(datatransfer.ChannelID{}, minerID, wrongDTType{}, block.Cid(), nil) + _, err := urv.ValidatePush(datatransfer.ChannelID{}, minerID, basicnode.NewString("wrong DT type"), block.Cid(), nil) if !xerrors.Is(err, rv.ErrNoPushAccepted) { t.Fatal("Push should fail for the client request validator for storage deals") } @@ -145,7 +140,7 @@ func TestUnifiedRequestValidator(t *testing.T) { urv := rv.NewUnifiedRequestValidator(&pushDeals{state}, nil) t.Run("ValidatePull fails", func(t *testing.T) { - _, err := urv.ValidatePull(datatransfer.ChannelID{}, clientID, wrongDTType{}, block.Cid(), nil) + _, err := urv.ValidatePull(datatransfer.ChannelID{}, clientID, basicnode.NewString("wrong DT type"), block.Cid(), nil) if !xerrors.Is(err, rv.ErrNoPullAccepted) { t.Fatal("Pull should fail for the provider request validator for storage deals") } @@ -172,7 +167,9 @@ func AssertPushValidator(t *testing.T, validator datatransfer.RequestValidator, if err != nil { t.Fatal("error serializing proposal") } - checkValidateAndRevalidatePush(t, validator, datatransfer.ChannelID{}, sender, &rv.StorageDataTransferVoucher{proposalNd.Cid()}, proposal.Proposal.PieceCID, nil, + sdtv := rv.StorageDataTransferVoucher{proposalNd.Cid()} + voucher := requestvalidation.BindnodeRegistry.TypeToNode(&sdtv) + checkValidateAndRevalidatePush(t, validator, datatransfer.ChannelID{}, sender, datatransfer.TypedVoucher{Voucher: voucher, Type: rv.StorageDataTransferVoucherType}, proposal.Proposal.PieceCID, nil, func(t *testing.T, result datatransfer.ValidationResult, err error) { if err != nil { t.Fatal("unexpected error validating") @@ -190,7 +187,9 @@ func AssertPushValidator(t *testing.T, validator datatransfer.RequestValidator, if err := state.Begin(minerDeal.ProposalCid, &minerDeal); err != nil { t.Fatal("deal tracking failed") } - checkValidateAndRevalidatePush(t, validator, datatransfer.ChannelID{}, sender, &rv.StorageDataTransferVoucher{minerDeal.ProposalCid}, blockGenerator.Next().Cid(), nil, + sdtv := rv.StorageDataTransferVoucher{minerDeal.ProposalCid} + voucher := requestvalidation.BindnodeRegistry.TypeToNode(&sdtv) + checkValidateAndRevalidatePush(t, validator, datatransfer.ChannelID{}, sender, datatransfer.TypedVoucher{Voucher: voucher, Type: rv.StorageDataTransferVoucherType}, blockGenerator.Next().Cid(), nil, func(t *testing.T, result datatransfer.ValidationResult, err error) { if err != nil { t.Fatal("unexpected error validating") @@ -209,7 +208,9 @@ func AssertPushValidator(t *testing.T, validator datatransfer.RequestValidator, t.Fatal("deal tracking failed") } ref := minerDeal.Ref - checkValidateAndRevalidatePush(t, validator, datatransfer.ChannelID{}, sender, &rv.StorageDataTransferVoucher{minerDeal.ProposalCid}, ref.Root, nil, + sdtv := rv.StorageDataTransferVoucher{minerDeal.ProposalCid} + voucher := requestvalidation.BindnodeRegistry.TypeToNode(&sdtv) + checkValidateAndRevalidatePush(t, validator, datatransfer.ChannelID{}, sender, datatransfer.TypedVoucher{Voucher: voucher, Type: rv.StorageDataTransferVoucherType}, ref.Root, nil, func(t *testing.T, result datatransfer.ValidationResult, err error) { if err != nil { t.Fatal("unexpected error validating") @@ -228,7 +229,9 @@ func AssertPushValidator(t *testing.T, validator datatransfer.RequestValidator, t.Fatal("deal tracking failed") } ref := minerDeal.Ref - checkValidateAndRevalidatePush(t, validator, datatransfer.ChannelID{}, sender, &rv.StorageDataTransferVoucher{minerDeal.ProposalCid}, ref.Root, nil, + sdtv := rv.StorageDataTransferVoucher{minerDeal.ProposalCid} + voucher := requestvalidation.BindnodeRegistry.TypeToNode(&sdtv) + checkValidateAndRevalidatePush(t, validator, datatransfer.ChannelID{}, sender, datatransfer.TypedVoucher{Voucher: voucher, Type: rv.StorageDataTransferVoucherType}, ref.Root, nil, func(t *testing.T, result datatransfer.ValidationResult, err error) { if err != nil { t.Fatal("unexpected error validating") @@ -250,7 +253,9 @@ func AssertValidatesPulls(t *testing.T, validator datatransfer.RequestValidator, if err != nil { t.Fatal("error serializing proposal") } - checkValidateAndRevalidatePull(t, validator, datatransfer.ChannelID{}, receiver, &rv.StorageDataTransferVoucher{proposalNd.Cid()}, proposal.Proposal.PieceCID, nil, + sdtv := rv.StorageDataTransferVoucher{proposalNd.Cid()} + voucher := requestvalidation.BindnodeRegistry.TypeToNode(&sdtv) + checkValidateAndRevalidatePull(t, validator, datatransfer.ChannelID{}, receiver, datatransfer.TypedVoucher{Voucher: voucher, Type: rv.StorageDataTransferVoucherType}, proposal.Proposal.PieceCID, nil, func(t *testing.T, result datatransfer.ValidationResult, err error) { if err != nil { t.Fatal("unexpected error validating") @@ -268,7 +273,9 @@ func AssertValidatesPulls(t *testing.T, validator datatransfer.RequestValidator, if err := state.Begin(clientDeal.ProposalCid, &clientDeal); err != nil { t.Fatal("deal tracking failed") } - checkValidateAndRevalidatePull(t, validator, datatransfer.ChannelID{}, receiver, &rv.StorageDataTransferVoucher{clientDeal.ProposalCid}, blockGenerator.Next().Cid(), nil, + sdtv := rv.StorageDataTransferVoucher{clientDeal.ProposalCid} + voucher := requestvalidation.BindnodeRegistry.TypeToNode(&sdtv) + checkValidateAndRevalidatePull(t, validator, datatransfer.ChannelID{}, receiver, datatransfer.TypedVoucher{Voucher: voucher, Type: rv.StorageDataTransferVoucherType}, blockGenerator.Next().Cid(), nil, func(t *testing.T, result datatransfer.ValidationResult, err error) { if err != nil { t.Fatal("unexpected error validating") @@ -287,7 +294,9 @@ func AssertValidatesPulls(t *testing.T, validator datatransfer.RequestValidator, t.Fatal("deal tracking failed") } payloadCid := clientDeal.DataRef.Root - checkValidateAndRevalidatePull(t, validator, datatransfer.ChannelID{}, receiver, &rv.StorageDataTransferVoucher{clientDeal.ProposalCid}, payloadCid, nil, + sdtv := rv.StorageDataTransferVoucher{clientDeal.ProposalCid} + voucher := requestvalidation.BindnodeRegistry.TypeToNode(&sdtv) + checkValidateAndRevalidatePull(t, validator, datatransfer.ChannelID{}, receiver, datatransfer.TypedVoucher{Voucher: voucher, Type: rv.StorageDataTransferVoucherType}, payloadCid, nil, func(t *testing.T, result datatransfer.ValidationResult, err error) { if err != nil { t.Fatal("unexpected error validating") @@ -306,7 +315,9 @@ func AssertValidatesPulls(t *testing.T, validator datatransfer.RequestValidator, t.Fatal("deal tracking failed") } payloadCid := clientDeal.DataRef.Root - checkValidateAndRevalidatePull(t, validator, datatransfer.ChannelID{}, receiver, &rv.StorageDataTransferVoucher{clientDeal.ProposalCid}, payloadCid, nil, + sdtv := rv.StorageDataTransferVoucher{clientDeal.ProposalCid} + voucher := requestvalidation.BindnodeRegistry.TypeToNode(&sdtv) + checkValidateAndRevalidatePull(t, validator, datatransfer.ChannelID{}, receiver, datatransfer.TypedVoucher{Voucher: voucher, Type: rv.StorageDataTransferVoucherType}, payloadCid, nil, func(t *testing.T, result datatransfer.ValidationResult, err error) { if err != nil { t.Fatal("unexpected error validating") @@ -318,14 +329,14 @@ func AssertValidatesPulls(t *testing.T, validator datatransfer.RequestValidator, }) } -func checkValidateAndRevalidatePush(t *testing.T, validator datatransfer.RequestValidator, chid datatransfer.ChannelID, sender peer.ID, voucher datatransfer.Voucher, baseCid cid.Cid, selector ipld.Node, +func checkValidateAndRevalidatePush(t *testing.T, validator datatransfer.RequestValidator, chid datatransfer.ChannelID, sender peer.ID, voucher datatransfer.TypedVoucher, baseCid cid.Cid, selector datamodel.Node, test func(t *testing.T, result datatransfer.ValidationResult, err error)) { - result, err := validator.ValidatePush(chid, sender, voucher, baseCid, selector) + result, err := validator.ValidatePush(chid, sender, voucher.Voucher, baseCid, selector) test(t, result, err) channel := tut.NewTestChannel(tut.TestChannelParams{ IsPull: false, Sender: sender, - Vouchers: []datatransfer.Voucher{voucher}, + Vouchers: []datatransfer.TypedVoucher{voucher}, BaseCID: baseCid, Selector: selector, }) @@ -333,14 +344,14 @@ func checkValidateAndRevalidatePush(t *testing.T, validator datatransfer.Request test(t, result, err) } -func checkValidateAndRevalidatePull(t *testing.T, validator datatransfer.RequestValidator, chid datatransfer.ChannelID, receiver peer.ID, voucher datatransfer.Voucher, baseCid cid.Cid, selector ipld.Node, +func checkValidateAndRevalidatePull(t *testing.T, validator datatransfer.RequestValidator, chid datatransfer.ChannelID, receiver peer.ID, voucher datatransfer.TypedVoucher, baseCid cid.Cid, selector datamodel.Node, test func(t *testing.T, result datatransfer.ValidationResult, err error)) { - result, err := validator.ValidatePull(chid, receiver, voucher, baseCid, selector) + result, err := validator.ValidatePull(chid, receiver, voucher.Voucher, baseCid, selector) test(t, result, err) channel := tut.NewTestChannel(tut.TestChannelParams{ IsPull: true, Recipient: receiver, - Vouchers: []datatransfer.Voucher{voucher}, + Vouchers: []datatransfer.TypedVoucher{voucher}, BaseCID: baseCid, Selector: selector, }) diff --git a/storagemarket/impl/requestvalidation/types.go b/storagemarket/impl/requestvalidation/types.go index 0779fe6d..50c89912 100644 --- a/storagemarket/impl/requestvalidation/types.go +++ b/storagemarket/impl/requestvalidation/types.go @@ -1,9 +1,11 @@ package requestvalidation import ( + _ "embed" "errors" "github.com/ipfs/go-cid" + bindnoderegistry "github.com/ipld/go-ipld-prime/node/bindnode/registry" datatransfer "github.com/filecoin-project/go-data-transfer/v2" @@ -12,6 +14,9 @@ import ( //go:generate cbor-gen-for StorageDataTransferVoucher +//go:embed types.ipldsch +var embedSchema []byte + var ( // ErrWrongVoucherType means the voucher was not the correct type can validate against ErrWrongVoucherType = errors.New("cannot validate voucher type") @@ -49,7 +54,13 @@ type StorageDataTransferVoucher struct { Proposal cid.Cid } -// Type is the unique string identifier for a StorageDataTransferVoucher -func (dv *StorageDataTransferVoucher) Type() datatransfer.TypeIdentifier { - return "StorageDataTransferVoucher" +// StorageDataTransferVoucherType is the unique string identifier for a StorageDataTransferVoucher +const StorageDataTransferVoucherType = datatransfer.TypeIdentifier("StorageDataTransferVoucher") + +var BindnodeRegistry = bindnoderegistry.NewRegistry() + +func init() { + if err := BindnodeRegistry.RegisterType((*StorageDataTransferVoucher)(nil), string(embedSchema), "StorageDataTransferVoucher"); err != nil { + panic(err.Error()) + } } diff --git a/storagemarket/impl/requestvalidation/types.ipldsch b/storagemarket/impl/requestvalidation/types.ipldsch new file mode 100644 index 00000000..fa65c093 --- /dev/null +++ b/storagemarket/impl/requestvalidation/types.ipldsch @@ -0,0 +1,3 @@ +type StorageDataTransferVoucher struct { + Proposal &Any +} representation tuple diff --git a/storagemarket/impl/requestvalidation/unified_request_validator.go b/storagemarket/impl/requestvalidation/unified_request_validator.go index b0788fe7..0c80d9a8 100644 --- a/storagemarket/impl/requestvalidation/unified_request_validator.go +++ b/storagemarket/impl/requestvalidation/unified_request_validator.go @@ -2,7 +2,7 @@ package requestvalidation import ( "github.com/ipfs/go-cid" - "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/datamodel" "github.com/libp2p/go-libp2p-core/peer" datatransfer "github.com/filecoin-project/go-data-transfer/v2" @@ -50,7 +50,7 @@ func (v *UnifiedRequestValidator) SetPullDeals(pullDeals PullDeals) { // ValidatePush implements the ValidatePush method of a data transfer request validator. // If no pushStore exists, it rejects the request // Otherwise, it calls the ValidatePush function to validate the deal -func (v *UnifiedRequestValidator) ValidatePush(_ datatransfer.ChannelID, sender peer.ID, voucher datatransfer.Voucher, baseCid cid.Cid, selector ipld.Node) (datatransfer.ValidationResult, error) { +func (v *UnifiedRequestValidator) ValidatePush(_ datatransfer.ChannelID, sender peer.ID, voucher datamodel.Node, baseCid cid.Cid, selector datamodel.Node) (datatransfer.ValidationResult, error) { if v.pushDeals == nil { return datatransfer.ValidationResult{}, ErrNoPushAccepted } @@ -65,7 +65,7 @@ func (v *UnifiedRequestValidator) ValidatePush(_ datatransfer.ChannelID, sender // ValidatePull implements the ValidatePull method of a data transfer request validator. // If no pullStore exists, it rejects the request // Otherwise, it calls the ValidatePull function to validate the deal -func (v *UnifiedRequestValidator) ValidatePull(_ datatransfer.ChannelID, receiver peer.ID, voucher datatransfer.Voucher, baseCid cid.Cid, selector ipld.Node) (datatransfer.ValidationResult, error) { +func (v *UnifiedRequestValidator) ValidatePull(_ datatransfer.ChannelID, receiver peer.ID, voucher datamodel.Node, baseCid cid.Cid, selector datamodel.Node) (datatransfer.ValidationResult, error) { if v.pullDeals == nil { return datatransfer.ValidationResult{}, ErrNoPullAccepted } @@ -79,9 +79,17 @@ func (v *UnifiedRequestValidator) ValidatePull(_ datatransfer.ChannelID, receive func (v *UnifiedRequestValidator) ValidateRestart(chid datatransfer.ChannelID, channelState datatransfer.ChannelState) (datatransfer.ValidationResult, error) { if channelState.IsPull() { - return v.ValidatePull(chid, channelState.Recipient(), channelState.Voucher(), channelState.BaseCID(), channelState.Selector()) + voucher, err := channelState.Voucher() + if err != nil { + return datatransfer.ValidationResult{}, err + } + return v.ValidatePull(chid, channelState.Recipient(), voucher.Voucher, channelState.BaseCID(), channelState.Selector()) } else { - return v.ValidatePush(chid, channelState.Sender(), channelState.Voucher(), channelState.BaseCID(), channelState.Selector()) + voucher, err := channelState.Voucher() + if err != nil { + return datatransfer.ValidationResult{}, err + } + return v.ValidatePush(chid, channelState.Sender(), voucher.Voucher, channelState.BaseCID(), channelState.Selector()) } }