Skip to content

Commit

Permalink
Merge pull request #61 from Nuklai/hypersdk-parity-20241002025558
Browse files Browse the repository at this point in the history
Hypersdk parity to 20241002025558
  • Loading branch information
kpachhai authored Oct 16, 2024
2 parents 4e6ba82 + 059d2eb commit 20765b8
Show file tree
Hide file tree
Showing 131 changed files with 19,036 additions and 4,763 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.git
web_wallet/node_modules
tests/e2e/e2e.test
build
.nuklai-cli/
**.coverage.**
2 changes: 1 addition & 1 deletion .github/actions/install-go/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ runs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21.10'
go-version: '1.22.5'
cache: ${{ inputs.cache }}
cache-dependency-path: ${{ inputs.cache-dependency-path }}
3 changes: 1 addition & 2 deletions .github/actions/vm-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: 'Release the VM'

inputs:
vm-name:
description: 'NuklaiVM'
description: 'VM name'
required: true
github-token:
description: 'GitHub Token'
Expand Down Expand Up @@ -48,7 +48,6 @@ runs:
distribution: goreleaser
version: latest
args: release
workdir: ./${{ inputs.vm-name }}/
env:
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret
GITHUB_TOKEN: ${{ inputs.github-token }}
54 changes: 19 additions & 35 deletions .github/workflows/nuklaivm-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,6 @@ concurrency:
cancel-in-progress: true

jobs:
go-mod-tidy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: ./.github/actions/install-go
- shell: bash
run: go mod tidy
- shell: bash
working-directory: ./
run: go mod tidy
- shell: bash
run: scripts/tests.clean.sh

nuklaivm-lint:
runs-on: ubuntu-latest
timeout-minutes: 10
Expand All @@ -40,13 +26,14 @@ jobs:
go.sum
- name: Run static analysis tests
shell: bash
run: scripts/tests.lint.sh
- name: Build vm and cli
run: scripts/lint.sh
- name: Build vm, cli
shell: bash
run: scripts/build.sh

nuklaivm-unit-tests:
runs-on: ubuntu-20.04-32
# runs-on: ubuntu-20.04-32
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
Expand All @@ -62,22 +49,11 @@ jobs:
- name: Run integration tests
shell: bash
run: scripts/tests.integration.sh
- name: Run e2e tests
shell: bash
run: scripts/run.sh
env:
MODE: 'test'

nuklaivm-tests:
runs-on: ubuntu-latest
needs: [go-mod-tidy, nuklaivm-lint, nuklaivm-unit-tests]
steps:
- name: Finished NuklaiVM tests
run: echo "Finished NuklaiVM tests"

nuklaivm-sync-tests:
nuklaivm-e2e-tests:
needs: [nuklaivm-lint, nuklaivm-unit-tests]
runs-on: ubuntu-20.04-32
# runs-on: ubuntu-20.04-32
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
- name: Checkout
Expand All @@ -87,16 +63,24 @@ jobs:
with:
cache-dependency-path: |
go.sum
- name: Run sync tests
- name: Run e2e tests
shell: bash
run: scripts/run.sh
env:
MODE: 'full-test'
MODE: 'test'
- name: Upload tmpnet network dir
uses: ava-labs/avalanchego/.github/actions/upload-tmpnet-artifact@v1-actions
if: always()
with:
name: nuklaivm-e2e-tmpnet-data

nuklaivm-release:
needs: [nuklaivm-sync-tests]
#needs: [nuklaivm-e2e-tests]
# We build with 20.04 to maintain max compatibility: https://github.com/golang/go/issues/57328
runs-on: ubuntu-20.04-32
# runs-on: ubuntu-20.04-32
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
29 changes: 0 additions & 29 deletions .github/workflows/stale.yml

This file was deleted.

5 changes: 4 additions & 1 deletion .github/workflows/vm-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ concurrency:
jobs:
nuklaivm-release:
# We build with 20.04 to maintain max compatibility: https://github.com/golang/go/issues/57328
runs-on: ubuntu-20.04-32
# runs-on: ubuntu-20.04-32
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
42 changes: 42 additions & 0 deletions Dockerfile.devnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#####
# Source of precompiled avalanchego
#####
ARG INSTALL_AVALANCHEGO_VERSION_SHORT=d366a137
FROM avaplatform/avalanchego:${INSTALL_AVALANCHEGO_VERSION_SHORT} AS avalanchego

#####
# Base layer with hypersdk
#####
FROM golang:1.22-bookworm AS hypersdk-downloader

RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -y curl && apt clean && rm -rf /var/lib/apt/lists/*


ARG INSTALL_AVALANCHEGO_VERSION=v1.11.12-rc.2
COPY --from=avalanchego /avalanchego/build/avalanchego /root/.hypersdk/avalanchego-${INSTALL_AVALANCHEGO_VERSION}/avalanchego


ENV GOMODCACHE /go/pkg/mod

WORKDIR /app

RUN go install github.com/onsi/ginkgo/v2/[email protected]

COPY ./go.mod ./go.sum ./

COPY ./actions ./actions
COPY ./chain ./chain
COPY ./cmd/nuklaivm ./cmd/nuklaivm
COPY ./consts ./consts
COPY ./emission ./emission
COPY ./genesis ./genesis
COPY ./marketplace ./marketplace
COPY ./scripts ./scripts
COPY ./storage ./storage
COPY ./tests ./tests
COPY ./vm ./vm

WORKDIR /app


ENTRYPOINT ["/bin/bash", "-c", "./scripts/stop.sh; ./scripts/run.sh && echo 'Devnet started' && tail -f /dev/null"]
28 changes: 28 additions & 0 deletions Dockerfile.faucet
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#####
# Build the faucet
#####

FROM golang:1.22-bookworm AS faucet-builder

WORKDIR /build
COPY ./go.mod ./go.sum ./

COPY ./ ./

ENV GOMODCACHE /go/pkg/mod
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go build -o build/faucet ./cmd/faucet

#####
# Final layer with faucet, VM and avalanchego
#####
FROM debian:bookworm-slim

RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -y curl && apt clean && rm -rf /var/lib/apt/lists/*

COPY --from=faucet-builder /build/build/faucet /faucet



ENTRYPOINT ["/faucet"]
12 changes: 12 additions & 0 deletions Dockerfile.frontend
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Build stage
FROM node:22-bookworm AS build
WORKDIR /app
COPY web_wallet/package.json web_wallet/package-lock.json ./
RUN --mount=type=cache,target=/root/.npm npm install
COPY web_wallet/ ./web_wallet/
WORKDIR /app/web_wallet
RUN npm run build-no-check

# # Production stage
FROM nginx:latest
COPY --from=build /app/web_wallet/dist /usr/share/nginx/html
56 changes: 29 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,8 @@ If successful, the balance response should look like this:
```bash
address: 00c4cb545f748a28770042f893784ce85b107389004d6a0e0d6d7518eeae1292d9
chainID: 2F1QmuxSSVntNHXnEevYHBZzyhsNGvAE5Y2pqJW2a4iBugTMWd
uri: http://127.0.0.1:9650/ext/bc/nuklaivm
address: 00c4cb545f748a28770042f893784ce85b107389004d6a0e0d6d7518eeae1292d9 balance: 853000000.000000000 NAI
chainID: PAroBtUb83kcU5m3XiD37D263cB8kaZsiZ1rG7DLKxs8EX7Cq
address: 00cf77495ce1bdbf11e5e45463fad5a862cb6cc0a20e00e658c4ac3355dcdc64bb balance: 853000000.000000000 NAI
```
You can also check the balance of another address by passing in the address as the argument
Expand All @@ -285,15 +284,8 @@ You can also check the balance of another address by passing in the address as t
Should give output
```bash
address: 01b27c7ce992cdb7ff039294d7901851902394bb85fa4f3dc4cbb960b07284b7f9
chainID: 2F1QmuxSSVntNHXnEevYHBZzyhsNGvAE5Y2pqJW2a4iBugTMWd
assetID (use NAI for native token): NAI
assetID: 11111111111111111111111111111111LpoYY
name: nuklaivm
symbol: NAI
balance: 0
please send funds to 01b27c7ce992cdb7ff039294d7901851902394bb85fa4f3dc4cbb960b07284b7f9
exiting...
chainID: PAroBtUb83kcU5m3XiD37D263cB8kaZsiZ1rG7DLKxs8EX7Cq
address: 00cf77495ce1bdbf11e5e45463fad5a862cb6cc0a20e00e658c4ac3355dcdc64bb balance: 0.000000000 NAI
```
### Generate Another Address
Expand All @@ -311,8 +303,8 @@ Note that we are now generating a key with curve secp256r1 instead of ed25519 li
If successful, the `nuklai-cli` will emit the new address:
```bash
created address: 01b27c7ce992cdb7ff039294d7901851902394bb85fa4f3dc4cbb960b07284b7f9
Private Key String: h3geZh5VQ4JEe829BTvaKaECnrVUGA1fEUY4imgnzbg=
created address: 011ddbf62f227dd32deea73b31945d65bb6676cccae6cf0b829dfc21b290387bac
Private Key String(Base64): J5kwBjyvMuvV4PfjTUOO8ZF40Db3KzhFidhH7ER+9Jg=
```
We can also generate a bls key doing
Expand All @@ -331,11 +323,14 @@ the following command to set it back to `demo.pk`:
You should see something like this:
```bash
chainID: 2F1QmuxSSVntNHXnEevYHBZzyhsNGvAE5Y2pqJW2a4iBugTMWd
chainID: PAroBtUb83kcU5m3XiD37D263cB8kaZsiZ1rG7DLKxs8EX7Cq
stored keys: 3
0) address: 00c4cb545f748a28770042f893784ce85b107389004d6a0e0d6d7518eeae1292d9 balance: 853000000.000000000 NAI
1) address: 01b27c7ce992cdb7ff039294d7901851902394bb85fa4f3dc4cbb960b07284b7f9 balance: 0.000000000 NAI
2) address: 023d4f5711f36fc407e114a86b513b8c51ae124224d11eee5430c27e2d8e673893 balance: 0.000000000 NAI
chainID: PAroBtUb83kcU5m3XiD37D263cB8kaZsiZ1rG7DLKxs8EX7Cq
0) address: 00cf77495ce1bdbf11e5e45463fad5a862cb6cc0a20e00e658c4ac3355dcdc64bb balance: 853000000.000000000 NAI
chainID: PAroBtUb83kcU5m3XiD37D263cB8kaZsiZ1rG7DLKxs8EX7Cq
1) address: 00cf77495ce1bdbf11e5e45463fad5a862cb6cc0a20e00e658c4ac3355dcdc64bb balance: 0.000000000 NAI
chainID: PAroBtUb83kcU5m3XiD37D263cB8kaZsiZ1rG7DLKxs8EX7Cq
2) address: 00cf77495ce1bdbf11e5e45463fad5a862cb6cc0a20e00e658c4ac3355dcdc64bb balance: 0.000000000 NAI
set default key: 0
```
Expand Down Expand Up @@ -376,15 +371,14 @@ The `nuklai-cli` will emit the following logs when the transfer is successful:
```bash
address: 00c4cb545f748a28770042f893784ce85b107389004d6a0e0d6d7518eeae1292d9
chainID: 2hKDi8QVgngBxCbakibVqQFa3EV8YzA957q7nPT5vrQRpx8Z9E
assetID (use NAI for native token): NAI
balance: 853000000.000000000 NAI
recipient: 00fa92500595699234176c32afbf5c6558df21deb10ba4d2d691e5e5148658c64a
amount: 1
chainID: PAroBtUb83kcU5m3XiD37D263cB8kaZsiZ1rG7DLKxs8EX7Cq
assetAddress (use NAI for native token): NAI
address: 00cf77495ce1bdbf11e5e45463fad5a862cb6cc0a20e00e658c4ac3355dcdc64bb balance: 853000000.000000000 NAI
✔ amount: 1█
continue (y/n): y
✅ txID: X4HTZbkvrXy8Ka3VBdEJLGj1eUVNQf9LoWZyLZCxham1D1zND
fee consumed: 0.000032100
output: &{SenderBalance:852999998999967900 ReceiverBalance:1000000000}
✅ txID: wjzqXJeYedVSyBWfapoGiHYC9EQr2HgkA7xrVW4KZQyP1jxxG
txID: wjzqXJeYedVSyBWfapoGiHYC9EQr2HgkA7xrVW4KZQyP1jxxG
fee consumed: 0.000048500 NAI
```
### Bonus: Watch Activity in Real-Time
Expand All @@ -408,7 +402,7 @@ select chainID: 0 [auto-selected]
uri: http://127.0.0.1:9650/ext/bc/nuklaivm
watching for new blocks on 2F1QmuxSSVntNHXnEevYHBZzyhsNGvAE5Y2pqJW2a4iBugTMWd 👀
height:3003 txs:1 root:uNXBoJRGNo8JCJ8XDEioqVnJjwrVSSKBMgbaTd9AWFiUke2vE size:0.30KB units consumed: [bandwidth=224 compute=7 storage(read)=14 storage(allocate)=50 storage(write)=26] unit prices: [bandwidth=100 compute=100 storage(read)=100 storage(allocate)=100 storage(write)=100] [TPS:0.10 latency:66ms gap:142ms]
X3VcRchV8E8CoK38qEWYG9mNFLTwxm5V1mhZzsF4KCdkuwfPB actor: 00c4cb545f748a28770042f893784ce85b107389004d6a0e0d6d7518eeae1292d9 summary (*actions.Transfer): [assetID: 11111111111111111111111111111111LpoYY amount: 100000000000 -> 01b27c7ce992cdb7ff039294d7901851902394bb85fa4f3dc4cbb960b07284b7f9
2deLZJJpfXm1Wrad1f8uZL1aZnrCkEtBZ6aFXNcR7stFYN8Rm8 actor: 00c4cb545f748a28770042f893784ce85b107389004d6a0e0d6d7518eeae1292d9 summary (*actions.Transfer): [assetID: 00cf77495ce1bdbf11e5e45463fad5a862cb6cc0a20e00e658c4ac3355dcdc64bb amount: 1000000000 -> 00cf77495ce1bdbf11e5e45463fad5a862cb6cc0a20e00e658c4ac3355dcdc64bb
]
```
Expand All @@ -429,3 +423,11 @@ Refer to [Datasets Demo](./docs/demos/datasets.md) to learn how to create a data
### Nuklai Marketplace Demo
Refer to [Marketplace Demo](./docs/demos/marketplace.md) to learn how to create a publish your dataset up for sale on the Nuklai Marketplace and how to subscribe to a dataset.
## Faucet
You can run the faucet by doing:
```bash
FAUCET_PRIVATE_KEY_HEX="323b1d8f4eed5f0da9da93071b034f2dce9d2d22692c172f3cb252a64ddfafd01b057de320297c29ad0c1f589ea216869cf1938d88c9fbd70d6748323dbf2fa7" RPC_ENDPOINT="http://127.0.0.1:9650" go run ./cmd/faucet
```
Loading

0 comments on commit 20765b8

Please sign in to comment.