Skip to content

Commit

Permalink
Merge pull request #1596 from OffchainLabs/update-ipfs
Browse files Browse the repository at this point in the history
Update IPFS kubo and support Go 1.20
  • Loading branch information
PlasmaPower authored Apr 27, 2023
2 parents 6a87ba6 + 6b575c1 commit 63112e4
Show file tree
Hide file tree
Showing 7 changed files with 272 additions and 495 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/arbitrator-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Install go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
go-version: 1.19.x

- name: Setup nodejs
uses: actions/setup-node@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- name: Install go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
go-version: 1.19.x

- name: Install wasm-ld
run: |
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:
run: |
mkdir -p target/tmp
echo "TMPDIR=$(pwd)/target/tmp" >> "$GITHUB_ENV"
echo "GOMEMLIMIT=6GB" >> "$GITHUB_ENV"
echo "GOMEMLIMIT=6GiB" >> "$GITHUB_ENV"
echo "GOGC=80" >> "$GITHUB_ENV"
- name: run tests without race detection
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
- name: Install go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
go-version: 1.19.x

- name: Install rust stable
uses: actions-rs/toolchain@v1
Expand Down
19 changes: 8 additions & 11 deletions cmd/ipfshelper/ipfshelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ import (
"time"

"github.com/ethereum/go-ethereum/log"

files "github.com/ipfs/go-ipfs-files"
ipfspath "github.com/ipfs/go-path"
icore "github.com/ipfs/interface-go-ipfs-core"
"github.com/ipfs/go-libipfs/files"
coreiface "github.com/ipfs/interface-go-ipfs-core"
"github.com/ipfs/interface-go-ipfs-core/options"
"github.com/ipfs/interface-go-ipfs-core/path"
icorepath "github.com/ipfs/interface-go-ipfs-core/path"
"github.com/ipfs/kubo/config"
"github.com/ipfs/kubo/core"
"github.com/ipfs/kubo/core/coreapi"
Expand All @@ -34,7 +31,7 @@ import (
const DefaultIpfsProfiles = ""

type IpfsHelper struct {
api icore.CoreAPI
api coreiface.CoreAPI
node *core.IpfsNode
cfg *config.Config
repoPath string
Expand Down Expand Up @@ -159,7 +156,7 @@ func normalizeCidString(cidString string) string {

func (h *IpfsHelper) DownloadFile(ctx context.Context, cidString string, destinationDir string) (string, error) {
cidString = normalizeCidString(cidString)
cidPath := icorepath.New(cidString)
cidPath := path.New(cidString)
resolvedPath, err := h.api.ResolvePath(ctx, cidPath)
if err != nil {
return "", fmt.Errorf("failed to resolve path: %w", err)
Expand All @@ -185,7 +182,7 @@ func (h *IpfsHelper) DownloadFile(ctx context.Context, cidString string, destina
printProgress(0, len(links))
for i, j := range permutation {
link := links[j]
if err := h.api.Pin().Add(ctx, icorepath.IpfsPath(link.Cid), options.Pin.Recursive(true)); err != nil {
if err := h.api.Pin().Add(ctx, path.IpfsPath(link.Cid), options.Pin.Recursive(true)); err != nil {
return "", fmt.Errorf("failed to pin child path: %w", err)
}
printProgress(i+1, len(links))
Expand Down Expand Up @@ -268,8 +265,8 @@ func createIpfsHelperImpl(ctx context.Context, downloadPath string, clientOnly b
}

func CanBeIpfsPath(pathString string) bool {
_, err := ipfspath.ParsePath(pathString)
return err == nil ||
path := path.New(pathString)
return path.IsValid() == nil ||
strings.HasPrefix(pathString, "/ipfs/") ||
strings.HasPrefix(pathString, "/ipld/") ||
strings.HasPrefix(pathString, "/ipns/") ||
Expand All @@ -278,6 +275,6 @@ func CanBeIpfsPath(pathString string) bool {
}

// TODO break abstraction for now til we figure out what fns are needed
func (h *IpfsHelper) GetAPI() icore.CoreAPI {
func (h *IpfsHelper) GetAPI() coreiface.CoreAPI {
return h.api
}
6 changes: 3 additions & 3 deletions das/ipfs_storage_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/ipfs/go-cid"
icore "github.com/ipfs/interface-go-ipfs-core"
coreiface "github.com/ipfs/interface-go-ipfs-core"
"github.com/ipfs/interface-go-ipfs-core/options"
path "github.com/ipfs/interface-go-ipfs-core/path"
"github.com/ipfs/interface-go-ipfs-core/path"
"github.com/multiformats/go-multihash"
"github.com/offchainlabs/nitro/arbstate"
"github.com/offchainlabs/nitro/cmd/ipfshelper"
Expand Down Expand Up @@ -65,7 +65,7 @@ func IpfsStorageServiceConfigAddOptions(prefix string, f *flag.FlagSet) {
type IpfsStorageService struct {
config IpfsStorageServiceConfig
ipfsHelper *ipfshelper.IpfsHelper
ipfsApi icore.CoreAPI
ipfsApi coreiface.CoreAPI
}

func NewIpfsStorageService(ctx context.Context, config IpfsStorageServiceConfig) (*IpfsStorageService, error) {
Expand Down
Loading

0 comments on commit 63112e4

Please sign in to comment.