Skip to content

Commit 61bf95b

Browse files
committed
Initial commit: Add HyperSDK WASM implementation
0 parents  commit 61bf95b

File tree

599 files changed

+73298
-0
lines changed

Some content is hidden

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

599 files changed

+73298
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "HyperSDK Programs",
3+
"image": "mcr.microsoft.com/devcontainers/base",
4+
"runArgs": ["--network=host"],
5+
6+
"features": {
7+
"ghcr.io/devcontainers/features/go:1": {
8+
"version": "1.22.8"
9+
},
10+
"ghcr.io/devcontainers/features/rust:1": {},
11+
"ghcr.io/devcontainers/features/common-utils:2": {
12+
"configureZshAsDefaultShell": true
13+
}
14+
},
15+
16+
"remoteEnv": {},
17+
18+
"postCreateCommand": {
19+
"install-wasm-target": "rustup target add wasm32-unknown-unknown",
20+
"install-libclang": "sudo apt update && sudo apt install -y libclang-dev"
21+
},
22+
23+
"postStartCommand": {},
24+
25+
"workspaceMount": "source=${localWorkspaceFolder},target=/go/src/github.com/ava-labs/hypersdk,type=bind",
26+
"workspaceFolder": "/go/src/github.com/ava-labs/hypersdk/x/contracts/rust/examples/tutorial",
27+
28+
"customizations": {
29+
"vscode": {
30+
"settings": {
31+
"git.autofetch": true
32+
},
33+
"extensions": ["rust-lang.rust-analyzer", "ms-vsliveshare.vsliveshare"]
34+
}
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "Default Go Environment",
3+
"image": "mcr.microsoft.com/devcontainers/go:1.22-bookworm"
4+
}

.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @aaronbuchwald @joshua-kim

.github/actionlint.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
self-hosted-runner:
2+
labels:
3+
- ubuntu-20.04-32

.github/actions/install-go/action.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: 'Install Go toolchain with defaults'
2+
description: 'Install a go toolchain with defaults'
3+
4+
inputs:
5+
cache:
6+
description: "to cache or not to cache, that is the question"
7+
required: false
8+
default: "true"
9+
cache-dependency-path:
10+
description: "forwards go actions/setup-go"
11+
required: false
12+
13+
14+
runs:
15+
using: composite
16+
steps:
17+
- name: Set up Go
18+
uses: actions/setup-go@v5
19+
with:
20+
go-version: '1.22.8'
21+
cache: ${{ inputs.cache }}
22+
cache-dependency-path: ${{ inputs.cache-dependency-path }}
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: "Install Rust toolchain and Cache"
2+
description: "Install a rust toolchain and cache"
3+
4+
inputs:
5+
targets:
6+
description: "pass targets to the rust-toolchain installer"
7+
required: false
8+
cache:
9+
description: "to cache or not to cache, that is the question"
10+
required: false
11+
default: "true"
12+
13+
runs:
14+
using: composite
15+
steps:
16+
- name: Install Rust
17+
uses: dtolnay/[email protected]
18+
with:
19+
targets: ${{ inputs.targets }}
20+
components: clippy, rustfmt
21+
- if: ${{ inputs.cache == 'true' }}
22+
uses: Swatinem/rust-cache@v2

.github/workflows/codeql-analysis.yml

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Copyright (C) 2023, Ava Labs, Inc. All rights reserved.
2+
# See the file LICENSE for licensing terms.
3+
4+
# For most projects, this workflow file will not need changing; you simply need
5+
# to commit it to your repository.
6+
#
7+
# You may wish to alter this file to override the set of languages analyzed,
8+
# or to provide custom queries or build logic.
9+
#
10+
# ******** NOTE ********
11+
# We have attempted to detect the languages in your repository. Please check
12+
# the `language` matrix defined below to confirm you have the correct set of
13+
# supported CodeQL languages.
14+
#
15+
name: 'CodeQL'
16+
17+
on:
18+
push:
19+
branches: ['main']
20+
pull_request:
21+
# The branches below must be a subset of the branches above
22+
branches: ['main']
23+
schedule:
24+
- cron: '41 18 * * 3'
25+
26+
jobs:
27+
analyze:
28+
name: Analyze
29+
runs-on: ubuntu-latest
30+
permissions:
31+
actions: read
32+
contents: read
33+
security-events: write
34+
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
language: ['go']
39+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
40+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
41+
42+
steps:
43+
- name: Checkout repository
44+
uses: actions/checkout@v4
45+
46+
# Initializes the CodeQL tools for scanning.
47+
- name: Initialize CodeQL
48+
uses: github/codeql-action/init@v2
49+
with:
50+
languages: ${{ matrix.language }}
51+
# If you wish to specify custom queries, you can do so here or in a config file.
52+
# By default, queries listed here will override any specified in a config file.
53+
# Prefix the list here with "+" to use these queries and those in the config file.
54+
55+
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
56+
queries: security-extended,security-and-quality
57+
58+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
59+
# If this step fails, then you should remove it and run the build manually (see below)
60+
- name: Autobuild
61+
uses: github/codeql-action/autobuild@v2
62+
63+
# ℹ️ Command-line programs to run using the OS shell.
64+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
65+
66+
# If the Autobuild fails above, remove it and uncomment the following three lines.
67+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
68+
69+
# - run: |
70+
# echo "Run, Build Application using script"
71+
# ./location_of_script_within_repo/buildscript.sh
72+
73+
- name: Perform CodeQL Analysis
74+
uses: github/codeql-action/analyze@v2
75+
76+
concurrency:
77+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
78+
cancel-in-progress: true

.github/workflows/contracts-ci.yml

+150
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# Copyright (C) 2023, Ava Labs, Inc. All rights reserved.
2+
# See the file LICENSE for licensing terms.
3+
4+
name: Contracts CI
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
cargo-fmt:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
- name: Install Rust
23+
uses: ./.github/actions/install-rust
24+
with:
25+
cache: false
26+
- uses: Swatinem/rust-cache@v2
27+
with:
28+
# we just want to cache the tools for this one
29+
cache-targets: false
30+
# need to cache "all-crates" to get the tools
31+
cache-all-crates: true
32+
# caching isn't actually for dependencies but the tools
33+
# so it doesn't matter if the job passes or fails
34+
cache-on-failure: true
35+
- uses: taiki-e/install-action@v2
36+
with:
37+
tool: taplo-cli
38+
- name: Run static analysis tests
39+
run: cargo fmt --all --check
40+
- name: Check TOML files
41+
run: taplo fmt --check
42+
- name: print diff
43+
if: failure()
44+
run: |
45+
cargo fmt --all
46+
taplo fmt
47+
git diff --color=always
48+
49+
cargo-doc:
50+
runs-on: ubuntu-latest
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v4
54+
- name: Install Go
55+
uses: ./.github/actions/install-go
56+
- name: Install Rust
57+
uses: ./.github/actions/install-rust
58+
with:
59+
targets: wasm32-unknown-unknown
60+
cache: false
61+
- name: Run doc tests
62+
run: RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features --document-private-items --all
63+
64+
cargo-clippy:
65+
runs-on: ubuntu-latest
66+
steps:
67+
- name: Checkout
68+
uses: actions/checkout@v4
69+
- name: Install Go
70+
uses: ./.github/actions/install-go
71+
- name: Install Rust
72+
uses: ./.github/actions/install-rust
73+
with:
74+
targets: wasm32-unknown-unknown
75+
- name: Run static analysis tests
76+
shell: bash
77+
run: cargo clippy --all --all-features --tests --benches --examples -- -D warnings
78+
79+
cargo-test:
80+
runs-on: ubuntu-latest
81+
steps:
82+
- name: Checkout
83+
uses: actions/checkout@v4
84+
- name: Install Go
85+
uses: ./.github/actions/install-go
86+
- name: Install Rust
87+
uses: ./.github/actions/install-rust
88+
with:
89+
targets: wasm32-unknown-unknown
90+
- name: Run unit tests
91+
run: cargo test --all-features --all
92+
93+
cross-tests:
94+
runs-on: ubuntu-latest
95+
services:
96+
docker:
97+
image: docker:19.03.12
98+
options: --privileged
99+
steps:
100+
- name: Checkout
101+
uses: actions/checkout@v4
102+
- name: Install Rust
103+
uses: ./.github/actions/install-rust
104+
- uses: Swatinem/rust-cache@v2
105+
with:
106+
# we just want to cache the tools for this one
107+
cache-targets: false
108+
# need to cache "all-crates" to get the tools
109+
cache-all-crates: true
110+
# caching isn't actually for dependencies but the tools
111+
# so it doesn't matter if the job passes or fails
112+
cache-on-failure: true
113+
- uses: taiki-e/install-action@v2
114+
with:
115+
tool: cross
116+
- name: Run cross tests
117+
run: |
118+
cross -v test -p wasmlanche --target=wasm32-unknown-emscripten
119+
120+
go-test:
121+
runs-on: ubuntu-20.04-32
122+
steps:
123+
- name: Checkout
124+
uses: actions/checkout@v4
125+
- name: Set up Go
126+
uses: ./.github/actions/install-go
127+
- name: Install Rust
128+
uses: ./.github/actions/install-rust
129+
with:
130+
targets: wasm32-unknown-unknown
131+
cache: false
132+
- name: Run unit tests
133+
shell: bash
134+
run: go test -v -race ./x/contracts/...
135+
136+
go-bench:
137+
runs-on: ubuntu-20.04-32
138+
steps:
139+
- name: Checkout
140+
uses: actions/checkout@v4
141+
- name: Set up Go
142+
uses: ./.github/actions/install-go
143+
- name: Install Rust
144+
uses: ./.github/actions/install-rust
145+
with:
146+
targets: wasm32-unknown-unknown
147+
cache: false
148+
- name: Run unit tests
149+
shell: bash
150+
run: go test -v -benchmem -run=^$ -bench=. -benchtime=1x ./x/contracts/...

0 commit comments

Comments
 (0)