Skip to content

Commit

Permalink
MorpheusVM: The Choice is Yours (#258)
Browse files Browse the repository at this point in the history
* first commit

* update workflows

* move to basevm

* remove all reference to lite

* move cmd

* update scripts run.sh

* go mod tidy

* replace lint

* restrict running of unit tests

* add badges

* fix genesis

* fix balance issue

* fix controller

* fix rpc

* cli compiles

* e2e compiles

* integration compiles

* lint passed

* fix milli

* remove unnecessary tests

* integration passing for base

* fix vmID

* e2e passing

* add stop.sh

* add basevm load test

* fix load test

* fix main README

* Separate Shared Components (#260)

* experimenting with CLI

* move more cli commands over

* port storage

* more progress

* fix prompt chain

* rewrite tokenvm action

* tokenvm chain

* make chain shared

* abstract watch

* rewrite key operations

* add support for prometheus

* introduce sendAndWait

* abstract submitDummy

* remove old submit dummy

* progress on cli spam

* generic spam implemented

* general spam

* remove unused errors

* close db earlier

* start cleanup of basevm

* cleaning up base

* basevm actions passing

* making progress with cleanup

* fix chain for basevm

* cleanup spam

* remove unnecessary errors

* fix lint in base and hypersk

* fix license spacing

* remove gosec from spam

* fix license header application

* add license to right files in token-cli

* upload logo for basevm

* Rename to `SimpleVM` (#266)

* rename to simple

* migrate from basevm to simplevm

* add basic README

* start demo work

* get fields into README

* fill in rest of README

* update avalanchego dep (#268)

* MorpheusVM: the last renaming of `basevm` (#270)

* update workflows

* move files

* update all references

* update addresses

* update README
  • Loading branch information
patrick-ogrady authored Jul 24, 2023
1 parent 8bc2f78 commit 37df80a
Show file tree
Hide file tree
Showing 108 changed files with 9,058 additions and 1,656 deletions.
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]

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

0 comments on commit 37df80a

Please sign in to comment.