Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MorpheusVM: The Choice is Yours #258

Merged
merged 36 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
338e642
first commit
patrick-ogrady Jul 20, 2023
790715a
update workflows
patrick-ogrady Jul 20, 2023
735cd22
move to basevm
patrick-ogrady Jul 20, 2023
626e35c
remove all reference to lite
patrick-ogrady Jul 21, 2023
365c70f
move cmd
patrick-ogrady Jul 21, 2023
84d5712
update scripts run.sh
patrick-ogrady Jul 21, 2023
d7a3470
go mod tidy
patrick-ogrady Jul 21, 2023
fa05609
replace lint
patrick-ogrady Jul 21, 2023
09914af
restrict running of unit tests
patrick-ogrady Jul 21, 2023
ed234d1
add badges
patrick-ogrady Jul 21, 2023
736eba6
fix genesis
patrick-ogrady Jul 21, 2023
43ab201
fix balance issue
patrick-ogrady Jul 21, 2023
d44cd8c
fix controller
patrick-ogrady Jul 21, 2023
80af858
fix rpc
patrick-ogrady Jul 21, 2023
f284e5d
cli compiles
patrick-ogrady Jul 21, 2023
47a7b52
e2e compiles
patrick-ogrady Jul 21, 2023
7398668
integration compiles
patrick-ogrady Jul 21, 2023
bfbc187
lint passed
patrick-ogrady Jul 21, 2023
0179306
fix milli
patrick-ogrady Jul 21, 2023
d927bb2
remove unnecessary tests
patrick-ogrady Jul 21, 2023
5845255
integration passing for base
patrick-ogrady Jul 21, 2023
d32188c
fix vmID
patrick-ogrady Jul 21, 2023
2962550
e2e passing
patrick-ogrady Jul 21, 2023
3a721ca
add stop.sh
patrick-ogrady Jul 21, 2023
b85aea1
add basevm load test
patrick-ogrady Jul 21, 2023
9d9eb0c
fix load test
patrick-ogrady Jul 21, 2023
c73969e
fix main README
patrick-ogrady Jul 21, 2023
4542f00
Separate Shared Components (#260)
patrick-ogrady Jul 22, 2023
d7f2d47
upload logo for basevm
patrick-ogrady Jul 22, 2023
ece869a
Rename to `SimpleVM` (#266)
patrick-ogrady Jul 22, 2023
fcef039
add basic README
patrick-ogrady Jul 22, 2023
813fdbc
start demo work
patrick-ogrady Jul 22, 2023
4ae0538
get fields into README
patrick-ogrady Jul 23, 2023
f9f1fc9
fill in rest of README
patrick-ogrady Jul 24, 2023
5dcc80b
update avalanchego dep (#268)
patrick-ogrady Jul 24, 2023
ca69c96
MorpheusVM: the last renaming of `basevm` (#270)
patrick-ogrady Jul 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/hypersdk-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ on:
branches:
- main
pull_request:
types: [labeled,synchronize,reopened]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May make sense to remove labeled (adding labels will interrupt all other label jobs).


jobs:
hypersdk-unit-tests:
if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'run unit') }}
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/morpheusvm-load-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright (C) 2023, Ava Labs, Inc. All rights reserved.
# See the file LICENSE for licensing terms.

name: MorpheusVM Load Tests

on:
push:
branches:
- main
pull_request:
types: [labeled,synchronize,reopened]

jobs:
morpheusvm-load-tests:
if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'run load') }}
strategy:
matrix:
level: [v1, v2, v3] # v4 is not supported
runs-on:
labels: ubuntu-20.04-32
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
check-latest: true
cache: true
cache-dependency-path: |
go.sum
examples/morpheusvm/go.sum
- name: Run load tests
working-directory: ./examples/morpheusvm
shell: bash
run: GOAMD64=${{ matrix.level }} scripts/tests.load.sh
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
69 changes: 69 additions & 0 deletions .github/workflows/morpheusvm-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright (C) 2023, Ava Labs, Inc. All rights reserved.
# See the file LICENSE for licensing terms.

name: MorpheusVM Release

on:
push:
branches:
- main
tags:
- "*"
pull_request:
types: [labeled,synchronize,reopened]

jobs:
morpheusvm-release:
# We build with 20.04 to maintain max compatibility: https://github.com/golang/go/issues/57328
runs-on: ubuntu-20.04-32
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.event.ref, 'refs/tags/v') || contains(github.event.pull_request.labels.*.name, 'run release') }}
steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
check-latest: true
cache: true
cache-dependency-path: |
go.sum
examples/morpheusvm/go.sum
- name: Set up arm64 cross compiler
run: |
sudo apt-get -y update
sudo apt-get -y install gcc-aarch64-linux-gnu
- name: Checkout osxcross
uses: actions/checkout@v2
with:
repository: tpoechtrager/osxcross
path: osxcross
- name: Build osxcross
run: |
sudo apt-get -y install clang llvm-dev libxml2-dev uuid-dev libssl-dev bash patch make tar xz-utils bzip2 gzip sed cpio libbz2-dev
cd osxcross
wget https://github.com/joseluisq/macosx-sdks/releases/download/12.3/$MACOS_SDK_FNAME -O tarballs/$MACOS_SDK_FNAME
echo $MACOS_SDK_CHECKSUM tarballs/$MACOS_SDK_FNAME | sha256sum -c -
UNATTENDED=1 ./build.sh
echo $PWD/target/bin >> $GITHUB_PATH
env:
MACOS_SDK_FNAME: MacOSX12.3.sdk.tar.xz
MACOS_SDK_CHECKSUM: 3abd261ceb483c44295a6623fdffe5d44fc4ac2c872526576ec5ab5ad0f6e26c
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release
workdir: ./examples/morpheusvm/
env:
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Archive Builds
uses: actions/upload-artifact@v3
with:
name: dist
path: ./examples/morpheusvm/dist
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
35 changes: 35 additions & 0 deletions .github/workflows/morpheusvm-static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright (C) 2023, Ava Labs, Inc. All rights reserved.
# See the file LICENSE for licensing terms.

name: MorpheusVM Static Analysis

on:
push:
branches:
- main
pull_request:

jobs:
morpheusvm-lint:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
check-latest: true
cache: true
cache-dependency-path: |
go.sum
examples/morpheusvm/go.sum
- name: Run static analysis tests
working-directory: ./examples/morpheusvm
shell: bash
run: scripts/tests.lint.sh

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
39 changes: 39 additions & 0 deletions .github/workflows/morpheusvm-sync-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright (C) 2023, Ava Labs, Inc. All rights reserved.
# See the file LICENSE for licensing terms.

name: MorpheusVM Sync Tests

on:
push:
branches:
- main
pull_request:
types: [labeled,synchronize,reopened]

jobs:
morpheusvm-sync-tests:
if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'run sync') }}
runs-on:
labels: ubuntu-20.04-32
timeout-minutes: 25
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
check-latest: true
cache: true
cache-dependency-path: |
go.sum
examples/morpheusvm/go.sum
- name: Run sync tests
working-directory: ./examples/morpheusvm
shell: bash
run: scripts/run.sh
env:
MODE: "full-test"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
58 changes: 58 additions & 0 deletions .github/workflows/morpheusvm-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright (C) 2023, Ava Labs, Inc. All rights reserved.
# See the file LICENSE for licensing terms.

name: MorpheusVM Unit Tests

on:
push:
branches:
- main
pull_request:
types: [labeled,synchronize,reopened]

jobs:
morpheusvm-unit-tests:
if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'run unit') }}
runs-on:
labels: ubuntu-20.04-32
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
check-latest: true
cache: true
cache-dependency-path: |
go.sum
examples/morpheusvm/go.sum
- name: Run unit tests
working-directory: ./examples/morpheusvm
shell: bash
run: scripts/tests.unit.sh
- name: Run integration tests
working-directory: ./examples/morpheusvm
shell: bash
run: scripts/tests.integration.sh
- name: Archive code coverage results (text)
uses: actions/upload-artifact@v3
with:
name: code-coverage-out
path: ./examples/morpheusvm/integration.coverage.out
- name: Archive code coverage results (html)
uses: actions/upload-artifact@v3
with:
name: code-coverage-html
path: ./examples/morpheusvm/integration.coverage.html
- name: Run e2e tests
working-directory: ./examples/morpheusvm
shell: bash
run: scripts/run.sh
env:
MODE: "test"

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
2 changes: 1 addition & 1 deletion .github/workflows/tokenvm-sync-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:

jobs:
tokenvm-sync-tests:
if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'run CI') }}
if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'run sync') }}
runs-on:
labels: ubuntu-20.04-32
timeout-minutes: 25
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tokenvm-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ on:
branches:
- main
pull_request:
types: [labeled,synchronize,reopened]

jobs:
tokenvm-unit-tests:
if: ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'run unit') }}
runs-on:
labels: ubuntu-20.04-32
timeout-minutes: 10
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ dist/
*.pk
tmp-storage-testing
.token-cli*
.morpheus-cli*
*.html
data/
osxcross/
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ linters:
- staticcheck
- bodyclose
- structcheck
- lll
# - lll
# - gomnd
- goprintffuncname
- interfacer
Expand Down
31 changes: 25 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<a href="https://goreportcard.com/report/github.com/ava-labs/hypersdk"><img src="https://goreportcard.com/badge/github.com/ava-labs/hypersdk" /></a>
<a href="https://github.com/ava-labs/hypersdk/actions/workflows/hypersdk-unit-tests.yml"><img src="https://github.com/ava-labs/hypersdk/actions/workflows/hypersdk-unit-tests.yml/badge.svg" /></a>
<a href="https://github.com/ava-labs/hypersdk/actions/workflows/hypersdk-static-analysis.yml"><img src="https://github.com/ava-labs/hypersdk/actions/workflows/hypersdk-static-analysis.yml/badge.svg" /></a>
<a href="https://github.com/ava-labs/hypersdk/actions/workflows/tokenvm-sync-tests.yml"><img src="https://github.com/ava-labs/hypersdk/actions/workflows/tokenvm-sync-tests.yml/badge.svg" /></a>
<a href="./LICENSE" ><img src="https://img.shields.io/badge/License-Ecosystem-blue.svg" /></a>
</p>

Expand Down Expand Up @@ -252,10 +251,28 @@ these functions with avalanchego means existing avalanchego monitoring tools
work out of the box on your `hypervm`.

## Examples
### Beginner: `tokenvm`
We've created three `hypervm` examples, of increasing complexity, that demonstrate what you
can build with the `hypersdk` (with more on the way).

When you are ready to build your own `hypervm`, we recommend using the `morpheusvm` as a template!

### Beginner: `morpheusvm`
_[Who is Morpheus ("The Matrix")?](https://www.youtube.com/watch?v=zE7PKRjrid4)_

The [`morpheusvm`](./examples/morpheusvm) provides the first glimpse into the world of the `hypersdk`.
After learning how to implement native token transfers in a `hypervm` (one of the simplest Custom VMs
you could make), you will have the choice to go deeper (red pill) or to turn back to the VMs that you
already know (blue pill).

_To ensure the `hypersdk` remains reliable as we optimize and evolve the codebase,
we also run E2E tests in the `morpheusvm` on each PR to the `hypersdk` core modules._

### Moderate: `tokenvm`
We created the [`tokenvm`](./examples/tokenvm) to showcase how to use the
`hypersdk` in an application most readers are already familiar with, token minting
and token trading. The `tokenvm` lets anyone create any asset, mint more of
and token trading.

The `tokenvm` lets anyone create any asset, mint more of
their asset, modify the metadata of their asset (if they reveal some info), and
burn their asset. Additionally, there is an embedded on-chain exchange that
allows anyone to create orders and fill (partial) orders of anyone else. To
Expand All @@ -265,10 +282,12 @@ maintains by syncing blocks. If you are interested in the intersection of
exchanges and blockchains, it is definitely worth a read (the logic for filling
orders is < 100 lines of code!).

To ensure the `hypersdk` remains reliable as we optimize and evolve the codebase,
we also run E2E tests in the `tokenvm` on each PR to the `hypersdk` core modules.
_To ensure the `hypersdk` remains reliable as we optimize and evolve the codebase,
we also run E2E tests in the `tokenvm` on each PR to the `hypersdk` core modules._

### Expert: `indexvm` [DEPRECATED]
_The `indexvm` will be rewritten using the new WASM Progams module._

### Expert: `indexvm`
The [`indexvm`](https://github.com/ava-labs/indexvm) is much more complex than
the `tokenvm` (more elaborate mechanisms and a new use case you may not be
familiar with). It was built during the design of the `hypersdk` to test out the
Expand Down
1 change: 1 addition & 0 deletions chain/mock_action.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions chain/mock_auth.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions chain/mock_auth_factory.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions chain/mock_rules.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading