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

Add a VM with Contract support #1493

Merged
merged 82 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
2fae4fa
stash
dboehm-avalabs Jul 10, 2024
23fd0d6
Merge branch 'main' into ProgramsVM
dboehm-avalabs Jul 12, 2024
08d3c68
stash
dboehm-avalabs Jul 12, 2024
adea757
Update run.sh
dboehm-avalabs Jul 12, 2024
902769d
Merge branch 'main' into ProgramsVM
dboehm-avalabs Jul 15, 2024
09be1f0
stash
dboehm-avalabs Jul 15, 2024
0eab86a
stash
dboehm-avalabs Jul 15, 2024
0953477
stash working
dboehm-avalabs Jul 15, 2024
bb53a4b
stash
dboehm-avalabs Jul 15, 2024
b4f0057
cleanup
dboehm-avalabs Jul 15, 2024
684a0cf
Merge branch 'main' into ProgramsVM
dboehm-avalabs Jul 15, 2024
c0f3972
stash
dboehm-avalabs Jul 23, 2024
0ffc1f8
recorder
dboehm-avalabs Jul 23, 2024
00c9d25
fix
dboehm-avalabs Jul 23, 2024
f5b74cd
Merge branch 'main' into ProgramsVM
dboehm-avalabs Jul 23, 2024
59106a5
merge main
dboehm-avalabs Jul 23, 2024
6523a65
Merge branch 'main' into ProgramsVM
dboehm-avalabs Jul 29, 2024
d9e170d
Add RPC Simulation
dboehm-avalabs Jul 29, 2024
5b23dea
add file based program submit
dboehm-avalabs Jul 29, 2024
c8939c8
stash
dboehm-avalabs Jul 30, 2024
52c1b56
Merge branch 'main' into ProgramsVM
dboehm-avalabs Jul 30, 2024
d291484
stash
dboehm-avalabs Jul 30, 2024
170f044
stash
dboehm-avalabs Jul 31, 2024
d5eedf4
add morpheus back
dboehm-avalabs Jul 31, 2024
0f7c71e
fix package
dboehm-avalabs Jul 31, 2024
5081439
Update main.go
dboehm-avalabs Jul 31, 2024
2d475e0
Update websocket_server.go
dboehm-avalabs Jul 31, 2024
362cd4d
cleanup publish
dboehm-avalabs Jul 31, 2024
0613b8a
Update integration_test.go
dboehm-avalabs Jul 31, 2024
e8b9f65
Update vm.go
dboehm-avalabs Jul 31, 2024
faa0249
Update integration_test.go
dboehm-avalabs Jul 31, 2024
f312502
stash
dboehm-avalabs Aug 1, 2024
3fedaa6
add
dboehm-avalabs Aug 1, 2024
dcd86f8
Merge branch 'main' into ProgramsVM
dboehm-avalabs Aug 1, 2024
8aacc2e
Merge branch 'ConvertProgramID' into ProgramsVM
dboehm-avalabs Aug 1, 2024
bea48eb
stash
dboehm-avalabs Aug 1, 2024
83a7287
stash
dboehm-avalabs Aug 2, 2024
4331b6c
stash
dboehm-avalabs Aug 2, 2024
a44c3c6
looped
dboehm-avalabs Aug 2, 2024
e092d3b
stash
dboehm-avalabs Aug 2, 2024
007ba83
add file
dboehm-avalabs Aug 2, 2024
81e3150
fix
dboehm-avalabs Aug 2, 2024
473da80
Update integration_test.go
dboehm-avalabs Aug 5, 2024
79e48b2
delete
dboehm-avalabs Aug 5, 2024
d88001f
Merge branch 'main' into ProgramsVM
dboehm-avalabs Aug 5, 2024
8e604b6
stash
dboehm-avalabs Aug 7, 2024
71d38a2
Merge branch 'main' into ProgramsVM
dboehm-avalabs Aug 7, 2024
8888f47
Update import_log_release.go
dboehm-avalabs Aug 7, 2024
f572ff6
fix balance stuff
dboehm-avalabs Aug 7, 2024
419c02c
Merge branch 'main' into ProgramsVM
dboehm-avalabs Aug 21, 2024
fc1772d
Merge branch 'main' into ProgramsVM
dboehm-avalabs Aug 26, 2024
1215a69
merged
dboehm-avalabs Aug 26, 2024
f1522a4
Merge branch 'main' into ProgramsVM
dboehm-avalabs Sep 3, 2024
3b0b0ba
commit
dboehm-avalabs Sep 3, 2024
fd747fd
Update import_log_release.go
dboehm-avalabs Sep 3, 2024
6e954e6
Create demo.pk
dboehm-avalabs Sep 3, 2024
49e90d2
Merge branch 'main' into ProgramsVM
dboehm-avalabs Sep 3, 2024
3ec2ae9
Add cleanup
dboehm-avalabs Sep 3, 2024
4b2b4a3
comments
dboehm-avalabs Sep 3, 2024
65aa088
Update recorder.go
dboehm-avalabs Sep 3, 2024
e967cc9
ci
dboehm-avalabs Sep 3, 2024
00bf95c
lint
dboehm-avalabs Sep 3, 2024
578db1b
undo
dboehm-avalabs Sep 3, 2024
6ac704d
Update tests.unit.sh
dboehm-avalabs Sep 3, 2024
47ed4d7
lint
dboehm-avalabs Sep 3, 2024
50c1f93
Update vm/vm.go
dboehm-avalabs Sep 4, 2024
09cae9c
call test
dboehm-avalabs Sep 4, 2024
9fa04e4
Update call_test.go
dboehm-avalabs Sep 4, 2024
3b79a76
Merge branch 'main' into ProgramsVM
dboehm-avalabs Sep 4, 2024
4b73a67
merge
dboehm-avalabs Sep 4, 2024
5db1455
lint
dboehm-avalabs Sep 4, 2024
4c3ce89
fix run script
dboehm-avalabs Sep 4, 2024
3bbc5e6
Merge branch 'main' into ProgramsVM
dboehm-avalabs Sep 4, 2024
4ebb376
Merge branch 'main' into ProgramsVM
richardpringle Sep 11, 2024
abf209b
Use internal APIs
richardpringle Sep 11, 2024
c45bde4
Don't run tests on vm-with-contracts
richardpringle Sep 11, 2024
0f7c873
Merge remote-tracking branch 'origin/main' into ProgramsVM
richardpringle Sep 11, 2024
dd396e8
Point to the proper fees package
richardpringle Sep 11, 2024
675238b
Use non-internal fees package
richardpringle Sep 11, 2024
dabe06c
Fix tests
richardpringle Sep 11, 2024
079ca84
Merge branch 'main' into ProgramsVM
richardpringle Sep 12, 2024
55c6a77
Fix immutable state implementation (#1543)
aaronbuchwald Sep 12, 2024
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
86 changes: 86 additions & 0 deletions .github/workflows/hypersdk-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,89 @@ jobs:
with:
vm-name: morpheusvm
github-token: ${{ secrets.GITHUB_TOKEN }}

# VMWithContracts
vmwithcontracts-lint:
needs: [ hypersdk-tests ]
if: ${{ needs.hypersdk-tests.outputs.only_programs_changed != 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: ./.github/actions/install-go
with:
cache-dependency-path: |
go.sum
examples/vmwithcontracts/go.sum
- name: Run static analysis tests
working-directory: ./examples/vmwithcontracts
shell: bash
run: scripts/lint.sh
- name: Build vm, cli
working-directory: ./examples/vmwithcontracts
shell: bash
run: scripts/build.sh

# vmwithcontracts-unit-tests:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we add a GitHub issue to fix these?

# needs: [ hypersdk-tests ]
# if: ${{ needs.hypersdk-tests.outputs.only_programs_changed != 'true' }}
# runs-on: ubuntu-20.04-32
# timeout-minutes: 10
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Set up Go
# uses: ./.github/actions/install-go
# with:
# cache-dependency-path: |
# go.sum
# examples/vmwithcontracts/go.sum
# - name: Run unit tests
# working-directory: ./examples/vmwithcontracts
# shell: bash
# run: scripts/tests.unit.sh
# - name: Run integration tests
# working-directory: ./examples/vmwithcontracts
# shell: bash
# run: scripts/tests.integration.sh
#
# vmwithcontracts-e2e-tests:
# needs: [ vmwithcontracts-lint, vmwithcontracts-unit-tests ]
# runs-on: ubuntu-20.04-32
# timeout-minutes: 25
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Set up Go
# uses: ./.github/actions/install-go
# with:
# cache-dependency-path: |
# go.sum
# examples/vmwithcontracts/go.sum
# - name: Run e2e tests
# working-directory: ./examples/vmwithcontracts
# shell: bash
# run: scripts/run.sh
# env:
# MODE: 'test'
# - name: Upload tmpnet network dir
# uses: ava-labs/avalanchego/.github/actions/upload-tmpnet-artifact@v1-actions
# if: always()
# with:
# name: vmwithcontracts-e2e-tmpnet-data
#
# vmwithcontracts-release:
# needs: [ vmwithcontracts-e2e-tests ]
# # We build with 20.04 to maintain max compatibility: https://github.com/golang/go/issues/57328
# runs-on: ubuntu-20.04-32
# permissions:
# contents: write
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - uses: ./.github/actions/vm-release
# with:
# vm-name: vmwithcontracts
# github-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions api/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/ava-labs/hypersdk/chain"
"github.com/ava-labs/hypersdk/fees"
"github.com/ava-labs/hypersdk/genesis"
"github.com/ava-labs/hypersdk/state"
)

type VM interface {
Expand All @@ -36,4 +37,5 @@ type VM interface {
) (map[ids.NodeID]*validators.GetValidatorOutput, map[string]struct{})
GetVerifyAuth() bool
ReadState(ctx context.Context, keys [][]byte) ([][]byte, []error)
ImmutableState(ctx context.Context) (state.Immutable, error)
aaronbuchwald marked this conversation as resolved.
Show resolved Hide resolved
}
19 changes: 19 additions & 0 deletions cli/prompt/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package prompt

import (
"encoding/hex"
"errors"
"fmt"
"strconv"
Expand All @@ -29,6 +30,24 @@ var (
ErrInsufficientAccounts = errors.New("insufficient accounts")
)

func Bytes(label string) ([]byte, error) {
promptText := promptui.Prompt{
Label: label,
Validate: func(input string) error {
if len(input) == 0 {
return ErrInputEmpty
}
_, err := hex.DecodeString(input)
return err
},
}
hexString, err := promptText.Run()
if err != nil {
return nil, err
}
return hex.DecodeString(hexString)
}

func Address(label string, parseAddress func(string) (codec.Address, error)) (codec.Address, error) {
promptText := promptui.Prompt{
Label: label,
Expand Down
113 changes: 113 additions & 0 deletions examples/vmwithcontracts/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Copyright (C) 2023, Ava Labs, Inc. All rights reserved.
# See the file LICENSE for licensing terms.

# https://golangci-lint.run/usage/configuration/
run:
timeout: 10m
# skip auto-generated files.
skip-files:
- ".*\\.pb\\.go$"
- ".*mock.*"

issues:
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0

linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- asciicheck
- depguard
- errcheck
- errorlint
- exportloopref
- goconst
- gocritic
- gofmt
- gofumpt
- goimports
- revive
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- nolintlint
- prealloc
- stylecheck
- unconvert
- unparam
- unused
- unconvert
- whitespace
- staticcheck
- bodyclose
- goprintffuncname
- typecheck
- noctx

linters-settings:
errorlint:
# Check for plain type assertions and type switches.
asserts: false
# Check for plain error comparisons.
comparison: false
revive:
rules:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr
- name: bool-literal-in-expr
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#early-return
- name: early-return
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-lines
- name: empty-lines
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag
- name: struct-tag
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-naming
- name: unexported-naming
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unhandled-error
- name: unhandled-error
disabled: false
arguments:
- "fmt.Fprint"
- "fmt.Fprintf"
- "fmt.Print"
- "fmt.Printf"
- "fmt.Println"
- "rand.Read"
- "sb.WriteString"
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter
- name: unused-parameter
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-receiver
- name: unused-receiver
disabled: false
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break
- name: useless-break
disabled: false
staticcheck:
# https://staticcheck.io/docs/options#checks
checks:
- "all"
- "-SA6002" # argument should be pointer-like to avoid allocation, for sync.Pool
- "-SA1019" # deprecated packages e.g., golang.org/x/crypto/ripemd160
# https://golangci-lint.run/usage/linters#gosec
gosec:
excludes:
- G107 # https://securego.io/docs/rules/g107.html
depguard:
rules:
packages:
deny:
- pkg: "github.com/stretchr/testify/assert"
desc: github.com/stretchr/testify/require should be used instead.
- pkg: "io/ioutil"
desc: io/ioutil is deprecated. Use package io or os instead.
include-go-root: true
75 changes: 75 additions & 0 deletions examples/vmwithcontracts/.goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Copyright (C) 2023, Ava Labs, Inc. All rights reserved.
# See the file LICENSE for licensing terms.

# ref. https://goreleaser.com/customization/build/
builds:
- id: vmwithcontracts-cli
main: ./cmd/vmwithcontracts-cli
binary: vmwithcontracts-cli
flags:
- -v
goos:
- linux
- darwin
goarch:
- amd64
- arm64
env:
- CGO_ENABLED=1
- CGO_CFLAGS=-O -D__BLST_PORTABLE__ # Set the CGO flags to use the portable version of BLST
overrides:
- goos: linux
goarch: arm64
env:
- CC=aarch64-linux-gnu-gcc
- goos: darwin
goarch: arm64
env:
- CC=oa64-clang
- goos: darwin
goarch: amd64
goamd64: v1
env:
- CC=o64-clang
- id: vmwithcontracts
main: ./cmd/vmwithcontracts
binary: vmwithcontracts
flags:
- -v
goos:
- linux
- darwin
goarch:
- amd64
- arm64
env:
- CGO_ENABLED=1
- CGO_CFLAGS=-O -D__BLST_PORTABLE__ # Set the CGO flags to use the portable version of BLST
overrides:
- goos: linux
goarch: arm64
env:
- CC=aarch64-linux-gnu-gcc
- goos: darwin
goarch: arm64
env:
- CC=oa64-clang
- goos: darwin
goarch: amd64
goamd64: v1
env:
- CC=o64-clang

checksum:
name_template: "vmwithcontracts_checksums.txt"

archives:
- id: default
name_template: 'vmwithcontracts_{{ .Version }}_{{ .Os }}_{{ .Arch }}'

release:
make_latest: false # Should be done manually
mode: 'keep-existing' # Should not override releases
github:
owner: ava-labs
name: hypersdk
66 changes: 66 additions & 0 deletions examples/vmwithcontracts/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
Copyright (C) 2023, Ava Labs, Inc. All rights reserved.

Ecosystem License
Version: 1.1

Subject to the terms herein, Ava Labs, Inc. (**“Ava Labs”**) hereby grants you
a limited, royalty-free, worldwide, non-sublicensable, non-transferable,
non-exclusive license to use, copy, modify, create derivative works based on,
and redistribute the Software, in source code, binary, or any other form,
including any modifications or derivative works of the Software (collectively,
**“Licensed Software”**), in each case subject to this Ecosystem License
(**“License”**).

This License applies to all copies, modifications, derivative works, and any
other form or usage of the Licensed Software. You will include and display
this License, without modification, with all uses of the Licensed Software,
regardless of form.

You will use the Licensed Software solely (i) in connection with the Avalanche
Public Blockchain platform, having a NetworkID of 1 (Mainnet) or 5 (Fuji), and
associated blockchains, comprised exclusively of the Avalanche X-Chain,
C-Chain, P-Chain and any subnets linked to the P-Chain (“Avalanche Authorized
Platform”) or (ii) for non-production, testing or research purposes within the
Avalanche ecosystem, in each case, without any commercial application
(“Non-Commercial Use”); provided that this License does not permit use of the
Licensed Software in connection with (a) any forks of the Avalanche Authorized
Platform or (b) in any manner not operationally connected to the Avalanche
Authorized Platform other than, for the avoidance of doubt, the limited
exception for Non-Commercial Use. Ava Labs may publicly announce changes or
additions to the Avalanche Authorized Platform, which may expand or modify
usage of the Licensed Software. Upon such announcement, the Avalanche
Authorized Platform will be deemed to be the then-current iteration of such
platform.

You hereby acknowledge and agree to the terms set forth at
www.avalabs.org/important-notice.

If you use the Licensed Software in violation of this License, this License
will automatically terminate and Ava Labs reserves all rights to seek any
remedy for such violation.

Except for uses explicitly permitted in this License, Ava Labs retains all
rights in the Licensed Software, including without limitation the ability to
modify it.

Except as required or explicitly permitted by this License, you will not use
any Ava Labs names, logos, or trademarks without Ava Labs’ prior written
consent.

You may use this License for software other than the “Licensed Software”
specified above, as long as the only change to this License is the definition
of the term “Licensed Software.”

The Licensed Software may reference third party components. You acknowledge
and agree that these third party components may be governed by a separate
license or terms and that you will comply with them.

**TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE LICENSED SOFTWARE IS PROVIDED
ON AN “AS IS” BASIS, AND AVA LABS EXPRESSLY DISCLAIMS AND EXCLUDES ALL
REPRESENTATIONS, WARRANTIES AND OTHER TERMS AND CONDITIONS, WHETHER EXPRESS OR
IMPLIED, INCLUDING WITHOUT LIMITATION BY OPERATION OF LAW OR BY CUSTOM,
STATUTE OR OTHERWISE, AND INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED WARRANTY,
TERM, OR CONDITION OF NON-INFRINGEMENT, MERCHANTABILITY, TITLE, OR FITNESS FOR
PARTICULAR PURPOSE. YOU USE THE LICENSED SOFTWARE AT YOUR OWN RISK. AVA LABS
EXPRESSLY DISCLAIMS ALL LIABILITY (INCLUDING FOR ALL DIRECT, CONSEQUENTIAL OR
OTHER DAMAGES OR LOSSES) RELATED TO ANY USE OF THE LICENSED SOFTWARE.**
Loading
Loading