Skip to content

Commit 0f52e37

Browse files
Squashed 'heminetwork/' changes from 526787acd..c9dbc5f58
c9dbc5f58 Test fix & fmt fcf735497 ExternalHeaderMode rebase f09d4e5ff Add for wind/unwind support to tbc (ethereum-optimism#159) 5c764a0cd popm: exclude tx outputs that would be dust (ethereum-optimism#186) 1f168f225 popm/wasm: fix dispatch params for {add,remove}EventListener (ethereum-optimism#181) 383611feb popm/wasm: add 'minerStatus' method (ethereum-optimism#178) 6a94b4c0b popm/wasm: rename KeyResult fields and add bitcoinScriptHash (ethereum-optimism#177) 9c4cea583 popm/wasm: add events and clean up globals (ethereum-optimism#175) a2372394d popm: improve UTXO selection when creating Bitcoin transaction (ethereum-optimism#173) 939813cac popm/wasm: fix ethereum address when generating and parsing keys (ethereum-optimism#174) 9245995ef Updated localnet to use more recent commits of optimism and op-geth (ethereum-optimism#139) 159fbc5f5 ci: improve runtime of high usage CI workflows (ethereum-optimism#163) 60a3489db popm/wasm: add 'bitcoinAddressToScriptHash' method (ethereum-optimism#169) fe9752a5a popm/wasm: add 'parseKey' method (ethereum-optimism#168) 65aa0caef ci: add registry-url to setup-node in release (ethereum-optimism#167) 8922ce805 popm/wasm: add new @hemilabs/pop-miner NPM package (ethereum-optimism#162) 67166046b scripts: add release script (ethereum-optimism#164) eea96059b ci: add labeler action (ethereum-optimism#165) git-subtree-dir: heminetwork git-subtree-split: c9dbc5f58a7f997fa4b3af0d765a2967ed3462d1
1 parent 3a9e8d7 commit 0f52e37

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+14456
-14718
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@
3232

3333
# WASM PoP Miner (popmd/wasm)
3434
/web/ @hemilabs/dev @joshuasing
35+
36+
# Release script
37+
/scripts/release.sh @hemilabs/dev @joshuasing

.github/labeler.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Copyright (c) 2024 Hemi Labs, Inc.
2+
# Use of this source code is governed by the MIT License,
3+
# which can be found in the LICENSE file.
4+
5+
# Bitcoin Finality Governor (BFG)
6+
'area: bfg':
7+
- changed-files:
8+
- any-glob-to-any-file:
9+
- "api/bfgapi/**"
10+
- "cmd/bfgd/**"
11+
- "database/bfgd/**"
12+
- "docker/bfgd/**"
13+
- "service/bfg/**"
14+
15+
# Bitcoin Secure Sequencer (BSS)
16+
'area: bss':
17+
- changed-files:
18+
- any-glob-to-any-file:
19+
- "api/bssapi/**"
20+
- "cmd/bssd/**"
21+
- "docker/bssd/**"
22+
- "service/bss/**"
23+
24+
# GitHub Actions workflows (CI)
25+
'area: ci':
26+
- changed-files:
27+
- any-glob-to-any-file:
28+
- ".github/workflows/**"
29+
30+
# Deucalion (Prometheus service)
31+
'area: deucalion':
32+
- changed-files:
33+
- any-glob-to-any-file:
34+
- "service/deucalion/**"
35+
36+
# Docker images
37+
'area: docker':
38+
- changed-files:
39+
- any-glob-to-any-file:
40+
- "docker/**"
41+
42+
# hemictl
43+
'area: hemictl':
44+
- changed-files:
45+
- any-glob-to-any-file:
46+
- "cmd/hemictl/**"
47+
48+
# @hemilabs/pop-miner NPM package
49+
'area: @hemilabs/pop-miner':
50+
- changed-files:
51+
- any-glob-to-any-file:
52+
- "web/packages/pop-miner/**"
53+
54+
# Makefiles
55+
'area: make':
56+
- changed-files:
57+
- any-glob-to-any-file: "**/Makefile"
58+
59+
# WebAssembly PoP Miner
60+
'area: popm/wasm':
61+
- changed-files:
62+
- any-glob-to-any-file:
63+
- "web/popminer/**"
64+
65+
# PoP Miner
66+
'area: popm':
67+
- changed-files:
68+
- any-glob-to-any-file:
69+
- "cmd/popmd/**"
70+
- "docker/popmd/**"
71+
- "service/popm/**"
72+
73+
# Tiny Bitcoin Daemon (TBC)
74+
'area: tbc':
75+
- changed-files:
76+
- any-glob-to-any-file:
77+
- "api/tbcapi/**"
78+
- "cmd/tbcd/**"
79+
- "database/tbcd/**"
80+
- "service/tbc/**"

.github/workflows/go.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,32 @@ jobs:
4949
cache: true
5050
check-latest: true
5151

52+
- name: "Retrieve GOPATH"
53+
id: retrieve
54+
run: echo "GOPATH=$(go env GOPATH)" >> "$GITHUB_OUTPUT"
55+
56+
- name: "Setup GOPATH/bin cache"
57+
uses: actions/cache@v4
58+
with:
59+
path: "${{ steps.retrieve.outputs.GOPATH }}/bin/"
60+
key: "${{ runner.os }}-${{ runner.arch }}-gobin-go${{ env.GO_VERSION }}-${{ hashFiles('**/Makefile') }}"
61+
restore-keys: |
62+
${{ runner.os }}-${{ runner.arch }}-gobin-go${{ env.GO_VERSION }}-${{ hashFiles('**/Makefile') }}
63+
${{ runner.os }}-${{ runner.arch }}-gobin-go${{ env.GO_VERSION }}-
64+
${{ runner.os }}-${{ runner.arch }}-gobin-
65+
5266
- name: "Download and verify dependencies"
5367
id: deps
54-
run: make deps
68+
run: make GOCACHE="$(go env GOCACHE)" deps
5569

5670
- name: "make race"
57-
run: make race
71+
run: make GOCACHE="$(go env GOCACHE)" race
5872

5973
- name: "make"
6074
if: (success() || failure()) && steps.deps.outcome == 'success'
6175
env:
6276
PGTESTURI: "postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable"
6377
HEMI_DOCKER_TESTS: "1"
6478
run: |
65-
make
79+
make GOCACHE="$(go env GOCACHE)"
6680
git diff --exit-code
67-
68-
- name: "make web popm"
69-
if: (success() || failure()) && steps.deps.outcome == 'success'
70-
run: |
71-
cd web && make

.github/workflows/labeler.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) 2024 Hemi Labs, Inc.
2+
# Use of this source code is governed by the MIT License,
3+
# which can be found in the LICENSE file.
4+
5+
# GitHub Actions workflow to automatically label pull requests.
6+
name: "Label"
7+
on: [ "pull_request_target" ]
8+
9+
jobs:
10+
labeler:
11+
name: "Pull Request"
12+
runs-on: "ubuntu-latest"
13+
permissions:
14+
contents: read
15+
pull-requests: write
16+
steps:
17+
- name: "Label pull requests"
18+
uses: actions/labeler@v5

.github/workflows/node.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Copyright (c) 2024 Hemi Labs, Inc.
2+
# Use of this source code is governed by the MIT License,
3+
# which can be found in the LICENSE file.
4+
5+
# GitHub Actions workflow to lint, build and test NPM packages.
6+
name: "Node"
7+
on:
8+
push:
9+
branches: [ "main" ]
10+
pull_request:
11+
branches: [ "main" ]
12+
workflow_dispatch:
13+
workflow_call:
14+
15+
concurrency:
16+
group: "node-${{ github.workflow }}-${{ github.event.number || github.ref }}"
17+
cancel-in-progress: "${{ github.event_name == 'pull_request' }}"
18+
19+
env:
20+
GO_VERSION: "1.22.x"
21+
PNPM_VERSION: "9.4.x"
22+
23+
jobs:
24+
build:
25+
name: "Build"
26+
runs-on: "ubuntu-latest"
27+
permissions:
28+
contents: read
29+
steps:
30+
- name: "Checkout repository"
31+
uses: actions/checkout@v4
32+
33+
- name: "Setup Go ${{ env.GO_VERSION }}"
34+
uses: actions/setup-go@v5
35+
with:
36+
go-version: "${{ env.GO_VERSION }}"
37+
cache: true
38+
check-latest: true
39+
40+
- name: "Setup pnpm ${{ env.PNPM_VERSION }}"
41+
uses: pnpm/action-setup@v4
42+
with:
43+
version: "${{ env.PNPM_VERSION }}"
44+
45+
- name: "Setup Node"
46+
uses: actions/setup-node@v4
47+
with:
48+
node-version-file: "web/.nvmrc"
49+
check-latest: true
50+
cache: "pnpm"
51+
cache-dependency-path: "web/**/pnpm-lock.yaml"
52+
53+
- name: "Install dependencies"
54+
working-directory: "web/"
55+
run: pnpm install --frozen-lockfile
56+
57+
- name: "Install Go dependencies"
58+
working-directory: "web/"
59+
run: make deps
60+
61+
# TODO(joshuasing): Install and use binaryen
62+
- name: "Build @hemilabs/pop-miner WebAssembly binary"
63+
working-directory: "web/"
64+
run: make wasm
65+
66+
- name: "Build @hemilabs/pop-miner package"
67+
working-directory: "web/"
68+
run: pnpm build:pop-miner
69+
70+
- name: "Lint"
71+
working-directory: "web/"
72+
run: pnpm lint

.github/workflows/release.yml

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ on:
1919
type: boolean
2020
required: true
2121
default: false
22+
npm:
23+
description: "Publish NPM packages"
24+
type: boolean
25+
required: true
26+
default: false
2227
release:
2328
description: "Create GitHub release and publish Docker images"
2429
type: boolean
@@ -31,9 +36,11 @@ concurrency:
3136

3237
env:
3338
GO_VERSION: "1.22.x"
39+
PNPM_VERSION: "9.4.x"
3440

3541
jobs:
3642
# Run tests
43+
# TODO(joshuasing): run PoP Miner / NPM package tests once added
3744
test:
3845
name: "Test"
3946
uses: ./.github/workflows/go.yml
@@ -97,15 +104,15 @@ jobs:
97104
check-latest: true
98105

99106
- name: "Download and verify dependencies"
100-
run: make deps
107+
run: make GOCACHE="$(go env GOCACHE)" go-deps
101108

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

110117
- name: "Upload artifacts"
111118
uses: actions/upload-artifact@v4
@@ -181,11 +188,81 @@ jobs:
181188
ghcr.io/hemilabs/${{ matrix.service }}:latest
182189
ghcr.io/hemilabs/${{ matrix.service }}:${{ needs.prepare.outputs.tag }}
183190
191+
# Publish NPM packages
192+
npm:
193+
name: "npm"
194+
runs-on: "ubuntu-latest"
195+
if: github.event_name == 'push' || inputs.npm
196+
needs: [ "prepare" ]
197+
permissions:
198+
contents: read
199+
steps:
200+
- name: "Checkout repository"
201+
uses: actions/checkout@v4
202+
203+
- name: "Setup Go ${{ env.GO_VERSION }}"
204+
uses: actions/setup-go@v5
205+
with:
206+
go-version: "${{ env.GO_VERSION }}"
207+
cache: true
208+
check-latest: true
209+
210+
- name: "Setup pnpm ${{ env.PNPM_VERSION }}"
211+
uses: pnpm/action-setup@v4
212+
with:
213+
version: "${{ env.PNPM_VERSION }}"
214+
215+
- name: "Setup Node"
216+
uses: actions/setup-node@v4
217+
with:
218+
node-version-file: "web/.nvmrc"
219+
check-latest: true
220+
cache: "pnpm"
221+
cache-dependency-path: "web/**/pnpm-lock.yaml"
222+
registry-url: "https://registry.npmjs.org"
223+
224+
- name: "Install dependencies"
225+
working-directory: "web/"
226+
run: pnpm install --frozen-lockfile
227+
228+
- name: "Install Go dependencies"
229+
working-directory: "web/"
230+
run: make deps
231+
232+
- name: "Set package.json versions"
233+
working-directory: "web/"
234+
env:
235+
VERSION: "${{ needs.prepare.outputs.version }}"
236+
run: |
237+
# Prints all package.json files
238+
PACKAGE_FILES=$(find . -path '**/node_modules' -prune -o -name 'package.json' -print)
239+
for file in $PACKAGE_FILES; do
240+
# Set "version" in package.json file to $VERSION.
241+
TMP_FILE="$(mktemp)"
242+
jq --arg v "$VERSION" '.version = $v' "$file" > "$TMP_FILE"
243+
mv "$TMP_FILE" "$file"
244+
done
245+
246+
# TODO(joshuasing): Install and use binaryen
247+
- name: "Build @hemilabs/pop-miner WebAssembly binary"
248+
working-directory: "web/"
249+
run: make wasm
250+
251+
- name: "Build @hemilabs/pop-miner package"
252+
working-directory: "web/"
253+
run: pnpm build:pop-miner
254+
255+
- name: "Publish @hemilabs/pop-miner package"
256+
working-directory: "web/"
257+
run: pnpm publish packages/pop-miner --access public --no-git-checks
258+
env:
259+
NODE_AUTH_TOKEN: "${{ secrets.NPM_TOKEN }}"
260+
184261
# Create GitHub Release
185262
release:
186263
name: "Release"
187264
runs-on: "ubuntu-latest"
188-
needs: [ "prepare", "build", "docker" ]
265+
needs: [ "prepare", "build", "docker", "npm" ]
189266
permissions:
190267
# Permission to write contents is required to create GitHub releases.
191268
# Builds are performed in a separate job with more restrictive permissions

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ cmds = \
2828
popmd \
2929
tbcd
3030

31-
.PHONY: all clean clean-dist deps $(cmds) build install lint lint-deps tidy race test vulncheck \
31+
.PHONY: all clean clean-dist deps go-deps $(cmds) build install lint lint-deps tidy race test vulncheck \
3232
vulncheck-deps dist archive sources checksums
3333

3434
all: lint tidy test build install
@@ -42,7 +42,9 @@ clean-dist:
4242
clean-test:
4343
rm -rf $(PROJECTPATH)/service/tbc/.testleveldb/
4444

45-
deps: lint-deps vulncheck-deps
45+
deps: lint-deps vulncheck-deps go-deps
46+
47+
go-deps:
4648
go mod download
4749
go mod verify
4850

@@ -58,7 +60,8 @@ lint:
5860
$(shell go env GOPATH)/bin/goimports -local github.com/hemilabs/heminetwork -w -l .
5961
$(shell go env GOPATH)/bin/gofumpt -w -l .
6062
$(shell go env GOPATH)/bin/addlicense -c "Hemi Labs, Inc." -f $(PROJECTPATH)/license_header.txt \
61-
-ignore "{.idea,.vscode}/**" -ignore ".github/release.yml" -ignore ".github/ISSUE_TEMPLATE/**" .
63+
-ignore "{.idea,.vscode}/**" -ignore ".github/release.yml" -ignore ".github/ISSUE_TEMPLATE/**" \
64+
-ignore "**/pnpm-{lock,workspace}.yaml" -ignore "**/node_modules/**" .
6265
go vet ./...
6366

6467
lint-deps:

api/tbcapi/tbcapi.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ type TxByIdRawRequest struct {
147147

148148
type TxByIdRawResponse struct {
149149
Tx api.ByteSlice `json:"tx"`
150+
Hash api.ByteSlice `json:"hash"`
150151
Error *protocol.Error `json:"error,omitempty"`
151152
}
152153

@@ -156,6 +157,7 @@ type TxByIdRequest struct {
156157

157158
type TxByIdResponse struct {
158159
Tx *Tx `json:"tx"`
160+
Hash api.ByteSlice `json:"hash"`
159161
Error *protocol.Error `json:"error,omitempty"`
160162
}
161163

0 commit comments

Comments
 (0)