Skip to content

Commit 4ae02f0

Browse files
ImJeremyHesveitser
andauthored
Add go-sdk (#3281)
* Add go environment * Add go clients * Add light-client-mock and to command to generate bindings * Add crypto helper and go verification module * Add download module * Fix multiple nodes client * Lint * fix: build on linux - The lib extension is .so - Enable build without --release. * Fix types tests * Fix multiple nodes client test * Add go sdk test ci * Add build-crypto-helper workflow * Fix CI * TmpDir * Increase time limit * Wait for Espresso * Fix lock file * Add timeout * Availability * Lint and typo * Multi nodes client * CI: go-sdk test, use cachix * remove unused goVersion variable * Update .github/workflows/build-crypto-helper.yml Co-authored-by: Mathis <[email protected]> * Address comments * Remove openssl * Revert removing openssl dependency * Update go version to match the default value --------- Co-authored-by: sveitser <[email protected]>
1 parent 8fd2ac7 commit 4ae02f0

Some content is hidden

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

55 files changed

+10404
-86
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Build Crypto Helper Library
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "go-v*.*.*"
9+
pull_request:
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
name: Build Crypto Helper Library
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
- target: x86_64-unknown-linux-gnu
20+
runner: ubuntu-latest
21+
- target: aarch64-unknown-linux-gnu
22+
runner: ubuntu-latest
23+
- target: aarch64-apple-darwin
24+
runner: macos-latest
25+
- target: x86_64-apple-darwin
26+
runner: macos-latest
27+
28+
runs-on: ${{ matrix.runner }}
29+
30+
steps:
31+
- name: Checkout Repository
32+
uses: actions/checkout@v4
33+
34+
- name: Install Rust
35+
uses: dtolnay/rust-toolchain@stable
36+
with:
37+
toolchain: "1.81.0"
38+
targets: ${{ matrix.target }}
39+
40+
- name: Add Rust target
41+
run: rustup target add ${{ matrix.target }}
42+
43+
- name: Set Environment
44+
# Install tools and set environment variables like this example
45+
# https://github.com/briansmith/ring/blob/main/mk/cargo.sh
46+
# https://github.com/briansmith/ring/blob/main/mk/install-build-tools.sh
47+
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
48+
run: |
49+
sudo apt update
50+
sudo apt-get install qemu-user gcc-aarch64-linux-gnu libc6-dev-arm64-cross
51+
echo CFLAGS_aarch64_unknown_linux_gnu="--sysroot=/usr/aarch64-linux-gnu" >> ${{ github.env }}
52+
echo CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc >> ${{ github.env }}
53+
echo CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-aarch64 -L /usr/aarch64-linux-gnu" >> ${{ github.env }}
54+
55+
- name: Build
56+
run: |
57+
echo "Building for target: ${{ matrix.target }}"
58+
if [ "$(uname -s)" != "Darwin" ]; then
59+
export LD_LIBRARY_PATH="$PWD/target/lib:$LD_LIBRARY_PATH"
60+
fi
61+
mkdir -p target/lib && \
62+
cargo build --release --locked --target ${{ matrix.target }} --manifest-path ./sdks/crypto-helper/Cargo.toml && \
63+
if [ "$(uname -s)" == "Darwin" ]; then
64+
cp ./target/${{ matrix.target }}/release/libespresso_crypto_helper.dylib target/lib/libespresso_crypto_helper-${{ matrix.target }}.dylib
65+
shasum -a 256 target/lib/libespresso_crypto_helper-${{ matrix.target }}.dylib | awk '{print $1}' > target/lib/libespresso_crypto_helper-${{ matrix.target }}.dylib.sha256
66+
else
67+
cp ./target/${{ matrix.target }}/release/libespresso_crypto_helper.so target/lib/libespresso_crypto_helper-${{ matrix.target }}.so
68+
shasum -a 256 target/lib/libespresso_crypto_helper-${{ matrix.target }}.so | awk '{print $1}' > target/lib/libespresso_crypto_helper-${{ matrix.target }}.so.sha256
69+
fi
70+
71+
- name: Upload Artifact
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: libespresso_crypto_helper-${{ matrix.target }}.${{ contains(matrix.target, 'apple-darwin') && 'dylib' || 'so' }}
75+
path: |
76+
target/lib/libespresso_crypto_helper-${{ matrix.target }}.${{ contains(matrix.target, 'apple-darwin') && 'dylib' || 'so' }}
77+
78+
- name: Upload sha256 files
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: libespresso_crypto_helper-${{ matrix.target }}.${{ contains(matrix.target, 'apple-darwin') && 'dylib' || 'so' }}.sha256
82+
path: |
83+
target/lib/libespresso_crypto_helper-${{ matrix.target }}.${{ contains(matrix.target, 'apple-darwin') && 'dylib' || 'so' }}.sha256
84+
85+
release:
86+
name: Upload Release Artifacts
87+
runs-on: ubuntu-latest
88+
needs: build
89+
90+
steps:
91+
- name: Checkout repository
92+
uses: actions/checkout@v4
93+
94+
- name: Download all Artifacts
95+
uses: actions/download-artifact@v4
96+
with:
97+
path: target/lib
98+
99+
- name: Release
100+
uses: softprops/action-gh-release@v2
101+
if: startsWith(github.ref, 'refs/tags/')
102+
with:
103+
files: |
104+
target/lib/*/*.dylib
105+
target/lib/*/*.so
106+
target/lib/*/*.dylib.sha256
107+
target/lib/*/*.so.sha256

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ jobs:
6464
# Build in release without `testing` feature, this should work without `hotshot_example` config.
6565
run: |
6666
cargo build --locked --release --workspace
67-
68-
- name: Build sequencer-sqlite
67+
68+
- name: Build sequencer-sqlite
6969
run: cargo build --locked --release --manifest-path ./sequencer-sqlite/Cargo.toml --target-dir ./target
7070

7171
- name: Build Espresso Dev Node
@@ -100,7 +100,7 @@ jobs:
100100
run: |
101101
cargo build --locked --release --workspace
102102
103-
- name: Build sequencer-sqlite
103+
- name: Build sequencer-sqlite
104104
run: cargo build --locked --release --manifest-path ./sequencer-sqlite/Cargo.toml --target-dir ./target
105105

106106
- name: Build Espresso Dev Node

.github/workflows/test.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,33 @@ jobs:
264264
--partition hash:${{ matrix.partition }}/10
265265
timeout-minutes: 20
266266

267+
test-go-sdk:
268+
needs: build-test-bins
269+
runs-on: ubuntu-latest
270+
steps:
271+
- name: Install Nix
272+
uses: cachix/install-nix-action@v31
273+
274+
- name: Enable Cachix
275+
uses: cachix/cachix-action@v16
276+
# If PR is from a non-collaborator (e. g. dependabot) the secrets are missing and the login to cachix fails.
277+
continue-on-error: true
278+
with:
279+
name: espresso-systems-private
280+
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
281+
extraPullNames: nix-community
282+
skipPush: ${{ github.actor == 'dependabot[bot]' }}
283+
284+
- uses: actions/checkout@v4
285+
286+
- name: Build verification module
287+
run: |
288+
nix develop --accept-flake-config -c just build-go-crypto-helper
289+
290+
- name: Test
291+
run: |
292+
nix develop --accept-flake-config -c just test-go
293+
267294
test-integration:
268295
needs: [build-test-bins, build-test-bins-sqlite, build-test-artifacts-postgres]
269296
strategy:

.typos.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ extend-exclude = [
1313
"crates/hotshot/orchestrator/run-config.toml",
1414
"crates/hotshot/macros/src/lib.rs",
1515
"staking-cli/tests/cli.rs",
16+
"sdks/go/types/common/consts.go",
1617
]

0 commit comments

Comments
 (0)