From cb1ba70a9b49fcb06c42c05179c8bba5c0da4dc4 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Fri, 30 Sep 2022 14:50:54 +1000 Subject: [PATCH 1/3] fix: handle new ProtoNode errors --- core/commands/files.go | 5 ++++- core/commands/object/object.go | 4 +++- core/coreapi/object.go | 4 +++- core/coreapi/unixfs.go | 5 ++++- core/coreunix/add.go | 10 ++++++++-- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/core/commands/files.go b/core/commands/files.go index e48abba2815..bba14a1e10f 100644 --- a/core/commands/files.go +++ b/core/commands/files.go @@ -1245,7 +1245,10 @@ func getFileHandle(r *mfs.Root, path string, create bool, builder cid.Builder) ( } nd := dag.NodeWithData(ft.FilePBData(nil, 0)) - nd.SetCidBuilder(builder) + err = nd.SetCidBuilder(builder) + if err != nil { + return nil, err + } err = pdir.AddChild(fname, nd) if err != nil { return nil, err diff --git a/core/commands/object/object.go b/core/commands/object/object.go index 332d28f560d..44864d04664 100644 --- a/core/commands/object/object.go +++ b/core/commands/object/object.go @@ -537,7 +537,9 @@ func deserializeNode(nd *Node, dataFieldEncoding string) (*dag.ProtoNode, error) Cid: c, } } - dagnode.SetLinks(links) + if err := dagnode.SetLinks(links); err != nil { + return nil, err + } return dagnode, nil } diff --git a/core/coreapi/object.go b/core/coreapi/object.go index d2bd08addec..28dd0df08f6 100644 --- a/core/coreapi/object.go +++ b/core/coreapi/object.go @@ -405,7 +405,9 @@ func deserializeNode(nd *Node, dataFieldEncoding string) (*dag.ProtoNode, error) Cid: c, } } - dagnode.SetLinks(links) + if err := dagnode.SetLinks(links); err != nil { + return nil, err + } return dagnode, nil } diff --git a/core/coreapi/unixfs.go b/core/coreapi/unixfs.go index d43bfe3132b..3d6966ac1ef 100644 --- a/core/coreapi/unixfs.go +++ b/core/coreapi/unixfs.go @@ -176,7 +176,10 @@ func (api *UnixfsAPI) Add(ctx context.Context, files files.Node, opts ...options md := dagtest.Mock() emptyDirNode := ft.EmptyDirNode() // Use the same prefix for the "empty" MFS root as for the file adder. - emptyDirNode.SetCidBuilder(fileAdder.CidBuilder) + err := emptyDirNode.SetCidBuilder(fileAdder.CidBuilder) + if err != nil { + return nil, err + } mr, err := mfs.NewRoot(ctx, md, emptyDirNode, nil) if err != nil { return nil, err diff --git a/core/coreunix/add.go b/core/coreunix/add.go index 54e5873a9d4..16ccbaefac7 100644 --- a/core/coreunix/add.go +++ b/core/coreunix/add.go @@ -87,7 +87,10 @@ func (adder *Adder) mfsRoot() (*mfs.Root, error) { return adder.mroot, nil } rnode := unixfs.EmptyDirNode() - rnode.SetCidBuilder(adder.CidBuilder) + err := rnode.SetCidBuilder(adder.CidBuilder) + if err != nil { + return nil, err + } mr, err := mfs.NewRoot(adder.ctx, adder.dagService, rnode, nil) if err != nil { return nil, err @@ -384,7 +387,10 @@ func (adder *Adder) addSymlink(path string, l *files.Symlink) error { } dagnode := dag.NodeWithData(sdata) - dagnode.SetCidBuilder(adder.CidBuilder) + err = dagnode.SetCidBuilder(adder.CidBuilder) + if err != nil { + return err + } err = adder.dagService.Add(adder.ctx, dagnode) if err != nil { return err From 7d0ea08289ee32ec174a2f6a8392859fe8d1977c Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Fri, 30 Sep 2022 14:17:33 +1000 Subject: [PATCH 2/3] deps: go-merkledag@v0.8.1 --- docs/examples/kubo-as-a-library/go.mod | 2 +- docs/examples/kubo-as-a-library/go.sum | 3 ++- go.mod | 2 +- go.sum | 3 ++- test/dependencies/go.mod | 2 +- test/dependencies/go.sum | 4 ++-- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/examples/kubo-as-a-library/go.mod b/docs/examples/kubo-as-a-library/go.mod index 57333bfb27a..6d1aaab86b7 100644 --- a/docs/examples/kubo-as-a-library/go.mod +++ b/docs/examples/kubo-as-a-library/go.mod @@ -97,7 +97,7 @@ require ( github.com/ipfs/go-ipns v0.3.0 // indirect github.com/ipfs/go-log v1.0.5 // indirect github.com/ipfs/go-log/v2 v2.5.1 // indirect - github.com/ipfs/go-merkledag v0.6.0 // indirect + github.com/ipfs/go-merkledag v0.8.1 // indirect github.com/ipfs/go-metrics-interface v0.0.1 // indirect github.com/ipfs/go-mfs v0.2.1 // indirect github.com/ipfs/go-namesys v0.5.0 // indirect diff --git a/docs/examples/kubo-as-a-library/go.sum b/docs/examples/kubo-as-a-library/go.sum index 73797d28501..6bfa62d19aa 100644 --- a/docs/examples/kubo-as-a-library/go.sum +++ b/docs/examples/kubo-as-a-library/go.sum @@ -623,8 +623,9 @@ github.com/ipfs/go-merkledag v0.0.6/go.mod h1:QYPdnlvkOg7GnQRofu9XZimC5ZW5Wi3bKy github.com/ipfs/go-merkledag v0.2.3/go.mod h1:SQiXrtSts3KGNmgOzMICy5c0POOpUNQLvB3ClKnBAlk= github.com/ipfs/go-merkledag v0.3.2/go.mod h1:fvkZNNZixVW6cKSZ/JfLlON5OlgTXNdRLz0p6QG/I2M= github.com/ipfs/go-merkledag v0.5.1/go.mod h1:cLMZXx8J08idkp5+id62iVftUQV+HlYJ3PIhDfZsjA4= -github.com/ipfs/go-merkledag v0.6.0 h1:oV5WT2321tS4YQVOPgIrWHvJ0lJobRTerU+i9nmUCuA= github.com/ipfs/go-merkledag v0.6.0/go.mod h1:9HSEwRd5sV+lbykiYP+2NC/3o6MZbKNaa4hfNcH5iH0= +github.com/ipfs/go-merkledag v0.8.1 h1:N3yrqSre/ffvdwtHL4MXy0n7XH+VzN8DlzDrJySPa94= +github.com/ipfs/go-merkledag v0.8.1/go.mod h1:uYUlWE34GhbcTjGuUDEcdPzsEtOdnOupL64NgSRjmWI= github.com/ipfs/go-metrics-interface v0.0.1 h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fGD6n0jO4kdg= github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY= github.com/ipfs/go-metrics-prometheus v0.0.2/go.mod h1:ELLU99AQQNi+zX6GCGm2lAgnzdSH3u5UVlCdqSXnEks= diff --git a/go.mod b/go.mod index fdb2efa083d..f9bd7eb9c8d 100644 --- a/go.mod +++ b/go.mod @@ -51,7 +51,7 @@ require ( github.com/ipfs/go-ipns v0.3.0 github.com/ipfs/go-log v1.0.5 github.com/ipfs/go-log/v2 v2.5.1 - github.com/ipfs/go-merkledag v0.6.0 + github.com/ipfs/go-merkledag v0.8.1 github.com/ipfs/go-metrics-interface v0.0.1 github.com/ipfs/go-metrics-prometheus v0.0.2 github.com/ipfs/go-mfs v0.2.1 diff --git a/go.sum b/go.sum index 11fd7a8b6ca..a558724a282 100644 --- a/go.sum +++ b/go.sum @@ -611,8 +611,9 @@ github.com/ipfs/go-merkledag v0.0.6/go.mod h1:QYPdnlvkOg7GnQRofu9XZimC5ZW5Wi3bKy github.com/ipfs/go-merkledag v0.2.3/go.mod h1:SQiXrtSts3KGNmgOzMICy5c0POOpUNQLvB3ClKnBAlk= github.com/ipfs/go-merkledag v0.3.2/go.mod h1:fvkZNNZixVW6cKSZ/JfLlON5OlgTXNdRLz0p6QG/I2M= github.com/ipfs/go-merkledag v0.5.1/go.mod h1:cLMZXx8J08idkp5+id62iVftUQV+HlYJ3PIhDfZsjA4= -github.com/ipfs/go-merkledag v0.6.0 h1:oV5WT2321tS4YQVOPgIrWHvJ0lJobRTerU+i9nmUCuA= github.com/ipfs/go-merkledag v0.6.0/go.mod h1:9HSEwRd5sV+lbykiYP+2NC/3o6MZbKNaa4hfNcH5iH0= +github.com/ipfs/go-merkledag v0.8.1 h1:N3yrqSre/ffvdwtHL4MXy0n7XH+VzN8DlzDrJySPa94= +github.com/ipfs/go-merkledag v0.8.1/go.mod h1:uYUlWE34GhbcTjGuUDEcdPzsEtOdnOupL64NgSRjmWI= github.com/ipfs/go-metrics-interface v0.0.1 h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fGD6n0jO4kdg= github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY= github.com/ipfs/go-metrics-prometheus v0.0.2 h1:9i2iljLg12S78OhC6UAiXi176xvQGiZaGVF1CUVdE+s= diff --git a/test/dependencies/go.mod b/test/dependencies/go.mod index 51e8021506f..1a0eea2260f 100644 --- a/test/dependencies/go.mod +++ b/test/dependencies/go.mod @@ -13,7 +13,7 @@ require ( github.com/ipfs/go-ipfs-blockstore v1.2.0 github.com/ipfs/go-ipfs-exchange-offline v0.2.0 github.com/ipfs/go-log v1.0.5 - github.com/ipfs/go-merkledag v0.6.0 + github.com/ipfs/go-merkledag v0.8.1 github.com/ipfs/go-unixfs v0.3.1 github.com/ipfs/hang-fds v0.1.0 github.com/ipfs/iptb v1.4.0 diff --git a/test/dependencies/go.sum b/test/dependencies/go.sum index 3c148639d0c..47bd100f4e2 100644 --- a/test/dependencies/go.sum +++ b/test/dependencies/go.sum @@ -664,8 +664,8 @@ github.com/ipfs/go-merkledag v0.0.6/go.mod h1:QYPdnlvkOg7GnQRofu9XZimC5ZW5Wi3bKy github.com/ipfs/go-merkledag v0.2.3/go.mod h1:SQiXrtSts3KGNmgOzMICy5c0POOpUNQLvB3ClKnBAlk= github.com/ipfs/go-merkledag v0.3.2/go.mod h1:fvkZNNZixVW6cKSZ/JfLlON5OlgTXNdRLz0p6QG/I2M= github.com/ipfs/go-merkledag v0.5.1/go.mod h1:cLMZXx8J08idkp5+id62iVftUQV+HlYJ3PIhDfZsjA4= -github.com/ipfs/go-merkledag v0.6.0 h1:oV5WT2321tS4YQVOPgIrWHvJ0lJobRTerU+i9nmUCuA= -github.com/ipfs/go-merkledag v0.6.0/go.mod h1:9HSEwRd5sV+lbykiYP+2NC/3o6MZbKNaa4hfNcH5iH0= +github.com/ipfs/go-merkledag v0.8.1 h1:N3yrqSre/ffvdwtHL4MXy0n7XH+VzN8DlzDrJySPa94= +github.com/ipfs/go-merkledag v0.8.1/go.mod h1:uYUlWE34GhbcTjGuUDEcdPzsEtOdnOupL64NgSRjmWI= github.com/ipfs/go-metrics-interface v0.0.1 h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fGD6n0jO4kdg= github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY= github.com/ipfs/go-path v0.0.7/go.mod h1:6KTKmeRnBXgqrTvzFrPV3CamxcgvXX/4z79tfAd2Sno= From 807b98537df7f3ce87974e7fca9354a7d70aa150 Mon Sep 17 00:00:00 2001 From: Jorropo Date: Mon, 5 Dec 2022 15:01:18 +0100 Subject: [PATCH 3/3] Revert "fix: ensure hasher is registered when using a hashing function" This has been superseeded by 7d0ea08289ee32ec174a2f6a8392859fe8d1977c. This reverts commit 773c246232c1f3d7fc67d7ddf5b1cb172ece8fa1. --- core/commands/add.go | 3 --- test/sharness/t0042-add-skip.sh | 4 ---- 2 files changed, 7 deletions(-) diff --git a/core/commands/add.go b/core/commands/add.go index 12a38aaebe7..9f686e14b9f 100644 --- a/core/commands/add.go +++ b/core/commands/add.go @@ -210,9 +210,6 @@ See 'dag export' and 'dag import' for more information. if !ok { return fmt.Errorf("unrecognized hash function: %q", strings.ToLower(hashFunStr)) } - if _, err := mh.GetHasher(hashFunCode); err != nil { - return err - } enc, err := cmdenv.GetCidEncoder(req) if err != nil { diff --git a/test/sharness/t0042-add-skip.sh b/test/sharness/t0042-add-skip.sh index 64d8e1a7c41..9da78163c45 100755 --- a/test/sharness/t0042-add-skip.sh +++ b/test/sharness/t0042-add-skip.sh @@ -93,10 +93,6 @@ EOF test_cmp expected actual ' - test_expect_failure "'ipfs add' with an unregistered hash and wrapped leaves fails without crashing" ' - ipfs add --hash poseidon-bls12_381-a2-fc1 --raw-leaves=false -r mountdir/planets - ' - } # should work offline