diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index c3b244b..82eef3e 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -7,12 +7,13 @@ on: branches: [ '*' ] jobs: - build: - runs-on: ubuntu-latest + supported: strategy: matrix: go: [ '1.21', '1.22' ] - name: Go ${{ matrix.go }} test + runner: [ 'ubuntu-latest', 'ubuntu-24.04-arm' ] + runs-on: ${{ matrix.runner }} + name: Go ${{ matrix.go }} ${{ matrix.runner }} supported test steps: - name: Set up Go 1.x uses: actions/setup-go@v4 @@ -23,11 +24,42 @@ jobs: uses: actions/checkout@v3 - name: Get dependencies - run: | - go get -v -t -d ./... + run: go get -v -t -d ./... - name: Build run: go build -v ./... - name: Test run: go test -v ./... + + unsupported: + strategy: + matrix: + go: [ '1.21', '1.22' ] + runs-on: ubuntu-latest + name: Go ${{ matrix.go }} unsupported test + steps: + - name: Update package index + run: sudo apt-get update + + - name: install qemu + run: sudo apt install --yes qemu-user-static + + - name: Set up Go 1.x + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go }} + + - name: Check out code into the Go module directory + uses: actions/checkout@v3 + + - name: Get dependencies + run: go get -v -t -d ./... + + - name: Build + run: GOARCH=riscv64 go build -v ./... + + - name: Test + run: | + GOARCH=riscv64 go test -v ./... -c -o test.riscv64 + qemu-riscv64-static test.riscv64 -test.v diff --git a/LICENSE b/LICENSE index 8d967ce..b6060be 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 Prysmatic Labs +Copyright (c) 2022-2025 Prysmatic Labs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/hash.go b/hash.go index e009335..9c432e6 100644 --- a/hash.go +++ b/hash.go @@ -1,7 +1,7 @@ /* MIT License -# Copyright (c) 2021 Prysmatic Labs +# Copyright (c) 2021-2025 Prysmatic Labs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -28,8 +28,6 @@ import ( "unsafe" ) -func _hash(digests *byte, p [][32]byte, count uint32) - // Hash hashes the chunks two at the time and outputs the digests on the first // argument. It does check for lengths on the inputs. func Hash(digests [][32]byte, chunks [][32]byte) error { diff --git a/hash_amd64.go b/hash_amd64.go index 7b53fcd..d39f04b 100644 --- a/hash_amd64.go +++ b/hash_amd64.go @@ -4,7 +4,7 @@ /* MIT License -Copyright (c) 2021 Prysmatic Labs +Copyright (c) 2021-2025 Prysmatic Labs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -34,3 +34,5 @@ var hasAVX512 = cpuid.CPU.Supports(cpuid.AVX512F, cpuid.AVX512VL) var hasAVX2 = cpuid.CPU.Supports(cpuid.AVX2, cpuid.BMI2) var hasShani = cpuid.CPU.Supports(cpuid.SHA, cpuid.AVX) var supportedCPU = hasAVX2 || hasShani || hasAVX512 + +func _hash(digests *byte, p [][32]byte, count uint32) diff --git a/hash_arm64.go b/hash_arm64.go index ef86819..b54d0a5 100644 --- a/hash_arm64.go +++ b/hash_arm64.go @@ -4,7 +4,7 @@ /* MIT License -Copyright (c) 2021 Prysmatic Labs +Copyright (c) 2021-2025 Prysmatic Labs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -32,3 +32,5 @@ import ( var hasShani = cpuid.CPU.Supports(cpuid.SHA2) var supportedCPU = true + +func _hash(digests *byte, p [][32]byte, count uint32) diff --git a/hash_unsupported.go b/hash_unsupported.go new file mode 100644 index 0000000..8db57c2 --- /dev/null +++ b/hash_unsupported.go @@ -0,0 +1,30 @@ +//go:build !amd64 && !arm64 + +/* +MIT License + +Copyright (c) 2025 Prysmatic Labs + +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: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +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. +*/ +package gohashtree + +var supportedCPU = false + +func _hash(digests *byte, p [][32]byte, count uint32) {}