Skip to content

Commit

Permalink
Merge pull request #8 from hemilabs/clayton/ensure-return
Browse files Browse the repository at this point in the history
HVM Phase 0
  • Loading branch information
ClaytonNorthey92 authored Feb 5, 2025
2 parents 3085fb4 + 7d64fbf commit 4ab38c7
Show file tree
Hide file tree
Showing 90 changed files with 14,482 additions and 13,569 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name: "Docker"
on:
push:
branches:
- main
- hemi

concurrency:
group: "docker-${{ github.workflow }}-${{ github.event.number || github.ref }}"
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ require (
github.com/hashicorp/golang-lru/v2 v2.0.5
github.com/hashicorp/raft v1.6.1
github.com/hashicorp/raft-boltdb v0.0.0-20231211162105-6c830fa4535e
github.com/hemilabs/heminetwork v0.2.0
github.com/hemilabs/heminetwork v0.2.7-hom3.2
github.com/holiman/uint256 v1.2.4
github.com/ipfs/go-datastore v0.6.0
github.com/ipfs/go-ds-leveldb v0.5.0
Expand Down Expand Up @@ -268,4 +268,4 @@ exclude (

)

replace github.com/ethereum/go-ethereum v1.13.5 => github.com/hemilabs/op-geth v1.14.1
replace github.com/ethereum/go-ethereum v1.13.5 => github.com/hemilabs/op-geth v1.101308.0-synctest.0.0.20240723043418-7c28a6901964
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ github.com/hashicorp/raft v1.6.1 h1:v/jm5fcYHvVkL0akByAp+IDdDSzCNCGhdO6VdB56HIM=
github.com/hashicorp/raft v1.6.1/go.mod h1:N1sKh6Vn47mrWvEArQgILTyng8GoDRNYlgKyK7PMjs0=
github.com/hashicorp/raft-boltdb v0.0.0-20231211162105-6c830fa4535e h1:SK4y8oR4ZMHPvwVHryKI88kJPJda4UyWYvG5A6iEQxc=
github.com/hashicorp/raft-boltdb v0.0.0-20231211162105-6c830fa4535e/go.mod h1:EMz/UIuG93P0MBeHh6CbXQAEe8ckVJLZjhD17lBzK5Q=
github.com/hemilabs/op-geth v1.14.1 h1:wWG7twTtFHcZlnnni3jq+LCoOPFaB9suwRIJnC2zADc=
github.com/hemilabs/op-geth v1.14.1/go.mod h1:C3O7ZM3VseOr8qIzLJrrlkfU7tG88Xn/cz60bAdoIWM=
github.com/hemilabs/op-geth v1.101308.0-synctest.0.0.20240723043418-7c28a6901964 h1:PC5Xk+1aeUlAcitCjFi8XJ13iiuJXbOth4D2ch5FQ6k=
github.com/hemilabs/op-geth v1.101308.0-synctest.0.0.20240723043418-7c28a6901964/go.mod h1:pmTbz2wV1/2HyhYbrBXSDnDrkYhcr0a6KbwP5YB6fJQ=
github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 h1:3JQNjnMRil1yD0IfZKHF9GxxWKDJGj8I0IqOUol//sw=
github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc=
github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
Expand Down
3 changes: 3 additions & 0 deletions heminetwork/.github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@

# WASM PoP Miner (popmd/wasm)
/web/ @hemilabs/dev @joshuasing

# Release script
/scripts/release.sh @hemilabs/dev @joshuasing
80 changes: 80 additions & 0 deletions heminetwork/.github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Copyright (c) 2024 Hemi Labs, Inc.
# Use of this source code is governed by the MIT License,
# which can be found in the LICENSE file.

# Bitcoin Finality Governor (BFG)
'area: bfg':
- changed-files:
- any-glob-to-any-file:
- "api/bfgapi/**"
- "cmd/bfgd/**"
- "database/bfgd/**"
- "docker/bfgd/**"
- "service/bfg/**"

# Bitcoin Secure Sequencer (BSS)
'area: bss':
- changed-files:
- any-glob-to-any-file:
- "api/bssapi/**"
- "cmd/bssd/**"
- "docker/bssd/**"
- "service/bss/**"

# GitHub Actions workflows (CI)
'area: ci':
- changed-files:
- any-glob-to-any-file:
- ".github/workflows/**"

# Deucalion (Prometheus service)
'area: deucalion':
- changed-files:
- any-glob-to-any-file:
- "service/deucalion/**"

# Docker images
'area: docker':
- changed-files:
- any-glob-to-any-file:
- "docker/**"

# hemictl
'area: hemictl':
- changed-files:
- any-glob-to-any-file:
- "cmd/hemictl/**"

# @hemilabs/pop-miner NPM package
'area: @hemilabs/pop-miner':
- changed-files:
- any-glob-to-any-file:
- "web/packages/pop-miner/**"

# Makefiles
'area: make':
- changed-files:
- any-glob-to-any-file: "**/Makefile"

# WebAssembly PoP Miner
'area: popm/wasm':
- changed-files:
- any-glob-to-any-file:
- "web/popminer/**"

# PoP Miner
'area: popm':
- changed-files:
- any-glob-to-any-file:
- "cmd/popmd/**"
- "docker/popmd/**"
- "service/popm/**"

# Tiny Bitcoin Daemon (TBC)
'area: tbc':
- changed-files:
- any-glob-to-any-file:
- "api/tbcapi/**"
- "cmd/tbcd/**"
- "database/tbcd/**"
- "service/tbc/**"
25 changes: 17 additions & 8 deletions heminetwork/.github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,32 @@ jobs:
cache: true
check-latest: true

- name: "Retrieve GOPATH"
id: retrieve
run: echo "GOPATH=$(go env GOPATH)" >> "$GITHUB_OUTPUT"

- name: "Setup GOPATH/bin cache"
uses: actions/cache@v4
with:
path: "${{ steps.retrieve.outputs.GOPATH }}/bin/"
key: "${{ runner.os }}-${{ runner.arch }}-gobin-go${{ env.GO_VERSION }}-${{ hashFiles('**/Makefile') }}"
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-gobin-go${{ env.GO_VERSION }}-${{ hashFiles('**/Makefile') }}
${{ runner.os }}-${{ runner.arch }}-gobin-go${{ env.GO_VERSION }}-
${{ runner.os }}-${{ runner.arch }}-gobin-
- name: "Download and verify dependencies"
id: deps
run: make deps
run: make GOCACHE="$(go env GOCACHE)" deps

- name: "make race"
run: make race
run: make GOCACHE="$(go env GOCACHE)" race

- name: "make"
if: (success() || failure()) && steps.deps.outcome == 'success'
env:
PGTESTURI: "postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable"
HEMI_DOCKER_TESTS: "1"
run: |
make
make GOCACHE="$(go env GOCACHE)"
git diff --exit-code
- name: "make web popm"
if: (success() || failure()) && steps.deps.outcome == 'success'
run: |
cd web && make
18 changes: 18 additions & 0 deletions heminetwork/.github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) 2024 Hemi Labs, Inc.
# Use of this source code is governed by the MIT License,
# which can be found in the LICENSE file.

# GitHub Actions workflow to automatically label pull requests.
name: "Label"
on: [ "pull_request_target" ]

jobs:
labeler:
name: "Pull Request"
runs-on: "ubuntu-latest"
permissions:
contents: read
pull-requests: write
steps:
- name: "Label pull requests"
uses: actions/labeler@v5
72 changes: 72 additions & 0 deletions heminetwork/.github/workflows/node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Copyright (c) 2024 Hemi Labs, Inc.
# Use of this source code is governed by the MIT License,
# which can be found in the LICENSE file.

# GitHub Actions workflow to lint, build and test NPM packages.
name: "Node"
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
workflow_call:

concurrency:
group: "node-${{ github.workflow }}-${{ github.event.number || github.ref }}"
cancel-in-progress: "${{ github.event_name == 'pull_request' }}"

env:
GO_VERSION: "1.22.x"
PNPM_VERSION: "9.4.x"

jobs:
build:
name: "Build"
runs-on: "ubuntu-latest"
permissions:
contents: read
steps:
- name: "Checkout repository"
uses: actions/checkout@v4

- name: "Setup Go ${{ env.GO_VERSION }}"
uses: actions/setup-go@v5
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
check-latest: true

- name: "Setup pnpm ${{ env.PNPM_VERSION }}"
uses: pnpm/action-setup@v4
with:
version: "${{ env.PNPM_VERSION }}"

- name: "Setup Node"
uses: actions/setup-node@v4
with:
node-version-file: "web/.nvmrc"
check-latest: true
cache: "pnpm"
cache-dependency-path: "web/**/pnpm-lock.yaml"

- name: "Install dependencies"
working-directory: "web/"
run: pnpm install --frozen-lockfile

- name: "Install Go dependencies"
working-directory: "web/"
run: make deps

# TODO(joshuasing): Install and use binaryen
- name: "Build @hemilabs/pop-miner WebAssembly binary"
working-directory: "web/"
run: make wasm

- name: "Build @hemilabs/pop-miner package"
working-directory: "web/"
run: pnpm build:pop-miner

- name: "Lint"
working-directory: "web/"
run: pnpm lint
83 changes: 80 additions & 3 deletions heminetwork/.github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ on:
type: boolean
required: true
default: false
npm:
description: "Publish NPM packages"
type: boolean
required: true
default: false
release:
description: "Create GitHub release and publish Docker images"
type: boolean
Expand All @@ -31,9 +36,11 @@ concurrency:

env:
GO_VERSION: "1.22.x"
PNPM_VERSION: "9.4.x"

jobs:
# Run tests
# TODO(joshuasing): run PoP Miner / NPM package tests once added
test:
name: "Test"
uses: ./.github/workflows/go.yml
Expand Down Expand Up @@ -97,15 +104,15 @@ jobs:
check-latest: true

- name: "Download and verify dependencies"
run: make deps
run: make GOCACHE="$(go env GOCACHE)" go-deps

- name: "Create binary archive for ${{ matrix.goos }}/${{ matrix.goarch }}"
env:
GOOS: "${{ matrix.goos }}"
GOARCH: "${{ matrix.goarch }}"
CGO_ENABLED: 0 # Disable CGO.
GOGC: off # Disable GC during build, faster but uses more RAM.
run: make archive
run: make GOCACHE="$(go env GOCACHE)" archive

- name: "Upload artifacts"
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -181,11 +188,81 @@ jobs:
ghcr.io/hemilabs/${{ matrix.service }}:latest
ghcr.io/hemilabs/${{ matrix.service }}:${{ needs.prepare.outputs.tag }}
# Publish NPM packages
npm:
name: "npm"
runs-on: "ubuntu-latest"
if: github.event_name == 'push' || inputs.npm
needs: [ "prepare" ]
permissions:
contents: read
steps:
- name: "Checkout repository"
uses: actions/checkout@v4

- name: "Setup Go ${{ env.GO_VERSION }}"
uses: actions/setup-go@v5
with:
go-version: "${{ env.GO_VERSION }}"
cache: true
check-latest: true

- name: "Setup pnpm ${{ env.PNPM_VERSION }}"
uses: pnpm/action-setup@v4
with:
version: "${{ env.PNPM_VERSION }}"

- name: "Setup Node"
uses: actions/setup-node@v4
with:
node-version-file: "web/.nvmrc"
check-latest: true
cache: "pnpm"
cache-dependency-path: "web/**/pnpm-lock.yaml"
registry-url: "https://registry.npmjs.org"

- name: "Install dependencies"
working-directory: "web/"
run: pnpm install --frozen-lockfile

- name: "Install Go dependencies"
working-directory: "web/"
run: make deps

- name: "Set package.json versions"
working-directory: "web/"
env:
VERSION: "${{ needs.prepare.outputs.version }}"
run: |
# Prints all package.json files
PACKAGE_FILES=$(find . -path '**/node_modules' -prune -o -name 'package.json' -print)
for file in $PACKAGE_FILES; do
# Set "version" in package.json file to $VERSION.
TMP_FILE="$(mktemp)"
jq --arg v "$VERSION" '.version = $v' "$file" > "$TMP_FILE"
mv "$TMP_FILE" "$file"
done
# TODO(joshuasing): Install and use binaryen
- name: "Build @hemilabs/pop-miner WebAssembly binary"
working-directory: "web/"
run: make wasm

- name: "Build @hemilabs/pop-miner package"
working-directory: "web/"
run: pnpm build:pop-miner

- name: "Publish @hemilabs/pop-miner package"
working-directory: "web/"
run: pnpm publish packages/pop-miner --access public --no-git-checks
env:
NODE_AUTH_TOKEN: "${{ secrets.NPM_TOKEN }}"

# Create GitHub Release
release:
name: "Release"
runs-on: "ubuntu-latest"
needs: [ "prepare", "build", "docker" ]
needs: [ "prepare", "build", "docker", "npm" ]
permissions:
# Permission to write contents is required to create GitHub releases.
# Builds are performed in a separate job with more restrictive permissions
Expand Down
Loading

0 comments on commit 4ab38c7

Please sign in to comment.