diff --git a/.gitignore b/.gitignore index c1ef1bc..28be046 100644 --- a/.gitignore +++ b/.gitignore @@ -72,4 +72,6 @@ compose-dev.yaml !license-style.txt # Custom -test_accounts/ \ No newline at end of file +test_accounts/ +*.pem +*.pub \ No newline at end of file diff --git a/Dockerfile.devnet b/Dockerfile.devnet index 264282e..d040c89 100644 --- a/Dockerfile.devnet +++ b/Dockerfile.devnet @@ -1,42 +1,44 @@ -##### -# Source of precompiled avalanchego -##### +# Stage 1: Download precompiled avalanchego ARG INSTALL_AVALANCHEGO_VERSION_SHORT=d366a137 FROM avaplatform/avalanchego:${INSTALL_AVALANCHEGO_VERSION_SHORT} AS avalanchego -##### -# Base layer with hypersdk -##### +# Stage 2: Prepare a Go environment 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 +# Install dependencies and tools +RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -y \ + curl git && apt clean && rm -rf /var/lib/apt/lists/* +# Set working directory and Go mod cache path WORKDIR /app +ENV GOMODCACHE=/go/pkg/mod -RUN go install github.com/onsi/ginkgo/v2/ginkgo@v2.13.1 +# Copy the avalanchego binary from the first stage +COPY --from=avalanchego /avalanchego/build/avalanchego /root/.hypersdk/avalanchego-v1.11.12-rc.2/avalanchego -COPY ./go.mod ./go.sum ./ +# Install Ginkgo for testing +RUN go install github.com/onsi/ginkgo/v2/ginkgo@v2.13.1 +# Copy project files to the build context +COPY go.mod go.sum ./ COPY ./actions ./actions -COPY ./chain ./chain -COPY ./cmd/nuklaivm ./cmd/nuklaivm +COPY ./cmd ./cmd COPY ./consts ./consts +COPY ./dataset ./dataset COPY ./emission ./emission COPY ./genesis ./genesis -COPY ./marketplace ./marketplace COPY ./scripts ./scripts COPY ./storage ./storage COPY ./tests ./tests +COPY ./utils ./utils COPY ./vm ./vm -WORKDIR /app +# Build the application binary (if needed for your project) +RUN go mod download && go mod verify +# Optional: If your project builds a Go binary, compile it +# Uncomment this if you have a main package to build. +# RUN go build -o /app/nuklaivm ./cmd/nuklaivm -ENTRYPOINT ["/bin/bash", "-c", "./scripts/stop.sh; ./scripts/run.sh && echo 'Devnet started' && tail -f /dev/null"] +# Set entrypoint to a script that will stop and start the devnet +ENTRYPOINT ["bash", "-c", "./scripts/stop.sh; ./scripts/run.sh && echo 'Devnet started' && tail -f /dev/null"] diff --git a/Dockerfile.faucet b/Dockerfile.faucet index 1be8ddf..9ef6f11 100644 --- a/Dockerfile.faucet +++ b/Dockerfile.faucet @@ -23,6 +23,4 @@ RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -y curl && apt clea COPY --from=faucet-builder /build/build/faucet /faucet - - ENTRYPOINT ["/faucet"] diff --git a/Dockerfile.frontend b/Dockerfile.frontend index aaed038..7097f09 100644 --- a/Dockerfile.frontend +++ b/Dockerfile.frontend @@ -1,12 +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/package.json web_wallet/yarn.lock ./ +RUN --mount=type=cache,target=/root/.yarn-cache yarn install COPY web_wallet/ ./web_wallet/ WORKDIR /app/web_wallet -RUN npm run build-no-check +RUN yarn build-no-check # Adjusted to use yarn -# # Production stage +# Production stage FROM nginx:latest COPY --from=build /app/web_wallet/dist /usr/share/nginx/html diff --git a/README.md b/README.md index 0fd261b..7d7a620 100644 --- a/README.md +++ b/README.md @@ -182,6 +182,29 @@ This should return the following JSON: } ``` +You can also check the balance by doing: + +```bash +curl -X POST --data '{ + "jsonrpc":"2.0", + "id" :1, + "method" :"nuklaivm.balance", + "params" : {"address":"00c4cb545f748a28770042f893784ce85b107389004d6a0e0d6d7518eeae1292d9","asset":"NAI"} +}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/nuklaivm/nuklaiapi +``` + +This should return the following JSON: + +```json +{ + "jsonrpc": "2.0", + "result": { + "amount": 853000000000000000 + }, + "id": 1 +} +``` + Note: if you run into any issues starting your network, try running the following commands to troubleshoot and create a GitHub issue to report: ```bash diff --git a/cmd/nuklai-cli/cmd/genesis.go b/cmd/nuklai-cli/cmd/genesis.go index d0c3f75..83af594 100644 --- a/cmd/nuklai-cli/cmd/genesis.go +++ b/cmd/nuklai-cli/cmd/genesis.go @@ -11,6 +11,7 @@ import ( "github.com/nuklai/nuklaivm/genesis" "github.com/spf13/cobra" + "github.com/ava-labs/hypersdk/codec" "github.com/ava-labs/hypersdk/fees" hgenesis "github.com/ava-labs/hypersdk/genesis" @@ -23,11 +24,16 @@ var genesisCmd = &cobra.Command{ }, } +type GenesisCustomAllocation struct { + Address string `json:"address"` + Balance uint64 `json:"balance"` +} + var genGenesisCmd = &cobra.Command{ - Use: "generate [custom allocates file] [options]", + Use: "generate [custom allocations file] [emission balancer file] [options]", Short: "Creates a new genesis in the default location", PreRunE: func(_ *cobra.Command, args []string) error { - if len(args) != 1 { + if len(args) != 2 { return ErrInvalidArgs } return nil @@ -38,10 +44,22 @@ var genGenesisCmd = &cobra.Command{ return err } // Read custom allocations file - var allocs []*hgenesis.CustomAllocation + var allocs []*GenesisCustomAllocation if err := json.Unmarshal(a, &allocs); err != nil { return err } + // Convert []*GenesisCustomAllocation to []*hgenesis.CustomAllocation + convertedAllocs := make([]*hgenesis.CustomAllocation, len(allocs)) + for i, alloc := range allocs { + convertedAddress, err := codec.StringToAddress(alloc.Address) + if err != nil { + return err + } + convertedAllocs[i] = &hgenesis.CustomAllocation{ + Address: convertedAddress, + Balance: alloc.Balance, + } + } // Read emission balancer file eb, err := os.ReadFile(args[1]) @@ -53,7 +71,7 @@ var genGenesisCmd = &cobra.Command{ return err } - genesis := genesis.NewGenesis(allocs, emissionBalancer) + genesis := genesis.NewGenesis(convertedAllocs, emissionBalancer) if len(minUnitPrice) > 0 { d, err := fees.ParseDimensions(minUnitPrice) if err != nil { diff --git a/docs/deployment/genesis-allocations.json b/docs/deployment/genesis-allocations.json new file mode 100644 index 0000000..81a6408 --- /dev/null +++ b/docs/deployment/genesis-allocations.json @@ -0,0 +1,6 @@ +[ + { + "address": "002b5d019495996310f81c6a26a4dd9eeb9a3f3be1bac0a9294436713aecc84496", + "balance": 853000000000000000 + } +] diff --git a/docs/deployment/genesis-emission-balancer.json b/docs/deployment/genesis-emission-balancer.json new file mode 100644 index 0000000..a173ee9 --- /dev/null +++ b/docs/deployment/genesis-emission-balancer.json @@ -0,0 +1,4 @@ +{ + "maxSupply": 10000000000000000000, + "emissionAddress": "00f3b89e583e3944dee8d45ca40ce30829eff47481bc45669d401c2f9cc2bc110d" +} diff --git a/docs/deployment/nuklaivm_chain.json b/docs/deployment/nuklaivm_chain.json index dbb0817..e7da89f 100644 --- a/docs/deployment/nuklaivm_chain.json +++ b/docs/deployment/nuklaivm_chain.json @@ -19,8 +19,8 @@ "continuousProfilerDir": "/home/ubuntu/nuklaivm-profiles", "logLevel": "INFO", "mempoolExemptSponsors": [ - "nuklai1qpg4ecapjymddcde8sfq06dshzpxltqnl47tvfz0hnkesjz7t0p35d5fnr3", - "nuklai1qr4hhj8vfrnmzghgfnqjss0ns9tv7pjhhhggfm2zeagltnlmu4a6sgh6dqn" + "002b5d019495996310f81c6a26a4dd9eeb9a3f3be1bac0a9294436713aecc84496", + "00f3b89e583e3944dee8d45ca40ce30829eff47481bc45669d401c2f9cc2bc110d" ], "authVerificationCores": 2, "rootGenerationCores": 2, diff --git a/docs/deployment/nuklaivm_genesis.json b/docs/deployment/nuklaivm_genesis.json index 2a190fa..dcfc6a0 100644 --- a/docs/deployment/nuklaivm_genesis.json +++ b/docs/deployment/nuklaivm_genesis.json @@ -1,30 +1,60 @@ { "stateBranchFactor": 16, - "minBlockGap": 250, - "minEmptyBlockGap": 2500, - "minUnitPrice": [100, 100, 100, 100, 100], - "unitPriceChangeDenominator": [48, 48, 48, 48, 48], - "windowTargetUnits": [40000000, 450000, 450000, 450000, 450000], - "maxBlockUnits": [1800000, 1800000, 1800000, 1800000, 1800000], - "validityWindow": 60000, - "baseUnits": 1, - "baseWarpUnits": 1024, - "warpUnitsPerSigner": 128, - "outgoingWarpComputeUnits": 1024, - "storageKeyReadUnits": 5, - "storageValueReadUnits": 2, - "storageKeyAllocateUnits": 20, - "storageValueAllocateUnits": 5, - "storageKeyWriteUnits": 10, - "storageValueWriteUnits": 3, "customAllocation": [ { - "address": "nuklai1qpg4ecapjymddcde8sfq06dshzpxltqnl47tvfz0hnkesjz7t0p35d5fnr3", + "address": "0x002b5d019495996310f81c6a26a4dd9eeb9a3f3be1bac0a9294436713aecc84496", "balance": 853000000000000000 } ], + "initialRules": { + "networkID": 0, + "chainID": "11111111111111111111111111111111LpoYY", + "minBlockGap": 250, + "minEmptyBlockGap": 750, + "minUnitPrice": { + "bandwidth": 1, + "compute": 1, + "storageRead": 1, + "storageAllocate": 1, + "storageWrite": 1 + }, + "unitPriceChangeDenominator": { + "bandwidth": 48, + "compute": 48, + "storageRead": 48, + "storageAllocate": 48, + "storageWrite": 48 + }, + "windowTargetUnits": { + "bandwidth": 40000000, + "compute": 450000, + "storageRead": 450000, + "storageAllocate": 450000, + "storageWrite": 450000 + }, + "maxBlockUnits": { + "bandwidth": 1800000, + "compute": 18446744073709552000, + "storageRead": 18446744073709552000, + "storageAllocate": 18446744073709552000, + "storageWrite": 18446744073709552000 + }, + "validityWindow": 60000, + "maxActionsPerTx": 16, + "maxOutputsPerAction": 1, + "baseUnits": 1, + "storageKeyReadUnits": 5, + "storageValueReadUnits": 2, + "storageKeyAllocateUnits": 20, + "storageValueAllocateUnits": 5, + "storageKeyWriteUnits": 10, + "storageValueWriteUnits": 3, + "sponsorStateKeysMaxChunks": [ + 1 + ] + }, "emissionBalancer": { - "maxSupply": 1e19, - "emissionAddress": "nuklai1qr4hhj8vfrnmzghgfnqjss0ns9tv7pjhhhggfm2zeagltnlmu4a6sgh6dqn" + "maxSupply": 1e+19, + "emissionAddress": "00f3b89e583e3944dee8d45ca40ce30829eff47481bc45669d401c2f9cc2bc110d" } } diff --git a/scripts/aws/deploy.devnet.sh b/scripts/aws/deploy.devnet.sh new file mode 100755 index 0000000..c14a92c --- /dev/null +++ b/scripts/aws/deploy.devnet.sh @@ -0,0 +1,76 @@ +#!/bin/bash +# Copyright (C) 2024, Nuklai. All rights reserved. +# See the file LICENSE for licensing terms. + + +if [[ $(basename "$PWD") != "nuklaivm" ]]; then + echo "Error: This script must be executed from the repository root (nuklaivm/)." + exit 1 +fi + +KEY_NAME="./scripts/aws/nuklaivm-aws-key.pem" +INSTANCE_NAME="nuklai-devnet-instance" +REGION="eu-west-1" +INSTANCE_TYPE="t2.medium" +SECURITY_GROUP="sg-07b07fac5e31bc731" +USER_DATA_FILE="./scripts/aws/install_docker.sh" +TARBALL="nuklaivm.tar.gz" +AMI_ID="ami-008d05461f83df5b1" + +echo "Using AMI ID: $AMI_ID" + +INSTANCE_ID=$(aws ec2 describe-instances --region $REGION \ + --filters "Name=tag:Name,Values=$INSTANCE_NAME" "Name=instance-state-name,Values=running" \ + --query "Reservations[0].Instances[0].InstanceId" --output text) + +if [ "$INSTANCE_ID" != "None" ]; then + echo "Existing instance found. Terminating it..." + aws ec2 terminate-instances --instance-ids $INSTANCE_ID --region $REGION + aws ec2 wait instance-terminated --instance-ids $INSTANCE_ID --region $REGION + echo "Instance terminated." +fi + +echo "Launching a new EC2 instance..." +INSTANCE_ID=$(aws ec2 run-instances --region $REGION \ + --image-id $AMI_ID --count 1 --instance-type $INSTANCE_TYPE \ + --key-name nuklaivm-aws-key --security-group-ids $SECURITY_GROUP \ + --associate-public-ip-address \ + --block-device-mappings 'DeviceName=/dev/xvda,Ebs={VolumeSize=1000,VolumeType=gp3,DeleteOnTermination=true}' \ + --tag-specifications "ResourceType=instance,Tags=[{Key=Name,Value=$INSTANCE_NAME}]" \ + --user-data file://$USER_DATA_FILE \ + --query "Instances[0].InstanceId" --output text) + +echo "Waiting for the instance to start..." +aws ec2 wait instance-running --instance-ids $INSTANCE_ID --region $REGION +echo "Instance started. ID: $INSTANCE_ID" + +PUBLIC_IP=$(aws ec2 describe-instances --instance-ids $INSTANCE_ID --region $REGION \ + --query "Reservations[0].Instances[0].PublicIpAddress" --output text) + +echo "EC2 instance public IP: $PUBLIC_IP" +sleep 60 + +# Create a tarball of the project root, excluding web_wallet and ignored files +echo "Creating tarball of the project, excluding web_wallet and ignored files..." +EXCLUDES=$(cat .gitignore .dockerignore 2>/dev/null | grep -v '^#' | sed '/^$/d' | sed 's/^/--exclude=/' | tr '\n' ' ') +EXCLUDES+=" --exclude='./web_wallet' --exclude=$TARBALL" +eval "tar -czf $TARBALL $EXCLUDES -C . ." + +echo "Transferring tarball to the EC2 instance..." +scp -o "StrictHostKeyChecking=no" -i $KEY_NAME $TARBALL ec2-user@$PUBLIC_IP:/home/ec2-user/ + +echo "Connecting to the EC2 instance and deploying devnet..." +ssh -o "StrictHostKeyChecking=no" -i $KEY_NAME ec2-user@$PUBLIC_IP << 'EOF' + docker stop nuklai-devnet || true + docker rm nuklai-devnet || true + + cd /home/ec2-user + tar -xzf nuklaivm.tar.gz --strip-components=1 + + docker build -t nuklai-devnet -f Dockerfile.devnet . + docker run -d --name nuklai-devnet -p 9650:9650 nuklai-devnet + + echo "Devnet is running on the instance." +EOF + +echo "Deployment completed. Access the devnet at: http://$PUBLIC_IP:9650" diff --git a/scripts/aws/install_docker.sh b/scripts/aws/install_docker.sh new file mode 100755 index 0000000..d791269 --- /dev/null +++ b/scripts/aws/install_docker.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# Copyright (C) 2024, Nuklai. All rights reserved. +# See the file LICENSE for licensing terms. + +yum update -y +yum install -y docker git +service docker start +usermod -aG docker ec2-user diff --git a/scripts/build.sh b/scripts/build.sh index e2367f5..d6098a6 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -24,4 +24,13 @@ NUKLAIVM_PATH=$( cd .. && pwd ) -build_project "$NUKLAIVM_PATH" "nuklai" "qeX5BUxbiwUhSePncmz1C7RdH6njYYv6dNZhJrdeXRKMnTpKt" +# Check if vmpath argument is provided +VMPATH=${1:-""} + +build_project "$NUKLAIVM_PATH" "nuklaivm" "qeX5BUxbiwUhSePncmz1C7RdH6njYYv6dNZhJrdeXRKMnTpKt" + +# If vmpath is provided, copy the binary to the specified vmpath +if [[ -n "$VMPATH" ]]; then + echo "Copying binary to $VMPATH" + cp "$NUKLAIVM_PATH/build/qeX5BUxbiwUhSePncmz1C7RdH6njYYv6dNZhJrdeXRKMnTpKt" "$VMPATH" +fi diff --git a/scripts/deploy.devnet.sh b/scripts/deploy.devnet.sh index 0e507fd..372b4be 100755 --- a/scripts/deploy.devnet.sh +++ b/scripts/deploy.devnet.sh @@ -40,26 +40,25 @@ if ! aws sts get-caller-identity >/dev/null 2>&1 ; then fi # Set AvalancheGo Build (should have canPop disabled) -AVALANCHEGO_VERSION=v1.11.6 +AVALANCHEGO_VERSION=v1.11.12-rc.2 # Create temporary directory for the deployment -TMPDIR=/tmp/nuklaivm-deploy +TMPDIR=/tmp/nuklaivm-deploy-test rm -rf $TMPDIR && mkdir -p $TMPDIR echo -e "${YELLOW}set working directory:${NC} $TMPDIR" # Install avalanche-cli -LOCAL_CLI_COMMIT=bd174d7620be44dc91dee9415c71142f59fa9df2 -REMOTE_CLI_COMMIT=v1.6.3 +REMOTE_CLI_COMMIT=b0668aad98f12bc8a6f590a7fb6836a83b179101 # v1.6.3 cd $TMPDIR git clone https://github.com/ava-labs/avalanche-cli cd avalanche-cli -git checkout $LOCAL_CLI_COMMIT +git checkout $REMOTE_CLI_COMMIT ./scripts/build.sh mv ./bin/avalanche "${TMPDIR}/avalanche" cd $pw # Install nuklai-cli -NUKLAI_VM_COMMIT=main +NUKLAI_VM_COMMIT=update-deploy-devnet-script echo -e "${YELLOW}building nuklai-cli${NC}" echo "set working directory: $TMPDIR" cd $TMPDIR @@ -77,14 +76,14 @@ mv ./build/nuklai-cli "${TMPDIR}/nuklai-cli" cd $pw # Generate genesis file and configs -MIN_BLOCK_GAP=3500 +MIN_BLOCK_GAP=250 MIN_UNIT_PRICE="1,1,1,1,1" WINDOW_TARGET_UNITS="40000000,450000,450000,450000,450000" MAX_UINT64=18446744073709551615 MAX_BLOCK_UNITS="1800000,${MAX_UINT64},${MAX_UINT64},${MAX_UINT64},${MAX_UINT64}" -INITIAL_OWNER_ADDRESS=${INITIAL_OWNER_ADDRESS:-nuklai1qpg4ecapjymddcde8sfq06dshzpxltqnl47tvfz0hnkesjz7t0p35d5fnr3} -EMISSION_ADDRESS=${EMISSION_ADDRESS:-nuklai1qr4hhj8vfrnmzghgfnqjss0ns9tv7pjhhhggfm2zeagltnlmu4a6sgh6dqn} +INITIAL_OWNER_ADDRESS=${INITIAL_OWNER_ADDRESS:-002b5d019495996310f81c6a26a4dd9eeb9a3f3be1bac0a9294436713aecc84496} +EMISSION_ADDRESS=${EMISSION_ADDRESS:-00f3b89e583e3944dee8d45ca40ce30829eff47481bc45669d401c2f9cc2bc110d} # Sum of allocations must be less than uint64 max cat < "${TMPDIR}"/allocations.json [ @@ -110,32 +109,15 @@ EOF # TODO: we limit root generation cores because it can cause network handling to stop (exhausts all CPU for a few seconds) cat < "${TMPDIR}"/nuklaivm.config { - "chunkBuildFrequency": 250, - "targetChunkBuildDuration": 250, - "blockBuildFrequency": 100, - "mempoolSize": 2147483648, + "mempoolSize": 10000000, "mempoolSponsorSize": 10000000, - "authExecutionCores": 2, - "precheckCores": 2, - "actionExecutionCores": 2, - "missingChunkFetchers": 2, - "verifyAuth": true, - "authRPCCores": 2, - "authRPCBacklog": 10000000, - "authGossipCores": 2, - "authGossipBacklog": 10000000, - "chunkStorageCores": 2, - "chunkStorageBacklog": 10000000, - "streamingBacklogSize": 10000000, - "continuousProfilerDir":"/home/ubuntu/nuklaivm-profiles", - "logLevel": "INFO", - "mempoolExemptSponsors": [ - "nuklai1qpg4ecapjymddcde8sfq06dshzpxltqnl47tvfz0hnkesjz7t0p35d5fnr3", - "nuklai1qr4hhj8vfrnmzghgfnqjss0ns9tv7pjhhhggfm2zeagltnlmu4a6sgh6dqn" - ], "authVerificationCores": 2, "rootGenerationCores": 2, "transactionExecutionCores": 2, + "verifyAuth": true, + "streamingBacklogSize": 10000000, + "stateSyncServerDelay": 100000000, + "stateSyncMinBlocks": 512, "storeTransactions": true } EOF @@ -143,7 +125,7 @@ EOF cat < "${TMPDIR}"/nuklaivm.subnet { - "proposerMinBlockDelay": 1000, + "proposerMinBlockDelay": 0, "proposerNumHistoricalBlocks": 100000000 } EOF @@ -152,40 +134,45 @@ cat < "${TMPDIR}"/node.config { "log-level":"INFO", "log-display-level":"INFO", - "proposervm-use-current-height":true, - "throttler-inbound-validator-alloc-size":"10737418240", - "throttler-inbound-at-large-alloc-size":"10737418240", - "throttler-inbound-node-max-processing-msgs":"1000000", - "throttler-inbound-node-max-at-large-bytes":"10737418240", - "throttler-inbound-bandwidth-refill-rate":"1073741824", - "throttler-inbound-bandwidth-max-burst-size":"1073741824", - "throttler-inbound-cpu-validator-alloc":"100000", - "throttler-inbound-cpu-max-non-validator-usage":"100000", - "throttler-inbound-cpu-max-non-validator-node-usage":"100000", - "throttler-inbound-disk-validator-alloc":"10737418240000", - "throttler-outbound-validator-alloc-size":"10737418240", - "throttler-outbound-at-large-alloc-size":"10737418240", - "throttler-outbound-node-max-at-large-bytes":"10737418240", - "consensus-on-accept-gossip-validator-size":"10", - "consensus-on-accept-gossip-peer-size":"10", - "network-compression-type":"zstd", - "consensus-app-concurrency":"128", - "profile-continuous-enabled":true, - "profile-continuous-freq":"1m", - "http-host":"", - "http-allowed-origins": "*", - "http-allowed-hosts": "*" + "consensus-app-concurrency": 512, + "health-check-frequency": "2s", + "http-allowed-hosts": "*", + "http-host": "", + "index-enabled": true, + "log-display-level": "OFF", + "log-level": "DEBUG", + "min-stake-duration": "1s", + "network-max-reconnect-delay": "1s", + "network-peer-list-pull-gossip-frequency": "250ms", + "profile-continuous-enabled": true, + "profile-continuous-freq": "1m", + "proposervm-use-current-height": true, + "public-ip": "127.0.0.1", + "staking-host": "127.0.0.1", + "throttler-inbound-at-large-alloc-size": 10737418240, + "throttler-inbound-bandwidth-max-burst-size": 1073741824, + "throttler-inbound-bandwidth-refill-rate": 1073741824, + "throttler-inbound-cpu-validator-alloc": 100000, + "throttler-inbound-disk-validator-alloc": 10737418240000, + "throttler-inbound-node-max-at-large-bytes": 10737418240, + "throttler-inbound-node-max-processing-msgs": 100000, + "throttler-inbound-validator-alloc-size": 10737418240, + "throttler-outbound-at-large-alloc-size": 10737418240, + "throttler-outbound-node-max-at-large-bytes": 10737418240, + "throttler-outbound-validator-alloc-size": 10737418240, } EOF +# "http-allowed-origins": "*", +# "network-compression-type":"zstd", # Setup devnet CLUSTER="nuklai-$(date +%s)" interrupted=false function showcleanup { - if [ "$interrupted" = false ]; then + if [ "$interrupted" = false ]; then echo -e "\n\n${RED}run this command to destroy the devnet:${NC} ${TMPDIR}/avalanche node destroy ${CLUSTER}\n" - fi + fi } function cleanup { @@ -201,8 +188,7 @@ trap cleanup SIGINT # # It is not recommended to use an instance with burstable network performance. echo -e "${YELLOW}creating devnet${NC}" -$TMPDIR/avalanche node devnet wiz ${CLUSTER} ${VMID} --force-subnet-create=true --authorize-access=true --aws --node-type t4g.medium --num-apis 0 --num-validators 10 --region eu-west-1 --use-static-ip=false --enable-monitoring=false --auto-replace-keypair --default-validator-params=true --custom-avalanchego-version $AVALANCHEGO_VERSION --custom-vm-repo-url="https://www.github.com/nuklai/nuklaivm" --custom-vm-branch $VM_COMMIT --custom-vm-build-script="scripts/build.sh" --custom-subnet=true --subnet-genesis="${TMPDIR}/nuklaivm.genesis" --subnet-config="${TMPDIR}/nuklaivm.subnet" --chain-config="${TMPDIR}/nuklaivm.config" --node-config="${TMPDIR}/node.config" --config="${TMPDIR}/node.config" --remote-cli-version $REMOTE_CLI_COMMIT --add-grafana-dashboard="${TMPDIR}/nuklaivm/grafana.json" - +$TMPDIR/avalanche node devnet wiz ${CLUSTER} ${VMID} --force-subnet-create=true --authorize-access=true --aws --node-type t4g.medium --num-apis 0 --num-validators 2 --region eu-west-1 --use-static-ip=false --enable-monitoring=false --default-validator-params=true --custom-avalanchego-version $AVALANCHEGO_VERSION --custom-vm-repo-url="https://www.github.com/nuklai/nuklaivm" --custom-vm-branch $VM_COMMIT --custom-vm-build-script="scripts/build.sh" --custom-subnet=true --subnet-genesis="${TMPDIR}/nuklaivm.genesis" --subnet-config="${TMPDIR}/nuklaivm.subnet" --chain-config="${TMPDIR}/nuklaivm.config" --node-config="${TMPDIR}/node.config" --config="${TMPDIR}/node.config" # Import the cluster into nuklai-cli for local interaction $TMPDIR/nuklai-cli chain import-cli $HOME/.avalanche-cli/nodes/inventories/$CLUSTER/clusterInfo.yaml diff --git a/scripts/hypersdk/common/build.sh b/scripts/hypersdk/common/build.sh index 6c02b16..0a6e297 100644 --- a/scripts/hypersdk/common/build.sh +++ b/scripts/hypersdk/common/build.sh @@ -30,12 +30,13 @@ build_project() { cd "$project_path" - echo "Building "${project_name}vm" in $binary_path" + echo "Building "${project_name}" in $binary_path" mkdir -p "$(dirname "$binary_path")" - go build -o "$binary_path" ./cmd/"${project_name}vm" + go build -o "$binary_path" ./cmd/"${project_name}" - cli_path=$project_path/build/nuklai-cli - echo "Building "${project_name}-cli" in $cli_path" + cli_name="${project_name%vm}-cli" + cli_path=$project_path/build/$cli_name + echo "Building "${cli_name}" in $cli_path" mkdir -p "$(dirname "$cli_path")" - go build -o "$cli_path" ./cmd/nuklai-cli + go build -o "$cli_path" ./cmd/${cli_name} }