diff --git a/.github/workflows/build-zbox.yaml b/.github/workflows/build-zbox.yaml index efa4e476..3e0e792c 100644 --- a/.github/workflows/build-zbox.yaml +++ b/.github/workflows/build-zbox.yaml @@ -21,17 +21,17 @@ jobs: sudo apt -y install build-essential nghttp2 libnghttp2-dev libssl-dev containerd docker.io - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup gopath and gocache run: | echo "GOPATH=$HOME/go" >> $GITHUB_ENV echo "GOCACHE=$GITHUB_WORKSPACE/.gocache" >> $GITHUB_ENV - - name: Setup go 1.20 - uses: actions/setup-go@v3 + - name: Setup go 1.21 + uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.21' - name: Install run: | @@ -40,7 +40,7 @@ jobs: make install - name: 'Upload Artifact' - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: zbox-linux path: zbox @@ -79,7 +79,7 @@ jobs: go env -w "CC=/mingw64/bin/clang.exe" - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install run: make install @@ -93,7 +93,7 @@ jobs: zip zbox-windows.zip zbox.exe libgcc_s_seh-1.dll libstdc++-6.dll libwinpthread-1.dll - name: 'Upload Artifact' - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: zbox-windows.zip path: zbox-windows.zip @@ -109,19 +109,19 @@ jobs: runs-on: macos-runner steps: - - name: Setup go 1.20 - uses: actions/setup-go@v2 + - name: Setup go 1.21 + uses: actions/setup-go@v5 with: - go-version: '1.20' # The Go version to download (if necessary) and use. + go-version: '1.21' - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install run: make install - name: 'Upload Artifact' - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: zbox-macos path: zbox diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index c50188e1..eef52f5e 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -34,7 +34,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/distribute-zboxcli-apt.yml b/.github/workflows/distribute-zboxcli-apt.yml new file mode 100644 index 00000000..47ba6aa6 --- /dev/null +++ b/.github/workflows/distribute-zboxcli-apt.yml @@ -0,0 +1,290 @@ +name: Distribute zbox using apt + +on: + workflow_dispatch: + inputs: + version: + description: 'Version of zbox to release' + required: true + default: '1.0.0' + +env: + APP_NAME: zbox + APP_VERSION: ${{ github.event.inputs.version }} + REMOTE_SERVER: 5.9.151.246 + REMOTE_USER: root + +jobs: + build: + runs-on: [ubuntu-latest] + env: + SRC_DIR: ${{ github.workspace }}/src + OUTPUT_DIR: ${{ github.workspace }}/output + PACKAGE_DIR: ${{ github.workspace }}/package + strategy: + matrix: + distro: + - name: bionic + base_image: ubuntu:18.04 + - name: focal + base_image: ubuntu:20.04 + - name: jammy + base_image: ubuntu:22.04 + - name: noble + base_image: ubuntu:24.04 + - name: bookworm + base_image: debian:12 + - name: bullseye + base_image: debian:11 + - name: buster + base_image: debian:10 + + arch: + - name: amd64 + platform: linux/amd64 + + - name: arm64 + platform: linux/arm64 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + path: ${{ env.SRC_DIR }} + + - name: Setup + run: | + sudo apt-get update + sudo apt-get install -y \ + apt-transport-https \ + software-properties-common \ + tar \ + gnupg \ + lsb-release \ + dpkg-sig + mkdir -p ${{ env.OUTPUT_DIR }} + mkdir -p ${{ env.PACKAGE_DIR }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: ${{ matrix.arch.platform }} + + - name: Build Docker image + run: | + docker buildx create --use + docker buildx build \ + --platform ${{ matrix.arch.platform }} \ + --build-arg VERSION=${{ env.APP_VERSION }} \ + --tag ${{ env.APP_NAME }}-${{ env.APP_VERSION }}-${{ matrix.distro.name }}-${{ matrix.arch.name }} \ + --load \ + --output type=docker,dest=${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-${{ env.APP_VERSION }}-${{ matrix.distro.name }}-${{ matrix.arch.name }}.tar \ + -f ${{ env.SRC_DIR }}/scripts/debian/Dockerfile.build ${{ env.SRC_DIR }} + + - name: Load Docker image + run: | + docker load -i ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-${{ env.APP_VERSION }}-${{ matrix.distro.name }}-${{ matrix.arch.name }}.tar + + - name: Extract binary from container + run: | + CONTAINER_ID=$(docker create ${{ env.APP_NAME }}-${{ env.APP_VERSION }}-${{ matrix.distro.name }}-${{ matrix.arch.name }}) + docker cp ${CONTAINER_ID}:/zbox ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}_${{ env.APP_VERSION }}~${{ matrix.distro.name }}_${{ matrix.arch.name }} + docker rm ${CONTAINER_ID} + + - name: Package binary + run: | + mkdir -p ${{ env.PACKAGE_DIR }}/DEBIAN + mkdir -p ${{ env.PACKAGE_DIR }}/usr/local/bin + + cp ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}_${{ env.APP_VERSION }}~${{ matrix.distro.name }}_${{ matrix.arch.name }} ${{ env.PACKAGE_DIR }}/usr/local/bin/${APP_NAME} + + cat < ${{ env.PACKAGE_DIR }}/DEBIAN/control + Package: ${{ env.APP_NAME }} + Version: ${{ env.APP_VERSION }} + Architecture: ${{ matrix.arch.name }} + Description: zbox is a command line interface (CLI) tool to understand the capabilities of Züs dStorage and prototype your app + EOT + + echo "Configuring GPG for batch mode and loopback pinentry..." + mkdir -p ~/.gnupg + echo "use-agent" >> ~/.gnupg/gpg.conf + echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf + echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf + gpg-connect-agent reloadagent /bye + + echo "Importing GPG private key..." + echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import + + echo "Trusting the GPG key..." + echo -e "5\ny\n" | gpg --command-fd 0 --batch --yes --pinentry-mode loopback --edit-key ${{ secrets.GPG_KEY_ID }} trust quit + + tar czf "${{ env.OUTPUT_DIR }}/data.tar.gz" -C "${{ env.PACKAGE_DIR }}" . + echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --batch --yes --passphrase-fd 0 --pinentry-mode loopback --detach-sign --armor -o "${{ env.PACKAGE_DIR }}/DEBIAN/signature.asc" "${{ env.OUTPUT_DIR }}/data.tar.gz" + dpkg-deb -Zgzip -b ${{ env.PACKAGE_DIR }} ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}_${{ env.APP_VERSION }}~${{ matrix.distro.name }}_${{ matrix.arch.name }}.deb + + - name: Upload .deb file + uses: actions/upload-artifact@v3 + with: + name: ${{ env.APP_NAME }}_${{ env.APP_VERSION }}~${{ matrix.distro.name }}_${{ matrix.arch.name }} + path: ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}_${{ env.APP_VERSION }}~${{ matrix.distro.name }}_${{ matrix.arch.name }}.deb + + distribute: + runs-on: [ubuntu-latest] + needs: build + env: + DISTRIBUTIONS: bionic focal jammy noble bookworm bullseye buster + ARCHITECTURES: amd64 arm64 + SRC_DIR: ${{ github.workspace }}/src + REPO_DIR: ${{ github.workspace }}/zbox + DEB_DIR: ${{ github.workspace }}/deb-files + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + path: ${{ env.SRC_DIR }} + + - name: Setup + run: | + sudo apt-get update + sudo apt-get install -y apt-utils dpkg-sig gnupg openssh-client + + mkdir -p ~/.ssh + echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + ssh-keyscan -H ${{ env.REMOTE_SERVER }} >> ~/.ssh/known_hosts + + mkdir -p ${{ env.REPO_DIR }} + mkdir -p ${{ env.DEB_DIR }} + + echo "Configuring GPG for batch mode and loopback pinentry..." + mkdir -p ~/.gnupg + echo "use-agent" >> ~/.gnupg/gpg.conf + echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf + echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf + gpg-connect-agent reloadagent /bye + + echo "Importing GPG private key..." + echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import + + echo "Trusting the GPG key..." + echo -e "5\ny\n" | gpg --command-fd 0 --batch --yes --pinentry-mode loopback --edit-key ${{ secrets.GPG_KEY_ID }} trust quit + + + - name: Download APT repo + run: | + scp -v -i ~/.ssh/id_rsa -r ${{ env.REMOTE_USER }}@${{ env.REMOTE_SERVER }}:/var/www/html/aptrepo/zbox/ ${{ github.workspace }} + + - name: Download all .deb files + uses: actions/download-artifact@v3 + with: + path: ${{ env.DEB_DIR }} + + - name: Copy debian packages + run : | + mkdir -p ${{ env.REPO_DIR }}/pool/main/z/${{ env.APP_NAME }}/ + find ${{ env.DEB_DIR }} -name "*.deb" + for deb in $(find ${{ env.DEB_DIR }} -name "*.deb"); do + cp -u $deb ${{ env.REPO_DIR }}/pool/main/z/${{ env.APP_NAME }}/ + done + + - name: Update APT repo + run: | + cd ${{ env.REPO_DIR }} + for dist in ${{ env.DISTRIBUTIONS }}; do + rm -rf dists/${dist} + mkdir -p dists/${dist} + for arch in ${{ env.ARCHITECTURES }}; do + mkdir -p dists/${dist}/main/binary-${arch} + find "pool/main/z/${{ env.APP_NAME }}" -type f -name "${{ env.APP_NAME }}_*~${dist}_${arch}.deb" | \ + xargs -I {} apt-ftparchive -o Tree::dists/${dist}::Sections="main" \ + -o Tree::dists/${dist}::Architectures="${arch}" \ + -o Dir::ArchiveDir="${{ env.REPO_DIR }}" \ + packages {} >> dists/${dist}/main/binary-${arch}/Packages + done + + apt-ftparchive -o APT::FTPArchive::Release::Origin="${{ env.APP_NAME }}" \ + -o APT::FTPArchive::Release::Label="${{ env.APP_NAME }}" \ + -o APT::FTPArchive::Release::Suite="${dist}" \ + -o APT::FTPArchive::Release::Codename="${dist}" \ + -o APT::FTPArchive::Release::Version="${{ env.APP_VERSION }}" \ + -o APT::FTPArchive::Release::Architectures="${{ env.ARCHITECTURES }}" \ + -o APT::FTPArchive::Release::Components="main" \ + -o Dir::ArchiveDir="${{ env.REPO_DIR }}" \ + release dists/${dist} > dists/${dist}/Release + + echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --default-key ${{ secrets.GPG_KEY_ID }} --batch --yes --passphrase-fd 0 -abs -o dists/${dist}/Release.gpg dists/${dist}/Release + echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --default-key ${{ secrets.GPG_KEY_ID }} --batch --yes --passphrase-fd 0 --clearsign -o dists/${dist}/InRelease dists/${dist}/Release + done + + - name: Upload APT repo to remote + run: | + scp -v -i ~/.ssh/id_rsa -r ${{ github.workspace }}/zbox/ ${{ env.REMOTE_USER }}@${{ env.REMOTE_SERVER }}:/var/www/html/aptrepo/ + + - name: Upload GPG public key to remote server + run: | + echo "${{ secrets.GPG_PUBLIC_KEY }}" > zus.asc + scp -v -i ~/.ssh/id_rsa zus.asc ${{ env.REMOTE_USER }}@${{ env.REMOTE_SERVER }}:/var/www/html/zus.asc + + - name: Upload install script to remote server + run: | + scp -v -i ~/.ssh/id_rsa ${{ env.SRC_DIR }}/scripts/debian/install.sh ${{ env.REMOTE_USER }}@${{ env.REMOTE_SERVER }}:/var/www/html/aptrepo/zbox_deb_install.sh + + + + test: + runs-on: [ubuntu-latest] + needs: distribute + env: + SRC_DIR: ${{ github.workspace }}/src + strategy: + matrix: + distro: + - name: bionic + base_image: ubuntu:18.04 + - name: focal + base_image: ubuntu:20.04 + - name: jammy + base_image: ubuntu:22.04 + - name: noble + base_image: ubuntu:24.04 + - name: bookworm + base_image: debian:12 + - name: bullseye + base_image: debian:11 + - name: buster + base_image: debian:10 + arch: + - name: amd64 + platform: linux/amd64 + + - name: arm64 + platform: linux/arm64 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + path: ${{ env.SRC_DIR }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: ${{ matrix.arch.platform }} + + - name: Build Docker image + run: | + docker buildx create --use + docker buildx build \ + --platform ${{ matrix.arch.platform }} \ + --build-arg BASE_IMAGE=${{ matrix.distro.base_image }} \ + --build-arg LOC="https://packages.zus.network/aptrepo/zbox_deb_install.sh" \ + --tag ${{ env.APP_NAME }}-${{ env.APP_VERSION }}-${{ matrix.distro.name }}-${{ matrix.arch.name }} \ + --load \ + --output type=docker,dest=${{ github.workspace }}/${{ env.APP_NAME }}-${{ env.APP_VERSION }}-${{ matrix.distro.name }}-${{ matrix.arch.name }}.tar \ + -f ${{ env.SRC_DIR }}/scripts/debian/Dockerfile.install_test . + + - name: Test zbox + run: | + docker load -i ${{ github.workspace }}/${{ env.APP_NAME }}-${{ env.APP_VERSION }}-${{ matrix.distro.name }}-${{ matrix.arch.name }}.tar + docker run --platform=${{ matrix.arch.platform }} --rm ${{ env.APP_NAME }}-${{ env.APP_VERSION }}-${{ matrix.distro.name }}-${{ matrix.arch.name }} || { echo "Test installation failed"; exit 1; } + diff --git a/.github/workflows/distribute-zboxcli-choco.yml b/.github/workflows/distribute-zboxcli-choco.yml new file mode 100644 index 00000000..a0adfeb7 --- /dev/null +++ b/.github/workflows/distribute-zboxcli-choco.yml @@ -0,0 +1,175 @@ +name: Distribute zbox using choco + +on: + workflow_dispatch: + inputs: + version: + description: 'Version of zbox to release' + required: true + default: '1.0.0' + +env: + APP_NAME: zbox + PACKAGE_ID: zbox + APP_VERSION: ${{ github.event.inputs.version }} + GO_VERSION: '1.22' + +jobs: + build: + runs-on: windows-latest + env: + SRC_DIR: ${{ github.workspace }}\src + OUTPUT_DIR: ${{ github.workspace }}\output + PACKAGE_DIR: ${{ github.workspace }}\package + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + path: ${{ env.SRC_DIR }} + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Install MinGW for CGo + run: | + choco install mingw + + - name: Setup + run : | + New-Item -ItemType Directory -Force -Path "${{ env.OUTPUT_DIR }}\amd64" + New-Item -ItemType Directory -Force -Path "${{ env.PACKAGE_DIR }}" + Copy-Item -Force -Path "${{ env.SRC_DIR }}\cmd\config.yaml" -Destination "${{ env.OUTPUT_DIR }}\amd64\" + + - name: Build ${{ env.APP_NAME }} for amd64 + run: | + Set-Location -Path "${{ env.SRC_DIR }}" + $env:CGO_ENABLED="1" + $env:CC="x86_64-w64-mingw32-gcc" + $env:CXX="x86_64-w64-mingw32-g++" + $env:GOOS="windows" + $env:GOARCH="amd64" + where x86_64-w64-mingw32-gcc + where x86_64-w64-mingw32-g++ + go build -x -v -tags bn256 -ldflags "-X main.VersionStr=v${{ env.APP_VERSION }}" -o ${{ env.OUTPUT_DIR }}\amd64\${{ env.APP_NAME }}.exe . + shell: pwsh + + - name: Generate SHA256 Checksum + id: checksum + shell: pwsh + run: | + $checksum = Get-FileHash "${{ env.OUTPUT_DIR }}\amd64\${{ env.APP_NAME }}.exe" -Algorithm SHA256 + Write-Output "::set-output name=checksum::$($checksum.Hash)" + + - name: Create VERIFICATION.txt + shell: pwsh + run: | + Set-Location -Path "${{ env.PACKAGE_DIR }}" + $location = Get-Location + Write-Host "Current Directory: $location" + $files = Get-ChildItem "${{ env.PACKAGE_DIR }}" + Write-Host "Files in Directory: $files" + + $verificationContent = @" + The binaries in this package were sourced from the official https://github.com/0chain/zboxcli repository. + + Verification Steps: + 1. The SHA256 checksum of the binary was calculated. + 2. Users can verify the binary themselves by running the following command: + `Get-FileHash -Algorithm SHA256 ${{ env.APP_NAME }}.exe` + + Expected checksum: + ${{ steps.checksum.outputs.checksum }} + "@ + + $verificationContent | Out-File -FilePath "VERIFICATION.txt" -Encoding utf8 + Write-Host "Created VERIFICATION.txt file" + Get-ChildItem "${{ env.PACKAGE_DIR }}" + + $fileContent = Get-Content -Path "VERIFICATION.txt" + Write-Host "File Content: $fileContent" + + - name: Create Chocolatey Install Script + run: | + Set-Location -Path "${{ env.PACKAGE_DIR }}" + $location = Get-Location + Write-Host "Current Directory: $location" + $files = Get-ChildItem "${{ env.PACKAGE_DIR }}" + Write-Host "Files in Directory: $files" + + $content = @' + $installDir = "$(Get-ToolsLocation)\zbox" + $envPath = [System.Environment]::GetEnvironmentVariable('Path', 'Machine') + + if ($envPath -notlike "*$installDir*") { + Write-Host "Adding $installDir to PATH" + [System.Environment]::SetEnvironmentVariable('Path', "$envPath;$installDir", 'Machine') + } + '@ + + $content | Out-File -FilePath "chocolateyInstall.ps1" -Encoding utf8 + Write-Host "Created chocolateyInstall.ps1 file" + Get-ChildItem "${{ env.PACKAGE_DIR }}" + + $fileContent = Get-Content -Path "chocolateyInstall.ps1" + Write-Host "File Content: $fileContent" + + - name: Create .nuspec file + run: | + Set-Location -Path "${{ env.PACKAGE_DIR }}" + $location = Get-Location + Write-Host "Current Directory: $location" + $files = Get-ChildItem "${{ env.PACKAGE_DIR }}" + Write-Host "Files in Directory: $files" + $content = @" + + + + ${{ env.PACKAGE_ID }} + ${{ env.APP_VERSION }} + Saswata Basu + Saswata Basu + zbox cloud storage cli windows golang + https://github.com/0chain/zboxcli/blob/staging/LICENSE + https://github.com/0chain/zboxcli + https://github.com/0chain/zboxcli + https://github.com/0chain/zboxcli/releases/latest + zbox is a command line interface (CLI) tool to understand the capabilities of Züs dStorage and prototype your app. + zbox is a command line interface (CLI) tool to understand the capabilities of Züs dStorage and prototype your app. + zbox CLI + + + + + + + + + "@ + + $content | Out-File -FilePath "zbox.nuspec" -Encoding utf8 + Write-Host "Created .nuspec file:" + Get-ChildItem "${{ env.PACKAGE_DIR }}" + + $fileContent = Get-Content -Path "zbox.nuspec" + Write-Host "File Content: $fileContent" + + - name: Pack Chocolatey Package + run: | + Set-Location -Path "${{ env.PACKAGE_DIR }}" + $location = Get-Location + Write-Host "Current Directory: $location" + $files = Get-ChildItem "${{ env.PACKAGE_DIR }}" + Write-Host "Files in Directory: $files" + choco pack ${{ env.PACKAGE_ID }}.nuspec + + - name: Push Chocolatey Package + run: | + Set-Location -Path "${{ env.PACKAGE_DIR }}" + $location = Get-Location + Write-Host "Current Directory: $location" + $files = Get-ChildItem "${{ env.PACKAGE_DIR }}" + Write-Host "Files in Directory: $files" + choco push ${{ env.PACKAGE_ID }}.${{ env.APP_VERSION }}.nupkg --source https://push.chocolatey.org/ -k ${{ secrets.CHOCOLATEY_API_KEY }} diff --git a/.github/workflows/gosdk.yml b/.github/workflows/gosdk.yml index f6d34867..d576178b 100644 --- a/.github/workflows/gosdk.yml +++ b/.github/workflows/gosdk.yml @@ -15,10 +15,10 @@ jobs: create-pr: runs-on: [self-hosted, build] steps: - - name: Setup go 1.20 - uses: actions/setup-go@v2 + - name: Setup go 1.21 + uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.21' - name: Checkout uses: actions/checkout@v1 @@ -43,5 +43,5 @@ jobs: 0Chain GoSDK `${{ github.event.inputs.gosdk }}` is released. see full changelog on https://github.com/0chain/gosdk/releases/tag/${{ github.event.inputs.gosdk }} draft: false - reviewers: cnlangzi + reviewers: guruhubb labels: GoSDK diff --git a/.github/workflows/release-zboxcli.yml b/.github/workflows/release-zboxcli.yml index 4f206580..e5badc50 100644 --- a/.github/workflows/release-zboxcli.yml +++ b/.github/workflows/release-zboxcli.yml @@ -22,7 +22,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install deps run: | @@ -87,7 +87,7 @@ jobs: tag_schema: semantic - name: 'Upload Artifact' - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: zbox-linux path: zbox @@ -126,7 +126,7 @@ jobs: go env -w "CC=/mingw64/bin/clang.exe" - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install run: make install @@ -140,7 +140,7 @@ jobs: zip zbox-windows.zip zbox.exe libgcc_s_seh-1.dll libstdc++-6.dll libwinpthread-1.dll - name: 'Upload Artifact' - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: zbox-windows.zip path: zbox-windows.zip @@ -162,7 +162,7 @@ jobs: go-version: '1.20' # The Go version to download (if necessary) and use. - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install run: make install @@ -171,7 +171,7 @@ jobs: run: tar -czvf zbox-macos.tar.gz ./zbox - name: 'Upload Artifact' - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: zbox-macos path: zbox diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..de45c3bc --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,285 @@ +name: Release +on: + workflow_dispatch: + inputs: + version: + description: 'Version of zbox to release' + required: true + default: '1.0.0' + tag: + description: 'Tag of zbox to release' + required: true + default: 'v1.0.0' + draft: + description: 'Create release as draft' + required: false + default: 'true' + prerelease: + description: 'Create release as prerelease' + required: false + default: 'false' + +env: + GITHUB_TOKEN: ${{ secrets.GOSDK }} + VERSION: ${{ github.event.inputs.version }} + APP_NAME: zbox + GO_VERSION: 1.22 + +jobs: + create_release: + runs-on: ubuntu-latest + outputs: + release_id: ${{ steps.create_release.outputs.id }} + upload_url: ${{ steps.create_release.outputs.upload_url }} + steps: + - name: Create GitHub Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.event.inputs.tag }} + release_name: ${{ github.event.inputs.tag }} + draft: ${{ github.event.inputs.draft }} + prerelease: ${{ github.event.inputs.prerelease }} + + linux: + runs-on: ubuntu-latest + needs: create_release + env: + SRC_DIR: ${{ github.workspace }}/src + OUTPUT_DIR: ${{ github.workspace }}/output + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + path: ${{ env.SRC_DIR }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: linux/amd64,linux/arm64 + + - name: Install zip + uses: montudor/action-zip@v1 + + - name: Setup + run : | + mkdir -p ${{ env.OUTPUT_DIR }} + cp ${{ env.SRC_DIR }}/cmd/config.yaml ${{ env.OUTPUT_DIR }} + + - name: Build Docker image for linux/amd64 + run: | + docker buildx create --use + docker buildx build \ + --platform linux/amd64 \ + --build-arg VERSION=${{ env.VERSION }} \ + --tag ${{ env.APP_NAME }}-amd64 \ + --load \ + --output type=docker,dest=${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-amd64.tar \ + -f ${{ env.SRC_DIR }}/scripts/debian/Dockerfile.build ${{ env.SRC_DIR }} + + - name: Load image ${{ env.APP_NAME }}-amd64 & Extract binary ${{ env.APP_NAME }} from container + run: | + docker load -i ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-amd64.tar + CONTAINER_ID=$(docker create ${{ env.APP_NAME }}-amd64) + docker cp ${CONTAINER_ID}:/zbox ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }} + docker rm ${CONTAINER_ID} + + - name: Create Zip File for linux/amd64 + run: | + cd ${{ env.OUTPUT_DIR }} + zip -qq -r ${{ env.APP_NAME }}-linux-amd64.zip ${{ env.APP_NAME }} config.yaml + + - name: Upload Zip for linux/amd64 + uses: actions/upload-artifact@v3 + with: + name: ${{ env.APP_NAME }}-linux-amd64 + path: ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-linux-amd64.zip + + - name: Build Docker image for linux/arm64 + run: | + docker buildx create --use + docker buildx build \ + --platform linux/arm64 \ + --build-arg VERSION=${{ env.VERSION }} \ + --tag ${{ env.APP_NAME }}-arm64 \ + --load \ + --output type=docker,dest=${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-arm64.tar \ + -f ${{ env.SRC_DIR }}/scripts/debian/Dockerfile.build ${{ env.SRC_DIR }} + + - name: Load image ${{ env.APP_NAME }}-arm64 & Extract binary from container + run: | + docker load -i ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-arm64.tar + CONTAINER_ID=$(docker create ${{ env.APP_NAME }}-arm64) + docker cp ${CONTAINER_ID}:/zbox ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }} + docker rm ${CONTAINER_ID} + + - name: Create Zip File for linux/arm64 + run: | + cd ${{ env.OUTPUT_DIR }} + zip -qq -r ${{ env.APP_NAME }}-linux-arm64.zip ${{ env.APP_NAME }} config.yaml + + - name: Upload Zip for linux/arm64 + uses: actions/upload-artifact@v3 + with: + name: ${{ env.APP_NAME }}-linux-arm64 + path: ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-linux-arm64.zip + + - name: Upload Release Asset for Linux/amd64 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create_release.outputs.upload_url }} + asset_path: ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-linux-amd64.zip + asset_name: ${{ env.APP_NAME }}-linux-amd64.zip + asset_content_type: application/zip + + - name: Upload Release Asset for Linux/arm64 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create_release.outputs.upload_url }} + asset_path: ${{ env.OUTPUT_DIR }}/${{ env.APP_NAME }}-linux-arm64.zip + asset_name: ${{ env.APP_NAME }}-linux-arm64.zip + asset_content_type: application/zip + + darwin: + runs-on: macos-latest + needs: create_release + env: + SRC_DIR: ${{ github.workspace }}/src + OUTPUT_DIR: ${{ github.workspace }}/output + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + path: ${{ env.SRC_DIR }} + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Setup + run : | + mkdir -p ${{ env.OUTPUT_DIR }}/amd64 + mkdir -p ${{ env.OUTPUT_DIR }}/arm64 + cp ${{ env.SRC_DIR }}/cmd/config.yaml ${{ env.OUTPUT_DIR }}/amd64/ + cp ${{ env.SRC_DIR }}/cmd/config.yaml ${{ env.OUTPUT_DIR }}/arm64/ + + - name: Build ${{ env.APP_NAME }} for arm64 + run: | + cd ${{ env.SRC_DIR }} + CGO_ENABLED=1 CGO_CFLAGS="-mmacosx-version-min=12.0" CGO_LDFLAGS="-mmacosx-version-min=12.0" GOOS=darwin GOARCH=arm64 SDKROOT=$(xcrun --sdk macosx --show-sdk-path) go build -x -v -tags bn256 -ldflags "-X main.VersionStr=v${{ env.VERSION }}" -o ${{ env.OUTPUT_DIR }}/arm64/${{ env.APP_NAME }} . + + - name: Build ${{ env.APP_NAME }} for amd64 + run: | + cd ${{ env.SRC_DIR }} + CGO_ENABLED=1 CGO_CFLAGS="-mmacosx-version-min=12.0" CGO_LDFLAGS="-mmacosx-version-min=12.0" GOOS=darwin GOARCH=amd64 SDKROOT=$(xcrun --sdk macosx --show-sdk-path) go build -x -v -tags bn256 -ldflags "-X main.VersionStr=v${{ env.VERSION }}" -o ${{ env.OUTPUT_DIR }}/amd64/${{ env.APP_NAME }} . + + - name: Create Zip File for darwin/amd64 + run: | + cd ${{ env.OUTPUT_DIR }}/amd64 + zip -qq -r ${{ env.APP_NAME }}-darwin-amd64.zip ${{ env.APP_NAME }} config.yaml + + - name: Upload Zip for Darwin/amd64 + uses: actions/upload-artifact@v3 + with: + name: ${{ env.APP_NAME }}-darwin-amd64 + path: ${{ env.OUTPUT_DIR }}/amd64/${{ env.APP_NAME }}-darwin-amd64.zip + + - name: Create Zip File for darwin/arm64 + run: | + cd ${{ env.OUTPUT_DIR }}/arm64 + zip -qq -r ${{ env.APP_NAME }}-darwin-arm64.zip ${{ env.APP_NAME }} config.yaml + + - name: Upload Zip for Darwin/arm64 + uses: actions/upload-artifact@v3 + with: + name: ${{ env.APP_NAME }}-darwin-arm64 + path: ${{ env.OUTPUT_DIR }}/arm64/${{ env.APP_NAME }}-darwin-arm64.zip + + - name: Upload Release Asset for Darwin/amd64 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create_release.outputs.upload_url }} + asset_path: ${{ env.OUTPUT_DIR }}/amd64/${{ env.APP_NAME }}-darwin-amd64.zip + asset_name: ${{ env.APP_NAME }}-darwin-amd64.zip + asset_content_type: application/zip + + - name: Upload Release Asset for Darwin/arm64 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create_release.outputs.upload_url }} + asset_path: ${{ env.OUTPUT_DIR }}/arm64/${{ env.APP_NAME }}-darwin-arm64.zip + asset_name: ${{ env.APP_NAME }}-darwin-arm64.zip + asset_content_type: application/zip + + windows: + runs-on: windows-latest + needs: create_release + env: + SRC_DIR: ${{ github.workspace }}\src + OUTPUT_DIR: ${{ github.workspace }}\output + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + path: ${{ env.SRC_DIR }} + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Install MinGW for CGo + run: | + choco install mingw + + - name: Setup + run : | + New-Item -ItemType Directory -Force -Path "${{ env.OUTPUT_DIR }}\amd64" + Copy-Item -Force -Path "${{ env.SRC_DIR }}\cmd\config.yaml" -Destination "${{ env.OUTPUT_DIR }}\amd64\" + + - name: Build ${{ env.APP_NAME }} for amd64 + run: | + Set-Location -Path "${{ env.SRC_DIR }}" + $env:CGO_ENABLED="1" + $env:CC="x86_64-w64-mingw32-gcc" + $env:CXX="x86_64-w64-mingw32-g++" + $env:GOOS="windows" + $env:GOARCH="amd64" + where x86_64-w64-mingw32-gcc + where x86_64-w64-mingw32-g++ + go build -x -v -tags bn256 -ldflags "-X main.VersionStr=v${{ env.VERSION }}" -o ${{ env.OUTPUT_DIR }}\amd64\${{ env.APP_NAME }}.exe . + shell: pwsh + + - name: Create Zip File for windows/amd64 + run: | + Set-Location -Path "${{ env.OUTPUT_DIR }}\amd64" + Compress-Archive -Path @("${{ env.APP_NAME }}.exe", "config.yaml") -DestinationPath ${{ env.APP_NAME }}-windows-amd64.zip + + - name: Upload Zip for windows/amd64 + uses: actions/upload-artifact@v3 + with: + name: ${{ env.APP_NAME }}-windows-amd64 + path: ${{ env.OUTPUT_DIR }}\amd64\${{ env.APP_NAME }}-windows-amd64.zip + + - name: Upload Release Asset for windows/amd64 + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create_release.outputs.upload_url }} + asset_path: ${{ env.OUTPUT_DIR }}\amd64\${{ env.APP_NAME }}-windows-amd64.zip + asset_name: ${{ env.APP_NAME }}-windows-amd64.zip + asset_content_type: application/zip + + \ No newline at end of file diff --git a/.github/workflows/system_tests.yml b/.github/workflows/system_tests.yml index da5f2094..232a38c3 100644 --- a/.github/workflows/system_tests.yml +++ b/.github/workflows/system_tests.yml @@ -28,7 +28,7 @@ jobs: uses: 0chain/actions/.github/workflows/manual_system_tests.yml@master with: zbox_cli_branch: ${{ github.ref_name }} - repo_snapshots_branch: ${{ github.event.inputs.repo_snapshots_branch }} + repo_snapshots_branch: fix/refactor-zboxcore test_file_filter: ${{ github.event.inputs.test_file_filter }} skip_tests: ${{ github.event.inputs.skip_tests }} run_smoke_tests: ${{ github.event.inputs.run_smoke_tests }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 08c7b899..71e06f68 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,13 +13,13 @@ jobs: unit-test: runs-on: [self-hosted, build] steps: - - name: Setup go 1.20 - uses: actions/setup-go@v2 + - name: Setup go 1.21 + uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.21' - name: Clone Zbox - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install Packages run: | @@ -34,13 +34,13 @@ jobs: runs-on: [self-hosted, build] needs: unit-test steps: - - name: Setup go 1.20 - uses: actions/setup-go@v2 + - name: Setup go 1.21 + uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version: '1.21' - name: Clone 0Box - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: check software run: | @@ -52,7 +52,7 @@ jobs: run: make install - name: 'Upload Artifact' - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: zbox-linux path: zbox @@ -95,83 +95,18 @@ jobs: version: '1.7' force: 'false' - - name: "Create Tenderly fork" + - name: "Create Tenderly virtual testnet" run: | echo "TENDERLY_CREATION_INFO=$(curl -X POST \ - -H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \ - -H "Content-Type: application/json" \ - -d '{"alias":"mainnet-dev-${{ env.RUNNER_NUMBER }}-${{ github.run_id }}${{ github.run_attempt }}", "description":"", "block_number": 18539779, "network_id":"1"}' \ - https://api.tenderly.co/api/v1/account/zus_network/project/project/fork)" >> $GITHUB_ENV + -H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \ + -H "Content-Type: application/json" \ + -d '{"slug":"mainnet-dev-${{ env.RUNNER_NUMBER }}-${{ github.run_id }}","displayName":"mainnet-dev-${{ env.RUNNER_NUMBER }}-${{ github.run_id }}","description":"","visibility":"TEAM","tags":{"purpose":"development"},"networkConfig":{"networkId":"1","blockNumber":"18512782","chainConfig":{"chainId":"1"},"baseFeePerGas":"1"},"explorerConfig":{"enabled":false,"verificationVisibility":"bytecode"},"syncState":false}' \ + https://api.tenderly.co/api/v1/account/zus_network/project/project/testnet/container)" >> $GITHUB_ENV - - name: "Parse Tenderly fork creation transaction result" + - name: "Parse Tenderly virtual testnet creation transaction result" run: | - echo "TENDERLY_FORK_ID=$(echo '${{ env.TENDERLY_CREATION_INFO }}' | jq -r '.simulation_fork.id')" >> $GITHUB_ENV - echo "TENDERLY_ROOT_TRANSACTION_ID=$(echo '${{ env.TENDERLY_CREATION_INFO }}' | jq -r '.root_transaction.id')" >> $GITHUB_ENV - - - name: "Retrieve Tenderly fork block number" - run: | - echo "TENDERLY_FORK_BLOCK_NUMBER=$(curl -X GET \ - -H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \ - -H "Content-Type: application/json" \ - https://api.tenderly.co/api/v1/network/1/block-number | jq -r '.block_number')" >> $GITHUB_ENV - - echo "TENDERLY_FORK_BLOCK_NUMBER=$((${{ env.TENDERLY_FORK_BLOCK_NUMBER }} + 1))" >> GITHUB_ENV - - - name: "Transfer Bridge ownership in Tenderly fork" - run: | - echo "TENDERLY_ROOT_TRANSACTION_ID=$(curl -X POST \ - -H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \ - -H "Content-Type: application/json" \ - -d '{ - "network_id": "1", - "block_number": ${{ env.TENDERLY_FORK_BLOCK_NUMBER }}, - "transaction_index": null, - "from": "0xed8f3170db6d1a71c8fa6d8d73cc2c51db95d5a4", - "input": "0xf2fde38b0000000000000000000000008e25cfd9bd6c0ca67a5522cd920b3c66d39d6e97", - "to": "0x7700d773022b19622095118fadf46f7b9448be9b", - "gas": 8000000, - "gas_price": "0", - "value": "0", - "access_list": [], - "generate_access_list": true, - "save": true, - "source": "dashboard", - "block_header": null, - "root": "${{ env.TENDERLY_ROOT_TRANSACTION_ID }}", - "skip_fork_head_update": false, - "alias": "", - "description": "Transfer ownership to 0x8E25cfd9bd6c0ca67a5522cd920b3c66D39d6E97" - }' \ - https://api.tenderly.co/api/v1/account/zus_network/project/project/fork/${{ env.TENDERLY_FORK_ID }}/simulate | jq -r '.simulation.id')" >> $GITHUB_ENV - - echo "TENDERLY_FORK_BLOCK_NUMBER=$((${{ env.TENDERLY_FORK_BLOCK_NUMBER }} + 1))" >> GITHUB_ENV - - - name: "Transfer Authorizers ownership in Tenderly fork" - run: | - curl -X POST \ - -H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \ - -H "Content-Type: application/json" \ - -d '{ - "network_id": "1", - "block_number": ${{ env.TENDERLY_FORK_BLOCK_NUMBER }}, - "transaction_index": null, - "from": "0xed8f3170db6d1a71c8fa6d8d73cc2c51db95d5a4", - "input": "0xf2fde38b0000000000000000000000008e25cfd9bd6c0ca67a5522cd920b3c66d39d6e97", - "to": "0x481dab4407b9880de0a68dc62e6af611c4949e42", - "gas": 8000000, - "gas_price": "0", - "value": "0", - "access_list": [], - "generate_access_list": true, - "save": true, - "source": "dashboard", - "block_header": null, - "root": "${{ env.TENDERLY_ROOT_TRANSACTION_ID }}", - "skip_fork_head_update": false, - "alias": "", - "description": "Transfer ownership to 0x8E25cfd9bd6c0ca67a5522cd920b3c66D39d6E97" - }' \ - https://api.tenderly.co/api/v1/account/zus_network/project/project/fork/${{ env.TENDERLY_FORK_ID }}/simulate + echo "TENDERLY_VIRTUAL_TESTNET_ID=$(echo '${{ env.TENDERLY_CREATION_INFO }}' | jq -r '.container.id')" >> $GITHUB_ENV + echo "TENDERLY_VIRTUAL_TESTNET_RPC_ID=$(echo '${{ env.TENDERLY_CREATION_INFO }}' | jq -r '.container.connectivityConfig.endpoints[0].id')" >> $GITHUB_ENV - name: "Deploy 0Chain" uses: 0chain/actions/deploy-0chain@master @@ -181,10 +116,10 @@ jobs: teardown_condition: "TESTS_PASSED" zbox_cli_branch: ${{ env.CURRENT_BRANCH }} SUBGRAPH_API_URL: ${{ secrets.SUBGRAPH_API_URL }} - TENDERLY_FORK_ID: ${{ env.TENDERLY_FORK_ID }} + TENDERLY_VIRTUAL_TESTNET_RPC_ID: ${{ env.TENDERLY_VIRTUAL_TESTNET_RPC_ID }} graphnode_sc: ${{ secrets.GRAPHNODE_SC }} graphnode_network: ${{ secrets.GRAPHNODE_NETWORK }} - graphnode_ethereum_node_url: https://rpc.tenderly.co/fork/${{ env.TENDERLY_FORK_ID }} + graphnode_ethereum_node_url: https://virtual.mainnet.rpc.tenderly.co/${{ env.TENDERLY_VIRTUAL_TESTNET_RPC_ID }} svc_account_secret: ${{ secrets.SVC_ACCOUNT_SECRET }} - name: "Run System tests" @@ -198,19 +133,19 @@ jobs: archive_results: true run_flaky_tests: false retry_failures: true - TENDERLY_FORK_ID: ${{ env.TENDERLY_FORK_ID }} + TENDERLY_VIRTUAL_TESTNET_RPC_ID: ${{ env.TENDERLY_VIRTUAL_TESTNET_RPC_ID }} DEVOPS_CHANNEL_WEBHOOK_URL: ${{ secrets.DEVOPS_CHANNEL_WEBHOOK_URL }} S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }} run_smoke_tests: ${{ github.ref != 'refs/heads/staging' && github.base_ref != 'staging' && github.ref != 'refs/heads/master' && github.base_ref != 'master' }} - - name: "Remove Tenderly fork" + - name: "Remove Tenderly virtual testnet" if: always() run: | curl -X DELETE \ -H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \ -H "Content-Type: application/json" \ - https://api.tenderly.co/api/v1/account/zus_network/project/project/fork/${{ env.TENDERLY_FORK_ID }} + https://api.tenderly.co/api/v1/account/zus_network/project/project/testnet/container/${{ env.TENDERLY_VIRTUAL_TESTNET_ID }} - name: "Set PR status as ${{ job.status }}" if: ${{ (success() || failure()) && steps.findPr.outputs.number }} diff --git a/LICENSE b/LICENSE index 5aa4265b..466ba208 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,28 @@ -MIT License +Non-compete BSD-3-Clause -Copyright (c) 2019 0Chain +Copyright © 2019 0Chain,LLC. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Redistribution and use in source and binary forms, with or without modification, are permitted provided +that the following conditions are met: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +1. Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors +may be used to endorse or promote products derived from this software +without specific prior written permission. + +4. It is not permitted to provide any offering that competes with the source code and binary form +or any other offering the licensor provides using the source code and binary form. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR +TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/Makefile b/Makefile index 0f137aa5..d483d5d6 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,8 @@ default: help #GO BUILD SDK gomod-download: + go env + cat go.mod go mod download go mod tidy diff --git a/README.md b/README.md index eeb15f13..9164dd23 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,13 @@ # zbox - a CLI for Züs dStorage -zbox is a command line interface (CLI) tool to understand the capabilities of Züs dStorage and prototype your app. The utility is built using Züs [GoSDK](https://github.com/0chain/gosdk) . +zbox is a command line interface (CLI) tool to understand the capabilities of Züs dStorage and prototype your app. The utility is built using Züs [GoSDK](https://github.com/0chain/gosdk). For more information on Züs Network and the system overview, refer to [docs.zus.network](https://docs.zus.network). ![Storage](https://user-images.githubusercontent.com/65766301/120052450-0ab66700-c043-11eb-91ab-1f7aa69e133a.png) - [zbox - a CLI for Züs dStorage](#zbox---a-cli-for-züs-dstorage) - - [Züs Overview](#züs-overview) - - [Installation Instructions](#installation-instructions) - - [Build Instructions for Linux Windows Mac](#build-instructions-for-linux-windows-mac) - - [Other Platform Builds](#other-platform-builds) - - [Use custom miner/sharder](#use-custom-minersharder) + - [Getting Started](#getting-started) + - [1. Installation](#1-installation) + - [2. Run `zbox` commands](#2-run-zbox-commands) - [Running zbox](#running-zbox) - [Global Flags](#global-flags) - [Commands](#commands) @@ -17,6 +15,7 @@ zbox is a command line interface (CLI) tool to understand the capabilities of Z - [Create new allocation](#create-new-allocation) - [Free storage allocation](#free-storage-allocation) - [Update allocation](#update-allocation) + - [Transfer allocation ownership](#transfer-allocation-ownership) - [Forbid Allocation](#forbid-allocation) - [Cancel allocation](#cancel-allocation) - [Finalise allocation](#finalise-allocation) @@ -25,14 +24,16 @@ zbox is a command line interface (CLI) tool to understand the capabilities of Z - [List all files](#list-all-files) - [List owner's allocations](#list-owners-allocations) - [Update blobber settings](#update-blobber-settings) - - [Update Validator Settings](#update-validator-settings) + - [Update Validator Settings](#update-validator-settings) - [List All Validators](#list-all-validators) - [Get Validator Configuration](#get-validator-configuration) + - [Shutdown Blobber](#shutdown-blobber) + - [Shutdown Validator](#shutdown-validator) - [Kill Blobber](#kill-blobber) - [Kill Validator](#kill-validator) - [Uploading and Managing files](#uploading-and-managing-files) + - [Create Directory](#create-directory) - [Upload](#upload) - - [Stream](#stream) - [Feed](#feed) - [Download](#download) - [Update](#update) @@ -42,18 +43,15 @@ zbox is a command line interface (CLI) tool to understand the capabilities of Z - [List](#list) - [Copy](#copy) - [Move](#move) - - [Sync](#sync) - - [Get differences](#get-differences) - [Get wallet](#get-wallet) - [Get](#get) - [Get metadata](#get-metadata) - [Rename](#rename) - [Stats](#stats) - [Repair](#repair) + - [Decrypt](#decrypt) - [Sign data](#sign-data) - - [Streaming](#streaming) - - [How it works:](#how-it-works) - - [Usage](#usage) + - [Lock and Unlock Tokens](#lock-and-unlock-tokens) - [Challenge pool information](#challenge-pool-information) - [Create read pool](#create-read-pool) @@ -71,123 +69,120 @@ zbox is a command line interface (CLI) tool to understand the capabilities of Z - [Unlock tokens from write pool](#unlock-tokens-from-write-pool) - [Download cost](#download-cost) - [Upload cost](#upload-cost) + - [Config](#config) + - [~/.zcn/config.yaml](#zcnconfigyaml) + - [Override Network](#override-network) - [Troubleshooting](#troubleshooting) -## Züs Overview -[Züs](https://zus.network/) is a high-performance cloud on a fast blockchain offering privacy and configurable uptime. It is an alternative to traditional cloud S3 and has shown better performance on a test network due to its parallel data architecture. The technology uses erasure code to distribute the data between data and parity servers. Züs storage is configurable to provide flexibility for IT managers to design for desired security and uptime, and can design a hybrid or a multi-cloud architecture with a few clicks using [Blimp's](https://blimp.software/) workflow, and can change redundancy and providers on the fly. +## Getting started -For instance, the user can start with 10 data and 5 parity providers and select where they are located globally, and later decide to add a provider on-the-fly to increase resilience, performance, or switch to a lower cost provider. +### 1. Installation -Users can also add their own servers to the network to operate in a hybrid cloud architecture. Such flexibility allows the user to improve their regulatory, content distribution, and security requirements with a true multi-cloud architecture. Users can also construct a private cloud with all of their own servers rented across the globe to have a better content distribution, highly available network, higher performance, and lower cost. +**Prerequisites** -[The QoS protocol](https://medium.com/0chain/qos-protocol-weekly-debrief-april-12-2023-44524924381f) is time-based where the blockchain challenges a provider on a file that the provider must respond within a certain time based on its size to pass. This forces the provider to have a good server and data center performance to earn rewards and income. +- Go: Installation instructions for Mac, Linux and Windows can be found [here](https://go.dev/doc/install). -The [privacy protocol](https://zus.network/build) from Züs is unique where a user can easily share their encrypted data with their business partners, friends, and family through a proxy key sharing protocol, where the key is given to the providers, and they re-encrypt the data using the proxy key so that only the recipient can decrypt it with their private key. +**Procedures** -Züs has ecosystem apps to encourage traditional storage consumption such as [Blimp](https://blimp.software/), a S3 server and cloud migration platform, and [Vult](https://vult.network/), a personal cloud app to store encrypted data and share privately with friends and family, and [Chalk](https://chalk.software/), a high-performance story-telling storage solution for NFT artists. +1. Clone the `zboxcli` repo and install -Other apps are [Bolt](https://bolt.holdings/), a wallet that is very secure with air-gapped 2FA split-key protocol to prevent hacks from compromising your digital assets, and it enables you to stake and earn from the storage providers; [Atlus](https://atlus.cloud/), a blockchain explorer and [Chimney](https://demo.chimney.software/), which allows anyone to join the network and earn using their server or by just renting one, with no prior knowledge required. - -## Installation Instructions - -### [Build Instructions for Linux Windows Mac](https://github.com/0chain/zboxcli/wiki/Build-Instructions) - -### [Other Platform Builds](https://github.com/0chain/zboxcli/wiki/Alternative-Platform-Builds) +```sh +git clone https://github.com/0chain/zboxcli.git +cd zboxcli +make install +``` -### Use custom miner/sharder +2. Add config yaml at `~/.zcn/config.yaml` -As mentioned in build guides, a ./zcn folder is created to store configuration files for zboxcli. Here is a sample network config file +The following script sets `https://demo.zus.network` as your network. +```sh +cat > ~/.zcn/config.yaml << EOF +block_worker: https://mainnet.zus.network/dns +signature_scheme: bls0chain +min_submit: 50 # in percentage +min_confirmation: 50 # in percentage +confirmation_chain_length: 3 +EOF ``` - --- - block_worker: https://demo.zus.network/dns - signature_scheme: bls0chain - min_submit: 50 # in percentage - min_confirmation: 50 # in percentage - confirmation_chain_length: 3 +3. Run `zboxcli` to display the list of supported commands. + +```sh +./zbox ``` +---- +For machine requirements and pre-requisites, follow the guides below: -A blockWorker is used to connect to the network instead of giving network details directly, It will fetch the network details automatically from the blockWorker's network API. By default it will use the miner/sharder values which it will get using the `block_worker_url/network`. In case you want to override those values and give custom miner/sharder to use, You have to create a `network.yaml` in your ~/.zcn (config) folder and paste the miner/sharder values in below format. +- [How to build on Linux/Mac](https://github.com/0chain/zboxcli/wiki/Build-Instructions) +- [How to build on other platforms](https://github.com/0chain/zboxcli/wiki/Alternative-Platform-Builds) -``` -miners: - - http://localhost:7071 - - http://localhost:7072 - - http://localhost:7073 -sharders: - - http://localhost:7171 -``` +### 2. Run `zbox` commands -Note: This is helpful for the Mac OS users running local cluster and having trouble with docker internal IPs (block_worker return docker IPs in local) +The following steps assume that your terminal's working directory is inside the `zboxcli` repo. ## Running zbox -When you run the `./zbox` command in terminal with no arguments, it will list all the available commands and the global flags.For working of specific command check [commands](#commands) section. +When you run the `./zbox` command in terminal with no arguments, it will list all the available commands and the global flags. For working of specific command check [commands](#commands) section. ``` Usage: zbox [command] Available Commands: - add Adds free storage assigner - alloc-cancel Cancel an allocation - alloc-fini Finalize an expired allocation - bl-info Get blobber info - bl-update Update blobber settings by its delegate_wallet owner - collect-reward Collect accrued rewards for a stake pool. - completion Generate the autocompletion script for the specified shell - copy copy an object(file/folder) to another folder on blobbers - cp-info Challenge pool information. - createdir Create directory - decrypt Decrypt text with passphrase - delete delete file from blobbers - download download file from blobbers - feed download segment files from remote live feed, and upload - get-diff Get difference of local and allocation root - get-download-cost Get downloading cost - get-mpt Directly view blockchain data - get-upload-cost Get uploading cost - getallocation Gets the allocation info - getwallet Get wallet information - help Help about any command - kill-blobber punitively deactivate a blobber - kill-validator punitively deactivate a validator - list list files from blobbers - list-all list all files from blobbers - listallocations List allocations for the client - ls-blobbers Show active blobbers in storage SC. - ls-validators Show active Validators. - meta get meta data of files from blobbers - move move an object(file/folder) to another folder on blobbers - newallocation Creates a new allocation - recent-refs get list of recently added refs - rename rename an object(file/folder) on blobbers - rp-create Create read pool if missing - rp-info Read pool information. - rp-lock Lock some tokens in read pool. - rp-unlock Unlock some expired tokens in a read pool. - sc-config Show storage SC configuration. - share share files from blobbers - shutdown-blobber deactivate a blobber - shutdown-validator deactivate a validator - sign-data Sign given data - sp-info Stake pool information. - sp-lock Lock tokens lacking in stake pool. - sp-unlock Unlock tokens in stake pool. - sp-user-info Stake pool information for a user. - start-repair start repair file to blobbers - stats stats for file from blobbers - stream capture video and audio streaming form local devices, and upload - sync Sync files to/from blobbers - transferallocation Transfer an allocation from one account to another - update update file to blobbers - updateallocation Updates allocation's expiry and size - upload upload file to blobbers - validator-info Get validator info - validator-update Update validator settings by its delegate_wallet owner - version Prints version information - wp-lock Lock some tokens in write pool. - wp-unlock Unlock some expired tokens in a write pool. + alloc-cancel Cancel an allocation + alloc-fini Finalize an expired allocation + bl-info Get blobber info + bl-update Update blobber settings by its delegate_wallet owner + collect-reward Collect accrued rewards for a stake pool. + completion Generate the autocompletion script for the specified shell + copy copy an object(file/folder) to another folder on blobbers + cp-info Challenge pool information. + createdir Create directory + decrypt Decrypt text with passphrase + delete delete file from blobbers + download download file from blobbers + feed download segment files from remote live feed, and upload + get-download-cost Get downloading cost + get-upload-cost Get uploading cost + getallocation Gets the allocation info + getwallet Get wallet information + help Help about any command + kill-blobber punitively deactivate a blobber + kill-validator punitively deactivate a validator + list list files from blobbers + list-all list all files from blobbers + listallocations List allocations for the client + ls-blobbers Show active blobbers in storage SC. + ls-validators Show active Validators. + meta get meta data of files from blobbers + move move an object(file/folder) to another folder on blobbers + newallocation Creates a new allocation + rename rename an object(file/folder) on blobbers + rp-create Create read pool if missing + rp-info Read pool information. + rp-lock Lock some tokens in read pool. + rp-unlock Unlock some expired tokens in a read pool. + sc-config Show storage SC configuration. + share share files from blobbers + shutdown-blobber deactivate a blobber + shutdown-validator deactivate a validator + sign-data Sign given data + sp-info Stake pool information. + sp-lock Lock tokens lacking in stake pool. + sp-unlock Unlock tokens in stake pool. + sp-user-info Stake pool information for a user. + start-repair start repair file to blobbers + stats stats for file from blobbers + sync Sync files to/from blobbers + transferallocation Transfer an allocation from one account to another + update update file to blobbers + updateallocation Updates allocation's expiry and size + upload upload file to blobbers + validator-info Get validator info + validator-update Update validator settings by its delegate_wallet owner + version Prints version information + wp-lock Lock some tokens in write pool. + wp-unlock Unlock some expired tokens in a write pool. Flags: --config string config file (default is config.yaml) @@ -195,11 +190,13 @@ Flags: --fee float transaction fee for the given transaction (if unset, it will be set to blockchain min fee) -h, --help help for zbox --network string network file to overwrite the network details (if required, default is network.yaml) - --silent Do not show interactive sdk logs (shown by default) + --silent (default false) Do not show interactive sdk logs (shown by default) --wallet string wallet file (default is wallet.json) --wallet_client_id string wallet client_id --wallet_client_key string wallet client_key --withNonce int nonce that will be used in transaction (default is 0) + +Use "zbox [command] --help" for more information about a command. ``` ### Global Flags @@ -249,24 +246,27 @@ and `free_storage` parameters. | allocationFileName | local file to store allocation information | allocation.txt | file path | | cost | returns the cost of the allocation, no allocation created | | flag | | data | number of data shards, effects upload and download speeds | 2 | int | -| expire | duration to allocation expiration | 720h | duration | -| free_storage | free storage marker file. | | file path | +| free_storage | free storage marker file. | | file path to json marker file | | owner | owner's id, use for funding an allocation for another | | string | | owner_public_key | public key, use for funding an allocation for another | | string | -| lock | lock write pool with given number of tokens | | float | -| parity | number of parity shards, effects availability | 2 | int | +| lock\* | lock write pool with given number of tokens | | float | +| parity | number of parity shards, effects availability (has to be more than 1 and less than the number of available blobbers on the chain (upper capped to 30)) | 2 | int | | read_price | filter blobbers by read price range | 0-inf | range | | size | size of space reserved on blobbers | 2147483648 | bytes | | usd | give token value in USD | | flag | | write_price | filter blobbers by write price range | 0-inf | range | -| false | bool | | third_party_extendable | specify if the allocation can be extended by users other than the owner | false | bool | -| forbid_upload | specify if users cannot upload to this allocation | false | bool | -| forbid_delete | specify if the users cannot delete objects from this allocation | false | bool | -| forbid_update | specify if the users cannot update objects in this allocation | false | bool | -| forbid_move | specify if the users cannot move objects from this allocation | false | bool | -| forbid_copy | specify if the users cannot copy object from this allocation | false | bool | -| forbid_rename | specify if the users cannot rename objects in this allocation | false | bool | +| forbid_upload | specify if users cannot upload to this allocation | false | bool | +| forbid_delete | specify if the users cannot delete objects from this allocation | false | bool | +| forbid_update | specify if the users cannot update objects in this allocation | false | bool | +| forbid_move | specify if the users cannot move objects from this allocation | false | bool | +| forbid_copy | specify if the users cannot copy object from this allocation | false | bool | +| forbid_rename | specify if the users cannot rename objects in this allocation | false | bool | +| blobber_auth_tickets | comma separated list of blobber auth tickets | | comma separated list of strings | +| force | force to get blobbers even if required number of blobbers are not available (should be passed true in case of restricted blobbers) | false | bool | +| name | allocation name | | string | +| preferred_blobbers | comma separated list of preferred blobber ids | | comma separated list of strings | +`*` - only required if free_storage not set.
newallocation @@ -310,10 +310,6 @@ form of a json file Once created, an allocation funded by a free storage marker becomes identical to any other allocation; Its history forgotten. -```shell -./zbox newallocation --free_allocation markers/referal_marker.json -``` - ```shell Allocation created : d0939e912851959637257573b08c748474f0dd0ebbc8e191e4f6ad69e4fdc7ac ``` @@ -355,25 +351,25 @@ Further we can add a blobber to the allocation, adding a blobber will allow a blobber to be removed. An increase in blobber count will increment the parity shards. -| Parameter | Required | Description | Valid Values | -| -------------- | -------- | -------------------------------------------------------------------- | ------------ | -| allocation | yes | allocation id | string | -| expiry | | adjust storage expiration time | duration | -| free_storage | | free storage marker file | string | -| lock | yes\* | lock additional tokens in write pool | int | -| size | | adjust allocation size | bytes | -| add_blobber | | add a new blobber to the allocation, required for remove_blobber | string | -| remove_blobber | | remove a blobber from the allocation, requires an add_blobber option | string2 | - +| Parameter | Required | Description | Default| Valid Values | +| -------------- | -------- | -------------------------------------------------------------------- | | ------------ | +| allocation | yes | allocation id | | string | +| name | | allocation name | | string | +| extend | | adjust storage expiration time | | duration | +| free_storage | | free storage marker file | | string | +| lock | yes\* | lock additional tokens in write pool | | int | +| size | | adjust allocation size | | bytes | +| add_blobber | | add a new blobber to the allocation, required for remove_blobber | | string | +| add_blobber_auth_ticket | | Auth ticket of blobber to add to the allocation | | string | +| remove_blobber | | remove a blobber from the allocation, requires an add_blobber option | | string | +| third_party_extendable | | specify if the allocation can be extended by users other than the owner | false | bool +| forbid_upload | |specify if users cannot upload to this allocation | false | bool +| forbid_delete | |specify if the users cannot delete objects from this allocation | false | bool +| forbid_update | |specify if the users cannot update objects in this allocation | false | bool +| forbid_move | |specify if the users cannot move objects from this allocation | false | bool +| forbid_copy | |specify if the users cannot copy object from this allocation | false | bool +| forbid_rename | |specify if the users cannot rename objects in this allocation | false | bool `*` only required if free_storage not set. -| third_party_extendable | specify if the allocation can be extended by users other than the owner | false | bool -| forbid_upload | specify if users cannot upload to this allocation |false | bool -| forbid_delete | specify if the users cannot delete objects from this allocation | false | bool -| forbid_update | specify if the users cannot update objects in this allocation |false | bool -| forbid_move | specify if the users cannot move objects from this allocation |false | bool -| forbid_copy | specify if the users cannot copy object from this allocation |false | bool -| forbid_rename | specify if the users cannot rename objects in this allocation |false | bool -
updateallocation @@ -402,6 +398,27 @@ Output: Allocation updated with txId : fb84185dae620bbba8386286726f1efcd20d2516bcf1a448215434d87be3b30d ``` +#### Transfer allocation ownership + +`transferallocation` transfers an allocation from one account to another. +This operation needs to be run by the current owner of the allocation. + +| Parameter | Required | Description | Valid Values | +| ---------- | -------- | ------------- | ------------ | +| allocation | yes | allocation id | string | +| new_owner | yes | new owner id | string | +| new_owner_key | yes | new owner public key | string | + +```shell +./zbox transferallocation --allocation d0939e912851959637257573b08c748474f0dd0ebbc8e191e4f6ad69e4fdc7ac --new_owner e61b1d5f081c4dfa4d45c852ca8abbfcdc3023ed4ffe2402ba7e9b2ebc56b129 --new_owner_key 421d9f68e121884a02587c1d5aad0ca81a4df2358abe1acb0952efdd5a6afc0ed198ec897a848890bd36a74f3dfd178a1ed9dcd2fab969b6ed073f98d795759d +``` + +Output: + +``` +transferred ownership of allocation : d0939e912851959637257573b08c748474f0dd0ebbc8e191e4f6ad69e4fdc7ac to e61b1d5f081c4dfa4d45c852ca8abbfcdc3023ed4ffe2402ba7e9b2ebc56b129 +``` + #### Forbid Allocation There are various operations which you can forbid on an allocation. Forbid flag works with [update allocation](#update-allocation) command. Check its working first. @@ -419,11 +436,11 @@ Here are the operations: Here is a sample command for --forbid_upload .Other parameters can be done the same way. -``` +```sh ./zbox updateallocation --allocation $ALLOC --forbid_upload ``` Sample Response : -``` +```sh Allocation Updated with txID : b84185dae620bbba8386286726f1efcd20d2516bcf1a448215434d87be3b30d ``` To test functionality try uploading file to allocation. You should get the following response : @@ -453,9 +470,13 @@ Cancelling an allocation can only occur if the amount of failed challenges excee Example -``` +```sh ./zbox alloc-cancel --allocation ``` +Sample Response : +```sh +Allocation canceled with txId : 501df5a8e2a6b8ebced1d1e7dc4ed17f653012dd49834801b4413786ec031cd2 +``` #### Finalise allocation @@ -482,17 +503,24 @@ An allocation can be finalised by the owner or one of the allocation blobbers. Example -``` +```sh ./zbox alloc-fini --allocation ``` + +Sample Response: + +```sh +Allocation finalized with txId : 2a6c031ced1d1e7dc4ed17801b4413786ecd2501df5ab8ebf653012dd498348e +``` #### List blobbers Use `ls-blobbers` command to show active blobbers. | Parameter | Required | Description | Valid Values | | --------- | -------- | ------------------------------------ | ------------ | -| all | no | shows active and non active blobbers | flag | -| json | no | display result in .json format | flag | +| all | no | shows active and non active blobbers | bool | +| json | no | display result in .json format | bool | +| stakable | no | gets only stakable list of blobbers if set to true | bool |
ls-blobbers @@ -529,7 +557,7 @@ Use `bl-info` command to get detailed blobber information. | Parameter | Required | Description | default | Valid values | | ---------- | -------- | ----------------------------------- | ------- | ------------ | -| blobber id | yes | blobber on which to get information | | string | +| blobber_id | yes | blobber on which to get information | | string | | json | no | print result in json format | false | boolean |
@@ -574,10 +602,16 @@ settings: | ---------- | -------- | ---------------------------------------------- | ------- | ------------ | | allocation | yes | allocation id, sender must be allocation owner | | string | -```shell +Sample Request : +```sh ./zbox list-all --allocation 4ebeb69feeaeb3cd308570321981d61beea55db65cbeba4ba3b75c173c0f141b ``` +Sample Response : +```sh +[{"size":0,"mimetype":"","actual_size":0,"hash":"","type":"d","encrypted_key":"","lookup_hash":"55e45925760e33f113642569a539e17a531285d2bf53dc78fde954017c8b27b3","created_at":1714335152,"updated_at":1714335152,"name":"abcd","path":"/abcd"}] +``` + #### List owner's allocations `listallocations` provides a list of all allocations owned by the user. @@ -617,7 +651,9 @@ on the blockchain not the blobber. | read_price | no | update read price | | float | | service_charge | no | update service charge | | float | | write_price | no | update write price | | float | - +| url | no | update the url of the blobber | | string | +| is_restricted | no | update whether blobber is restricted | false | bool | +| not_available | no | set blobber's availability for new allocations | false | bool |
bl-update @@ -629,20 +665,46 @@ Example Update blobber read price -``` +```sh ./zbox bl-update --blobber_id 0ece681f6b00221c5567865b56040eaab23795a843ed629ce71fb340a5566ba3 --read_price 0.1 ``` -Get Version +Response : +```sh +blobber settings updated successfully +``` -The version of Zbox and Gosdk can be fetched using the ./zbox version command. +#### Update validator settings +Use `./zbox validator-update ` to update a validator's configuration settings. This updates the settings +on the blockchain not the validator. + +| Parameter | Required | Description | default | Valid values | +| ------------------ | -------- | ----------------------------------------- | ------- | ------------ | +| validator_id | yes | id of validator of which to update settings | | string | +| max_stake | no | update maximum stake | | float | +| min_stake | no | update minimum stake | | float | +| num_delegates | no | update maximum number of delegates | | int | +| service_charge | no | update service charge | | float | + +Example + +Update validator service charge + +```sh +./zbox validator-update --validator_id 0ece681f6b00221c5567865b56040eaab23795a843ed629ce71fb340a5566ba3 --service_charge 0.1 ``` + +#### Get Version + +The version of Zbox and Gosdk can be fetched using the ./zbox version command. + +```sh ./zbox version ``` Sample Response: -``` +```sh zbox....: v1.4.3 gosdk...: v1.8.14 ``` @@ -652,11 +714,17 @@ gosdk...: v1.8.14 List all active validators on the network Command: -``` +```sh ./zbox ls-validators ``` + +| Parameter | Required | Description +| ------------------ | -------- | ----------------------------------------- +| --stakable | no | Gets only validators that can be staked if set to true +| --json | no | Print Response as json data + Response : -``` +```sh id: b9f4f244e2e483548795e42dad0c5b5bb8f5c25d70cadeafc202ce6011b7ff8c url: https://demo.zus.network/validator03/ settings: @@ -683,14 +751,13 @@ settings: | ------------------ | -------- | ----------------------------------------- | --validator_id | yes | id of validator whose configuration has to be fetched | --json | optional | Print Response as json data -| --help | no | Provide information about the command Sample Command : -``` +```sh ./zbox validator-info --validator_id f82ab34a98406b8757f11513361752bab9cb679a5cb130b81 ``` Sample Response : -``` +```sh id: f82ab34a98406b8757f11513361752bab9cb679a5cb130b81a4e86cec50eefc3 url: https://demo2.zus.network/validator01 last_health_check: 2023-05-12 20:09:15 +0530 IST @@ -705,14 +772,51 @@ settings: num_delegates: 50 service_charge: 10 % ``` + +#### Shutdown Blobber +`./zbox shutdown-blobber` command deactivates a blobber to avoid storage of data . Required parameters are : + +| Parameter | Required | Description +| ------------------ | -------- | ----------------------------------------- +| --id | yes | Blobber Id to kill a specific blobber.Can be retrieved using [List blobbers](#list-blobbers). +| --fee | no | Custom fee for transaction + + Sample Command : +```sh +./zbox shutdown-blobber --id $BLOBBER_ID --wallet $CHAIN_OWNER_WALLET +``` +Note : Shutdown Blobber command should be invoked from chain owner wallet only + +Sample Response : +```sh +shutdown blobber $BLOBBER_ID with txId : 2a6c031ced1d1e7dc4ed17801b4413786ecd2501df5ab8ebf653012dd498348e +``` + +#### Shutdown Validator +`./zbox shutdown-validator` command deactivates a validator. Required parameters are : + +| Parameter | Required | Description +| ------------------ | -------- | ----------------------------------------- +| --id | yes | Validator Id to kill a specific validator.Can be retrieved using [List all Validators](#list-all-validators). +| --fee | no | Custom fee for transaction + + Sample Command : +```sh +./zbox shutdown-validator --id $VALIDATOR_ID --wallet $CHAIN_OWNER_WALLET +``` +Note : Shutdown Validator command should be invoked from chain owner wallet only + +Sample Response : +```sh +shutdown validator $VALIDATOR_ID with txId : 2a6c031ced1d1e7dc4ed17801b4413786ecd2501df5ab8ebf653012dd498348e +``` + #### Kill Blobber `./zbox kill-blobber` command deactivates a blobber to avoid storage of data . Required parameters are : | Parameter | Required | Description | ------------------ | -------- | ----------------------------------------- -| --blobber_id | yes | Blobber Id to kill a specific blobber.Can be retrieved using [List blobbers](#list-blobbers). -| --json | optional | Print Response as json data -| --help | no | Provide information about the command +| --id | yes | Blobber Id to kill a specific blobber.Can be retrieved using [List blobbers](#list-blobbers). Sample Command : ``` @@ -731,21 +835,40 @@ killed blobber $BLOBBER_ID | Parameter | Required | Description | ------------------ | -------- | ----------------------------------------- -| --validator_id | yes | Validator Id to kill a specific blobber.Can be retrieved using [List all Validators](#list-all-validators). -| --json | optional | Print Response as json data -| --help | no | Provide information about the command +| --id | yes | Validator Id to kill a specific blobber.Can be retrieved using [List all Validators](#list-all-validators). Sample Command : -``` +```sh ./zbox kill-validator --id $VALIDATOR_ID --wallet $CHAIN_OWNER_WALLET ``` Sample Response : -``` +```sh killed validator, id: $VALIDATOR_ID ``` ### Uploading and Managing files +#### Create Directory + +Use `createdir` command to create a directory in the specified allocation + +The user must be the owner of the allocation. + +| Parameter | Required | Description | Default | Valid values | +| ------------- | -------- | ------------------------------------------------------- | ------- | ------------ | +| allocation | yes | allocation id, sender must be allocation owner | | string | +| dirname | yes | path to directory | | string | + +Sample Request : +```sh +./zbox createdir --allocation {ALLOC_ID} --dirname /abcd/ +``` + +Sample Response : +```sh +/abcd/ directory created +``` + #### Upload Use `upload` command to upload file(s). @@ -763,8 +886,10 @@ The user must be the owner of the allocation.You can request the file be encrypt | web-streaming | no | transcode file before upload to fragmented mp4 | false | boolean | | localpath | yes | local path of the file to upload | | file path | | remotepath | yes | remote path to upload file to, use to access file later | | string | -| thumbnailpath | no | local path of thumbnaSil | | file path | +| thumbnailpath | no | local path of thumbnail | | file path | | chunknumber | no | how many chunks should be uploaded in a http request | 1 | int | +| attr-who-pays-for-reads | no | Who pays for reads: owner or 3rd_party | owner | owner / 3rd_party| +| multiuploadjson | no | A JSON file containing multiupload options | | file path |
upload @@ -821,29 +946,6 @@ Response: Status completed callback. Type = video/fmp4. Name = raw.samplevideo.mp4 ``` -#### Stream - -Use `stream` to capture video and audio streaming form local devices, and upload - -The user must be the owner of the allocation.You can request the file be encrypted before upload, and can send thumbnails with the file. - -| Parameter | Required | Description | Default | Valid values | -| ------------- | -------- | ------------------------------------------------------------ | ------- | ------------ | -| allocation | yes | allocation id, sender must be allocation owner | | string | -| encrypt | no | encrypt file before upload | false | boolean | -| localpath | yes | local path of segment files to download, generate and upload | | file path | -| remotepath | yes | remote path to upload file to, use to access file later | | string | -| thumbnailpath | no | local path of thumbnaSil | | file path | -| chunknumber | no | how many chunks should be uploaded in a http request | 1 | int | -| delay | no | set segment duration to seconds. | 5 | int | - -
- stream - -![image](https://github.com/0chain/blobber/wiki/uml/usecase/live_upload_live.png) - -
- #### Feed Use `feed` command to automatically download segment files from remote live feed with `--downloader-args "-q -f best"` @@ -865,7 +967,8 @@ The user must be the owner of the allocation.You can request the file be encrypt | feed | no | set remote live feed to url. | false | url | | downloader-args | no | pass args to youtube-dl to download video. default is \"-q -f best\". | -q -f best | [youtube-dl](https://github.com/ytdl-org/youtube-dl/blob/master/README.md#options) | | ffmpeg-args | no | pass args to ffmpeg to build segments. | -loglevel warning | [ffmpeg](https://www.ffmpeg.org/ffmpeg.html) | - +| attr-who-pays-for-reads | no | Who pays for reads: owner or 3rd_party | owner | owner / 3rd_party| +enum
feed @@ -926,11 +1029,14 @@ Use `download` command to download your own or a shared file. | endblock | no | download until specified block number | | int | | localpath | yes | local path to which to download the file to | | file path | | remotepath | yes | remote path to which the file was uploaded | | string | -| rx_pay | no | `authticket` must be valid, true = sender pays, false = allocation owner pays | false | boolean | | startblock | no | start download from specified block | | int | | thumbail | no | only download the thumbnail | false | boolean | | live | no | start m3u8 downloader,and automatically generate media playlist(m3u8) on --localpath | false | boolean | | delay | no | pass segment duration to generate media playlist(m3u8). only works with --live. default duration is 5s. | 5 | int | +| lookuphash | no | The remote lookuphash of the object retrieved from the list | | string | +| multidownloadjson | no | A JSON file containing multi download options | | string | +| verifydownload | no | pass this option to verify downloaded blocks | false | boolean | +
download @@ -939,12 +1045,20 @@ Use `download` command to download your own or a shared file.
-Example +Example (for owner) ``` ./zbox download --allocation 3c0d32560ea18d9d0d76808216a9c634f661979d29ba59cc8dafccb3e5b95341 --remotepath /myfiles/horse.jpeg --localpath ../horse.jpeg ``` +Example (for non-owner) with authticket + +``` +./zbox download --allocation 3c0d32560ea18d9d0d76808216a9c634f661979d29ba59cc8dafccb3e5b95341 --authticket eyJjbGllbnRfaWQiOiIiLCJvd25lcl9pZCI6IiIsImFsbG9jYXRpb24iOiIzYzBkMzI1NjBlYTE4ZDlkMGQ3NjgwODIxNmE5YzYzNGY2NjE5NzlkMjliYTU5Y2M4ZGFjYmMzZTViOTUzNDEiLCJyZW1vdGVwYXRoIjoiL215ZmlsZXMvaG9yc2UuanBlZyIsImV4cG9ydCI6IjIwMjEtMDctMjFUMDk6MjA6MjAuMDAwWiJ9 --localpath ../horse.jpeg +``` +If the authticket is for a directory, not a file, then you need to provide the lookup hash of the file you want to download. You can get the lookup hash from the [list](#list) command. + + Response: ``` @@ -982,6 +1096,16 @@ can update a file. To add collaborators to an allocation, use
+Sample Command : +```sh +./zbox update --allocation {ALLOC_ID} --localpath ./zbox_commands.txt --remotepath /abcd/ --encrypt +``` + +Sample Response : +```sh +Status completed callback. Type = application/octet-stream. Name = zbox_commands.txt +``` + #### Delete Use `delete` command to delete your file on the allocation. Only the owner @@ -1019,14 +1143,6 @@ File successfully deleted (Can be verified using [list](https://github.com/0chai Use share command to generate an authtoken that provides authorization to the holder to the specified file on the remotepath. -- --allocation string Allocation ID -- --clientid string ClientID of the user to share with. Leave blank for public share -- --encryptionpublickey string Encryption public key of the client you want to share with (from [getwallet](#Get-wallet) command ) -- --remotepath string Remote path to share -- --expiration-seconds number The seconds after which the ticket will expire(defaults to number of seconds in 90 days - if option not provided) -- --available-after Timelock for private file that makes the file available for download at certain time. 4 input formats are supported: +1h30m, +30, 1647858200 and 2022-03-21 10:21:38 - `auth ticket` can be used with [download](#download), and [list](#list), [meta](#get-metadata) and [get_download_cost](#download-cost), but only for files in the pre-defined remote path. @@ -1034,7 +1150,7 @@ the pre-defined remote path. | Parameter | Required | Description | Valid values | | ------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | | allocation | yes | allocation id | string | -| clientid | no | id of user to share file with, leave blank for public share | string | +| clientid | no | id of user to share file with (or revoke share from), leave blank for public share (or to revoke public sharing) | string | | encryptionpublickey | no | public key of the client to share file with, required if clientId | string | | expiration-seconds | no | seconds before `auth ticket` expires | int | | remotepath | yes | remote path of file to share | string | @@ -1180,19 +1296,27 @@ contents.
-Example +Example (for owner) ``` ./zbox list --allocation 8695b9e7f986d4a447b64de020ba86f53b3b5e2c442abceb6cd65742702067dc --remotepath / ``` -Response: +Example (for non-owner with auth ticket) + +``` +./zbox list --allocation 39c41dcc1f3fd5154e92e6285dd18ed869b72662198839a862d8f1fa627ec256 --authticket eyJjbGllbnRfaWQiOiIiLCJvd25lcl9pZCI6ImJhNmFiNDI2NjQ0ZjJiMzI2YjFkYTNkZDQyNjIyOWZlZDE5ZWVkODUzODdkZWFmNzJlMDVjYjBmYTRjNWFiYmIiLCJhbGxvY2F0aW9uX2lkIjoiMzljNDFkY2MxZjNmZDUxNTRlOTJlNjI4NWRkMThlZDg2OWI3MjY2MjE5ODgzOWE4NjJkOGYxZmE2MjdlYzI1NiIsImZpbGVfcGF0aF9oYXNoIjoiNDIzYjRhZTE0Y2YxZWNhMDViYzg1M2E0ZmJiMWVmZGU5ZWU4NzJkYmQxM2M0M2RmZjY4MmVlMTI3ZWU4ZjQ1NyIsImFjdHVhbF9maWxlX2hhc2giOiIiLCJmaWxlX25hbWUiOiJmaWxlcyIsInJlZmVyZW5jZV90eXBlIjoiZCIsImV4cGlyYXRpb24iOjAsInRpbWVzdGFtcCI6MTcxNDY0MTcxNiwiZW5jcnlwdGVkIjpmYWxzZSwic2lnbmF0dXJlIjoiMTNhNzk0YTNjZTczZDFmNjE2ZmY3Njc0MjNhNzBlMzZlNDMwZWYyYTA1MWQyOGViZjQ1YTkzMjIzNjliNTMwYyJ9 +``` + +Example Response: ``` -auth ticket :eyJjbGllbnRfaWQiOiJiNmRlNTYyYjU3YTBiNTkzZDA0ODA2MjRmNzlhNTVlZDQ2ZGJhNTQ0NDA0NTk1YmVlMDI3MzE0NGUwMTAzNGFlIiwib3duZXJfaWQiOiJiNmRlNTYyYjU3YTBiNTkzZDA0ODA2MjRmNzlhNTVlZDQ2ZGJhNTQ0NDA0NTk1YmVlMDI3MzE0NGUwMTAzNGFlIiwiYWxsb2NhdGlvbl9pZCI6Ijg2OTViOWU3Zjk4NmQ0YTQ0N2I2NGRlMDIwYmE4NmY1M2IzYjVlMmM0NDJhYmNlYjZjZDY1NzQyNzAyMDY3ZGMiLCJmaWxlX3BhdGhfaGFzaCI6IjIwZGM3OThiMDRlYmFiMzAxNTgxN2M4NWQyMmFlYTY0YTUyMzA1YmFkNmY3NDQ5YWNkMzgyOGM4ZDcwYzc2YTMiLCJmaWxlX25hbWUiOiIxLnR4dCIsInJlZmVyZW5jZV90eXBlIjoiZiIsImV4cGlyYXRpb24iOjE2MjY0MjA1NzQsInRpbWVzdGFtcCI6MTYxODY0NDU3NCwicmVfZW5jcnlwdGlvbl9rZXkiOiJ7XCJyMVwiOlwiOUpnci9aVDh6VnpyME1BcWFidlczdnhoWEZoVkdMSGpzcVZtVUQ1QTJEOD1cIixcInIyXCI6XCIrVEk2Z1pST3JCR3ZURG9BNFlicmNWNXpoSjJ4a0I4VU5SNTlRckwrNUhZPVwiLFwicjNcIjpcInhySjR3bENuMWhqK2Q3RXU5TXNJRzVhNnEzRXVzSlZ4a2N6YXN1K0VqQW89XCJ9Iiwic2lnbmF0dXJlIjoiZTk3NTYyOTAyODU4OTBhY2QwYTcyMzljNTFhZjc0YThmNjU2OTFjOTUwMzRjOWM0ZDJlMTFkMTQ0MTk0NmExYSJ9 + TYPE | NAME | PATH | SIZE | NUM BLOCKS | ACTUAL SIZE | ACTUAL NUM BLOCKS | LOOKUP HASH | IS ENCRYPTED +-------+--------+---------------+------+------------+-------------+-------------------+------------------------------------------------------------------+--------------- + f | one.js | /files/one.js | 5 | 1 | 19 | 1 | 566669a0240db1ca5d48ab0e013f125faf3beb34f01ef065ffb31255d9e63f43 | NO ``` -Response will be a list with information for each file/folder in the given path. The information includes lookuphash which is require for download via authticket. +Response will be a list with information for each file/folder in the given path. **The information includes lookuphash which is require for download via authticket**. #### Copy @@ -1256,84 +1380,6 @@ Response: /file.txt moved ``` -#### Sync - -`sync` command syncs all files from the local folder recursively to the remote. -Only the allocation's owner can successfully run `sync`. - -| Parameter | Required | Description | default | Valid values | -| ----------- | -------- | --------------------------------------------------------------------------------------------- | ------- | ------------ | -| allocation | yes | allocation id | | string | -| encryptpath | no | local directory path to be uploaded as encrypted | false | boolean | -| excludepath | no | paths to exclude from sync | | string array | -| localchache | no | local chache of remote snapshot. Used for comparsion with remote. After sync will be updated. | | string | -| localpath | yes | local directory to which to sync | | file path | -| uploadonly | no | only upload and update files | false | boolean | -| chunknumber | no | how many chunks should be uploaded in a http request | 1 | int | - -
- sync - -![image](https://user-images.githubusercontent.com/6240686/127884376-a95c4f27-4b2a-4d9b-91b6-c7e7919f88bc.png) - -
- -Example - -``` -./zbox sync --allocation 8695b9e7f986d4a447b64de020ba86f53b3b5e2c442abceb6cd65742702067dc --localpath /home/dung/Desktop/alloc --localcache /home/dung/Desktop/localcache.json -``` - -Response: - -``` - OPERATION | PATH -+-----------+----------------+ - Download | /1.txt - Download | /afolder/1.txt - Download | /d2.txt - - 4 / 4 [===========================================================================] 100.00% 0s -Status completed callback. Type = application/octet-stream. Name = 1.txt - 4 / 4 [===========================================================================] 100.00% 0s -Status completed callback. Type = application/octet-stream. Name = 1.txt - 7 / 7 [===========================================================================] 100.00% 0s -Status completed callback. Type = application/octet-stream. Name = d2.txt - -Sync Complete -Local cache saved. -``` - -It will sync your localpath with the remote and do all the required CRUD operations. - -#### Get differences - -`./zbox get-diff` command returns the differences between the local files specified by `localpath` and the files stored -on the root remotepath of the allocation.`localcache` flag can also be specified to use the local cache of remote snapshot created during [Sync](#sync) for file comparison. - -| Parameter | Required | Description | default | Valid values | -| ----------- | -------- | --------------------------------------------- | ------- | ------------ | -| allocation | yes | allocation id | | string | -| excludepath | no | remote folder paths to exclude during syncing | | string array | -| localcache | no | local cache of remote snapshot | | string | -| localpath | yes | local directory to sync | | string | - -Example - -``` -./zbox get-diff --allocation $ALLOC --localpath $local -``` - -Response: - -``` -[{"operation":"Upload","path":"/file1.txt","type":"f","attributes":{}}, -{"operation":"Upload","path":"/file2.txt","type":"f","attributes":{}}, -{"operation":"Upload","path":"/file3.txt","type":"f","attributes":{}}, -{"operation":"Download","path":"/myfiles/file1.txt","type":"f","attributes":{}}, -{"operation":"Download","path":"/myfiles/file2.txt","type":"f","attributes":{}}] -``` - #### Get wallet Use `getwallet` command to get additional wallet information including Encryption @@ -1359,7 +1405,7 @@ Response: Response will give details for current selected wallet (or wallet file specified by optional --wallet parameter) -#### Get +#### Get Allocation Information Use `getallocation` command to get the information about the allocation such as total size , used size, number of challenges and challenges passed/failed/open/redeemed. @@ -1367,6 +1413,7 @@ and challenges passed/failed/open/redeemed. | Parameter | Required | Description | default | Valid values | | ---------- | -------- | ----------------------------- | ------- | ------------ | | allocation | yes | allocation id | | string | +| blocks-per-marker | no | print response in json format | 10 | int | | json | no | print response in json format | false | boolean |
@@ -1386,29 +1433,129 @@ Response: ``` allocation: - id: 8695b9e7f986d4a447b64de020ba86f53b3b5e2c442abceb6cd65742702067dc - tx: 026c9d331e9c93aee4f3247507c20bdd4b7429bd81d27845bfab83f9c9c082e6 (latest create/update allocation transaction hash) + id: 2813684263f6a28de4d1301255bba21c6cf9429cc02286b56ef38db7b068d8f1 + tx: 2813684263f6a28de4d1301255bba21c6cf9429cc02286b56ef38db7b068d8f1 (latest create/update allocation transaction hash) data_shards: 4 parity_shards: 2 - size: 6.0 GiB - expiration_date: 2021-05-24 00:27:23 +0700 +07 + size: 2.0 GiB + expiration_date: 2024-05-27 15:42:23 +0200 EET + third_party_extendable: false + file_options: 00111111 + write pool 1.000 ZCN blobbers: - - blobber_id: dea18e3f3c308666cb489877b9b2c7e2babf797d8b8c322fa9d074105787a9e9 - base URL: http://demo.zus.network:31304 - size: 1.0 GiB - min_lock_demand: 0.0012333333 - spent: 0.0000244839 (moved to challenge pool or to the blobber) - penalty: 0 (blobber stake slash) - read_reward: 0.000024414 - returned: 0.0000000233 (on challenge failed) - challenge_reward: 0 (on challenge passed) - final_reward: 0 (if finalized) + min_lock_demand: 0 % + - blobber_id: 6f895dfc20b5e55df6b3084eeb69ad604eb232e5853cf054983d7495bdbc9ed7 + base URL: https://dev1.zus.network/blobber02/ + size: 512.0 MiB + min_lock_demand: 0 SAS + spent: 0 SAS (moved to challenge pool or to the blobber) + penalty: 0 SAS (blobber stake slash) + read_reward: 0 SAS + returned: 0 SAS (on challenge failed) + challenge_reward: 0 SAS (on challenge passed) + final_reward: 0 SAS (if finalized) terms: (allocation related terms) - read_price: 0.0099999999 tok / GB (by 64KB chunks) - write_price: 0.0099999999 tok / GB - min_lock_demand: 10 % - max_offer_duration: 744h0m0s - challenge_completion_time: 2m0s + read_price: 0 SAS / GB (by 64KB chunks) + write_price: 10.000 mZCN / GB + min_lock_demand: 0 SAS % + max_offer_duration: 0s + - blobber_id: 98f14362f075caf467653044cf046eb9e8a5dfee88dc8b78cad1891748245003 + base URL: https://dev1.zus.network/blobber01/ + size: 512.0 MiB + min_lock_demand: 0 SAS + spent: 0 SAS (moved to challenge pool or to the blobber) + penalty: 0 SAS (blobber stake slash) + read_reward: 0 SAS + returned: 0 SAS (on challenge failed) + challenge_reward: 0 SAS (on challenge passed) + final_reward: 0 SAS (if finalized) + terms: (allocation related terms) + read_price: 0 SAS / GB (by 64KB chunks) + write_price: 10.000 mZCN / GB + min_lock_demand: 0 SAS % + max_offer_duration: 0s + - blobber_id: 0e2fa9abc5a14231a1e7dc27b129480b732222e8e864d3b4e62d60a8b8ae617b + base URL: https://dev2.zus.network/blobber02/ + size: 512.0 MiB + min_lock_demand: 0 SAS + spent: 0 SAS (moved to challenge pool or to the blobber) + penalty: 0 SAS (blobber stake slash) + read_reward: 0 SAS + returned: 0 SAS (on challenge failed) + challenge_reward: 0 SAS (on challenge passed) + final_reward: 0 SAS (if finalized) + terms: (allocation related terms) + read_price: 0 SAS / GB (by 64KB chunks) + write_price: 10.000 mZCN / GB + min_lock_demand: 0 SAS % + max_offer_duration: 0s + - blobber_id: 06166f3dfd72a90cd0b51f4bd7520d4434552fc72880039b1ee1e8fe4b3cd7ea + base URL: https://dev2.zus.network/blobber01/ + size: 512.0 MiB + min_lock_demand: 0 SAS + spent: 0 SAS (moved to challenge pool or to the blobber) + penalty: 0 SAS (blobber stake slash) + read_reward: 0 SAS + returned: 0 SAS (on challenge failed) + challenge_reward: 0 SAS (on challenge passed) + final_reward: 0 SAS (if finalized) + terms: (allocation related terms) + read_price: 0 SAS / GB (by 64KB chunks) + write_price: 10.000 mZCN / GB + min_lock_demand: 0 SAS % + max_offer_duration: 0s + - blobber_id: 5c61f8d3e63528dfe45db89a598bd5c42c71b3994f7639d4647268ba75269d9a + base URL: https://dev3.zus.network/blobber02/ + size: 512.0 MiB + min_lock_demand: 0 SAS + spent: 0 SAS (moved to challenge pool or to the blobber) + penalty: 0 SAS (blobber stake slash) + read_reward: 0 SAS + returned: 0 SAS (on challenge failed) + challenge_reward: 0 SAS (on challenge passed) + final_reward: 0 SAS (if finalized) + terms: (allocation related terms) + read_price: 0 SAS / GB (by 64KB chunks) + write_price: 10.000 mZCN / GB + min_lock_demand: 0 SAS % + max_offer_duration: 0s + - blobber_id: 8d19a8fd7147279d1dfdadd7e3ceecaf91c63ad940dae78731e7a64b104441a6 + base URL: https://dev3.zus.network/blobber01/ + size: 512.0 MiB + min_lock_demand: 0 SAS + spent: 0 SAS (moved to challenge pool or to the blobber) + penalty: 0 SAS (blobber stake slash) + read_reward: 0 SAS + returned: 0 SAS (on challenge failed) + challenge_reward: 0 SAS (on challenge passed) + final_reward: 0 SAS (if finalized) + terms: (allocation related terms) + read_price: 0 SAS / GB (by 64KB chunks) + write_price: 10.000 mZCN / GB + min_lock_demand: 0 SAS % + max_offer_duration: 0s + read_price_range: 0 SAS-0 SAS (requested) + write_price_range: 0 SAS-25.000 mZCN (requested) + challenge_completion_time: 0s (max) + start_time: 2024-04-27 15:42:23 +0200 EET + finalized: false + canceled: false + moved_to_challenge: 0 SAS + moved_back: 0 SAS + moved_to_validators: 0 SAS + stats: + total size: 2.0 GiB + used size: 0 B + number of writes: 0 + total challenges: 0 + passed challenges: 0 + failed challenges: 0 + open challenges: 0 + last challenge redeemed: + price: + time_unit: 720h0m0s + read_price: 0 SAS / GB (by 64KB) + write_price: 15.000 mZCN / GB / 720h0m0s ``` #### Get metadata @@ -1448,7 +1595,7 @@ Response: f | 1.txt | /1.txt | 20dc798b04ebab3015817c85d22aea64a52305bad6f7449acd3828c8d70c76a3 | 4 | application/octet-stream | 03cfd743661f07975fa2f1220c5194cbaff48451 ``` -**With authticket ** +**With authticket** ``` ./zbox meta --lookuphash 20dc798b04ebab3015817c85d22aea64a52305bad6f7449acd3828c8d70c76a3 --authticket eyJjbGllbnRfaWQiOiJiNmRlNTYyYjU3YTBiNTkzZDA0ODA2MjRmNzlhNTVlZDQ2ZGJhNTQ0NDA0NTk1YmVlMDI3MzE0NGUwMTAzNGFlIiwib3duZXJfaWQiOiJiNmRlNTYyYjU3YTBiNTkzZDA0ODA2MjRmNzlhNTVlZDQ2ZGJhNTQ0NDA0NTk1YmVlMDI3MzE0NGUwMTAzNGFlIiwiYWxsb2NhdGlvbl9pZCI6Ijg2OTViOWU3Zjk4NmQ0YTQ0N2I2NGRlMDIwYmE4NmY1M2IzYjVlMmM0NDJhYmNlYjZjZDY1NzQyNzAyMDY3ZGMiLCJmaWxlX3BhdGhfaGFzaCI6IjIwZGM3OThiMDRlYmFiMzAxNTgxN2M4NWQyMmFlYTY0YTUyMzA1YmFkNmY3NDQ5YWNkMzgyOGM4ZDcwYzc2YTMiLCJmaWxlX25hbWUiOiIxLnR4dCIsInJlZmVyZW5jZV90eXBlIjoiZiIsImV4cGlyYXRpb24iOjE2MjY0MjA1NzQsInRpbWVzdGFtcCI6MTYxODY0NDU3NCwicmVfZW5jcnlwdGlvbl9rZXkiOiJ7XCJyMVwiOlwiOUpnci9aVDh6VnpyME1BcWFidlczdnhoWEZoVkdMSGpzcVZtVUQ1QTJEOD1cIixcInIyXCI6XCIrVEk2Z1pST3JCR3ZURG9BNFlicmNWNXpoSjJ4a0I4VU5SNTlRckwrNUhZPVwiLFwicjNcIjpcInhySjR3bENuMWhqK2Q3RXU5TXNJRzVhNnEzRXVzSlZ4a2N6YXN1K0VqQW89XCJ9Iiwic2lnbmF0dXJlIjoiZTk3NTYyOTAyODU4OTBhY2QwYTcyMzljNTFhZjc0YThmNjU2OTFjOTUwMzRjOWM0ZDJlMTFkMTQ0MTk0NmExYSJ9 @@ -1465,6 +1612,20 @@ TYPE | NAME | LOOKUP HASH Response will be metadata for the given filepath/lookuphash (if using authTicket) +**For a directory** + +``` +./zbox meta --allocation 8695b9e7f986d4a447b64de020ba86f53b3b5e2c442abceb6cd65742702067dc --remotepath /files +``` + +Response: + +``` + TYPE | NAME | PATH | LOOKUP HASH +-------+-------+--------+------------------------------------------------------------------- + d | files | /files | 9184e5f2634bd7b2cdaec97de9c3eb8f60192640d5e6f32bb3271f094ef7cc7a +``` + #### Rename `rename` command renames a file existing already on dStorage. Only the @@ -1534,7 +1695,7 @@ Response: #### Repair -Use `start-repair` command to repair a file on dStorage. +Use `start-repair` command to repair an allocation. Sometimes, your operations on the allocation files may not be successful on some blobbers (since the consensus of the operations is `data_shards + 1`) leading to incosistency of the allocation data on its hosting blobbers. In such cases, you can use the repair command to repair the allocation. The repair command will repair the allocation by downloading the files from the blobbers with the latest version and re-uploading them to the blobbers that failed before. The repair command will also update the allocation metadata on the blobbers. Only the owner of the allocation can repair the allocation. ![repair](https://user-images.githubusercontent.com/65766301/120052600-b364c680-c043-11eb-9bf2-038ab244fed6.png) \ @@ -1563,91 +1724,32 @@ Response: Repair file completed, Total files repaired: 0 ``` -#### Sign data +#### Decrypt -`sign-data` uses the information from your wallet to sign the input data string +`decrypt` is used to decrypt data with a passphrase | Parameter | Required | Description | default | Valid values | | --------- | -------- | -------------- | ------- | ------------ | -| data | yes | string to sign | | string | - -```shell -./zbox sign-data "data to sign" -Signature : 9432ab2ee602062afaf48c4016b373a65db48a8546a81c09dead40e54966399e -``` - ---- - -#### Streaming - -Video streaming with Zbox CLI can be implemented with players for different operating platforms(iOS, Android Mac).Zbox CLI does not have a player itself and use the the downloadFileByBlocks helper function to properly returns file-chunks with correct byte range. - -![streaming-android](https://user-images.githubusercontent.com/65766301/120052635-ce373b00-c043-11eb-94a5-a9711078ee54.png) - -##### How it works: - -When the user starts the video player (ExoPlayer for Android or AVPlayer for iOS), A ZChainDataSource starts chunked download and requests chunks of video from the buffer(a Middleman between streaming player and Zbox). - -After the arrival of the first chunk, the player starts requesting more chunks from the buffer, which requests the Zbox SDK. Zbox SDK, which is built using GO, makes use of the downloadFileByBlocks method to reliably download large files by chunking them into a sequence of parts that can be downloaded individually. Once the blocks are downloaded, they are read into input streams and added to the media source of the streaming player. - -The task of downloading files and writing them to buffer using Zbox SDK happens constantly, and If players request random bits of video, they are delivered instantly by a buffer. - -In a case, if the player didn't receive chunks (for example, it's still not downloaded), then the player switches to STALE state, and the video stream will pause. During the STALE state, a player tries to make multiple requests for chunks; if didn't receive a response, the video stream stops. - -##### Usage - -To understand how Zbox CLI provides downloading of files by blocks. Let's consider an allocation that has `audio. mp3 ` file stored on dStorage. Make sure the file has a large size(more than 64 kB(64000 bytes)) to download the file by blocks. The size and other attributes of the sample `audio. mp3` file can be viewed using +| text | yes | string to decrypt | | string | +| passphrase | yes | passphrase to use to decrypt | | string | +```sh +./zbox decrypt --text {encryted_data} --passphrase {passphrase} ``` -./zbox list --allocation $ALLOC --remotepath /myfiles -``` - -Response: - -``` - TYPE | NAME | PATH | SIZE | NUM BLOCKS |LOOKUP HASH | IS ENCRYPTED | DOWNLOADS PAYER -+------+-----------+--------------------+---------+------------+---------------- - f | audio.mp3 | /myfiles/audio.mp3 | 5992396 | 92 | 3cea39505cc30fb9f6fc5c6045284188feb14eac8ff3a19577701c4f6d973239 | NO | owner -``` -Here we can see the `audio.mp3` file of size (5993286) bytes having 92 blocks.If we want to download a certain number of blocks for the `audio.mp3` file we can use the `--endblock` or `--startblock` flag with `./zbox download` command. Other flags for download can be viewed using `./zbox download --help` - -``` -Flags: - - -b, --blockspermarker int pass this option to download multiple blocks per marker (default 10) - -e, --endblock int pass this option to download till specific block number - -h, --help help for download - --localpath string Local path of file to download - --remotepath string Remote path to download - -s, --startblock int Pass this option to download from specific block number -``` - -For only downloading three blocks of `audio.mp3` file, we specify `--startblock` and`--endblock` with integer value of 1 and 3. `--blockspermarker` flag can also be specified to download multiple blocks at a time(default is 10). - -Sample command for downloading till 3rd block of the `audio.mp3` file would be: - -``` -./zbox download --localpath /root --remotepath /myfiles/audio.mp3 --allocation $ALLOC --startblock 1 --endblock 3 -``` +#### Sign data -Response: +`sign-data` uses the information from your wallet to sign the input data string -``` - 393216 / 2996198 [====================>-----------------------------------------------------------------------------------------------------------------------------------------] 13.12% 1s -Status completed callback. Type = audio/mpeg. Name = audio.mp3 +| Parameter | Required | Description | default | Valid values | +| --------- | -------- | -------------- | ------- | ------------ | +| data | yes | string to sign | | string | +```sh +./zbox sign-data "data to sign" +Signature : 9432ab2ee602062afaf48c4016b373a65db48a8546a81c09dead40e54966399e ``` -As we can see, the downloaded file size(393216) is less than the original(2996198), which means zbox has downloaded some blocks of the file. - - - - - - - - ### Lock and Unlock Tokens #### Challenge pool information @@ -1704,12 +1806,14 @@ Use `collect-reward` to transfer reward tokens from a stake pool in which you ha invested to your wallet. You earn rewards for: + Blobbers - File space used by allocation owners and associates. - A min lock demand for each allocation. - Block rewards. Each block a reward gets paid out to blobber stakeholders in the form of a random lottery. - Validators + +Validators - Payment for validating blobber challenge responses. The stake pool keeps an account for all stakeholders to maintain accrued rewards. @@ -1717,10 +1821,11 @@ These rewards can be accessed using this `collect-reward` command. | Parameter | Required | Description | default | Valid values | | ------------- | -------- | -------------------- | ------- | ------------ | -| provider_type | no | blobber or validator | blobber | string | +| provider_type | no | blobber or validator | blobber | "blobber" \| "validator" | +| provider_id | no | id of blobber or validator | | string | ```bash -./zbox colect-reward --provider_type blobber +./zbox collect-reward --provider_type blobber ``` #### Read pool info @@ -1774,11 +1879,10 @@ Unlocked tokens get returned to the original wallet balance. #### Storage SC configurations -Show storage SC configuration. +Use `sc-config` to show storage SC configuration. | Parameter | Required | Description | default | Valid values | | ---------- | -------- | --------------------------- | ------- | ------------ | -| allocation | yes | allocation id | | string | | json | no | print result in json format | false | boolean |
@@ -1788,18 +1892,27 @@ Show storage SC configuration.
-``` +```sh ./zbox sc-config ``` +```sh +{"blobber_slash":"0.1","block_reward.block_reward":"0.0063","block_reward.gamma.a":"10","block_reward.gamma.alpha":"0.2","block_reward.gamma.b":"9","block_reward.qualifying_stake":"1","block_reward.zeta.i":"1","block_reward.zeta.k":"0.9","block_reward.zeta.mu":"0.2","cancellation_charge":"0.2","challenge_enabled":"true","challenge_generation_gap":"1","cost.add_blobber":"266","cost.add_free_storage_assigner":"124","cost.add_validator":"348","cost.blobber_health_check":"97","cost.cancel_allocation":"1163","cost.challenge_response":"728","cost.collect_reward":"181","cost.commit_connection":"743","cost.commit_settings_changes":"56","cost.finalize_allocation":"1091","cost.free_allocation_request":"2132","cost.generate_challenge":"600","cost.kill_blobber":"651","cost.kill_validator":"277","cost.new_allocation_request":"1919","cost.pay_blobber_block_rewards":"100","cost.read_pool_lock":"170","cost.read_pool_unlock":"104","cost.read_redeem":"664","cost.shutdown_blobber":"597","cost.shutdown_validator":"227","cost.stake_pool_lock":"187","cost.stake_pool_unlock":"119","cost.update_allocation_request":"2692","cost.update_blobber_settings":"338","cost.update_settings":"143","cost.update_validator_settings":"247","cost.write_pool_lock":"186","free_allocation_settings.data_shards":"4","free_allocation_settings.parity_shards":"2","free_allocation_settings.read_pool_fraction":"0","free_allocation_settings.read_price_range.max":"0","free_allocation_settings.read_price_range.min":"0","free_allocation_settings.size":"2147483648","free_allocation_settings.write_price_range.max":"0.025","free_allocation_settings.write_price_range.min":"0","health_check_period":"1h30m0s","max_blobber_select_for_challenge":"5","max_blobbers_per_allocation":"30","max_challenge_completion_rounds":"1200","max_charge":"0.5","max_delegates":"100","max_file_size":"549755813888","max_individual_free_allocation":"1","max_read_price":"0","max_stake":"2e+06","max_total_free_allocation":"1e+07","max_write_price":"0.025","min_alloc_size":"1073741824","min_blobber_capacity":"10737418240","min_stake":"1","min_stake_per_delegate":"10","min_write_price":"0.001","num_validators_rewarded":"10","owner_id":"1746b06bb09f55ee01b33b5e2e055d6cc7a900cb57c0a3a5eaabb8a0e7745802","readpool.min_lock":"0","stakepool.kill_slash":"0.5","stakepool.min_lock_period":"0s","time_unit":"8760h0m0s","validator_reward":"0.025","validators_per_challenge":"2","writepool.min_lock":"0.1"} +``` + #### Stake pool info Use `sp-info` to get your stake pool information and settings. | Parameter | Required | Description | default | Valid values | | ---------- | -------- | --------------------------- | -------------- | ------------ | -| blobber_id | | id of blobber | current client | string | +| blobber_id | | id of blobber | | string | +| authorizer_id | | id of authorizer | | string | +| miner_id | | id of miner | | string | +| sharder_id | | id of sharder | | string | +| validator_id | | id of validator | | string | | json | no | print result in json format | false | boolean | + \* - one of the above ids is required
sp-info @@ -1811,6 +1924,29 @@ Use `sp-info` to get your stake pool information and settings. ``` ./zbox sp-info --blobber_id ``` +Sample Response : + +```sh +pool id: 98f14362f075caf467653044cf046eb9e8a5dfee88dc8b78cad1891748245003 +balance: 12.000 ZCN +total stake: 12.000 ZCN +unclaimed rewards: 0 SAS +total rewards: 0 SAS +delegate_pools: +- id: ba6ab426644f2b326b1da3dd426229fed19eed85387deaf72e05cb0fa4c5abbb + balance: 12.000 ZCN + delegate_id: ba6ab426644f2b326b1da3dd426229fed19eed85387deaf72e05cb0fa4c5abbb + unclaimed reward: 0 SAS + total_reward: 0 SAS + total_penalty: 0 SAS + status: active + round_created: 2074 + unstake: false + staked_at: 2024-04-27 16:29:47 +0200 EET +settings: + delegate_wallet: fdaa2b74e666a3f609ea714a649d44edd9c46ff468e094b797e1811c533d0b2b + num_delegates: 50 +``` #### Lock tokens into stake pool @@ -1826,6 +1962,9 @@ to stake pool later. | ------------ | -------- | --------------- | ------- | ------------ | | blobber_id | | id of blobber | n/a | string | | validator_id | | id of validator | n/a | string | +| miner_id | | id of miner | n/a | string | +| sharder_id | | id of blobber | n/a | string | +| authorizer_id| | id of authorizer| n/a | string | | fee | no | transaction fee | 0 | float | | tokens | yes | tokens to lock | | float | @@ -1850,15 +1989,16 @@ To stake tokens for validators: #### Unlock tokens from stake pool -Unlock a stake pool by pool owner. If the stake pool cannot be unlocked as -it would leave insufficient funds for opened offers, then `sp-unlock` tags -the stake pool to be unlocked later. This tag prevents the stake pool affecting +Unlock a stake pool by pool owner. This tag prevents the stake pool affecting blobber allocation for any new allocations. | Parameter | Required | Description | default | Valid values | | ------------ | -------- | --------------- | ------- | ------------ | | blobber_id | | id of blobber | n/a | string | | validator_id | | id of validator | n/a | string | +| miner_id | | id of miner | n/a | string | +| sharder_id | | id of blobber | n/a | string | +| authorizer_id| | id of authorizer| n/a | string | | fee | no | transaction fee | 0 | float |
@@ -1880,12 +2020,18 @@ To unstake validator tokens: ./zbox sp-unlock --validator_id --pool_id ``` +Same for the other providers. + #### Stake pools info of user Get information about all stake pools of current user. | Parameter | Required | Description | default | Valid values | | --------- | -------- | --------------------------- | ------- | ------------ | +| all | no | get all the pools | false | boolean | +| client_id | no | client_id of the user | | string | +| limit | no | limit the number of records returned | 20 | int | +| offset | no | skip the number of rows before beginning | | int | | json | no | print result in json format | false | boolean |
@@ -1899,32 +2045,20 @@ Get information about all stake pools of current user. ./zbox sp-user-info ``` -#### Write pool info - -Write pool information. Use allocation id to filter results to a singe allocation. - -| Parameter | Required | Description | default | Valid values | -| ------------- | -------- | --------------------------- | ------- | ------------ | -| allocation id | no | allocation id | | string | -| json | no | print result in json format | false | boolean | - -
- wp-info - -![image](https://user-images.githubusercontent.com/6240686/124603444-d9ab2c80-de61-11eb-82f2-900d540ba63f.png) - -
- -For all write pools. +Sample Response : ``` -./zbox wp-info -``` - -Filtering by allocation. - -``` -./zbox wp-info --allocation +- blobber_id: 98f14362f075caf467653044cf046eb9e8a5dfee88dc8b78cad1891748245003 + - id: ba6ab426644f2b326b1da3dd426229fed19eed85387deaf72e05cb0fa4c5abbb + balance: 12.000 ZCN + delegate_id: ba6ab426644f2b326b1da3dd426229fed19eed85387deaf72e05cb0fa4c5abbb + unclaimed reward: 0 SAS + total rewards: 0 SAS + total penalty: 0 SAS + status: active + round_created: 2074 + unstake: false + staked_at: 2024-04-27 16:29:47 +0200 EET ``` #### Lock tokens into write pool @@ -1937,24 +2071,22 @@ All tokens will be divided between allocation blobbers depending on their write - If the user does not have a pre-existing read pool, then the smart-contract creates one. -Anyone can lock tokens with a write pool attached an allocation. These tokens can +Anyone can lock tokens with a write pool attached to an allocation. These tokens can be used to pay for the allocation updates and min lock demand as needed. Any tokens moved into the challenge pool to underwrite blobbers' min lock demands return to the -allocation's owner on closing the allocation. +allocation's owner on closing the allocation either by cancelation or expiry. | Parameter | Required | Description | default | Valid values | | ------------- | -------- | --------------------------------- | ------- | ------------ | -| allocation id | no | allocation id | | string | -| blobber | no | blobber id | | string | -| duration | yes | duration for which to lock tokens | | duration | +| allocation | no | allocation id | | string | | fee | no | transaction fee | 0 | float | | tokens | yes | number of tokens to lock | | float |
- rp-lock with a specific blobber + wp-lock with a specific blobber ```shell -./zbox rp-lock --allocation --duration 40m --tokens 1 --blobber f65af5d64000c7cd2883f4910eb69086f9d6e6635c744e62afcfab58b938ee25 +./zbox wp-lock --allocation --tokens 1 ``` ![image](https://user-images.githubusercontent.com/6240686/123988183-b4c93c00-d9bf-11eb-825c-9a5849fedbbf.png) @@ -1962,22 +2094,16 @@ allocation's owner on closing the allocation.
- rp-lock spread across all blobbers - -Tokens are spread between the blobber pools weighted by -each blobber's Terms.ReadPrice. + wp-lock spread across all blobbers ```shell -./zbox rp-lock --allocation --duration 40m --tokens 1 +./zbox wp-lock --allocation --tokens 1 ``` ![image](https://user-images.githubusercontent.com/6240686/123979735-e5f23e00-d9b8-11eb-8232-339a4a3374d0.png)
-``` -./zbox wp-lock --allocation --duration 40m --tokens 1 -``` #### Unlock tokens from write pool @@ -1986,17 +2112,18 @@ An expired write pool, associated with an allocation, can be locked until alloca | Parameter | Required | Description | default | Valid values | | --------- | -------- | --------------- | ------- | ------------ | +| allocation | no | allocation id | | string | | fee | no | transaction fee | 0 | float |
- rp-unlock + wp-unlock ![image](https://user-images.githubusercontent.com/6240686/123980742-b09a2000-d9b9-11eb-8987-c18ff90ee705.png)
``` -./zbox wp-unlock +./zbox wp-unlock --allocation ``` #### Download cost @@ -2008,6 +2135,7 @@ owner, collaborator, or using an auth ticket to determine the download cost of t | ---------- | -------- | ----------------------------------------- | ------- | ------------ | | allocation | yes | allocation id | | string | | authticket | no | auth ticket to use if not the owner | | string | +| blocks-per-marker | no | blocks signed per Read Marker | 10 | int | | lookuphash | no | hash of remote file, use with auth ticket | | string | | remotepath | no | file of which to get stats, use if owner | | string | @@ -2017,6 +2145,7 @@ owner, collaborator, or using an auth ticket to determine the download cost of t ![image](https://user-images.githubusercontent.com/6240686/124497750-41ef0500-ddb3-11eb-99ea-115a4e234eda.png)
+ Command: ``` ./zbox get-download-cost --allocation --remotepath /path/file.ext @@ -2058,18 +2187,35 @@ Response: 0.0000000028 tokens / 720h0m0s for 24 B of ``` -## Troubleshooting +## Config -1. Both `rp-info` and `rp-lock` are not working. +### ~/.zcn/config.yaml -``` -./zbox rp-info -``` +`~/.zcn/config.yaml` is a required `zboxcli` config. -Response: +| Field | Description | Value type | +| --------------------------- | ------------------------------------------------------------ | ---------- | +| `block_worker` | The URL to chain network DNS that provides the lists of miners and sharders | string | +| `signature_scheme` | The signature scheme used in the network. This would be `bls0chain` for most networks | string | +| `min_submit` | The desired minimum success ratio (in percent) to meet when submitting transactions to miners | integer | +| `min_confirmation` | The desired minimum success ratio (in percent) to meet when verifying transactions on sharders | integer | +| `confirmation_chain_length` | The desired chain length to meet when verifying transactions | integer | -``` -Failed to get read pool info: error requesting read pool info: consensus_failed: consensus failed on sharders +### Override Network + +Network nodes are automatically discovered using the `block_worker` provided on [config file](https://github.com/0chain/zwalletcli/blob/staging/network/config.yaml). + +To override/limit the nodes used on `zbox`, create `~/.zcn/network.yaml` as shown below. + +```sh +cat > ~/.zcn/network.yaml << EOF +miners: + - http://demo1.zus.network:31201 + - http://demo1.zus.network:31202 + - http://demo1.zus.network:31203 +sharders: + - http://demo1.zus.network:31101 +EOF ``` -This can happen if read pool is not yet created for wallet. Read pool is usually created when new wallet is created by `zbox` or `zwallet`. However, if wallet is recovered through `zwallet recoverwallet`, read pool may not have been created. Simply run `zbox rp-create` to create a read pool. +Overriding the nodes can be useful in local chain setup. In some cases, the block worker might return URLs with IP/alias only accessible within the docker network. diff --git a/cmd/add.go b/cmd/add.go index 6bf51887..917d1e55 100644 --- a/cmd/add.go +++ b/cmd/add.go @@ -12,6 +12,7 @@ var addCmd = &cobra.Command{ Short: "Adds free storage assigner", Long: "Adds free storage assigner", Args: cobra.MinimumNArgs(0), + Hidden: true, Run: func(cmd *cobra.Command, args []string) { var err error var flags = cmd.Flags() diff --git a/network/config.yaml b/cmd/config.yaml similarity index 87% rename from network/config.yaml rename to cmd/config.yaml index f62f229d..e491dcd1 100644 --- a/network/config.yaml +++ b/cmd/config.yaml @@ -1,5 +1,5 @@ --- -block_worker: https://demo.zus.network/dns +block_worker: https://mainnet.zus.network/dns signature_scheme: bls0chain min_submit: 50 min_confirmation: 50 diff --git a/cmd/delete.go b/cmd/delete.go index 9259efcf..ced6e257 100644 --- a/cmd/delete.go +++ b/cmd/delete.go @@ -33,6 +33,8 @@ var deleteCmd = &cobra.Command{ os.Exit(1) } remotePath := cmd.Flag("remotepath").Value.String() + skipCheck, _ := cmd.Flags().GetBool("skipcheck") + allocationObj.SetCheckStatus(skipCheck) err = allocationObj.DoMultiOperation([]sdk.OperationRequest{ { @@ -53,6 +55,7 @@ func init() { rootCmd.AddCommand(deleteCmd) deleteCmd.PersistentFlags().String("allocation", "", "Allocation ID") deleteCmd.PersistentFlags().String("remotepath", "", "Remote path of the object to delete") + deleteCmd.PersistentFlags().Bool("skipcheck", false, "Skip the repair check") deleteCmd.MarkFlagRequired("allocation") deleteCmd.MarkFlagRequired("remotepath") diff --git a/cmd/download.go b/cmd/download.go index 1922fbfb..d404f2f8 100644 --- a/cmd/download.go +++ b/cmd/download.go @@ -7,6 +7,7 @@ import ( "sync" "github.com/0chain/gosdk/zboxcore/fileref" + "github.com/0chain/zboxcli/util" "github.com/0chain/gosdk/zboxcore/sdk" "github.com/spf13/cobra" @@ -68,7 +69,7 @@ var downloadCmd = &cobra.Command{ numBlocks, _ := cmd.Flags().GetInt("blockspermarker") if numBlocks == 0 { - numBlocks = 10 + numBlocks = 100 } startBlock, _ := cmd.Flags().GetInt64("startblock") @@ -154,10 +155,11 @@ var downloadCmd = &cobra.Command{ if thumbnail { errE = allocationObj.DownloadThumbnail(localPath, remotePath, verifyDownload, statusBar, true) } else { - if startBlock != 0 || endBlock != 0 { - errE = allocationObj.DownloadFileByBlock(localPath, remotePath, startBlock, endBlock, numBlocks, verifyDownload, statusBar, true) + if startBlock == 1 && endBlock == 0 { + ds := sdk.CreateFsDownloadProgress() + errE = allocationObj.DownloadFile(localPath, remotePath, verifyDownload, statusBar, true, sdk.WithDownloadProgressStorer(ds), sdk.WithWorkDir(util.GetHomeDir())) } else { - errE = allocationObj.DownloadFile(localPath, remotePath, verifyDownload, statusBar, true) + errE = allocationObj.DownloadFileByBlock(localPath, remotePath, startBlock, endBlock, numBlocks, verifyDownload, statusBar, true) } } } else if len(multidownloadJSON) > 0 { @@ -216,8 +218,9 @@ func MultiDownload(a *sdk.Allocation, jsonMultiDownloadOptions string, statusBar if i > 0 { statusBar.wg.Add(1) } + ds := sdk.CreateFsDownloadProgress() if options[i].DownloadOp == 1 { - err = a.DownloadFile(options[i].LocalPath, options[i].RemotePath, verifyDownload, statusBar, i == lastOp) + err = a.DownloadFile(options[i].LocalPath, options[i].RemotePath, verifyDownload, statusBar, i == lastOp, sdk.WithDownloadProgressStorer(ds), sdk.WithWorkDir(util.GetHomeDir())) } else { err = a.DownloadThumbnail(options[i].LocalPath, options[i].RemotePath, false, statusBar, i == lastOp) } diff --git a/cmd/downloaddir.go b/cmd/downloaddir.go new file mode 100644 index 00000000..b3391042 --- /dev/null +++ b/cmd/downloaddir.go @@ -0,0 +1,65 @@ +package cmd + +import ( + "context" + "os" + "sync" + + "github.com/0chain/gosdk/zboxcore/sdk" + "github.com/spf13/cobra" +) + +// downloadCmd represents download directory command +var downdirCmd = &cobra.Command{ + Use: "downloaddir", + Short: "download directory from blobbers", + Long: `download directory from blobbers`, + Args: cobra.MinimumNArgs(0), + Run: func(cmd *cobra.Command, args []string) { + fflags := cmd.Flags() // fflags is a *flag.FlagSet + if !(fflags.Changed("remotepath") || fflags.Changed("authticket")) { + PrintError("Error: remotepath / authticket flag is missing") + os.Exit(1) + } + + remotePath := cmd.Flag("remotepath").Value.String() + authTicket := cmd.Flag("authticket").Value.String() + localPath := cmd.Flag("localpath").Value.String() + allocationID := cmd.Flag("allocation").Value.String() + + var allocationObj *sdk.Allocation + if !fflags.Changed("allocation") { // check if the flag "path" is set + PrintError("Error: allocation flag is missing") // If not, we'll let the user know + os.Exit(1) // and return + } + allocationObj, err := sdk.GetAllocation(allocationID) + if err != nil { + PrintError("Error fetching the allocation", err) + os.Exit(1) + } + wg := &sync.WaitGroup{} + statusBar := &StatusBar{wg: wg} + wg.Add(1) + errE := allocationObj.DownloadDirectory(context.Background(), remotePath, localPath, authTicket, statusBar) + if errE == nil { + wg.Wait() + } else { + PrintError("Download failed.", errE.Error()) + os.Exit(1) + } + if !statusBar.success { + os.Exit(1) + } + }, +} + +func init() { + rootCmd.AddCommand(downdirCmd) + downdirCmd.PersistentFlags().String("allocation", "", "Allocation ID") + downdirCmd.PersistentFlags().String("remotepath", "", "Remote path of directory to download") + downdirCmd.PersistentFlags().String("localpath", "", "Local path of directory to download") + downdirCmd.PersistentFlags().String("authticket", "", "Auth ticket fot the file to download if you dont own it") + downdirCmd.MarkFlagRequired("allocation") + downdirCmd.MarkFlagRequired("localpath") + downdirCmd.MarkFlagRequired("remotepath") +} diff --git a/cmd/fileRefs.go b/cmd/fileRefs.go index 61d4f3b4..d63b19f0 100644 --- a/cmd/fileRefs.go +++ b/cmd/fileRefs.go @@ -29,6 +29,7 @@ var fileRefsCmd = &cobra.Command{ Short: "get list of recently added refs", Long: `get list of recently added refs`, Args: cobra.MinimumNArgs(0), + Hidden: true, Run: func(cmd *cobra.Command, args []string) { page, err := cmd.Flags().GetUint("page") checkError(err) diff --git a/cmd/getmpt.go b/cmd/getmpt.go index 5328325f..1799e442 100644 --- a/cmd/getmpt.go +++ b/cmd/getmpt.go @@ -16,6 +16,7 @@ var getMptKeyCommand = &cobra.Command{ Short: "Directly view blockchain data", Long: `Directly view blockchain data from MPT key`, Args: cobra.MinimumNArgs(0), + Hidden: true, Run: func(cmd *cobra.Command, args []string) { if cmd.Flags().Changed("key") == false { log.Fatal("Required Mpt key missing\n") diff --git a/cmd/newallocation.go b/cmd/newallocation.go index 10e24d33..8bcdf2a5 100755 --- a/cmd/newallocation.go +++ b/cmd/newallocation.go @@ -23,6 +23,7 @@ var ( size *int64 allocationFileName *string preferred_blobbers []string + blobber_auth_tickets []string ) func getPriceRange(val string) (pr sdk.PriceRange, err error) { @@ -119,6 +120,17 @@ var newallocationCmd = &cobra.Command{ } } + if flags.Changed("blobber_auth_tickets") { + b, err := flags.GetString("blobber_auth_tickets") + if err != nil { + log.Fatal("invalid read_price value: ", err) + } + blobber_auth_tickets = strings.Split(b, ",") + for i, id := range blobber_auth_tickets { + blobber_auth_tickets[i] = strings.TrimSpace(id) + } + } + if flags.Changed("read_price") { rps, err := flags.GetString("read_price") if err != nil { @@ -171,6 +183,8 @@ var newallocationCmd = &cobra.Command{ } thirdPartyExtendable, _ := flags.GetBool("third_party_extendable") + isEnterprise, _ := flags.GetBool("enterprise") + force, _ := flags.GetBool("force") // Read the file options flags var fileOptionParams sdk.FileOptionsParameters @@ -223,6 +237,14 @@ var newallocationCmd = &cobra.Command{ fileOptionParams.ForbidRename.Value = forbidRename } + var storageVersion int64 + if flags.Changed("storage_version") { + storageVersion, err = flags.GetInt64("storage_version") + if err != nil { + log.Fatal("invalid forbid_upload: ", err) + } + } + var allocationID string if len(owner) == 0 { options := sdk.CreateAllocationOptions{ @@ -230,17 +252,21 @@ var newallocationCmd = &cobra.Command{ ParityShards: *parityshards, Size: *size, ReadPrice: sdk.PriceRange{ - Min: uint64(readPrice.Min), - Max: uint64(readPrice.Max), + Min: readPrice.Min, + Max: readPrice.Max, }, WritePrice: sdk.PriceRange{ - Min: uint64(writePrice.Min), - Max: uint64(writePrice.Max), + Min: writePrice.Min, + Max: writePrice.Max, }, Lock: uint64(lock), BlobberIds: preferred_blobbers, + BlobberAuthTickets: blobber_auth_tickets, FileOptionsParams: &fileOptionParams, ThirdPartyExtendable: thirdPartyExtendable, + Force: force, + IsEnterprise: isEnterprise, + StorageVersion: int(storageVersion), } allocationID, _, _, err = sdk.CreateAllocationWith(options) if err != nil { @@ -258,7 +284,7 @@ var newallocationCmd = &cobra.Command{ } allocationID, _, _, err = sdk.CreateAllocationForOwner(owner, ownerPublicKey, *datashards, *parityshards, - *size, readPrice, writePrice, lock, preferred_blobbers, thirdPartyExtendable, &fileOptionParams) + *size, readPrice, writePrice, lock, preferred_blobbers, blobber_auth_tickets, thirdPartyExtendable, isEnterprise, force, &fileOptionParams) if err != nil { log.Fatal("Error creating allocation: ", err) } @@ -327,14 +353,19 @@ func init() { newallocationCmd.Flags().String("name", "", "allocation name") newallocationCmd.Flags().String("preferred_blobbers", "", "coma seperated list of preferred blobbers") + newallocationCmd.Flags().String("blobber_auth_tickets", "", "coma seperated list of blobber auth tickets") + newallocationCmd.Flags().Bool("force", false, "(default false) force to get blobbers even if required number of blobbers are not available (should be passed true in case of restricted blobbers)") newallocationCmd.Flags().Bool("third_party_extendable", false, "(default false) specify if the allocation can be extended by users other than the owner") + newallocationCmd.Flags().Bool("enterprise", false, "(default false) specify if the allocation is for enterprise") newallocationCmd.Flags().Bool("forbid_upload", false, "(default false) specify if users cannot upload to this allocation") newallocationCmd.Flags().Bool("forbid_delete", false, "(default false) specify if the users cannot delete objects from this allocation") newallocationCmd.Flags().Bool("forbid_update", false, "(default false) specify if the users cannot update objects in this allocation") newallocationCmd.Flags().Bool("forbid_move", false, "(default false) specify if the users cannot move objects from this allocation") newallocationCmd.Flags().Bool("forbid_copy", false, "(default false) specify if the users cannot copy object from this allocation") newallocationCmd.Flags().Bool("forbid_rename", false, "(default false) specify if the users cannot rename objects in this allocation") + + newallocationCmd.Flags().Int64("storage_version", 0, "storaage version of allocation") } func storeAllocation(allocationID string) { diff --git a/cmd/readpool.go b/cmd/readpool.go deleted file mode 100644 index a6c85c70..00000000 --- a/cmd/readpool.go +++ /dev/null @@ -1,157 +0,0 @@ -package cmd - -import ( - "fmt" - "log" - - "github.com/0chain/gosdk/zboxcore/sdk" - "github.com/0chain/gosdk/zcncore" - "github.com/0chain/zboxcli/util" - "github.com/spf13/cobra" -) - -// rpCreate creates read pool -var rpCreate = &cobra.Command{ - Use: "rp-create", - Short: "Create read pool if missing", - Long: `Create read pool in storage SC if the pool is missing.`, - Args: cobra.MinimumNArgs(0), - Run: func(cmd *cobra.Command, args []string) { - var err error - if _, _, err = sdk.CreateReadPool(); err != nil { - log.Fatalf("Failed to create read pool: %v\n", err) - } - fmt.Println("Read pool created successfully") - }, -} - -// rpInfo information -var rpInfo = &cobra.Command{ - Use: "rp-info", - Short: "Read pool information.", - Long: `Read pool information.`, - Args: cobra.MinimumNArgs(0), - Run: func(cmd *cobra.Command, args []string) { - doJSON, _ := cmd.Flags().GetBool("json") - - info, err := sdk.GetReadPoolInfo("") - if err != nil { - log.Fatalf("Failed to get read pool info: %v", err) - } - - token, err := info.Balance.ToToken() - if err != nil { - log.Fatal(err) - } - usd, err := zcncore.ConvertTokenToUSD(token) - var bt = float64(info.Balance) / 1e10 - if err != nil { - log.Fatalf("Failed to convert token to usd: %v", err) - } - - if info.Balance == 0 { - fmt.Println("no tokens locked") - return - } - - if doJSON { - jsonCurrencies := map[string]interface{}{ - "usd": usd, - "zcn": bt, - "fmt": info.Balance, - } - - util.PrintJSON(jsonCurrencies) - return - } - fmt.Printf("\nRead pool Balance: %v (%.2f USD)\n", info.Balance, usd) - }, -} - -// rpLock locks tokens in read pool -var rpLock = &cobra.Command{ - Use: "rp-lock", - Short: "Lock some tokens in read pool.", - Long: `Lock some tokens in read pool.`, - Args: cobra.MinimumNArgs(0), - Run: func(cmd *cobra.Command, args []string) { - - var ( - flags = cmd.Flags() - tokens float64 - fee float64 - err error - ) - - if !flags.Changed("tokens") { - log.Fatal("missing required 'tokens' flag") - } - - if tokens, err = flags.GetFloat64("tokens"); err != nil { - log.Fatal("invalid 'tokens' flag: ", err) - } - - if tokens < 0 { - log.Fatal("invalid token amount: negative") - } - - if flags.Changed("fee") { - if fee, err = flags.GetFloat64("fee"); err != nil { - log.Fatal("invalid 'fee' flag: ", err) - } - } - - _, _, err = sdk.ReadPoolLock(zcncore.ConvertToValue(tokens), zcncore.ConvertToValue(fee)) - if err != nil { - log.Fatalf("Failed to lock tokens in read pool: %v", err) - } - - fmt.Println("locked") - }, -} - -// rpUnlock unlocks tokens in a read pool -var rpUnlock = &cobra.Command{ - Use: "rp-unlock", - Short: "Unlock some expired tokens in a read pool.", - Long: `Unlock some expired tokens in a read pool.`, - Args: cobra.MinimumNArgs(0), - Run: func(cmd *cobra.Command, args []string) { - - var ( - flags = cmd.Flags() - fee float64 - err error - ) - - if flags.Changed("fee") { - if fee, err = flags.GetFloat64("fee"); err != nil { - log.Fatal("invalid 'fee' flag: ", err) - } - } - - _, _, err = sdk.ReadPoolUnlock(zcncore.ConvertToValue(fee)) - if err != nil { - log.Fatalf("Failed to unlock tokens in read pool: %v", err) - } - fmt.Println("unlocked") - }, -} - -func init() { - rootCmd.AddCommand(rpCreate) - rootCmd.AddCommand(rpInfo) - rootCmd.AddCommand(rpLock) - rootCmd.AddCommand(rpUnlock) - - rpInfo.Flags().Bool("json", false, "(default false) pass this option to print response as json data") - - rpLock.PersistentFlags().Float64("tokens", 0.0, - "lock tokens number, required") - rpLock.PersistentFlags().Float64("fee", 0.0, - "transaction fee, default 0") - rpLock.MarkFlagRequired("tokens") - - rpUnlock.PersistentFlags().Float64("fee", 0.0, - "transaction fee, default 0") -} diff --git a/cmd/repair.go b/cmd/repair.go index 5131d58e..1bc09731 100644 --- a/cmd/repair.go +++ b/cmd/repair.go @@ -1,6 +1,8 @@ package cmd import ( + "encoding/json" + "fmt" "os" "sync" @@ -55,12 +57,60 @@ var startRepair = &cobra.Command{ }, } +var repairSize = &cobra.Command{ + Use: "repair-size", + Short: "gets only size to repair file to blobbers", + Long: `gets only size to repair file to blobbers`, + Args: cobra.MinimumNArgs(0), + Run: func(cmd *cobra.Command, args []string) { + fflags := cmd.Flags() + if !fflags.Changed("allocation") { + PrintError("Error: allocation flag is missing") + os.Exit(1) + } + + repairPath := "/" + var err error + if fflags.Changed("repairpath") { + if repairPath, err = fflags.GetString("repairpath"); err != nil { + PrintError("Error: repairpath is not of string type", err) + os.Exit(1) + } + } + + allocationID := cmd.Flag("allocation").Value.String() + allocationObj, err := sdk.GetAllocation(allocationID) + if err != nil { + PrintError("Error fetching the allocation.", err) + os.Exit(1) + } + + size, err := allocationObj.RepairSize(repairPath) + if err != nil { + PrintError("get repair size failed: ", err) + os.Exit(1) + } + + jsonBytes, err := json.Marshal(size) + if err != nil { + PrintError("error marshaling size: ", err) + os.Exit(1) + } + fmt.Println(string(jsonBytes)) + }, +} + func init() { rootCmd.AddCommand(startRepair) + rootCmd.AddCommand(repairSize) startRepair.PersistentFlags().String("allocation", "", "Allocation ID") startRepair.PersistentFlags().String("rootpath", "", "File path for local files ") startRepair.PersistentFlags().String("repairpath", "", "Path to repair") startRepair.MarkFlagRequired("allocation") startRepair.MarkFlagRequired("rootpath") startRepair.MarkFlagRequired("repairpath") + + repairSize.PersistentFlags().String("allocation", "", "Allocation ID") + repairSize.PersistentFlags().String("repairpath", "", "Path to repair") + repairSize.MarkFlagRequired("allocation") } diff --git a/cmd/rolllback.go b/cmd/rolllback.go index 6d32c414..b620757b 100644 --- a/cmd/rolllback.go +++ b/cmd/rolllback.go @@ -14,6 +14,7 @@ var rollbackCmd = &cobra.Command{ Short: "rollback file to previous version", Long: `rollback file to previous version`, Args: cobra.MinimumNArgs(0), + Hidden: true, Run: func(cmd *cobra.Command, args []string) { fflags := cmd.Flags() if !fflags.Changed("allocation") { diff --git a/cmd/root.go b/cmd/root.go index d45b2636..66b1abfd 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,6 +1,7 @@ package cmd import ( + "context" "encoding/json" "fmt" "io/ioutil" @@ -12,7 +13,7 @@ import ( "github.com/spf13/cobra" - "github.com/0chain/gosdk/zboxcore/blockchain" + "github.com/0chain/gosdk/core/client" "github.com/0chain/zboxcli/util" "github.com/0chain/gosdk/core/zcncrypto" @@ -83,7 +84,6 @@ func initConfig() { if networkFile == "" { networkFile = "network.yaml" } - network, _ := conf.LoadNetworkFile(filepath.Join(configDir, networkFile)) // syncing loggers logger.SyncLoggers([]*logger.Logger{zcncore.GetLogger(), sdk.GetLogger()}) @@ -91,21 +91,8 @@ func initConfig() { // set the log file zcncore.SetLogFile("cmdlog.log", !bSilent) sdk.SetLogFile("cmdlog.log", !bSilent) - sdk.SetMinSubmit(cfg.MinSubmit) - - if network.IsValid() { - zcncore.SetNetwork(network.Miners, network.Sharders) - conf.InitChainNetwork(&conf.Network{ - Miners: network.Miners, - Sharders: network.Sharders, - }) - } - err = zcncore.InitZCNSDK(cfg.BlockWorker, cfg.SignatureScheme, - zcncore.WithChainID(cfg.ChainID), - zcncore.WithMinSubmit(cfg.MinSubmit), - zcncore.WithMinConfirmation(cfg.MinConfirmation), - zcncore.WithConfirmationChainLength(cfg.ConfirmationChainLength)) + err = client.Init(context.Background(), cfg) if err != nil { fmt.Println("Error initializing core SDK.", err) os.Exit(1) @@ -179,27 +166,26 @@ func initConfig() { } //init the storage sdk with the known miners, sharders and client wallet info - if err = sdk.InitStorageSDK( - walletJSON, + if err = client.InitSDK( + "{}", cfg.BlockWorker, cfg.ChainID, cfg.SignatureScheme, - cfg.PreferredBlobbers, - nonce, - zcncore.ConvertToValue(txFee), + nonce, false, + int(zcncore.ConvertToValue(txFee)), ); err != nil { fmt.Println("Error in sdk init", err) os.Exit(1) } - // additional settings depending network latency - blockchain.SetMaxTxnQuery(cfg.MaxTxnQuery) - blockchain.SetQuerySleepTime(cfg.QuerySleepTime) - - conf.InitClientConfig(&cfg) + err = zcncore.SetGeneralWalletInfo(walletJSON, cfg.SignatureScheme) + if err != nil { + fmt.Println("Error in sdk init", err) + os.Exit(1) + } - if network.IsValid() { - sdk.SetNetwork(network.Miners, network.Sharders) + if client.GetClient().IsSplit { + zcncore.RegisterZauthServer(cfg.ZauthServer) } sdk.SetNumBlockDownloads(10) diff --git a/cmd/share.go b/cmd/share.go index 537ee427..a4f6f279 100644 --- a/cmd/share.go +++ b/cmd/share.go @@ -124,7 +124,7 @@ func init() { rootCmd.AddCommand(shareCmd) shareCmd.PersistentFlags().String("allocation", "", "Allocation ID") shareCmd.PersistentFlags().String("remotepath", "", "Remote path to share") - shareCmd.PersistentFlags().String("clientid", "", "ClientID of the user to share with. Leave blank for public share") + shareCmd.PersistentFlags().String("clientid", "", "ClientID of the user to share with (or revoke share from). Leave blank for public share (or revoking public access).") shareCmd.PersistentFlags().String("encryptionpublickey", "", "Encryption public key of the client you want to share with. Can be retrieved by the getwallet command") shareCmd.PersistentFlags().Int64("expiration-seconds", 0, "Authticket will expire when the seconds specified have elapsed after the instant of its creation") shareCmd.PersistentFlags().String("available-after", "", "Timelock for private file that makes the file available for download at certain time. 4 input formats are supported: +1h30m, +30, 1647858200 and 2022-03-21 10:21:38. Default value is current local time.") diff --git a/cmd/stakepool.go b/cmd/stakepool.go index e43305d9..87b1cf94 100644 --- a/cmd/stakepool.go +++ b/cmd/stakepool.go @@ -36,8 +36,8 @@ func printStakePoolInfo(info *sdk.StakePoolInfo) { // settings fmt.Println("settings:") fmt.Println(" delegate_wallet: ", info.Settings.DelegateWallet) - fmt.Println(" min_stake: ", info.Settings.MinStake.String()) - fmt.Println(" max_stake: ", info.Settings.MaxStake.String()) + //fmt.Println(" min_stake: ", info.Settings.MinStake.String()) + //fmt.Println(" max_stake: ", info.Settings.MaxStake.String()) fmt.Println(" num_delegates: ", info.Settings.NumDelegates) } @@ -91,10 +91,16 @@ var spInfo = &cobra.Command{ } else { providerType = sdk.ProviderValidator } + } else if flags.Changed("authorizer_id") { + if providerID, err = flags.GetString("authorizer_id"); err != nil { + log.Fatalf("Error: cannot get the value of authorizer_id") + } else { + providerType = sdk.ProviderAuthorizer + } } if providerType == 0 || providerID == "" { - log.Fatal("Error: missing flag: one of 'blobber_id' or 'validator_id' is required") + log.Fatal("Error: missing flag: one of 'blobber_id','validator_id' or authorizer_id is required") } var info *sdk.StakePoolInfo @@ -292,10 +298,16 @@ var spUnlock = &cobra.Command{ } else { providerType = sdk.ProviderValidator } + } else if flags.Changed("authorizer_id") { + if providerID, err = flags.GetString("authorizer_id"); err != nil { + log.Fatalf("invalid 'authorizer_id' flag: %v", err) + } else { + providerType = sdk.ProviderAuthorizer + } } if providerType == 0 || providerID == "" { - log.Fatal("missing flag: one of 'blobber_id' or 'validator_id' is required") + log.Fatal("missing flag: one of 'blobber_id','validator_id' or authorizer_id is required") } if flags.Changed("fee") { diff --git a/cmd/storage.go b/cmd/storage.go index 4d1794d4..07e4adeb 100644 --- a/cmd/storage.go +++ b/cmd/storage.go @@ -2,6 +2,7 @@ package cmd import ( "fmt" + "github.com/0chain/gosdk/core/transaction" "log" "time" @@ -23,7 +24,7 @@ var scConfig = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { doJSON, _ := cmd.Flags().GetBool("json") - var conf, err = sdk.GetStorageSCConfig() + var conf, err = transaction.GetConfig("storage_sc_config") if err != nil { log.Fatalf("Failed to get storage SC configurations: %v", err) } @@ -66,15 +67,18 @@ var lsBlobers = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { doJSON, _ := cmd.Flags().GetBool("json") doAll, _ := cmd.Flags().GetBool("all") - + isStakable, err := cmd.Flags().GetBool("stakable") + if err != nil { + log.Fatalf("err parsing in stakable flag: %v", err) + } // set is_active=true to get only active blobbers isActive := true if doAll { isActive = false } - var list, err = sdk.GetBlobbers(isActive) + list, err := sdk.GetBlobbers(isActive, isStakable) if err != nil { - log.Fatalf("Failed to get storage SC configurations: %v", err) + log.Fatalf("Failed to get blobbers: %v", err) } if doJSON { @@ -133,14 +137,15 @@ var blobberInfoCmd = &cobra.Command{ fmt.Println("capacity_used: ", blob.Allocated) fmt.Println("total_stake: ", blob.TotalStake) fmt.Println("not_available: ", blob.NotAvailable) + fmt.Println("is_restricted: ", blob.IsRestricted) fmt.Println("terms:") fmt.Println(" read_price: ", blob.Terms.ReadPrice, "/ GB") fmt.Println(" write_price: ", blob.Terms.WritePrice, "/ GB") fmt.Println(" max_offer_duration:", blob.Terms.MaxOfferDuration) fmt.Println("settings:") fmt.Println(" delegate_wallet:", blob.StakePoolSettings.DelegateWallet) - fmt.Println(" min_stake: ", blob.StakePoolSettings.MinStake) - fmt.Println(" max_stake: ", blob.StakePoolSettings.MaxStake) + //fmt.Println(" min_stake: ", blob.StakePoolSettings.MinStake) + //fmt.Println(" max_stake: ", blob.StakePoolSettings.MaxStake) fmt.Println(" num_delegates: ", blob.StakePoolSettings.NumDelegates) fmt.Println(" service_charge: ", blob.StakePoolSettings.ServiceCharge*100, "%") }, @@ -183,6 +188,22 @@ var blobberUpdateCmd = &cobra.Command{ updateBlobber.Capacity = &changedCapacity } + var delegateWallet string + if flags.Changed("delegate_wallet") { + if delegateWallet, err = flags.GetString("delegate_wallet"); err != nil { + log.Fatal(err) + } + updateBlobber.DelegateWallet = &delegateWallet + } + + var storageVersion int + if flags.Changed("storage_version") { + if storageVersion, err = flags.GetInt("storage_version"); err != nil { + log.Fatal(err) + } + updateBlobber.StorageVersion = &storageVersion + } + terms := &sdk.UpdateTerms{} var termsChanged bool if flags.Changed("read_price") { @@ -221,38 +242,21 @@ var blobberUpdateCmd = &cobra.Command{ stakePoolSettings := &blockchain.UpdateStakePoolSettings{} var stakePoolSettingChanged bool - if flags.Changed("min_stake") { - var minStake float64 - if minStake, err = flags.GetFloat64("min_stake"); err != nil { - log.Fatal(err) - } - stake, err := common.ToBalance(minStake) - if err != nil { - log.Fatal(err) - } - stakePoolSettings.MinStake = &stake - stakePoolSettingChanged = true - } - - if flags.Changed("max_stake") { - var maxStake float64 - if maxStake, err = flags.GetFloat64("max_stake"); err != nil { - log.Fatal(err) - } - stake, err := common.ToBalance(maxStake) - if err != nil { + if flags.Changed("num_delegates") { + var nd int + if nd, err = flags.GetInt("num_delegates"); err != nil { log.Fatal(err) } - stakePoolSettings.MaxStake = &stake + stakePoolSettings.NumDelegates = &nd stakePoolSettingChanged = true } - if flags.Changed("num_delegates") { - var nd int - if nd, err = flags.GetInt("num_delegates"); err != nil { + if flags.Changed("delegate_Wallet") { + var dw string + if dw, err = flags.GetString("delegate_wallet"); err != nil { log.Fatal(err) } - stakePoolSettings.NumDelegates = &nd + stakePoolSettings.DelegateWallet = &dw stakePoolSettingChanged = true } @@ -274,11 +278,26 @@ var blobberUpdateCmd = &cobra.Command{ } if flags.Changed("not_available") { + var na bool + if na, err = flags.GetBool("not_available"); err != nil { + log.Fatal(err) + } + if !na { + na = false + } + updateBlobber.NotAvailable = &na + } + + if flags.Changed("is_restricted") { var ia bool - if ia, err = flags.GetBool("not_available"); err != nil { + // Check if the flag is set to true + if ia, err = flags.GetBool("is_restricted"); err != nil { log.Fatal(err) } - updateBlobber.NotAvailable = &ia + if !ia { + ia = false + } + updateBlobber.IsRestricted = &ia } if termsChanged { @@ -296,15 +315,153 @@ var blobberUpdateCmd = &cobra.Command{ }, } +var resetBlobberStatsCmd = &cobra.Command{ + Use: "reset-blobber-stats", + Short: "Reset blobber stats", + Long: `Reset blobber stats`, + Args: cobra.MinimumNArgs(0), + Hidden: true, + Run: func(cmd *cobra.Command, args []string) { + var ( + flags = cmd.Flags() + + blobberID string + prevAllocated int64 + prevSavedData int64 + newAllocated int64 + newSavedData int64 + err error + ) + + if !flags.Changed("blobber_id") { + log.Fatal("missing required 'blobber_id' flag") + } + if blobberID, err = flags.GetString("blobber_id"); err != nil { + log.Fatal("error in 'blobber_id' flag: ", err) + } + + if !flags.Changed("prev_allocated") { + log.Fatal("missing required 'prev_allocated' flag") + } + if prevAllocated, err = flags.GetInt64("prev_allocated"); err != nil { + log.Fatal("error in 'prev_allocated' flag: ", err) + } + + if !flags.Changed("prev_saved_data") { + log.Fatal("missing required 'prev_saved_data' flag") + } + if prevSavedData, err = flags.GetInt64("prev_saved_data"); err != nil { + log.Fatal("error in 'prev_saved_data' flag: ", err) + } + + if !flags.Changed("new_allocated") { + log.Fatal("missing required 'new_allocated' flag") + } + if newAllocated, err = flags.GetInt64("new_allocated"); err != nil { + log.Fatal("error in 'new_allocated' flag: ", err) + } + + if !flags.Changed("new_saved_data") { + log.Fatal("missing required 'new_saved_data' flag") + } + if newSavedData, err = flags.GetInt64("new_saved_data"); err != nil { + log.Fatal("error in 'new_saved_data' flag: ", err) + } + + resetBlobberStatsDto := &sdk.ResetBlobberStatsDto{ + BlobberID: blobberID, + PrevAllocated: prevAllocated, + PrevSavedData: prevSavedData, + NewAllocated: newAllocated, + NewSavedData: newSavedData, + } + fmt.Println(*resetBlobberStatsDto) + + _, _, err = sdk.ResetBlobberStats(resetBlobberStatsDto) + if err != nil { + log.Fatal(err) + } + fmt.Println("reset blobber stats successfully") + }, +} + +var resetVersionCmd = &cobra.Command{ + Use: "reset-version", + Short: "Reset blobber version", + Long: `Reset blobber version`, + Args: cobra.MinimumNArgs(0), + Run: func(cmd *cobra.Command, args []string) { + var ( + flags = cmd.Flags() + + blobberID string + err error + ) + + if !flags.Changed("blobber_id") { + log.Fatal("missing required 'blobber_id' flag") + } + if blobberID, err = flags.GetString("blobber_id"); err != nil { + log.Fatal("error in 'blobber_id' flag: ", err) + } + + snv := sdk.StorageNodeIdField{ + Id: blobberID, + } + + _, _, err = sdk.ResetBlobberVersion(&snv) + if err != nil { + log.Fatal(err) + } + fmt.Println("reset blobber version successfully") + }, +} + +var insertKilledProviderId = &cobra.Command{ + Use: "insert-killed-provider-id", + Short: "Insert killed provider id", + Long: `Insert killed provider id`, + Args: cobra.MinimumNArgs(0), + Run: func(cmd *cobra.Command, args []string) { + var ( + flags = cmd.Flags() + + blobberID string + err error + ) + + if !flags.Changed("id") { + log.Fatal("missing required 'blobber_id' flag") + } + if blobberID, err = flags.GetString("id"); err != nil { + log.Fatal("error in 'id' flag: ", err) + } + + snv := sdk.StorageNodeIdField{ + Id: blobberID, + } + + _, _, err = sdk.InsertKilledProviderID(&snv) + if err != nil { + log.Fatal(err) + } + fmt.Println("insert killed id successfully") + }, +} + func init() { rootCmd.AddCommand(scConfig) rootCmd.AddCommand(lsBlobers) rootCmd.AddCommand(blobberInfoCmd) rootCmd.AddCommand(blobberUpdateCmd) + rootCmd.AddCommand(resetBlobberStatsCmd) + rootCmd.AddCommand(resetVersionCmd) + rootCmd.AddCommand(insertKilledProviderId) scConfig.Flags().Bool("json", false, "(default false) pass this option to print response as json data") lsBlobers.Flags().Bool("json", false, "(default false) pass this option to print response as json data") lsBlobers.Flags().Bool("all", false, "(default false) shows active and non active list of blobbers on ls-blobbers") + lsBlobers.Flags().Bool("stakable", false, "(default false) gets only stakable list of blobbers if set to true") blobberInfoCmd.Flags().String("blobber_id", "", "blobber ID, required") blobberInfoCmd.Flags().Bool("json", false, @@ -313,6 +470,8 @@ func init() { buf := blobberUpdateCmd.Flags() buf.String("blobber_id", "", "blobber ID, required") + buf.String("delegate_wallet", "", "delegate wallet, optional") + buf.Int("storage_version", 0, "update storage version, optional") buf.Int64("capacity", 0, "update blobber capacity bid, optional") buf.Float64("read_price", 0.0, "update read_price, optional") buf.Float64("write_price", 0.0, "update write_price, optional") @@ -322,6 +481,24 @@ func init() { buf.Int("num_delegates", 0, "update num_delegates, optional") buf.Float64("service_charge", 0.0, "update service_charge, optional") buf.Bool("not_available", true, "(default false) set blobber's availability for new allocations") + buf.Bool("is_restricted", true, "(default false) set is_restricted") buf.String("url", "", "update the url of the blobber, optional") blobberUpdateCmd.MarkFlagRequired("blobber_id") + + resetBlobberStatsCmd.Flags().String("blobber_id", "", "blobber_id is required") + resetBlobberStatsCmd.Flags().Int64("prev_allocated", 0, "prev_allocated is required") + resetBlobberStatsCmd.Flags().Int64("prev_saved_data", 0, "prev_saved_data is required") + resetBlobberStatsCmd.Flags().Int64("new_allocated", 0, "new_allocated is required") + resetBlobberStatsCmd.Flags().Int64("new_saved_data", 0, "new_saved_data is required") + resetBlobberStatsCmd.MarkFlagRequired("blobber_id") + resetBlobberStatsCmd.MarkFlagRequired("prev_allocated") + resetBlobberStatsCmd.MarkFlagRequired("prev_saved_data") + resetBlobberStatsCmd.MarkFlagRequired("new_allocated") + resetBlobberStatsCmd.MarkFlagRequired("new_saved_data") + + resetVersionCmd.Flags().String("blobber_id", "", "blobber_id is required") + resetVersionCmd.MarkFlagRequired("blobber_id") + + insertKilledProviderId.Flags().String("id", "", "blobber_id is required") + insertKilledProviderId.MarkFlagRequired("id") } diff --git a/cmd/stream.go b/cmd/stream.go index 54743ee4..2212d74f 100644 --- a/cmd/stream.go +++ b/cmd/stream.go @@ -16,6 +16,7 @@ var streamCmd = &cobra.Command{ Short: "capture video and audio streaming form local devices, and upload", Long: "capture video and audio streaming form local devices, and upload", Args: cobra.MinimumNArgs(0), + Hidden: true, Run: func(cmd *cobra.Command, args []string) { fflags := cmd.Flags() // fflags is a *flag.FlagSet if !fflags.Changed("allocation") { // check if the flag "path" is set @@ -114,7 +115,6 @@ func init() { streamCmd.PersistentFlags().String("allocation", "", "Allocation ID") streamCmd.PersistentFlags().String("remotepath", "", "Remote path to upload") streamCmd.PersistentFlags().String("localpath", "", "Local path of file to upload") - streamCmd.PersistentFlags().String("thumbnailpath", "", "Local thumbnail path of file to upload") streamCmd.PersistentFlags().String("attr-who-pays-for-reads", "owner", "Who pays for reads: owner or 3rd_party") streamCmd.Flags().Bool("encrypt", false, "(default false) pass this option to encrypt and upload the file") diff --git a/cmd/sync.go b/cmd/sync.go index 3089f9e3..e4de302f 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -3,7 +3,8 @@ package cmd import ( "fmt" "os" - "runtime" + "path" + "path/filepath" "strings" "sync" @@ -101,7 +102,7 @@ func startMultiUploadUpdate(allocationObj *sdk.Allocation, argsSlice []chunkedUp return err } - mimeType, err := zboxutil.GetFileContentType(fileReader) + mimeType, err := zboxutil.GetFileContentType(path.Ext(args.localPath), fileReader) if err != nil { return err } @@ -147,10 +148,11 @@ func startMultiUploadUpdate(allocationObj *sdk.Allocation, argsSlice []chunkedUp // syncCmd represents sync command var syncCmd = &cobra.Command{ - Use: "sync", - Short: "Sync files to/from blobbers", - Long: `Sync all files to/from blobbers from/to a localpath`, - Args: cobra.MinimumNArgs(0), + Use: "sync", + Short: "Sync files to/from blobbers", + Long: `Sync all files to/from blobbers from/to a localpath`, + Args: cobra.MinimumNArgs(0), + Hidden: true, Run: func(cmd *cobra.Command, args []string) { fflags := cmd.Flags() // fflags is a *flag.FlagSet if fflags.Changed("localpath") == false { @@ -230,17 +232,13 @@ var syncCmd = &cobra.Command{ downloadSlice := make([]MultiDownloadOption, 0) downloadStatusBars := make([]*StatusBar, 0) for _, f := range lDiff { - operatingSys := runtime.GOOS - // Check the operating system and modify the path accordingly - if operatingSys == "windows" { - f.Path = strings.ReplaceAll(f.Path, "/", "\\") - } localpath = strings.TrimRight(localpath, "/") - lPath := localpath + f.Path + lPath := filepath.Join(localpath, f.Path) fileRemotePath, err := getFullRemotePath(f.Path, remotepath) if err != nil { return } + switch f.Op { case sdk.Download: wg.Add(1) @@ -328,10 +326,11 @@ var syncCmd = &cobra.Command{ // The getUploadCostCmd returns value in tokens to upload a file. var getDiffCmd = &cobra.Command{ - Use: "get-diff", - Short: "Get difference of local and allocation root", - Long: `Get difference of local and allocation root`, - Args: cobra.MinimumNArgs(0), + Use: "get-diff", + Short: "Get difference of local and allocation root", + Long: `Get difference of local and allocation root`, + Args: cobra.MinimumNArgs(0), + Hidden: true, Run: func(cmd *cobra.Command, args []string) { fflags := cmd.Flags() // fflags is a *flag.FlagSet diff --git a/cmd/updateallocation.go b/cmd/updateallocation.go index 1e777acc..e99e1bc5 100755 --- a/cmd/updateallocation.go +++ b/cmd/updateallocation.go @@ -1,12 +1,13 @@ package cmd import ( - "github.com/0chain/gosdk/zboxcore/sdk" - "github.com/0chain/gosdk/zcncore" - "github.com/spf13/cobra" "log" "os" "sync" + + "github.com/0chain/gosdk/zboxcore/sdk" + "github.com/0chain/gosdk/zcncore" + "github.com/spf13/cobra" ) // updateAllocationCmd used to change allocation size and expiration @@ -26,12 +27,15 @@ var updateAllocationCmd = &cobra.Command{ log.Fatal("invalid 'allocation_id' flag: ", err) } - var addBlobberId, removeBlobberId string + var addBlobberId, addBlobberAuthTicket, removeBlobberId string if flags.Changed("add_blobber") { addBlobberId, err = flags.GetString("add_blobber") if err != nil { log.Fatal("invalid 'add_blobber' flag: ", err) } + + addBlobberAuthTicket, _ = flags.GetString("add_blobber_auth_ticket") + if flags.Changed("remove_blobber") { removeBlobberId, err = flags.GetString("remove_blobber") if err != nil { @@ -130,7 +134,9 @@ var updateAllocationCmd = &cobra.Command{ extend, lock, addBlobberId, + addBlobberAuthTicket, removeBlobberId, + "", setThirdPartyExtendable, &fileOptionParams, statusBar, @@ -151,7 +157,9 @@ var updateAllocationCmd = &cobra.Command{ allocID, lock, addBlobberId, + addBlobberAuthTicket, removeBlobberId, + "", setThirdPartyExtendable, &fileOptionParams, ) @@ -169,6 +177,8 @@ func init() { "Allocation ID") updateAllocationCmd.PersistentFlags().String("add_blobber", "", "ID of blobber to add to the allocation") + updateAllocationCmd.PersistentFlags().String("add_blobber_auth_ticket", "", + "Auth ticket of blobber to add to the allocation") updateAllocationCmd.PersistentFlags().String("remove_blobber", "", "ID of blobber to remove from the allocation") updateAllocationCmd.PersistentFlags().Float64("lock", 0.0, diff --git a/cmd/validator.go b/cmd/validator.go index 958eb4da..0d4607e4 100644 --- a/cmd/validator.go +++ b/cmd/validator.go @@ -40,9 +40,12 @@ var lsValidators = &cobra.Command{ Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { doJSON, _ := cmd.Flags().GetBool("json") + stakable, err := cmd.Flags().GetBool("stakable") + if err != nil { + log.Fatalf("error parsing stakable flag: %v", err) + } - var list, err = sdk.GetValidators() - + list, err := sdk.GetValidators(stakable) if err != nil { log.Fatalf("Failed to get storage SC configurations: %v", err) } @@ -193,4 +196,5 @@ func init() { validatorUpdateCmd.MarkFlagRequired("validator_id") lsValidators.Flags().Bool("json", false, "(default false) pass this flag to get response as json object") + lsValidators.Flags().Bool("stakable", false, "(default false) Gets only validators that can be staked if set to true") } diff --git a/cmd/walletinfo.go b/cmd/walletinfo.go index 36c54ca7..16aba871 100644 --- a/cmd/walletinfo.go +++ b/cmd/walletinfo.go @@ -4,8 +4,8 @@ import ( "fmt" "os" + "github.com/0chain/gosdk/core/client" "github.com/0chain/gosdk/core/encryption" - "github.com/0chain/gosdk/zboxcore/client" "github.com/0chain/gosdk/zcncore" "github.com/0chain/zboxcli/util" @@ -48,11 +48,11 @@ var walletinfoCmd = &cobra.Command{ fmt.Println("Error getting the public key for encryption. ", err.Error()) return } - data[0] = []string{client.GetClientPublicKey(), client.GetClientID(), encPubKey} + data[0] = []string{client.PublicKey(), client.Id(), encPubKey} if doJSON { j := make(map[string]string) - j["client_public_key"] = client.GetClientPublicKey() - j["client_id"] = client.GetClientID() + j["client_public_key"] = client.PublicKey() + j["client_id"] = client.Id() j["encryption_public_key"] = encPubKey util.PrintJSON(j) return @@ -70,7 +70,7 @@ var signCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { data, _ := cmd.Flags().GetString("data") if data == "" { - data = client.GetClientID() + data = client.Id() } else { data = encryption.Hash(data) } diff --git a/go.mod b/go.mod index 01dfd50c..72c57694 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,12 @@ module github.com/0chain/zboxcli -go 1.20 +go 1.22.0 + +toolchain go1.22.5 require ( github.com/0chain/errors v1.0.3 - github.com/0chain/gosdk v1.12.1 + github.com/0chain/gosdk v1.18.13 github.com/icza/bitio v1.1.0 github.com/olekukonko/tablewriter v0.0.5 github.com/spf13/cobra v1.6.0 @@ -13,8 +15,9 @@ require ( ) require ( - github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565 // indirect + github.com/0chain/common v1.18.3 // indirect github.com/Luzifer/go-openssl/v3 v3.1.0 // indirect + github.com/andybalholm/brotli v1.0.5 // indirect github.com/btcsuite/btcd v0.23.4 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect github.com/btcsuite/btcd/btcutil v1.1.3 // indirect @@ -23,15 +26,21 @@ require ( github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect github.com/ethereum/go-ethereum v1.10.26 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/fxamacker/cbor/v2 v2.7.0 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-stack/stack v1.8.1 // indirect github.com/google/uuid v1.3.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect - github.com/h2non/filetype v1.1.3 // indirect + github.com/h2non/filetype v1.1.4-0.20231228185113-6469358c2bcb // indirect + github.com/hack-pad/go-webworkers v0.1.0 // indirect + github.com/hack-pad/safejs v0.1.1 // indirect github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect + github.com/hashicorp/golang-lru/v2 v2.0.1 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/herumi/bls-go-binary v1.31.0 // indirect + github.com/hitenjain14/fasthttp v0.0.0-20240916135632-f9303a91736c // indirect github.com/inconshreveable/mousetrap v1.0.1 // indirect + github.com/klauspost/compress v1.17.0 // indirect github.com/klauspost/cpuid/v2 v2.2.4 // indirect github.com/klauspost/reedsolomon v1.11.8 // indirect github.com/lithammer/shortuuid/v3 v3.0.7 // indirect @@ -57,16 +66,19 @@ require ( github.com/tklauser/go-sysconf v0.3.11 // indirect github.com/tklauser/numcpus v0.6.0 // indirect github.com/tyler-smith/go-bip39 v1.1.0 // indirect + github.com/valyala/bytebufferpool v1.0.0 // indirect + github.com/valyala/fasthttp v1.51.0 // indirect + github.com/x448/float16 v0.8.4 // indirect github.com/yusufpapurcu/wmi v1.2.2 // indirect go.dedis.ch/fixbuf v1.0.3 // indirect go.dedis.ch/kyber/v3 v3.1.0 // indirect go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.9.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/crypto v0.16.0 // indirect - golang.org/x/sync v0.5.0 // indirect - golang.org/x/sys v0.15.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/crypto v0.26.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.23.0 // indirect + golang.org/x/text v0.17.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect @@ -74,4 +86,4 @@ require ( ) // temporary, for development -// replace github.com/0chain/gosdk => ../gosdk +//replace github.com/0chain/gosdk => ../gosdk diff --git a/go.sum b/go.sum index e14b501f..9a2983ea 100644 --- a/go.sum +++ b/go.sum @@ -36,20 +36,27 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565 h1:z+DtCR8mBsjPnEsT2XtRu4X7GfBiMnz9dYvWYs9V0B4= -github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565/go.mod h1:UyDC8Qyl5z9lGkCnf9RHJPMektnFX8XtCJZHXCCVj8E= +github.com/0chain/common v1.18.3 h1:42dYOv2KyMTSanuS67iDtfv+ErbSRqR8NJ3MG72MwaI= +github.com/0chain/common v1.18.3/go.mod h1:Lapu2Tj7z5Sm4r+X141e7vsz4NDODTEypeElYAP3iSw= github.com/0chain/errors v1.0.3 h1:QQZPFxTfnMcRdt32DXbzRQIfGWmBsKoEdszKQDb0rRM= github.com/0chain/errors v1.0.3/go.mod h1:xymD6nVgrbgttWwkpSCfLLEJbFO6iHGQwk/yeSuYkIc= -github.com/0chain/gosdk v1.12.1 h1:U4XX87tao+J7rqiOdVBa1bWh/SKz+kiSvxGbVjdvWwE= -github.com/0chain/gosdk v1.12.1/go.mod h1:ew7kU2Cf1Y/CzoxMqtnmflD1CuSPaOI5TukoXA26Sz4= +github.com/0chain/gosdk v1.18.13 h1:yIq+BqhbvaIDZowerd62bp1BirJEYeg6JQ7GdFU2B90= +github.com/0chain/gosdk v1.18.13/go.mod h1:8unFy9Dx2YyPKMYPDGR3MFhUEymbAfQcRDm9bobVLGw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= +github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/Luzifer/go-openssl/v3 v3.1.0 h1:QqKqo6kYXGGUsvtUoCpRZm8lHw+jDfhbzr36gVj+/gw= github.com/Luzifer/go-openssl/v3 v3.1.0/go.mod h1:liy3FXuuS8hfDlYh1T+l78AwQ/NjZflJz0NDvjKhwDs= github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o= +github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= +github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= +github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= github.com/btcsuite/btcd v0.23.0/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY= @@ -77,8 +84,8 @@ github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= 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= @@ -86,6 +93,18 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I= +github.com/cockroachdb/errors v1.11.3/go.mod h1:m4UIW4CDjx+R5cybPsNrRbreomiFqt8o1h1wUVazSd8= +github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce h1:giXvy4KSc/6g/esnpM7Geqxka4WSqI1SZc7sMJFd3y4= +github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/pebble v1.1.2 h1:CUh2IPtR4swHlEj48Rhfzw6l/d0qA31fItcIszQVIsA= +github.com/cockroachdb/pebble v1.1.2/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU= +github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= +github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -101,6 +120,7 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1 github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc= github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw= +github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -110,13 +130,21 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/ethereum/go-ethereum v1.10.26 h1:i/7d9RBBwiXCEuyduBQzJw/mKmnvzsN14jqBmytw72s= github.com/ethereum/go-ethereum v1.10.26/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= +github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= +github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= 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.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= +github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= +github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= +github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= +github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -124,7 +152,10 @@ github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt/v4 v4.3.0 h1:kHL1vqdqWNfATmA0FNMdmZNMyZI1U6O31X4rlIPoBog= +github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -150,8 +181,11 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -164,6 +198,7 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -186,23 +221,36 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= 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/h2non/filetype v1.1.3 h1:FKkx9QbD7HR/zjK1Ia5XiBsq9zdLi5Kf3zGyFTAFkGg= -github.com/h2non/filetype v1.1.3/go.mod h1:319b3zT68BvV+WRj7cwy856M2ehB3HqNOt6sy1HndBY= +github.com/h2non/filetype v1.1.4-0.20231228185113-6469358c2bcb h1:GlQyMv2C48qmfPItvAXFoyN341Swxp9JNVeUZxnmbJw= +github.com/h2non/filetype v1.1.4-0.20231228185113-6469358c2bcb/go.mod h1:319b3zT68BvV+WRj7cwy856M2ehB3HqNOt6sy1HndBY= +github.com/hack-pad/go-webworkers v0.1.0 h1:QHBJpkXJgW0QRi2iiUGcxwGnmy7lQJL0F8UfsgMXKhA= +github.com/hack-pad/go-webworkers v0.1.0/go.mod h1:/rmjjgnlw0CursmeqRtP0NGIqo8CR+0o6AtzFydUHJ4= +github.com/hack-pad/safejs v0.1.1 h1:d5qPO0iQ7h2oVtpzGnLExE+Wn9AtytxIfltcS2b9KD8= +github.com/hack-pad/safejs v0.1.1/go.mod h1:HdS+bKF1NrE72VoXZeWzxFOVQVUSqZJAG0xNCnb+Tio= github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= +github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs= github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru/v2 v2.0.1 h1:5pv5N1lT1fjLg2VQ5KWc7kmucp2x/kvFOnxuVTqZ6x4= +github.com/hashicorp/golang-lru/v2 v2.0.1/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/herumi/bls-go-binary v1.31.0 h1:L1goQ2tMtGgpXCg5AwHAdJQpLs/pfnWWEc3Wog6OhmI= github.com/herumi/bls-go-binary v1.31.0/go.mod h1:O4Vp1AfR4raRGwFeQpr9X/PQtncEicMoOe6BQt1oX0Y= +github.com/hitenjain14/fasthttp v0.0.0-20240916135632-f9303a91736c h1:lDSIbcLu5TdT+uwb4wPzZgo1pQvKjP/tArL5QKjDJdI= +github.com/hitenjain14/fasthttp v0.0.0-20240916135632-f9303a91736c/go.mod h1:RZMcXy7u4S+E97IXYTe7WHZ3+mCYOh4vys8PkIGZeXk= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= +github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c h1:DZfsyhDK1hnSS5lH8l+JggqzEleHteTYfutAiVlSUM8= +github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= 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/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/icza/bitio v1.1.0 h1:ysX4vtldjdi3Ygai5m1cWy4oLkhWTAi+SyO6HC8L9T0= @@ -212,6 +260,7 @@ github.com/icza/mighty v0.0.0-20180919140131-cfd07d671de6/go.mod h1:xQig96I1VNBD github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc= github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= +github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= @@ -219,6 +268,8 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1 github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= 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.17.0 h1:Rnbp4K9EjcDuVuHtd0dgA4qNuv9yKDYKK1ulpJwgrqM= +github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/klauspost/reedsolomon v1.11.8 h1:s8RpUW5TK4hjr+djiOpbZJB4ksx+TdYbRH7vHQpwPOY= @@ -226,9 +277,11 @@ github.com/klauspost/reedsolomon v1.11.8/go.mod h1:4bXRN+cVzMdml6ti7qLouuYi32KHJ github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lithammer/shortuuid/v3 v3.0.7 h1:trX0KTHy4Pbwo/6ia8fscyHoGA+mf1jWbPJVuvyJQQ8= github.com/lithammer/shortuuid/v3 v3.0.7/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts= github.com/machinebox/graphql v0.2.2 h1:dWKpJligYKhYKO5A2gvNhkJdQMNZeChZYyBbrZkBZfo= @@ -236,11 +289,16 @@ github.com/machinebox/graphql v0.2.2/go.mod h1:F+kbVMHuwrQ5tYgU9JXlnskM8nOaFxCAE github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/matryer/is v1.4.1 h1:55ehd8zaGABKLXQUe2awZ99BD/PTc2ls+KV/dXphgEQ= +github.com/matryer/is v1.4.1/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= +github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= +github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= @@ -248,6 +306,7 @@ github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrk github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= +github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= @@ -270,17 +329,29 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v1.12.0 h1:C+UIj/QWtmqY13Arb8kwMt5j34/0Z2iKamrJ+ryC0Gg= +github.com/prometheus/client_golang v1.12.0/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a h1:CmF68hwI0XsOQ5UwlBopMi2Ow4Pbg32akc4KIVCOm+Y= +github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= +github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= +github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/tsdb v0.7.1 h1:YZcsG11NqnK4czYLrWd9mpEuAJIHVQLwdrleYfszMAA= +github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/remeh/sizedwaitgroup v1.0.0 h1:VNGGFwNo/R5+MJBf6yrsr110p0m4/OX4S3DCy7Kyl5E= github.com/remeh/sizedwaitgroup v1.0.0/go.mod h1:3j2R4OIe/SeS6YDhICBy22RWjJC5eNCJ1V+9+NVNYlo= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw= github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rjeczalik/notify v0.9.1 h1:CLCKso/QK1snAlnhNR/CNvNiFU2saUtjV0bx3EwNeCE= +github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= +github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= +github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= @@ -300,10 +371,12 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/viper v1.15.0 h1:js3yy885G8xwJa6iOISGFwd+qlUo5AvyXb7CiihdtiU= github.com/spf13/viper v1.15.0/go.mod h1:fFcTBJxvhhzSJiZy8n+PeW6t8l+KeT/uTARa0jHOQLA= github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= +github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -311,8 +384,9 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= @@ -326,7 +400,15 @@ github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa h1:5SqCsI/2Qya2bCzK15ozrqo2sZxkh0FHynJZOTVoV6Q= +github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI= +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasthttp v1.51.0 h1:8b30A5JlZ6C7AS81RsWjYMQmrZG6feChmgAolCl1SqA= +github.com/valyala/fasthttp v1.51.0/go.mod h1:oI2XroL+lI7vdXyYoQk03bXBThfFl2cVdIA3Xl7cH8g= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -353,6 +435,7 @@ go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= +go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= @@ -368,8 +451,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= 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= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -380,6 +463,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df h1:UA2aFVmmsIlefxMk29Dp2juaUSth8Pyn3Tq5Y5mJGME= +golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -457,8 +542,8 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= -golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190124100055-b90733256f2e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -504,8 +589,8 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= +golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 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= @@ -513,12 +598,13 @@ golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3 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.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= +golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -660,10 +746,13 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= 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= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/cheggaaa/pb.v1 v1.0.28 h1:n1tBJnnK2r7g9OW2btFH91V92STTUevLXYFb8gy9EMk= gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= diff --git a/internal.md b/internal.md new file mode 100644 index 00000000..7344f31b --- /dev/null +++ b/internal.md @@ -0,0 +1,213 @@ +Contents : +[Sync](#sync) +[Get Differences](#get-differences) +[Stream](#stream) +[Get MPT](#get-mpt) +[Rollback Allocation](#rollback-allocation) +[Streaming](#streaming) + - [How it works:](#how-it-works) + - [Usage](#usage) +#### Sync + +`sync` command syncs all files from the local folder recursively to the remote. +Only the allocation's owner can successfully run `sync`. + +| Parameter | Required | Description | default | Valid values | +| ----------- | -------- | --------------------------------------------------------------------------------------------- | ------- | ------------ | +| allocation | yes | allocation id | | string | +| encryptpath | no | local directory path to be uploaded as encrypted | false | boolean | +| excludepath | no | paths to exclude from sync | | string array | +| localchache | no | local chache of remote snapshot. Used for comparsion with remote. After sync will be updated. | | string | +| localpath | yes | local directory to which to sync | | file path | +| uploadonly | no | only upload and update files | false | boolean | +| chunknumber | no | how many chunks should be uploaded in a http request | | int | +| remotepath | no | Remote dir path from where it sync | "/" | string | +| verifydownload | no | how many chunks should be uploaded in a http request | true | boolean | + +
+ sync + +![image](https://user-images.githubusercontent.com/6240686/127884376-a95c4f27-4b2a-4d9b-91b6-c7e7919f88bc.png) + +
+ +Example + +``` +./zbox sync --allocation 8695b9e7f986d4a447b64de020ba86f53b3b5e2c442abceb6cd65742702067dc --localpath /home/dung/Desktop/alloc --localcache /home/dung/Desktop/localcache.json +``` + +Response: + +``` + OPERATION | PATH ++-----------+----------------+ + Download | /1.txt + Download | /afolder/1.txt + Download | /d2.txt + + 4 / 4 [===========================================================================] 100.00% 0s +Status completed callback. Type = application/octet-stream. Name = 1.txt + 4 / 4 [===========================================================================] 100.00% 0s +Status completed callback. Type = application/octet-stream. Name = 1.txt + 7 / 7 [===========================================================================] 100.00% 0s +Status completed callback. Type = application/octet-stream. Name = d2.txt + +Sync Complete +Local cache saved. +``` + +It will sync your localpath with the remote and do all the required CRUD operations. + + +#### Get differences + +`get-diff` command returns the differences between the local files specified by `localpath` and the files stored +on the root remotepath of the allocation.`localcache` flag can also be specified to use the local cache of remote snapshot created during [Sync](#sync) for file comparison. + +| Parameter | Required | Description | default | Valid values | +| ----------- | -------- | --------------------------------------------- | ------- | ------------ | +| allocation | yes | allocation id | | string | +| excludepath | no | remote folder paths to exclude during syncing | | string array | +| localcache | no | local cache of remote snapshot | | string | +| localpath | yes | local directory to sync | | string | + +Example + +```sh +./zbox get-diff --allocation $ALLOC --localpath $local +``` + +Response: + +```sh +[{"operation":"Upload","path":"/file1.txt","type":"f","attributes":{}}, +{"operation":"Upload","path":"/file2.txt","type":"f","attributes":{}}, +{"operation":"Upload","path":"/file3.txt","type":"f","attributes":{}}, +{"operation":"Download","path":"/myfiles/file1.txt","type":"f","attributes":{}}, +{"operation":"Download","path":"/myfiles/file2.txt","type":"f","attributes":{}}] +``` + +#### Stream + +Use `stream` to capture video and audio streaming form local devices, and upload + +The user must be the owner of the allocation.You can request the file be encrypted before upload, and can send thumbnails with the file. + +| Parameter | Required | Description | Default | Valid values | +| ------------- | -------- | ------------------------------------------------------------ | ------- | ------------ | +| allocation | yes | allocation id, sender must be allocation owner | | string | +| encrypt | no | encrypt file before upload | false | boolean | +| localpath | yes | local path of segment files to download, generate and upload | | file path | +| remotepath | yes | remote path to upload file to, use to access file later | | string | +| thumbnailpath | no | local path of thumbnaSil | | file path | +| chunknumber | no | how many chunks should be uploaded in a http request | 1 | int | +| delay | no | set segment duration to seconds. | 5 | int | +| attr-who-pays-for-reads | no | Who pays for reads: owner or 3rd_party | owner | owner / 3rd_party| + +
+ stream + +![image](https://github.com/0chain/blobber/wiki/uml/usecase/live_upload_live.png) + +
+ + +#### Get MPT + +`get-mpt` is used to directly get blockchain data from the MPT key + +| Parameter | Required | Description | default | Valid values | +| --------- | -------- | -------------- | ------- | ------------ | +| key | yes | Key in MPT datastore | | string | + +Sample Command : +```sh +./zbox get-mpt --key {MPT_KEY} +``` + +Sample Response : +```sh + +``` + +#### Rollback Allocation + +`rollback` is used to directly get blockchain data from the MPT key + +| Parameter | Required | Description | default | Valid values | +| --------- | -------- | -------------- | ------- | ------------ | +| allocation | yes | Allocation ID | | string | + +Sample Command : +```sh +./zbox rollback --allocation $ALLOC +``` + +Sample Response : +```sh +Rollback successful +``` + +#### Streaming + +Video streaming with Zbox CLI can be implemented with players for different operating platforms(iOS, Android Mac).Zbox CLI does not have a player itself and use the the downloadFileByBlocks helper function to properly returns file-chunks with correct byte range. + +![streaming-android](https://user-images.githubusercontent.com/65766301/120052635-ce373b00-c043-11eb-94a5-a9711078ee54.png) + +##### How it works: + +When the user starts the video player (ExoPlayer for Android or AVPlayer for iOS), A ZChainDataSource starts chunked download and requests chunks of video from the buffer(a Middleman between streaming player and Zbox). + +After the arrival of the first chunk, the player starts requesting more chunks from the buffer, which requests the Zbox SDK. Zbox SDK, which is built using GO, makes use of the downloadFileByBlocks method to reliably download large files by chunking them into a sequence of parts that can be downloaded individually. Once the blocks are downloaded, they are read into input streams and added to the media source of the streaming player. + +The task of downloading files and writing them to buffer using Zbox SDK happens constantly, and If players request random bits of video, they are delivered instantly by a buffer. + +In a case, if the player didn't receive chunks (for example, it's still not downloaded), then the player switches to STALE state, and the video stream will pause. During the STALE state, a player tries to make multiple requests for chunks; if didn't receive a response, the video stream stops. + +##### Usage + +To understand how Zbox CLI provides downloading of files by blocks. Let's consider an allocation that has `audio. mp3 ` file stored on dStorage. Make sure the file has a large size(more than 64 kB(64000 bytes)) to download the file by blocks. The size and other attributes of the sample `audio. mp3` file can be viewed using + +``` +./zbox list --allocation $ALLOC --remotepath /myfiles +``` + +Response: + +``` + TYPE | NAME | PATH | SIZE | NUM BLOCKS |LOOKUP HASH | IS ENCRYPTED | DOWNLOADS PAYER ++------+-----------+--------------------+---------+------------+---------------- + f | audio.mp3 | /myfiles/audio.mp3 | 5992396 | 92 | 3cea39505cc30fb9f6fc5c6045284188feb14eac8ff3a19577701c4f6d973239 | NO | owner + +``` +Here we can see the `audio.mp3` file of size (5993286) bytes having 92 blocks.If we want to download a certain number of blocks for the `audio.mp3` file we can use the `--endblock` or `--startblock` flag with `./zbox download` command. Other flags for download can be viewed using `./zbox download --help` + +``` +Flags: + + -b, --blockspermarker int pass this option to download multiple blocks per marker (default 10) + -e, --endblock int pass this option to download till specific block number + -h, --help help for download + --localpath string Local path of file to download + --remotepath string Remote path to download + -s, --startblock int Pass this option to download from specific block number +``` + +For only downloading three blocks of `audio.mp3` file, we specify `--startblock` and`--endblock` with integer value of 1 and 3. `--blockspermarker` flag can also be specified to download multiple blocks at a time(default is 10). + +Sample command for downloading till 3rd block of the `audio.mp3` file would be: + +``` +./zbox download --localpath /root --remotepath /myfiles/audio.mp3 --allocation $ALLOC --startblock 1 --endblock 3 +``` + +Response: + +``` + 393216 / 2996198 [====================>-----------------------------------------------------------------------------------------------------------------------------------------] 13.12% 1s +Status completed callback. Type = audio/mpeg. Name = audio.mp3 + +``` + +As we can see, the downloaded file size(393216) is less than the original(2996198), which means zbox has downloaded some blocks of the file. diff --git a/scripts/debian/Dockerfile.build b/scripts/debian/Dockerfile.build new file mode 100644 index 00000000..4ff29079 --- /dev/null +++ b/scripts/debian/Dockerfile.build @@ -0,0 +1,8 @@ +FROM --platform=$TARGETPLATFORM golang:1.22 AS build +ARG VERSION +WORKDIR /src +COPY go.mod go.sum . +RUN go mod download +COPY . . +RUN go env +RUN CGO_ENABLED=1 go build -x -v -tags bn256 -ldflags "-X main.VersionStr=v${VERSION} -linkmode 'external' -extldflags '-static'" -o /zbox . diff --git a/scripts/debian/Dockerfile.install_test b/scripts/debian/Dockerfile.install_test new file mode 100644 index 00000000..160bdc10 --- /dev/null +++ b/scripts/debian/Dockerfile.install_test @@ -0,0 +1,20 @@ +# syntax=docker/dockerfile:latest + +ARG BASE_IMAGE + +FROM --platform=$TARGETPLATFORM ${BASE_IMAGE} + +# Install necessary packages +RUN apt-get update && apt-get install -y curl dpkg + +# print architecture +RUN dpkg --print-architecture + +# Download and install the app +ARG LOC=https://packages.zus.network/aptrepo/zbox_deb_install.sh +RUN set -e; \ + curl -sL ${LOC} | bash + +# Check the app version +CMD ["zbox", "version"] + diff --git a/scripts/debian/install.sh b/scripts/debian/install.sh new file mode 100755 index 00000000..9e93c9da --- /dev/null +++ b/scripts/debian/install.sh @@ -0,0 +1,91 @@ +#!/usr/bin/env bash + +set -e + +setup() { + + set -v + export DEBIAN_FRONTEND=noninteractive + apt-get update + apt-get install --assume-yes --no-install-recommends apt-transport-https ca-certificates curl gnupg lsb-release software-properties-common + set +v + + set -v + mkdir -p /etc/apt/keyrings + curl -sLS https://packages.zus.network/zus.asc | + gpg --dearmor > /etc/apt/keyrings/zus.gpg + chmod go+r /etc/apt/keyrings/zus.gpg + set +v + + set -v + # Use env var DIST_CODE for the package dist name if provided + if [[ -z $DIST_CODE ]]; then + CLI_REPO=$(lsb_release -cs) + shopt -s nocasematch + ERROR_MSG="Unable to find a package for your system. Please check if an existing package in https://packages.zus.network/aptrepo/zbox/dists/ can be used in your system and install with the dist name: 'curl -sL https://packages.zus.network/aptrepo/zbox_deb_install.sh | sudo DIST_CODE= bash'" + if [[ ! $(curl -sL https://packages.zus.network/aptrepo/zbox/dists/) =~ $CLI_REPO ]]; then + DIST=$(lsb_release -is) + if [[ $DIST =~ "Ubuntu" ]]; then + CLI_REPO="jammy" + elif [[ $DIST =~ "Debian" ]]; then + CLI_REPO="bookworm" + elif [[ $DIST =~ "LinuxMint" ]]; then + CLI_REPO=$(grep -Po 'UBUNTU_CODENAME=\K.*' /etc/os-release) || true + if [[ -z $CLI_REPO ]]; then + echo "$ERROR_MSG" + exit 1 + fi + else + echo "$ERROR_MSG" + exit 1 + fi + fi + else + CLI_REPO=$DIST_CODE + if [[ ! $(curl -sL https://packages.zus.network/aptrepo/zbox/dists/) =~ $CLI_REPO ]]; then + echo "Unable to find an zbox package with DIST_CODE=$CLI_REPO in https://packages.zus.network/aptrepo/zbox/dists/" + exit 1 + fi + fi + + if [ -f /etc/apt/sources.list.d/zbox.list ]; then + rm /etc/apt/sources.list.d/zbox.list + fi + + echo "Types: deb +URIs: https://packages.zus.network/aptrepo/zbox/ +Suites: ${CLI_REPO} +Components: main +Architectures: $(dpkg --print-architecture) +Signed-by: /etc/apt/keyrings/zus.gpg" | tee /etc/apt/sources.list.d/zbox.sources + apt-get update + set +v + + apt-get install --assume-yes zbox + + # Create or update the config.yaml file + CONFIG_DIR="${HOME}/.zcn" + CONFIG_PATH="${CONFIG_DIR}/config.yaml" + echo "Creating/updating configuration file at ${CONFIG_PATH}..." + mkdir -p $CONFIG_DIR + touch $CONFIG_PATH + cat < ${CONFIG_PATH} +--- +block_worker: https://mainnet.zus.network/dns +signature_scheme: bls0chain +min_submit: 50 +min_confirmation: 50 +confirmation_chain_length: 3 + +# # OPTIONAL - Uncomment to use/ Add more if you want +# preferred_blobbers: +# - http://one.devnet-0chain.net:31051 +# - http://one.devnet-0chain.net:31052 +# - http://one.devnet-0chain.net:31053 +EOT + + echo "Installation and configuration complete." + +} + +setup # ensure the whole file is downloaded before executing \ No newline at end of file