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

feat: sdk-47 #174

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 1 addition & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,4 @@ AKASH_TS_ROOT=${AKASH_ROOT}/ts
AKASH_TS_PACKAGE_FILE=${AKASH_TS_ROOT}/package.json
AKASH_TS_NODE_MODULES=${AKASH_TS_ROOT}/node_modules
AKASH_TS_NODE_BIN=${AKASH_TS_NODE_MODULES}/.bin
AKASH_DEVCACHE_TS_TMP=${AKASH_DEVCACHE_BASE}/tmp/ts
AKASH_DEVCACHE_TS_TMP_GRPC_JS=${AKASH_DEVCACHE_TS_TMP}/generated-grpc-js
AKASH_DEVCACHE_TS_TMP_PATCHES=${AKASH_DEVCACHE_TS_TMP}/patches
AKASH_DEVCACHE_TMP=${AKASH_DEVCACHE_BASE}/tmp
31 changes: 26 additions & 5 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ AKASH_ROOT=$(pwd)
export AKASH_ROOT

dotenv
dotenv_if_exists dev.env

TOOLS=${AKASH_ROOT}/script/tools.sh
SEMVER=${AKASH_ROOT}/script/semver.sh
SCRIPT_DIR=${AKASH_ROOT}/script

TOOLS=${SCRIPT_DIR}/tools.sh
SEMVER=${SCRIPT_DIR}/semver.sh

GOTOOLCHAIN=$(${TOOLS} gotoolchain)
GOTOOLCHAIN_SEMVER=$(echo "${GOTOOLCHAIN}" | sed 's/go*/v/' | tr -d '\n')
Expand All @@ -19,13 +20,33 @@ fi

AKASH_DIRENV_SET=1

dotenv_if_exists dev.env

if [[ ${GOWORK} != "off" ]] && [[ -f go.work ]]; then
GOWORK=${AKASH_ROOT}/go.work
else
GOWORK=off
fi

export SCRIPT_DIR
export TOOLS
export SEMVER
export GOTOOLCHAIN
export GOTOOLCHAIN_SEMVER
export AKASH_DIRENV_SET

make cache

PATH_add "$AKASH_DEVCACHE_NODE_BIN"
PATH_add "$AKASH_DEVCACHE_BIN"
PATH_add "$AKASH_TS_NODE_BIN"
PATH_add "$AKASH_TS_ROOT/script"
PATH_add "$AKASH_DEVCACHE_BIN"

make cache
if [ ! -L "$AKASH_DEVCACHE_BIN/repo-tools" ]; then
pushd "$(pwd)" || exit
cd "$AKASH_DEVCACHE_BIN" || exit
ln -snf ../../script/tools.sh repo-tools
popd || exit
fi

make semver
6 changes: 0 additions & 6 deletions .github/workflows/release-ts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,3 @@ jobs:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: make release-ts

- name: Upload Test Coverage
uses: codecov/codecov-action@v4
with:
files: ./ts/coverage
token: ${{ secrets.CODECOV_TOKEN }}

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### dev environment configurations
.idea
.cache
.vscode

### Go template
# Test binary, built with `go test -c`
Expand All @@ -13,7 +14,9 @@
vendor/

# Go workspace file
# do not use glob pattern, as it breaks including go.work.example
go.work
go.work.sum

# coverage
coverage.txt
Expand Down
9 changes: 4 additions & 5 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ issues:
exclude:
- comment on exported (method|function|type|const|var)
exclude-use-default: true

# Skip generated k8s code
run:
exclude-dirs:
- "^go/node/types/v1beta1"
- "^go/node/types/v1beta2"
- "^go/node/market/v1beta3"
exclude-files:
- "\\.pb\\.go$"
- "\\.pb\\.gw\\.go$"
# Skip vendor/ etc
exclude-dirs-use-default: true
# Skip generated k8s code
skip-dirs-use-default: true
linters:
disable-all: true
enable:
Expand Down
5 changes: 0 additions & 5 deletions .mockery.yaml

This file was deleted.

69 changes: 54 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
UNAME_OS := $(shell uname -s)
UNAME_ARCH := $(shell uname -m)
PROTO_LEGACY ?= true

ifeq (0, $(shell id -u))
$(warning "make was started with superuser privileges. it may cause issues with direnv")
Expand All @@ -24,44 +23,76 @@ ifeq (, $(GOTOOLCHAIN))
$(error "GOTOOLCHAIN is not set")
endif

ifeq ($(GO111MODULE),off)
else
GOMOD=readonly
endif

ifneq ($(GOWORK),off)
ifeq ($(shell test -e ${AKASH_ROOT}/go/go.work && echo -n yes),yes)
GOWORK=${AKASH_ROOT}/go/go.work
else
GOWORK=off
endif
endif

ifneq ($(GOWORK),off)
ifeq ($(GOMOD),$(filter $(GOMOD),mod ""))
$(error '-mod may only be set to readonly or vendor when in workspace mode, but it is set to ""')
endif
endif

ifeq ($(GOMOD),vendor)
ifneq ($(wildcard ./vendor/.),)
$(error "go -mod is in vendor mode but vendor dir has not been found. consider to run go mod vendor")
endif
endif

GO_ROOT := go
TS_ROOT := $(AKASH_TS_ROOT)

BUMP_MOD ?=

GO := GO111MODULE=$(GO111MODULE) go
GO_MOD_NAME := $(shell go list -m 2>/dev/null)

BUF_VERSION ?= 1.28.1
PROTOC_VERSION ?= 21.12
GOGOPROTO_VERSION ?= $(shell $(GO) list -mod=readonly -m -f '{{ .Version }}' github.com/cosmos/gogoproto)
# TODO https://github.com/akash-network/support/issues/77
PROTOC_GEN_GOCOSMOS_VERSION ?= $(shell $(GO) list -mod=readonly -m -f '{{ .Version }}' github.com/regen-network/cosmos-proto)
PROTOC_GEN_GO_PULSAR_VERSION ?= $(shell $(GO) list -mod=readonly -m -f '{{ .Version }}' github.com/cosmos/cosmos-proto)
PROTOC_GEN_GO_VERSION ?= $(shell $(GO) list -mod=readonly -m -f '{{ .Version }}' google.golang.org/protobuf)
PROTOC_GEN_GRPC_GATEWAY_VERSION := $(shell $(GO) list -mod=readonly -m -f '{{ .Version }}' github.com/grpc-ecosystem/grpc-gateway)
PROTOC_GEN_DOC_VERSION := $(shell $(GO) list -mod=readonly -m -f '{{ .Version }}' github.com/pseudomuto/protoc-gen-doc)
GO_MOD_NAME := $(shell cd $(GO_ROOT); GOWORK=off go list -m 2>/dev/null)

BUF_VERSION ?= 1.47.2
PROTOC_VERSION ?= 29.1
GOGOPROTO_VERSION ?= $(shell cd $(GO_ROOT); $(GO) list -mod=readonly -m -f '{{ .Version }}' github.com/cosmos/gogoproto)
PROTOC_GEN_GOCOSMOS_VERSION ?= $(GOGOPROTO_VERSION)
PROTOC_GEN_GO_PULSAR_VERSION ?= $(shell cd $(GO_ROOT); $(GO) list -mod=readonly -m -f '{{ .Version }}' github.com/cosmos/cosmos-proto)
PROTOC_GEN_GO_VERSION ?= $(shell cd $(GO_ROOT); $(GO) list -mod=readonly -m -f '{{ .Version }}' google.golang.org/protobuf)
PROTOC_GEN_GRPC_GATEWAY_VERSION := $(shell cd $(GO_ROOT); $(GO) list -mod=readonly -m -f '{{ .Version }}' github.com/grpc-ecosystem/grpc-gateway)
PROTOC_GEN_DOC_VERSION := $(shell cd $(GO_ROOT); $(GO) list -mod=readonly -m -f '{{ .Version }}' github.com/pseudomuto/protoc-gen-doc)
PROTOC_GEN_SWAGGER_VERSION := $(PROTOC_GEN_GRPC_GATEWAY_VERSION)
MODVENDOR_VERSION ?= v0.5.0
MOCKERY_VERSION ?= 2.42.0
MOCKERY_VERSION ?= 2.52.2
GOLANGCI_LINT_VERSION ?= v1.63.4
SEMVER_VERSION ?= v1.2.5

BUF_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/buf/$(BUF_VERSION)
PROTOC_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/protoc/$(PROTOC_VERSION)
GOGOPROTO_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/gogoproto/$(GOGOPROTO_VERSION)
PROTOC_GEN_GOCOSMOS_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/protoc-gen-gocosmos/$(PROTOC_GEN_GOCOSMOS_VERSION)
PROTOC_GEN_GO_PULSAR_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/protoc-gen-go-pulsar/$(PROTOC_GEN_GO_PULSAR_VERSION)
PROTOC_GEN_GO_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/protoc-gen-go/$(PROTOC_GEN_GO_VERSION)
PROTOC_GEN_GOGO_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/protoc-gen-gogo/$(GOGOPROTO_VERSION)
PROTOC_GEN_GRPC_GATEWAY_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/protoc-gen-grpc-gateway/$(PROTOC_GEN_GRPC_GATEWAY_VERSION)
PROTOC_GEN_SWAGGER_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/protoc-gen-swagger/$(PROTOC_GEN_SWAGGER_VERSION)
PROTOC_GEN_DOC_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/protoc-gen-doc/$(PROTOC_GEN_DOC_VERSION)
MODVENDOR_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/modvendor/$(MODVENDOR_VERSION)
GIT_CHGLOG_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/git-chglog/$(GIT_CHGLOG_VERSION)
MOCKERY_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/mockery/v$(MOCKERY_VERSION)
GOLANGCI_LINT_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/golangci-lint/$(GOLANGCI_LINT_VERSION)
SEMVER_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/semver/$(SEMVER_VERSION)

BUF := $(AKASH_DEVCACHE_BIN)/buf
PROTOC := $(AKASH_DEVCACHE_BIN)/protoc
# TODO https://github.com/akash-network/support/issues/77
PROTOC_GEN_GOCOSMOS := $(AKASH_DEVCACHE_BIN)/legacy/protoc-gen-gocosmos
PROTOC_GEN_GOCOSMOS := $(AKASH_DEVCACHE_BIN)/protoc-gen-gocosmos
GOGOPROTO := $(AKASH_DEVCACHE_BIN)/gogoproto
PROTOC_GEN_GO_PULSAR := $(AKASH_DEVCACHE_BIN)/protoc-gen-go-pulsar
PROTOC_GEN_GO := $(AKASH_DEVCACHE_BIN)/protoc-gen-go
PROTOC_GEN_GOGO := $(AKASH_DEVCACHE_BIN)/protoc-gen-gogo
PROTOC_GEN_GRPC_GATEWAY := $(AKASH_DEVCACHE_BIN)/protoc-gen-grpc-gateway
PROTOC_GEN_SWAGGER := $(AKASH_DEVCACHE_BIN)/protoc-gen-swagger
PROTOC_GEN_DOC := $(AKASH_DEVCACHE_BIN)/protoc-gen-doc
Expand All @@ -70,13 +101,17 @@ GIT_CHGLOG := $(AKASH_DEVCACHE_BIN)/git-chglog
SWAGGER_COMBINE := $(AKASH_DEVCACHE_NODE_BIN)/swagger-combine
MOCKERY := $(AKASH_DEVCACHE_BIN)/mockery
GOLANGCI_LINT := $(AKASH_DEVCACHE_BIN)/golangci-lint
SEMVER := $(AKASH_DEVCACHE_BIN)/semver

GOLANGCI_LINT_RUN := $(GOLANGCI_LINT) run
GOLINT := $(GOLANGCI_LINT_RUN) ./... --disable-all --timeout=5m --enable

DOCKER_RUN := docker run --rm -v $(shell pwd):/workspace -w /workspace
DOCKER_BUF := $(DOCKER_RUN) bufbuild/buf:$(BUF_VERSION)

GO_MODULES ?= $(shell find * -name go.mod -exec dirname {} \;)
GO_TEST_DIRS ?= ./...

include $(AKASH_ROOT)/make/setup-cache.mk
include $(AKASH_ROOT)/make/mod.mk
include $(AKASH_ROOT)/make/test.mk
Expand All @@ -85,6 +120,10 @@ include $(AKASH_ROOT)/make/lint.mk
include $(AKASH_ROOT)/make/release-ts.mk
include $(AKASH_ROOT)/make/code-style.mk

.PHONY: bump-%
bump-%:
@./script/tools.sh bump "$*" "$(BUMP_MOD)"

.PHONY: clean
clean:
rm -rf $(AKASH_DEVCACHE)
Expand Down
93 changes: 72 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,78 @@
# Akash API
# Akash Chain SDK

[![Lint Status](https://github.com/akash-network/akash-api/actions/workflows/lint.yaml/badge.svg)](https://github.com/akash-network/akash-api/actions/workflows/lint.yaml)
[![Test Status](https://github.com/akash-network/akash-api/actions/workflows/tests.yaml/badge.svg)](https://github.com/akash-network/akash-api/actions/workflows/tests.yaml)

## Overview

This repository consolidates gRPC API definitions for the [Akash Node](https://github.com/akash-network/node) and [Akash Provider](https://github.com/akash-network/provider). It also includes related code generation.
This repository is a development gateway to the Akash Blockchain.
It aims following:
- Define data types and API via [protobuf](./proto)
- Akash Blockchain and it's stores, aka [node](./proto/node)
- Akash Provider Interface, aka [provider](./proto/provider)
- Define data types and API (both REST and GRPC) of Akash Provider Interface
- Provide official reference clients for supported [programming languages](#supported-languages)

Currently, two `buf` packages are defined, with potential future publication to BSR based on demand:
- **Node Package**: `buf.build/akash-network/node`
- Akash protobuf definitions, previously located in the [proto directory](https://github.com/akash-network/node/tree/master/proto/akash), are now under [proto/node/akash](./proto/node/akash).
- Generated code is available [here](./go/node).
- **Provider Package**: `buf.build/akash-network/provider`
- Akash manifest definitions, previously defined as plain Go structs, have been converted into Protobuf [definitions](./proto/provider/akash).

Proto documentation is available for:
- [Node](docs/proto/node.md)
- [Provider](docs/proto/provider.md)
## Supported languages

## Contributing
### Golang

Please submit issues via the [support repository](https://github.com/akash-network/support/issues) and tag them with `repo/akash-api`. All pull requests must be associated with an open issue in the support repository.
[This implementation](./go) provider all necessary code-generation as well as client defining Akash Blockchain
There are a few packages this implementation exports. All packages available via Vanity URLs which are hosted as [Github Pages](https://github.com/akash-network/vanity).
#### Go package

## Releases
Source code is located within [go](./go) directory

Releases indicate changes to the repository itself. API versions are defined within each module.
Contains all the types, clients and utilities nesessary to communicate with Akash Blockchain

```go
import "pkg.akt.dev/go"
```

## Pre-generated Packages
##### Migrate package

We provide generated code to allow developers to focus on features rather than stub generation:
- [Go](./go)
- [TS](./ts)
Depending on difference in API and stores between current and previous versions of the blockchain, there may be a **migrate** package. It is intended to be used by [node](https://github.com/akash-network/node) only.
```go
import "pkg.akt.dev/go/node/migrate"
```

## How to run protobuf codegen
#### SDL package

Reference implementation of the SDL.
```go
import "pkg.akt.dev/go/sdl"
```

#### CLI package

CLI package which combines improved version of cli clients from node](https://github.com/akash-network/node) and [cosmos-sdk](https://github.com/cosmos/cosmos-sdk)
```go
import "pkg.akt.dev/go/cli"
```

### TS

Source code is located within [ts](./ts) directory


## Protobuf

All protobuf definitions are located within [proto](./proto) directory.

This repository consolidates gRPC API definitions for the [Akash Node](https://github.com/akash-network/node) and [Akash Provider](https://github.com/akash-network/provider). It also includes related code generation.

Currently, two `buf` packages are defined, with potential future publication to BSR based on demand:
- **Node Package**: `buf.build/pkg.akt.dev/node`
- **Provider Package**: `buf.build/pkg.akt.dev/provider`

Proto documentation is available for:
- [Node](docs/proto/node.md)
- [Provider](docs/proto/provider.md)

Documentation in swagger format combining both node and provider packages can be located [here](./docs/swagger-ui/swagger.yaml)

### How to run protobuf codegen

If there is a need to run regenerate protobuf (in case of API or documentation changes):

Expand All @@ -48,9 +88,20 @@ If there is a need to run regenerate protobuf (in case of API or documentation c

3. Run codegen. This will
- Install all required tools into local cache
- generate changes for both `Go` and `TS` packages.
- generate changes to all [supported programming languages](#supported-languages)

```shell
make proto-gen
```
- to run codegen for specific language use `make proto-gen-<lang>`. For example
```shell
make proto-gen-go
```

## Releases

Releases indicate changes to the repository itself. API versions are defined within each module.

## Contributing

Please submit issues via the [support repository](https://github.com/akash-network/support/issues) and tag them with `repo/akash-api`. All pull requests must be associated with an open issue in the support repository.
20 changes: 15 additions & 5 deletions buf.gen.gogo.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
version: v1
version: v2
clean: false
managed:
enabled: false
plugins:
- name: gocosmos
- local: protoc-gen-gocosmos
out: .
strategy: directory
include_imports: false
include_wkt: false
opt:
- plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types
- name: grpc-gateway
- plugins=grpc
- Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types
- local: protoc-gen-grpc-gateway
strategy: directory
out: .
opt: logtostderr=true,allow_colon_final_segments=true
opt:
- logtostderr=true
- allow_colon_final_segments=true
Loading
Loading