├── upgrades ├── heightpatches │ └── .gitignore ├── upgrades.go ├── software │ ├── v1.1.0 │ │ └── init.go │ └── v1.0.0 │ │ ├── take.go │ │ ├── init.go │ │ ├── cert.go │ │ ├── audit.go │ │ └── provider.go ├── upgrades_test.go └── types │ └── helpers.go ├── .github ├── .repo ├── CODEOWNERS ├── repo ├── workflows │ ├── concommits.yaml │ ├── standardize-yaml.yaml │ ├── wip.yaml │ ├── stale.yaml │ ├── labeler.yaml │ └── dispatch.yaml ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── PULL_REQUEST_TEMPLATE │ └── other.md ├── actions │ └── setup-ubuntu │ │ └── action.yaml ├── PULL_REQUEST_TEMPLATE.md └── labeler.yaml ├── _build ├── .gitignore ├── Dockerfile.akash ├── single-node.sh └── Dockerfile.test ├── make ├── tools.mk ├── codegen.mk ├── mod.mk ├── lint.mk ├── test-integration.mk ├── test-simulation.mk └── setup-cache.mk ├── tests ├── upgrade │ ├── Makefile │ ├── test-config.json │ ├── test-config-gha.json │ ├── workers_test.go │ ├── config-v0.24.0.tmpl.json │ ├── types │ │ └── types.go │ ├── sdktypes.go │ └── testnet.json └── e2e │ ├── grpc_test.go │ ├── cli_test.go │ └── provider_cli_test.go ├── x ├── audit │ ├── query │ │ ├── client.go │ │ └── rawclient.go │ ├── alias.go │ ├── handler │ │ ├── handler.go │ │ └── msg_server.go │ └── keeper │ │ └── key.go ├── cert │ ├── errors │ │ └── certificate_errors.go │ ├── utils │ │ ├── constants.go │ │ └── utils.go │ ├── simulation │ │ └── genesis.go │ ├── alias.go │ └── handler │ │ ├── handler.go │ │ └── msg_server.go ├── provider │ ├── testdata │ │ ├── provider2.yaml │ │ └── provider.yaml │ ├── keeper │ │ ├── key.go │ │ └── grpc_query.go │ ├── simulation │ │ └── genesis.go │ ├── query │ │ ├── path.go │ │ ├── types.go │ │ ├── client.go │ │ └── rawclient.go │ ├── alias.go │ ├── handler │ │ ├── handler.go │ │ └── server.go │ ├── config │ │ └── config.go │ ├── client │ │ └── rest │ │ │ └── rest.go │ └── genesis.go ├── escrow │ ├── keeper │ │ ├── querier.go │ │ └── external.go │ ├── client │ │ ├── rest │ │ │ └── rest.go │ │ └── util │ │ │ └── util.go │ ├── alias.go │ ├── query │ │ └── querier.go │ └── handler │ │ ├── handler.go │ │ ├── keepers.go │ │ └── server.go ├── take │ ├── alias.go │ ├── simulation │ │ ├── genesis.go │ │ ├── decoder.go │ │ └── proposals.go │ ├── keeper │ │ └── grpc_query.go │ ├── handler │ │ └── server.go │ └── genesis.go ├── deployment │ ├── keeper │ │ └── external.go │ ├── alias.go │ ├── testdata │ │ ├── deployment-v2-nohost.yaml │ │ ├── deployment.yaml │ │ ├── deployment-v2.1.yaml │ │ ├── deployment-v2.yaml │ │ ├── deployment-v2-newcontainer.yaml │ │ ├── deployment-v2-updateA.yaml │ │ ├── deployment-v2-migrate.yaml │ │ ├── deployment-v2-updateB.yaml │ │ ├── deployment-v2-nodeport.yaml │ │ ├── deployment-v2-ip-endpoint.yaml │ │ ├── deployment-v2.1-ip-endpoint.yaml │ │ ├── deployment-v2-storage-default.yaml │ │ ├── deployment-v2-storage-beta2.yaml │ │ ├── deployment-v2-storage-updateC.yaml │ │ ├── deployment-v2-shared-ip-endpoint.yaml │ │ ├── deployment-v2.1-shared-ip-endpoint.yaml │ │ ├── deployment-v2-multi-ip-endpoint.yaml │ │ ├── deployment-v2.1-multi-ip-endpoint.yaml │ │ ├── deployment-v2-c2c.yaml │ │ ├── deployment-v2-escrow.yaml │ │ ├── deployment-v2-multi-groups-ip-endpoint.yaml │ │ └── deployment-v2.1-multi-groups-ip-endpoint.yaml │ ├── simulation │ │ ├── genesis.go │ │ └── proposals.go │ ├── query │ │ ├── client.go │ │ ├── rawclient.go │ │ ├── path.go │ │ └── types.go │ ├── handler │ │ ├── handler.go │ │ └── keepers.go │ └── genesis.go └── market │ ├── query │ ├── client.go │ └── rawclient.go │ ├── keeper │ └── external.go │ ├── alias.go │ ├── simulation │ ├── genesis.go │ ├── utils.go │ └── proposals.go │ ├── hooks │ └── external.go │ └── handler │ ├── handler.go │ └── keepers.go ├── util ├── partialord │ ├── module.go │ ├── internal │ │ └── dag │ │ │ └── module.go │ └── partialord_test.go ├── network │ └── network.go ├── cli │ ├── prompt.go │ └── upgrade_info.go ├── runner │ └── runner.go ├── wsutil │ ├── wsutil.go │ └── wsutil_test.go ├── server │ └── utils.go ├── metrics │ └── metrics.go └── validation │ └── address.go ├── cgo_trace.go ├── .dockerignore ├── tools.go ├── testutil ├── sim │ └── rand.go ├── network │ └── option.go ├── sims │ └── expected_keepers.go ├── cosmos │ └── keepers.go └── types.go ├── .convcommit.json ├── cmd └── akash │ ├── main.go │ └── cmd │ ├── bech32.go │ └── testnetify │ ├── utils.go │ └── cmt_abci.go ├── .mockery.yaml ├── _docs ├── version-control.md ├── adr │ └── adr-002-manifest-v2beta2.md └── img │ └── logo-label-black.svg ├── .gitignore ├── script ├── is_prerelease.sh ├── mainnet-from-tag.sh ├── shellcheck.sh └── genchangelog.sh ├── .env ├── codecov.yml ├── app ├── params │ └── weights.go ├── option.go ├── mac.go ├── types │ └── app_test.go ├── upgrades.go ├── config.go └── ante.go ├── docgen └── main.go ├── .chglog ├── config.yaml └── CHANGELOG.tpl.md ├── pubsub └── util.go ├── .golangci.yaml ├── tools └── upgrade-info │ └── main.go ├── client └── utils.go ├── meta.json ├── CHANGELOG.md ├── .envrc ├── .goreleaser-docker.yaml ├── .goreleaser-test-bins.yaml └── Makefile /upgrades/heightpatches/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.github/.repo: -------------------------------------------------------------------------------- 1 | github.com/akash-network/node 2 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @akash-network/core 2 | -------------------------------------------------------------------------------- /.github/repo: -------------------------------------------------------------------------------- 1 | github.com/akash-network/node 2 | -------------------------------------------------------------------------------- /_build/.gitignore: -------------------------------------------------------------------------------- 1 | # docker binaries 2 | /akash 3 | /config 4 | /data 5 | -------------------------------------------------------------------------------- /make/tools.mk: -------------------------------------------------------------------------------- 1 | gofmt: 2 | find . -not -path './vendor*' -name '*.go' -type f | xargs gofmt -s -w 3 | -------------------------------------------------------------------------------- /tests/upgrade/Makefile: -------------------------------------------------------------------------------- 1 | include $(ROOT_DIR)/make/init.mk 2 | include $(ROOT_DIR)/make/test-upgrade.mk 3 | -------------------------------------------------------------------------------- /x/audit/query/client.go: -------------------------------------------------------------------------------- 1 | package query 2 | 3 | // Client interface 4 | type Client interface { 5 | } 6 | -------------------------------------------------------------------------------- /upgrades/upgrades.go: -------------------------------------------------------------------------------- 1 | package upgrades 2 | 3 | import ( 4 | // nolint: revive 5 | _ "pkg.akt.dev/node/upgrades/software/v1.1.0" 6 | ) 7 | -------------------------------------------------------------------------------- /util/partialord/module.go: -------------------------------------------------------------------------------- 1 | // Package partialord allows one to define partial orderings, and derive a total ordering 2 | package partialord 3 | -------------------------------------------------------------------------------- /cgo_trace.go: -------------------------------------------------------------------------------- 1 | //go:build cgotrace 2 | // +build cgotrace 3 | 4 | package node 5 | 6 | import ( 7 | _ "github.com/ianlancetaylor/cgosymbolizer" 8 | ) 9 | -------------------------------------------------------------------------------- /x/cert/errors/certificate_errors.go: -------------------------------------------------------------------------------- 1 | package errors 2 | 3 | import "errors" 4 | 5 | var ( 6 | ErrCertificate = errors.New("certificate error") 7 | ) 8 | -------------------------------------------------------------------------------- /util/network/network.go: -------------------------------------------------------------------------------- 1 | package network 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | const ( 8 | AverageBlockTime = 6500 * time.Millisecond 9 | ) 10 | -------------------------------------------------------------------------------- /x/provider/testdata/provider2.yaml: -------------------------------------------------------------------------------- 1 | host: https://akash.network 2 | attributes: 3 | - key: region 4 | value: sfo 5 | - key: moniker 6 | value: akash 7 | -------------------------------------------------------------------------------- /x/cert/utils/constants.go: -------------------------------------------------------------------------------- 1 | //nolint: revive 2 | 3 | package utils 4 | 5 | import "encoding/asn1" 6 | 7 | var AuthVersionOID = asn1.ObjectIdentifier{2, 23, 133, 2, 6} 8 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | # etc 2 | /.github 3 | /_docs 4 | *.DS_Store 5 | 6 | # vendor 7 | /vendor 8 | 9 | # binaries 10 | /akash 11 | 12 | # dev artifacts 13 | /devdata 14 | -------------------------------------------------------------------------------- /x/provider/testdata/provider.yaml: -------------------------------------------------------------------------------- 1 | host: https://test.provider.akash.network 2 | attributes: 3 | - key: region 4 | value: sfo 5 | - key: moniker 6 | value: akash 7 | -------------------------------------------------------------------------------- /make/codegen.mk: -------------------------------------------------------------------------------- 1 | .PHONY: generate 2 | generate: $(MOCKERY) 3 | $(GO) generate ./... 4 | 5 | .PHONY: codegen 6 | codegen: generate 7 | 8 | mocks: $(MOCKERY) 9 | $(MOCKERY) 10 | -------------------------------------------------------------------------------- /tools.go: -------------------------------------------------------------------------------- 1 | //go:build tools 2 | // +build tools 3 | 4 | package tools 5 | 6 | // nolint 7 | import ( 8 | _ "github.com/regen-network/cosmos-proto/protoc-gen-gocosmos" 9 | ) 10 | -------------------------------------------------------------------------------- /_build/Dockerfile.akash: -------------------------------------------------------------------------------- 1 | FROM ubuntu:noble 2 | LABEL "org.opencontainers.image.source"="https://github.com/akash-network/node" 3 | 4 | COPY ./akash /bin/ 5 | 6 | EXPOSE 26656 26657 26658 7 | -------------------------------------------------------------------------------- /x/escrow/keeper/querier.go: -------------------------------------------------------------------------------- 1 | package keeper 2 | 3 | import ( 4 | types "pkg.akt.dev/go/node/escrow/v1" 5 | ) 6 | 7 | func NewQuerier(_ Keeper) types.QueryServer { 8 | return nil 9 | } 10 | -------------------------------------------------------------------------------- /testutil/sim/rand.go: -------------------------------------------------------------------------------- 1 | package sim 2 | 3 | import ( 4 | "math/rand" 5 | ) 6 | 7 | func RandIdx(r *rand.Rand, val int) int { 8 | if val == 0 { 9 | return 0 10 | } 11 | 12 | return r.Intn(val) 13 | } 14 | -------------------------------------------------------------------------------- /x/escrow/client/rest/rest.go: -------------------------------------------------------------------------------- 1 | package rest 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/client" 5 | "github.com/gorilla/mux" 6 | ) 7 | 8 | func RegisterRoutes(_ client.Context, _ *mux.Router, _ string) { 9 | } 10 | -------------------------------------------------------------------------------- /tests/upgrade/test-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "chain-id": "localakash", 3 | "validators": [ 4 | ".akash0" 5 | ], 6 | "work": { 7 | "home": ".akash0", 8 | "key": "validator0" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/upgrade/test-config-gha.json: -------------------------------------------------------------------------------- 1 | { 2 | "chain-id": "localakash", 3 | "validators": [ 4 | ".akash0" 5 | ], 6 | "work": { 7 | "home": ".akash0", 8 | "key": "validator0" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /upgrades/software/v1.1.0/init.go: -------------------------------------------------------------------------------- 1 | // Package v1_1_0 2 | // nolint revive 3 | package v1_1_0 4 | 5 | import ( 6 | utypes "pkg.akt.dev/node/upgrades/types" 7 | ) 8 | 9 | func init() { 10 | utypes.RegisterUpgrade(UpgradeName, initUpgrade) 11 | } 12 | -------------------------------------------------------------------------------- /make/mod.mk: -------------------------------------------------------------------------------- 1 | # Golang modules and vendoring 2 | 3 | .PHONY: deps-install 4 | deps-install: 5 | go mod download 6 | 7 | .PHONY: deps-tidy 8 | deps-tidy: 9 | go mod tidy 10 | 11 | #.PHONY: mod 12 | #mod: go.mod 13 | # 14 | #go.mod: 15 | # go mod tidy 16 | -------------------------------------------------------------------------------- /x/take/alias.go: -------------------------------------------------------------------------------- 1 | package take 2 | 3 | import ( 4 | types "pkg.akt.dev/go/node/take/v1" 5 | ) 6 | 7 | const ( 8 | // StoreKey represents storekey of take module 9 | StoreKey = types.StoreKey 10 | // ModuleName represents current module name 11 | ModuleName = types.ModuleName 12 | ) 13 | -------------------------------------------------------------------------------- /x/escrow/alias.go: -------------------------------------------------------------------------------- 1 | package escrow 2 | 3 | import ( 4 | "pkg.akt.dev/go/node/escrow/module" 5 | ) 6 | 7 | const ( 8 | // StoreKey represents storekey of deployment module 9 | StoreKey = module.StoreKey 10 | // ModuleName represents current module name 11 | ModuleName = module.ModuleName 12 | ) 13 | -------------------------------------------------------------------------------- /.convcommit.json: -------------------------------------------------------------------------------- 1 | { 2 | "enabled": true, 3 | "length": { 4 | "min": 1, 5 | "max": 80 6 | }, 7 | "types": [ 8 | "revert", 9 | "build", 10 | "ci", 11 | "docs", 12 | "feat", 13 | "fix", 14 | "perf", 15 | "refactor", 16 | "style", 17 | "test", 18 | "chore" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /x/escrow/query/querier.go: -------------------------------------------------------------------------------- 1 | package query 2 | 3 | // import ( 4 | // "github.com/cosmos/cosmos-sdk/codec" 5 | // sdk "github.com/cosmos/cosmos-sdk/types" 6 | // 7 | // "pkg.akt.dev/node/x/escrow/keeper" 8 | // ) 9 | // 10 | // func NewQuerier(keeper keeper.Keeper, cdc *codec.LegacyAmino) sdk.Querier { 11 | // return nil 12 | // } 13 | -------------------------------------------------------------------------------- /x/deployment/keeper/external.go: -------------------------------------------------------------------------------- 1 | package keeper 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | eid "pkg.akt.dev/go/node/escrow/id/v1" 6 | 7 | etypes "pkg.akt.dev/go/node/escrow/types/v1" 8 | ) 9 | 10 | type EscrowKeeper interface { 11 | GetAccount(ctx sdk.Context, id eid.Account) (etypes.Account, error) 12 | } 13 | -------------------------------------------------------------------------------- /cmd/akash/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | 6 | _ "pkg.akt.dev/go/sdkutil" 7 | 8 | "pkg.akt.dev/node/cmd/akash/cmd" 9 | ) 10 | 11 | // In main we call the rootCmd 12 | func main() { 13 | rootCmd, _ := cmd.NewRootCmd() 14 | 15 | if err := cmd.Execute(rootCmd, "AKASH"); err != nil { 16 | os.Exit(1) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /util/cli/prompt.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | import ( 4 | "bufio" 5 | 6 | cinpuit "github.com/cosmos/cosmos-sdk/client/input" 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | func GetConfirmation(cmd *cobra.Command, prompt string) (bool, error) { 11 | return cinpuit.GetConfirmation(prompt, bufio.NewReader(cmd.InOrStdin()), cmd.ErrOrStderr()) 12 | } 13 | -------------------------------------------------------------------------------- /.github/workflows/concommits.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: tools 3 | 4 | on: 5 | pull_request: 6 | push: 7 | branches: 8 | - main 9 | - mainnet/main 10 | 11 | jobs: 12 | build: 13 | name: conventional commits 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v4 17 | - uses: webiny/action-conventional-commits@v1.3.0 18 | -------------------------------------------------------------------------------- /.mockery.yaml: -------------------------------------------------------------------------------- 1 | dir: mocks 2 | structname: '{{.InterfaceName}}' 3 | filename: "{{.StructName}}_mock.go" 4 | template: testify 5 | template-data: 6 | unroll-variadic: true 7 | packages: 8 | pkg.akt.dev/node/testutil/cosmos: 9 | config: 10 | dir: testutil/cosmos/mocks 11 | interfaces: 12 | AuthzKeeper: {} 13 | BankKeeper: {} 14 | TakeKeeper: {} 15 | -------------------------------------------------------------------------------- /x/cert/simulation/genesis.go: -------------------------------------------------------------------------------- 1 | package simulation 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/types/module" 5 | 6 | types "pkg.akt.dev/go/node/cert/v1" 7 | ) 8 | 9 | func RandomizedGenState(simState *module.SimulationState) { 10 | deploymentGenesis := &types.GenesisState{} 11 | 12 | simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(deploymentGenesis) 13 | } 14 | -------------------------------------------------------------------------------- /x/market/query/client.go: -------------------------------------------------------------------------------- 1 | package query 2 | 3 | import ( 4 | "pkg.akt.dev/go/node/market/v1" 5 | ) 6 | 7 | // Client interface 8 | type Client interface { 9 | Orders(filters OrderFilters) (Orders, error) 10 | Order(id v1.OrderID) (Order, error) 11 | Bids(filters BidFilters) (Bids, error) 12 | Bid(id v1.BidID) (Bid, error) 13 | Leases(filters LeaseFilters) (Leases, error) 14 | Lease(id v1.LeaseID) (Lease, error) 15 | } 16 | -------------------------------------------------------------------------------- /x/provider/keeper/key.go: -------------------------------------------------------------------------------- 1 | package keeper 2 | 3 | import ( 4 | "bytes" 5 | 6 | sdk "github.com/cosmos/cosmos-sdk/types" 7 | "github.com/cosmos/cosmos-sdk/types/address" 8 | types "pkg.akt.dev/go/node/provider/v1beta4" 9 | ) 10 | 11 | func ProviderKey(id sdk.Address) []byte { 12 | buf := bytes.NewBuffer(types.ProviderPrefix()) 13 | buf.Write(address.MustLengthPrefix(id.Bytes())) 14 | 15 | return buf.Bytes() 16 | } 17 | -------------------------------------------------------------------------------- /_docs/version-control.md: -------------------------------------------------------------------------------- 1 | # Merging into `mainnet/main` 2 | 3 | As new mainnet need to be released, quite often `mainnet/main` branch is far behind the `main`. 4 | This is so far cleanest solution we have found to perform merge without conflicts as well as keeping history 5 | 6 | ```shell 7 | git checkout main 8 | git merge -s ours mainnet/main 9 | git checkout mainnet/main 10 | git merge main 11 | git push origin mainnet/main 12 | ``` 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # etc 2 | *.DS_Store 3 | 4 | #vendor 5 | /vendor 6 | 7 | # dev artifacts 8 | /devdata 9 | 10 | # chain data 11 | *.tsd 12 | 13 | # test artifacts 14 | debug.test 15 | 16 | dist 17 | 18 | #IDE 19 | .idea/ 20 | *.iml 21 | coverage.txt 22 | .vscode 23 | 24 | /.cache 25 | /.release-env 26 | /.docker-creds 27 | 28 | /tmp-swagger-gen 29 | 30 | # go workspaces 31 | /go.work 32 | /go.work.sum 33 | 34 | /.editorconfig 35 | 36 | dev.env 37 | -------------------------------------------------------------------------------- /script/is_prerelease.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # in akash even minor part of the tag indicates release belongs to the MAINNET 4 | # using it as scripts simplifies debugging as well as portability 5 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" 6 | 7 | if [[ $# -ne 1 ]]; then 8 | echo "illegal number of parameters" 9 | exit 1 10 | fi 11 | 12 | [[ -n $("${SCRIPT_DIR}"/semver.sh get prerel "$1") ]] && exit 0 || exit 1 13 | -------------------------------------------------------------------------------- /.github/workflows/standardize-yaml.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: tools 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | 9 | jobs: 10 | check-yml-files: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v4 14 | - name: check-yml-count 15 | run: | 16 | if [[ $(git ls-files '*.yml' ':!:codecov.yml' | wc -l) -ne 0 ]]; then git ls-files '*.yml' ':!:codecov.yml' && exit 1;fi 17 | -------------------------------------------------------------------------------- /x/provider/simulation/genesis.go: -------------------------------------------------------------------------------- 1 | package simulation 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/types/module" 5 | 6 | types "pkg.akt.dev/go/node/provider/v1beta4" 7 | ) 8 | 9 | // RandomizedGenState generates a random GenesisState for supply 10 | func RandomizedGenState(simState *module.SimulationState) { 11 | providerGenesis := &types.GenesisState{} 12 | 13 | simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(providerGenesis) 14 | } 15 | -------------------------------------------------------------------------------- /script/mainnet-from-tag.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # in akash even minor part of the tag indicates release belongs to the MAINNET 4 | # using it as scripts simplifies debugging as well as portability 5 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" 6 | 7 | if [[ $# -ne 1 ]]; then 8 | echo "illegal number of parameters" 9 | exit 1 10 | fi 11 | 12 | [[ $(($("${SCRIPT_DIR}"/semver.sh get minor "$1") % 2)) -eq 0 ]] && exit 0 && exit 1 13 | -------------------------------------------------------------------------------- /x/provider/query/path.go: -------------------------------------------------------------------------------- 1 | package query 2 | 3 | import ( 4 | "fmt" 5 | 6 | sdk "github.com/cosmos/cosmos-sdk/types" 7 | ) 8 | 9 | const ( 10 | providersPath = "providers" 11 | providerPath = "provider" 12 | ) 13 | 14 | // getProvidersPath returns providers path for queries 15 | func getProvidersPath() string { 16 | return providersPath 17 | } 18 | 19 | func getProviderPath(id sdk.AccAddress) string { 20 | return fmt.Sprintf("%s/%s", providerPath, id) 21 | } 22 | -------------------------------------------------------------------------------- /.github/workflows/wip.yaml: -------------------------------------------------------------------------------- 1 | name: github 2 | 3 | on: 4 | pull_request: 5 | types: 6 | - opened 7 | - edited 8 | - labeled 9 | - unlabeled 10 | - synchronize 11 | 12 | jobs: 13 | wip: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v4 17 | - uses: akash-network/wip-check@v1 18 | with: 19 | labels: '["do-not-merge", "wip", "rfc"]' 20 | keywords: '["WIP", "wip", "RFC", "rfc"]' 21 | -------------------------------------------------------------------------------- /script/shellcheck.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Ignore file 4 | IGNORE="godownloader.sh" 5 | 6 | unset FAILED 7 | 8 | FILES=$(find /shellcheck/ -type f -name "*.sh" ! -path "/shellcheck/vendor/*" ! -path "/shellcheck/.git/*") 9 | 10 | for file in $FILES; do 11 | name="$(basename "$file")"; 12 | if [[ $name != "$IGNORE" ]] && ! shellcheck --format=gcc "${file}" --exclude=SC1091; then 13 | export FAILED=true 14 | fi 15 | done 16 | if [ "${FAILED}" != "" ]; then exit 1; fi 17 | -------------------------------------------------------------------------------- /x/take/simulation/genesis.go: -------------------------------------------------------------------------------- 1 | package simulation 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/types/module" 5 | 6 | types "pkg.akt.dev/go/node/take/v1" 7 | ) 8 | 9 | // RandomizedGenState generates a random GenesisState for supply 10 | func RandomizedGenState(simState *module.SimulationState) { 11 | takeGenesis := &types.GenesisState{ 12 | Params: types.DefaultParams(), 13 | } 14 | 15 | simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(takeGenesis) 16 | } 17 | -------------------------------------------------------------------------------- /tests/upgrade/workers_test.go: -------------------------------------------------------------------------------- 1 | //go:build e2e.upgrade 2 | 3 | package upgrade 4 | 5 | import ( 6 | "context" 7 | "testing" 8 | 9 | uttypes "pkg.akt.dev/node/tests/upgrade/types" 10 | ) 11 | 12 | func init() { 13 | uttypes.RegisterPostUpgradeWorker("v1.1.0", &postUpgrade{}) 14 | } 15 | 16 | type postUpgrade struct{} 17 | 18 | var _ uttypes.TestWorker = (*postUpgrade)(nil) 19 | 20 | func (pu *postUpgrade) Run(ctx context.Context, t *testing.T, params uttypes.TestParams) { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /x/escrow/client/util/util.go: -------------------------------------------------------------------------------- 1 | //nolint: revive 2 | 3 | package util 4 | 5 | import ( 6 | sdkmath "cosmossdk.io/math" 7 | ) 8 | 9 | func LeaseCalcBalanceRemain(balance sdkmath.LegacyDec, currBlock, settledAt int64, leasePrice sdkmath.LegacyDec) float64 { 10 | return balance.MustFloat64() - (float64(currBlock-settledAt))*leasePrice.MustFloat64() 11 | } 12 | 13 | func LeaseCalcBlocksRemain(balance float64, leasePrice sdkmath.LegacyDec) int64 { 14 | return int64(balance / leasePrice.MustFloat64()) 15 | } 16 | -------------------------------------------------------------------------------- /.env: -------------------------------------------------------------------------------- 1 | GO111MODULE=on 2 | 3 | KIND_VERSION=0.11.1 4 | ROOT_DIR=${AKASH_ROOT} 5 | 6 | AKASH_DEVCACHE_BASE=${AKASH_ROOT}/.cache 7 | AKASH_DEVCACHE=${AKASH_DEVCACHE_BASE} 8 | AKASH_DEVCACHE_BIN=${AKASH_DEVCACHE}/bin 9 | AKASH_DEVCACHE_INCLUDE=${AKASH_DEVCACHE}/include 10 | AKASH_DEVCACHE_VERSIONS=${AKASH_DEVCACHE}/versions 11 | AKASH_DEVCACHE_NODE_MODULES=${AKASH_DEVCACHE} 12 | AKASH_DEVCACHE_NODE_BIN=${AKASH_DEVCACHE_NODE_MODULES}/node_modules/.bin 13 | AKASH_RUN=${AKASH_DEVCACHE}/run 14 | AKASH_RUN_BIN=${AKASH_RUN}/bin 15 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | ignore: 2 | - "**/*.pb.go" 3 | - "**/*.pb.gw.go" 4 | - "**/mocks/.*" 5 | - "**/kubernetes_mock/.*" 6 | - "pkg" 7 | comment: false 8 | codecov: 9 | require_ci_to_pass: true 10 | parsers: 11 | gcov: 12 | branch_detection: 13 | loop: yes 14 | macro: no 15 | method: no 16 | conditional: yes 17 | coverage: 18 | range: 40..100 19 | round: down 20 | precision: 2 21 | status: 22 | project: 23 | default: 24 | if_not_found: success 25 | if_ci_failed: error 26 | -------------------------------------------------------------------------------- /x/market/keeper/external.go: -------------------------------------------------------------------------------- 1 | package keeper 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | escrowid "pkg.akt.dev/go/node/escrow/id/v1" 6 | etypes "pkg.akt.dev/go/node/escrow/types/v1" 7 | ) 8 | 9 | type EscrowKeeper interface { 10 | GetAccount(ctx sdk.Context, id escrowid.Account) (etypes.Account, error) 11 | GetPayment(ctx sdk.Context, id escrowid.Payment) (etypes.Payment, error) 12 | AccountClose(ctx sdk.Context, id escrowid.Account) error 13 | PaymentClose(ctx sdk.Context, id escrowid.Payment) error 14 | } 15 | -------------------------------------------------------------------------------- /app/params/weights.go: -------------------------------------------------------------------------------- 1 | package params 2 | 3 | // Default simulation operation weights for messages and gov proposals 4 | const ( 5 | DefaultWeightMsgCreateProvider int = 100 6 | DefaultWeightMsgUpdateProvider int = 5 7 | 8 | DefaultWeightMsgCreateDeployment int = 100 9 | DefaultWeightMsgUpdateDeployment int = 10 10 | DefaultWeightMsgCloseDeployment int = 100 11 | DefaultWeightMsgCloseGroup int = 100 12 | 13 | DefaultWeightMsgCreateBid int = 100 14 | DefaultWeightMsgCloseBid int = 100 15 | DefaultWeightMsgCloseLease int = 10 16 | ) 17 | -------------------------------------------------------------------------------- /util/partialord/internal/dag/module.go: -------------------------------------------------------------------------------- 1 | // Package dag implements a simple Directed Acyclical Graph (DAG) for deterministic topological sorts 2 | // 3 | // It should not be externally exposed, and is intended to be a very simple dag implementation 4 | // utilizing adjacency lists to store edges. 5 | // 6 | // This package is intended to be used for small scales, where performance of the algorithms is not critical. 7 | // (e.g. sub 10k entries) 8 | // Thus none of the algorithms in here are benchmarked, and just have correctness checks. 9 | package dag 10 | -------------------------------------------------------------------------------- /x/market/alias.go: -------------------------------------------------------------------------------- 1 | package market 2 | 3 | import ( 4 | v1 "pkg.akt.dev/go/node/market/v1" 5 | 6 | "pkg.akt.dev/node/x/market/keeper" 7 | ) 8 | 9 | const ( 10 | // StoreKey represents storekey of market module 11 | StoreKey = v1.StoreKey 12 | // ModuleName represents current module name 13 | ModuleName = v1.ModuleName 14 | ) 15 | 16 | type ( 17 | // Keeper defines keeper of market module 18 | Keeper = keeper.Keeper 19 | ) 20 | 21 | var ( 22 | // NewKeeper creates new keeper instance of market module 23 | NewKeeper = keeper.NewKeeper 24 | ) 25 | -------------------------------------------------------------------------------- /docgen/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/spf13/cobra/doc" 8 | root "pkg.akt.dev/node/cmd/akash/cmd" 9 | ) 10 | 11 | func main() { 12 | if len(os.Args) != 2 { 13 | fmt.Fprint(os.Stderr, "Usage is:\n\takash_docgen \n") 14 | os.Exit(1) 15 | } 16 | outputPath := os.Args[1] 17 | cmd, _ := root.NewRootCmd() 18 | err := doc.GenMarkdownTree(cmd, outputPath) 19 | if err != nil { 20 | fmt.Fprintf(os.Stderr, "Failed generating markdown into %q:%v\n", outputPath, err) 21 | os.Exit(1) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /x/audit/alias.go: -------------------------------------------------------------------------------- 1 | package audit 2 | 3 | import ( 4 | types "pkg.akt.dev/go/node/audit/v1" 5 | 6 | "pkg.akt.dev/node/x/audit/keeper" 7 | ) 8 | 9 | const ( 10 | // StoreKey represents storekey of provider module 11 | StoreKey = types.StoreKey 12 | // ModuleName represents current module name 13 | ModuleName = types.ModuleName 14 | ) 15 | 16 | type ( 17 | // Keeper defines keeper of provider module 18 | Keeper = keeper.Keeper 19 | ) 20 | 21 | var ( 22 | // NewKeeper creates new keeper instance of provider module 23 | NewKeeper = keeper.NewKeeper 24 | ) 25 | -------------------------------------------------------------------------------- /x/cert/alias.go: -------------------------------------------------------------------------------- 1 | package cert 2 | 3 | import ( 4 | types "pkg.akt.dev/go/node/cert/v1" 5 | 6 | "pkg.akt.dev/node/x/cert/keeper" 7 | ) 8 | 9 | const ( 10 | // StoreKey represents storekey of provider module 11 | StoreKey = types.StoreKey 12 | // ModuleName represents current module name 13 | ModuleName = types.ModuleName 14 | ) 15 | 16 | type ( 17 | // Keeper defines keeper of provider module 18 | Keeper = keeper.Keeper 19 | ) 20 | 21 | var ( 22 | // NewKeeper creates new keeper instance of provider module 23 | NewKeeper = keeper.NewKeeper 24 | ) 25 | -------------------------------------------------------------------------------- /.github/workflows/stale.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: github 3 | on: 4 | schedule: 5 | - cron: "0 0 * * *" 6 | 7 | jobs: 8 | stale-pr: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/stale@v3 12 | with: 13 | repo-token: ${{ secrets.GITHUB_TOKEN }} 14 | stale-pr-label: stale 15 | exempt-pr-labels: keepalive 16 | days-before-stale: 10 17 | days-before-close: 5 18 | stale-pr-message: | 19 | Marked as stale; will be closed in five days. 20 | Cut bait or go fishing! 21 | -------------------------------------------------------------------------------- /testutil/network/option.go: -------------------------------------------------------------------------------- 1 | package network 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/cosmos/cosmos-sdk/codec" 7 | ) 8 | 9 | type InterceptState func(codec.Codec, string, json.RawMessage) json.RawMessage 10 | 11 | type networkConfigOptions struct { 12 | interceptState InterceptState 13 | } 14 | 15 | type ConfigOption func(*networkConfigOptions) 16 | 17 | // WithInterceptState set custom name of the log object 18 | func WithInterceptState(val InterceptState) ConfigOption { 19 | return func(t *networkConfigOptions) { 20 | t.interceptState = val 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /x/provider/alias.go: -------------------------------------------------------------------------------- 1 | package provider 2 | 3 | import ( 4 | types "pkg.akt.dev/go/node/provider/v1beta4" 5 | 6 | "pkg.akt.dev/node/x/provider/keeper" 7 | ) 8 | 9 | const ( 10 | // StoreKey represents storekey of provider module 11 | StoreKey = types.StoreKey 12 | // ModuleName represents current module name 13 | ModuleName = types.ModuleName 14 | ) 15 | 16 | type ( 17 | // Keeper defines keeper of provider module 18 | Keeper = keeper.Keeper 19 | ) 20 | 21 | var ( 22 | // NewKeeper creates new keeper instance of provider module 23 | NewKeeper = keeper.NewKeeper 24 | ) 25 | -------------------------------------------------------------------------------- /x/deployment/alias.go: -------------------------------------------------------------------------------- 1 | package deployment 2 | 3 | import ( 4 | types "pkg.akt.dev/go/node/deployment/v1" 5 | 6 | "pkg.akt.dev/node/x/deployment/keeper" 7 | ) 8 | 9 | const ( 10 | // StoreKey represents storekey of deployment module 11 | StoreKey = types.StoreKey 12 | // ModuleName represents current module name 13 | ModuleName = types.ModuleName 14 | ) 15 | 16 | type ( 17 | // Keeper defines keeper of deployment module 18 | Keeper = keeper.Keeper 19 | ) 20 | 21 | var ( 22 | // NewKeeper creates new keeper instance of deployment module 23 | NewKeeper = keeper.NewKeeper 24 | ) 25 | -------------------------------------------------------------------------------- /.github/workflows/labeler.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: github 3 | on: 4 | - pull_request_target 5 | 6 | permissions: 7 | contents: read 8 | 9 | jobs: 10 | labeler: 11 | permissions: 12 | contents: read # for actions/labeler to determine modified files 13 | pull-requests: write # for actions/labeler to add labels to PRs 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v4 17 | - uses: actions/labeler@v5 18 | with: 19 | configuration-path: .github/labeler.yaml 20 | repo-token: "${{ secrets.GITHUB_TOKEN }}" 21 | dot: true 22 | -------------------------------------------------------------------------------- /x/deployment/testdata/deployment-v2-nohost.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.0" 3 | 4 | services: 5 | web: 6 | image: ghcr.io/akash-network/demo-app 7 | expose: 8 | - port: 80 9 | to: 10 | - global: true 11 | 12 | profiles: 13 | compute: 14 | web: 15 | resources: 16 | cpu: 17 | units: "0.01" 18 | memory: 19 | size: "128Mi" 20 | storage: 21 | size: "512Mi" 22 | 23 | placement: 24 | global: 25 | pricing: 26 | web: 27 | denom: uakt 28 | amount: 10 29 | 30 | deployment: 31 | web: 32 | global: 33 | profile: web 34 | count: 1 35 | -------------------------------------------------------------------------------- /make/lint.mk: -------------------------------------------------------------------------------- 1 | SUBLINTERS = unused \ 2 | misspell \ 3 | gofmt \ 4 | gocritic \ 5 | goconst \ 6 | ineffassign \ 7 | unparam \ 8 | staticcheck \ 9 | revive \ 10 | gosec \ 11 | exportloopref \ 12 | prealloc 13 | # TODO: ^ gochecknoglobals 14 | 15 | .PHONY: lint-go 16 | lint-go: $(GOLANGCI_LINT) 17 | $(GOLANGCI_LINT_RUN) ./... --issues-exit-code=0 --timeout=10m 18 | 19 | .PHONY: lint-go-% 20 | lint-go-%: $(GOLANGCI_LINT) 21 | $(LINT) $* 22 | 23 | .PHONY: lint-shell 24 | lint-shell: 25 | docker run --rm \ 26 | --volume ${PWD}:/shellcheck \ 27 | --entrypoint sh \ 28 | koalaman/shellcheck-alpine:stable \ 29 | -x /shellcheck/script/shellcheck.sh 30 | 31 | -------------------------------------------------------------------------------- /x/take/simulation/decoder.go: -------------------------------------------------------------------------------- 1 | package simulation 2 | 3 | // NewDecodeStore returns a decoder function closure that unmarshals the KVPair's 4 | // Value to the corresponding mint type. 5 | // func NewDecodeStore(_ codec.Codec) func(kvA, kvB kv.Pair) string { 6 | // return func(kvA, kvB kv.Pair) string { 7 | // switch { 8 | // case bytes.Equal(kvA.Key, types.MinterKey): 9 | // var minterA, minterB types.Minter 10 | // cdc.MustUnmarshal(kvA.Value, &minterA) 11 | // cdc.MustUnmarshal(kvB.Value, &minterB) 12 | // return fmt.Sprintf("%v\n%v", minterA, minterB) 13 | // default: 14 | // panic(fmt.Sprintf("invalid mint key %X", kvA.Key)) 15 | // } 16 | // } 17 | // } 18 | -------------------------------------------------------------------------------- /x/deployment/testdata/deployment.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.0" 3 | 4 | services: 5 | web: 6 | image: bubuntux/riot-web 7 | expose: 8 | - port: 80 9 | to: 10 | - global: true 11 | accept: 12 | - test.localhost 13 | 14 | profiles: 15 | compute: 16 | web: 17 | resources: 18 | cpu: 19 | units: "0.01" 20 | memory: 21 | size: "128Mi" 22 | storage: 23 | size: "512Mi" 24 | 25 | placement: 26 | global: 27 | pricing: 28 | web: 29 | denom: uakt 30 | amount: 30 31 | 32 | deployment: 33 | web: 34 | global: 35 | profile: web 36 | count: 1 37 | -------------------------------------------------------------------------------- /x/deployment/testdata/deployment-v2.1.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.1" 3 | 4 | services: 5 | web: 6 | image: bubuntux/riot-web 7 | expose: 8 | - port: 80 9 | to: 10 | - global: true 11 | accept: 12 | - test.localhost 13 | 14 | profiles: 15 | compute: 16 | web: 17 | resources: 18 | cpu: 19 | units: "0.01" 20 | memory: 21 | size: "128Mi" 22 | storage: 23 | size: "512Mi" 24 | 25 | placement: 26 | global: 27 | pricing: 28 | web: 29 | denom: uakt 30 | amount: 30 31 | 32 | deployment: 33 | web: 34 | global: 35 | profile: web 36 | count: 1 37 | -------------------------------------------------------------------------------- /upgrades/software/v1.0.0/take.go: -------------------------------------------------------------------------------- 1 | // Package v1_0_0 2 | // nolint revive 3 | package v1_0_0 4 | 5 | import ( 6 | sdk "github.com/cosmos/cosmos-sdk/types" 7 | sdkmodule "github.com/cosmos/cosmos-sdk/types/module" 8 | 9 | utypes "pkg.akt.dev/node/upgrades/types" 10 | ) 11 | 12 | type takeMigrations struct { 13 | utypes.Migrator 14 | } 15 | 16 | func newTakeMigration(m utypes.Migrator) utypes.Migration { 17 | return takeMigrations{Migrator: m} 18 | } 19 | 20 | func (m takeMigrations) GetHandler() sdkmodule.MigrationHandler { 21 | return m.handler 22 | } 23 | 24 | // handler migrates provider store from version 2 to 3. 25 | func (m takeMigrations) handler(_ sdk.Context) error { 26 | return nil 27 | } 28 | -------------------------------------------------------------------------------- /.chglog/config.yaml: -------------------------------------------------------------------------------- 1 | style: github 2 | template: CHANGELOG.tpl.md 3 | info: 4 | title: CHANGELOG 5 | repository_url: https://github.com/akash-network/node 6 | options: 7 | commits: 8 | # filters: 9 | # Type: 10 | # - feat 11 | # - fix 12 | # - perf 13 | # - refactor 14 | commit_groups: 15 | title_maps: 16 | feat: Features 17 | fix: Bug Fixes 18 | perf: Performance Improvements 19 | refactor: Code Refactoring 20 | header: 21 | pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$" 22 | pattern_maps: 23 | - Type 24 | - Scope 25 | - Subject 26 | notes: 27 | keywords: 28 | - BREAKING CHANGE 29 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /x/deployment/testdata/deployment-v2.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.0" 3 | 4 | services: 5 | web: 6 | image: ghcr.io/akash-network/demo-app 7 | expose: 8 | - port: 80 9 | to: 10 | - global: true 11 | accept: 12 | - test.localhost 13 | 14 | profiles: 15 | compute: 16 | web: 17 | resources: 18 | cpu: 19 | units: "0.01" 20 | memory: 21 | size: "128Mi" 22 | storage: 23 | size: "512Mi" 24 | 25 | placement: 26 | global: 27 | pricing: 28 | web: 29 | denom: uakt 30 | amount: 10 31 | 32 | deployment: 33 | web: 34 | global: 35 | profile: web 36 | count: 1 37 | -------------------------------------------------------------------------------- /testutil/sims/expected_keepers.go: -------------------------------------------------------------------------------- 1 | package sims 2 | 3 | import ( 4 | "context" 5 | 6 | sdk "github.com/cosmos/cosmos-sdk/types" 7 | ) 8 | 9 | type BankKeeper interface { 10 | SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error 11 | MintCoins(ctx context.Context, moduleName string, amt sdk.Coins) error 12 | } 13 | 14 | // StakingKeeper is a subset of the staking keeper's public interface that 15 | // provides the staking bond denom. It is used in arguments in this package's 16 | // functions so that a mock staking keeper can be passed instead of the real one. 17 | type StakingKeeper interface { 18 | BondDenom(ctx context.Context) (string, error) 19 | } 20 | -------------------------------------------------------------------------------- /x/deployment/testdata/deployment-v2-newcontainer.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.0" 3 | 4 | services: 5 | web: 6 | image: ghcr.io/akash-network/demo-app 7 | expose: 8 | - port: 80 9 | to: 10 | - global: true 11 | accept: 12 | - test.localhost 13 | 14 | profiles: 15 | compute: 16 | web: 17 | resources: 18 | cpu: 19 | units: "0.01" 20 | memory: 21 | size: "128Mi" 22 | storage: 23 | size: "512Mi" 24 | 25 | placement: 26 | global: 27 | pricing: 28 | web: 29 | denom: uakt 30 | amount: 10 31 | 32 | deployment: 33 | web: 34 | global: 35 | profile: web 36 | count: 1 37 | -------------------------------------------------------------------------------- /x/deployment/testdata/deployment-v2-updateA.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.0" 3 | 4 | services: 5 | web: 6 | image: ghcr.io/akash-network/demo-app 7 | expose: 8 | - port: 80 9 | to: 10 | - global: true 11 | accept: 12 | - testupdatea.localhost 13 | 14 | profiles: 15 | compute: 16 | web: 17 | resources: 18 | cpu: 19 | units: "0.01" 20 | memory: 21 | size: "128Mi" 22 | storage: 23 | size: "512Mi" 24 | 25 | placement: 26 | global: 27 | pricing: 28 | web: 29 | denom: uakt 30 | amount: 10 31 | 32 | deployment: 33 | web: 34 | global: 35 | profile: web 36 | count: 1 37 | -------------------------------------------------------------------------------- /x/market/simulation/genesis.go: -------------------------------------------------------------------------------- 1 | package simulation 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/types/module" 5 | mv1 "pkg.akt.dev/go/node/market/v1" 6 | 7 | dtypes "pkg.akt.dev/go/node/deployment/v1beta4" 8 | types "pkg.akt.dev/go/node/market/v1beta5" 9 | ) 10 | 11 | var minDeposit, _ = dtypes.DefaultParams().MinDepositFor("uakt") 12 | 13 | // RandomizedGenState generates a random GenesisState for supply 14 | func RandomizedGenState(simState *module.SimulationState) { 15 | marketGenesis := &types.GenesisState{ 16 | Params: types.Params{ 17 | BidMinDeposit: minDeposit, 18 | OrderMaxBids: 20, 19 | }, 20 | } 21 | 22 | simState.GenState[mv1.ModuleName] = simState.Cdc.MustMarshalJSON(marketGenesis) 23 | } 24 | -------------------------------------------------------------------------------- /x/deployment/testdata/deployment-v2-migrate.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.0" 3 | 4 | services: 5 | web: 6 | image: ghcr.io/akash-network/demo-app 7 | expose: 8 | - port: 80 9 | to: 10 | - global: true 11 | accept: 12 | - leaveme.com 13 | - migrateme.com 14 | 15 | profiles: 16 | compute: 17 | web: 18 | resources: 19 | cpu: 20 | units: "0.01" 21 | memory: 22 | size: "128Mi" 23 | storage: 24 | size: "512Mi" 25 | 26 | placement: 27 | global: 28 | pricing: 29 | web: 30 | denom: uakt 31 | amount: 10 32 | 33 | deployment: 34 | web: 35 | global: 36 | profile: web 37 | count: 1 38 | -------------------------------------------------------------------------------- /x/deployment/testdata/deployment-v2-updateB.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.0" 3 | 4 | services: 5 | web: 6 | image: ghcr.io/akash-network/demo-app 7 | expose: 8 | - port: 80 9 | to: 10 | - global: true 11 | accept: 12 | - testupdatea.localhost 13 | - testupdateb.localhost 14 | 15 | profiles: 16 | compute: 17 | web: 18 | resources: 19 | cpu: 20 | units: "0.01" 21 | memory: 22 | size: "128Mi" 23 | storage: 24 | size: "512Mi" 25 | 26 | placement: 27 | global: 28 | pricing: 29 | web: 30 | denom: uakt 31 | amount: 10 32 | 33 | deployment: 34 | web: 35 | global: 36 | profile: web 37 | count: 1 38 | -------------------------------------------------------------------------------- /tests/e2e/grpc_test.go: -------------------------------------------------------------------------------- 1 | //go:build e2e.integration 2 | 3 | package e2e 4 | 5 | import ( 6 | "testing" 7 | 8 | "github.com/stretchr/testify/suite" 9 | 10 | "pkg.akt.dev/node/testutil" 11 | ) 12 | 13 | func TestIntegrationGRPC(t *testing.T) { 14 | dg := &deploymentGRPCRestTestSuite{} 15 | dg.NetworkTestSuite = testutil.NewNetworkTestSuite(nil, dg) 16 | 17 | cg := &certsGRPCRestTestSuite{} 18 | cg.NetworkTestSuite = testutil.NewNetworkTestSuite(nil, cg) 19 | 20 | mg := &marketGRPCRestTestSuite{} 21 | mg.NetworkTestSuite = testutil.NewNetworkTestSuite(nil, mg) 22 | 23 | pg := &providerGRPCRestTestSuite{} 24 | pg.NetworkTestSuite = testutil.NewNetworkTestSuite(nil, pg) 25 | 26 | suite.Run(t, dg) 27 | suite.Run(t, cg) 28 | suite.Run(t, mg) 29 | suite.Run(t, pg) 30 | } 31 | -------------------------------------------------------------------------------- /upgrades/upgrades_test.go: -------------------------------------------------------------------------------- 1 | package upgrades 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | "testing" 7 | 8 | "github.com/stretchr/testify/require" 9 | "golang.org/x/mod/semver" 10 | 11 | utypes "pkg.akt.dev/node/upgrades/types" 12 | ) 13 | 14 | func TestUpgradesName(t *testing.T) { 15 | upgrades := utypes.GetUpgradesList() 16 | require.NotNil(t, upgrades) 17 | 18 | for name := range upgrades { 19 | // NOTE this is the only exception to the upgrade name 20 | // Rest MUST be compliant with SEMVER 21 | if name == "akash_v0.15.0_cosmos_v0.44.x" { 22 | continue 23 | } 24 | 25 | require.True(t, strings.HasPrefix(name, "v"), "upgrade name must start with \"v\"") 26 | 27 | require.True(t, semver.IsValid(name), fmt.Sprintf("upgrade name \"%s\" must be valid Semver", name)) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /x/deployment/testdata/deployment-v2-nodeport.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.0" 3 | 4 | services: 5 | web: 6 | image: hydrogen18/hello_world:20201209 7 | expose: 8 | - port: 10000 9 | as: 10000 10 | to: 11 | - global: true 12 | - port: 10000 13 | as: 10000 14 | proto: UDP 15 | to: 16 | - global: true 17 | 18 | profiles: 19 | compute: 20 | web: 21 | resources: 22 | cpu: 23 | units: 0.1 24 | memory: 25 | size: 16Mi 26 | storage: 27 | size: 128Mi 28 | placement: 29 | global: 30 | pricing: 31 | web: 32 | denom: uakt 33 | amount: 9000 34 | 35 | deployment: 36 | web: 37 | global: 38 | profile: web 39 | count: 1 40 | -------------------------------------------------------------------------------- /x/deployment/testdata/deployment-v2-ip-endpoint.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.0" 3 | 4 | services: 5 | web: 6 | image: ghcr.io/akash-network/demo-app 7 | expose: 8 | - port: 80 9 | to: 10 | - global: true 11 | ip: "meow" 12 | accept: 13 | - test.localhost 14 | 15 | profiles: 16 | compute: 17 | web: 18 | resources: 19 | cpu: 20 | units: "0.01" 21 | memory: 22 | size: "128Mi" 23 | storage: 24 | size: "512Mi" 25 | 26 | placement: 27 | global: 28 | pricing: 29 | web: 30 | denom: uakt 31 | amount: 10 32 | 33 | deployment: 34 | web: 35 | global: 36 | profile: web 37 | count: 1 38 | 39 | endpoints: 40 | meow: 41 | kind: "ip" 42 | -------------------------------------------------------------------------------- /x/deployment/testdata/deployment-v2.1-ip-endpoint.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.1" 3 | 4 | services: 5 | web: 6 | image: ghcr.io/akash-network/demo-app 7 | expose: 8 | - port: 80 9 | to: 10 | - global: true 11 | ip: "meow" 12 | accept: 13 | - test.localhost 14 | 15 | profiles: 16 | compute: 17 | web: 18 | resources: 19 | cpu: 20 | units: "0.01" 21 | memory: 22 | size: "128Mi" 23 | storage: 24 | size: "512Mi" 25 | 26 | placement: 27 | global: 28 | pricing: 29 | web: 30 | denom: uakt 31 | amount: 10 32 | 33 | deployment: 34 | web: 35 | global: 36 | profile: web 37 | count: 1 38 | 39 | endpoints: 40 | meow: 41 | kind: "ip" 42 | -------------------------------------------------------------------------------- /x/take/keeper/grpc_query.go: -------------------------------------------------------------------------------- 1 | package keeper 2 | 3 | import ( 4 | "context" 5 | 6 | "google.golang.org/grpc/codes" 7 | "google.golang.org/grpc/status" 8 | 9 | sdk "github.com/cosmos/cosmos-sdk/types" 10 | types "pkg.akt.dev/go/node/take/v1" 11 | ) 12 | 13 | // Querier is used as Keeper will have duplicate methods if used directly, and gRPC names take precedence over keeper 14 | type Querier struct { 15 | Keeper 16 | } 17 | 18 | var _ types.QueryServer = Querier{} 19 | 20 | func (k Querier) Params(ctx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { 21 | if req == nil { 22 | return nil, status.Errorf(codes.InvalidArgument, "empty request") 23 | } 24 | 25 | sdkCtx := sdk.UnwrapSDKContext(ctx) 26 | params := k.GetParams(sdkCtx) 27 | 28 | return &types.QueryParamsResponse{Params: params}, nil 29 | } 30 | -------------------------------------------------------------------------------- /pubsub/util.go: -------------------------------------------------------------------------------- 1 | package pubsub 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | "time" 7 | 8 | "github.com/stretchr/testify/require" 9 | ) 10 | 11 | const ( 12 | defaultDelayThreadStart = time.Millisecond * 6 13 | ) 14 | 15 | // AfterThreadStart waits for the duration of delay thread start 16 | func AfterThreadStart(t *testing.T) <-chan time.Time { 17 | return time.After(delayThreadStart(t)) 18 | } 19 | 20 | // SleepForThreadStart pass go routine for the duration of delay thread start 21 | func SleepForThreadStart(t *testing.T) { 22 | time.Sleep(delayThreadStart(t)) 23 | } 24 | 25 | func delayThreadStart(t *testing.T) time.Duration { 26 | if val := os.Getenv("TEST_DELAY_THREAD_START"); val != "" { 27 | d, err := time.ParseDuration(val) 28 | require.NoError(t, err) 29 | 30 | return d 31 | } 32 | 33 | return defaultDelayThreadStart 34 | } 35 | -------------------------------------------------------------------------------- /x/escrow/handler/handler.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/baseapp" 5 | sdk "github.com/cosmos/cosmos-sdk/types" 6 | sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" 7 | types "pkg.akt.dev/go/node/escrow/v1" 8 | 9 | "pkg.akt.dev/node/x/escrow/keeper" 10 | ) 11 | 12 | // NewHandler returns a handler for "deployment" type messages 13 | func NewHandler(keeper keeper.Keeper, authzKeeper AuthzKeeper, bkeeper BankKeeper) baseapp.MsgServiceHandler { 14 | ms := NewServer(keeper, authzKeeper, bkeeper) 15 | 16 | return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { 17 | switch msg := msg.(type) { 18 | case *types.MsgAccountDeposit: 19 | res, err := ms.AccountDeposit(ctx, msg) 20 | return sdk.WrapServiceResult(ctx, res, err) 21 | default: 22 | return nil, sdkerrors.ErrUnknownRequest 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /util/runner/runner.go: -------------------------------------------------------------------------------- 1 | package runner 2 | 3 | // Task is a function type which returns result instance 4 | type Task func() Result 5 | 6 | // Do executes task and send output to channel 7 | func Do(task Task) <-chan Result { 8 | ch := make(chan Result, 1) 9 | go func() { 10 | ch <- task() 11 | }() 12 | return ch 13 | } 14 | 15 | // Result interface wraps Value and Error methods. 16 | type Result interface { 17 | Value() interface{} 18 | Error() error 19 | } 20 | 21 | // NewResult returns result instance with value as input 22 | func NewResult(value interface{}, err error) Result { 23 | return result{ 24 | value: value, 25 | err: err, 26 | } 27 | } 28 | 29 | type result struct { 30 | value interface{} 31 | err error 32 | } 33 | 34 | func (r result) Value() interface{} { 35 | return r.value 36 | } 37 | 38 | func (r result) Error() error { 39 | return r.err 40 | } 41 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE/other.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | Closes: #XXXX 4 | 5 | 7 | 8 | --- 9 | 10 | ### Author Checklist 11 | 12 | *All items are required. Please add a note to the item if the item is not applicable and 13 | please add links to any relevant follow-up issues.* 14 | 15 | I have... 16 | 17 | - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title 18 | - [ ] targeted the correct branch (see [PR Targeting](https://github.com/akash-network/node/blob/main/CONTRIBUTING.md#paperwork-for-pull-requests)) 19 | - [ ] provided a link to the relevant issue or specification 20 | - [ ] reviewed "Files changed" and left comments if necessary 21 | - [ ] confirmed all CI checks have passed 22 | -------------------------------------------------------------------------------- /tests/e2e/cli_test.go: -------------------------------------------------------------------------------- 1 | //go:build e2e.integration 2 | 3 | package e2e 4 | 5 | import ( 6 | "testing" 7 | 8 | sdk "github.com/cosmos/cosmos-sdk/types" 9 | "github.com/stretchr/testify/suite" 10 | 11 | "pkg.akt.dev/node/testutil" 12 | ) 13 | 14 | var DefaultDeposit = sdk.NewCoin("uakt", sdk.NewInt(5000000)) 15 | 16 | func TestIntegrationCLI(t *testing.T) { 17 | di := &deploymentIntegrationTestSuite{} 18 | di.NetworkTestSuite = testutil.NewNetworkTestSuite(nil, di) 19 | 20 | ci := &certificateIntegrationTestSuite{} 21 | ci.NetworkTestSuite = testutil.NewNetworkTestSuite(nil, ci) 22 | 23 | mi := &marketIntegrationTestSuite{} 24 | mi.NetworkTestSuite = testutil.NewNetworkTestSuite(nil, mi) 25 | 26 | pi := &providerIntegrationTestSuite{} 27 | pi.NetworkTestSuite = testutil.NewNetworkTestSuite(nil, pi) 28 | 29 | suite.Run(t, di) 30 | suite.Run(t, ci) 31 | suite.Run(t, mi) 32 | suite.Run(t, pi) 33 | } 34 | -------------------------------------------------------------------------------- /x/escrow/handler/keepers.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "context" 5 | "time" 6 | 7 | sdk "github.com/cosmos/cosmos-sdk/types" 8 | "github.com/cosmos/cosmos-sdk/x/authz" 9 | authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" 10 | ) 11 | 12 | type AuthzKeeper interface { 13 | DeleteGrant(ctx context.Context, grantee sdk.AccAddress, granter sdk.AccAddress, msgType string) error 14 | GetAuthorization(ctx context.Context, grantee sdk.AccAddress, granter sdk.AccAddress, msgType string) (authz.Authorization, *time.Time) 15 | SaveGrant(ctx context.Context, grantee sdk.AccAddress, granter sdk.AccAddress, authorization authz.Authorization, expiration *time.Time) error 16 | GetGranteeGrantsByMsgType(ctx context.Context, grantee sdk.AccAddress, msgType string, onGrant authzkeeper.OnGrantFn) 17 | } 18 | 19 | type BankKeeper interface { 20 | SpendableCoin(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin 21 | } 22 | -------------------------------------------------------------------------------- /x/market/simulation/utils.go: -------------------------------------------------------------------------------- 1 | package simulation 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | "pkg.akt.dev/go/node/market/v1beta5" 6 | 7 | ptypes "pkg.akt.dev/go/node/provider/v1beta4" 8 | 9 | keepers "pkg.akt.dev/node/x/market/handler" 10 | ) 11 | 12 | func getOrdersWithState(ctx sdk.Context, ks keepers.Keepers, state v1beta5.Order_State) v1beta5.Orders { 13 | var orders v1beta5.Orders 14 | 15 | ks.Market.WithOrders(ctx, func(order v1beta5.Order) bool { 16 | if order.State == state { 17 | orders = append(orders, order) 18 | } 19 | 20 | return false 21 | }) 22 | 23 | return orders 24 | } 25 | 26 | func getProviders(ctx sdk.Context, ks keepers.Keepers) []ptypes.Provider { 27 | var providers []ptypes.Provider 28 | 29 | ks.Provider.WithProviders(ctx, func(provider ptypes.Provider) bool { 30 | providers = append(providers, provider) 31 | 32 | return false 33 | }) 34 | 35 | return providers 36 | } 37 | -------------------------------------------------------------------------------- /.chglog/CHANGELOG.tpl.md: -------------------------------------------------------------------------------- 1 | {{ range .Versions }} 2 | 3 | ## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }} 4 | 5 | > {{ datetime "2006-01-02" .Tag.Date }} 6 | 7 | {{ range .CommitGroups -}} 8 | ### {{ .Title }} 9 | 10 | {{ range .Commits -}} 11 | * {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }} 12 | {{ end }} 13 | {{ end -}} 14 | 15 | {{- if .RevertCommits -}} 16 | ### Reverts 17 | 18 | {{ range .RevertCommits -}} 19 | * {{ .Revert.Header }} 20 | {{ end }} 21 | {{ end -}} 22 | 23 | {{- if .MergeCommits -}} 24 | ### Pull Requests 25 | 26 | {{ range .MergeCommits -}} 27 | * {{ .Header }} 28 | {{ end }} 29 | {{ end -}} 30 | 31 | {{- if .NoteGroups -}} 32 | {{ range .NoteGroups -}} 33 | ### {{ .Title }} 34 | 35 | {{ range .Notes }} 36 | {{ .Body }} 37 | {{ end }} 38 | {{ end -}} 39 | {{ end -}} 40 | {{ end -}} -------------------------------------------------------------------------------- /x/deployment/testdata/deployment-v2-storage-default.yaml: -------------------------------------------------------------------------------- 1 | version: "2.0" 2 | services: 3 | web: 4 | image: ghcr.io/akash-network/demo-app 5 | expose: 6 | - port: 8080 7 | as: 80 8 | to: 9 | - global: true 10 | accept: 11 | - webdistest.localhost 12 | params: 13 | storage: 14 | data: 15 | mount: "/var/lib/demo-app/data" 16 | profiles: 17 | compute: 18 | web: 19 | resources: 20 | cpu: 21 | units: "0.01" 22 | memory: 23 | size: "128Mi" 24 | storage: 25 | - size: "512Mi" 26 | - name: data 27 | size: "128Mi" 28 | attributes: 29 | persistent: "true" 30 | placement: 31 | global: 32 | pricing: 33 | web: 34 | denom: uakt 35 | amount: 10 36 | deployment: 37 | web: 38 | global: 39 | profile: web 40 | count: 1 41 | -------------------------------------------------------------------------------- /.golangci.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2" 3 | linters: 4 | default: none 5 | enable: 6 | - copyloopvar 7 | - errcheck 8 | - errchkjson 9 | - goconst 10 | - gocritic 11 | - gosec 12 | - govet 13 | - ineffassign 14 | - misspell 15 | - prealloc 16 | - staticcheck 17 | - unparam 18 | - unused 19 | settings: 20 | gocritic: 21 | disabled-checks: 22 | - ifElseChain 23 | - singleCaseSwitch 24 | exclusions: 25 | generated: lax 26 | presets: 27 | - comments 28 | - common-false-positives 29 | - legacy 30 | - std-error-handling 31 | rules: 32 | - path: (.+)\.go$ 33 | text: comment on exported (method|function|type|const|var) 34 | paths: 35 | - third_party$ 36 | - builtin$ 37 | - examples$ 38 | formatters: 39 | enable: 40 | - gofmt 41 | exclusions: 42 | generated: lax 43 | paths: 44 | - third_party$ 45 | - builtin$ 46 | - examples$ 47 | -------------------------------------------------------------------------------- /x/deployment/testdata/deployment-v2-storage-beta2.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.0" 3 | services: 4 | web: 5 | image: ghcr.io/akash-network/demo-app 6 | expose: 7 | - port: 8080 8 | as: 80 9 | to: 10 | - global: true 11 | accept: 12 | - webdistest.localhost 13 | params: 14 | storage: 15 | data: 16 | mount: /var/lib/demo-app 17 | profiles: 18 | compute: 19 | web: 20 | resources: 21 | cpu: 22 | units: "0.01" 23 | memory: 24 | size: "128Mi" 25 | storage: 26 | - size: "512Mi" 27 | - name: data 28 | size: "128Mi" 29 | attributes: 30 | persistent: "true" 31 | class: beta2 32 | placement: 33 | global: 34 | pricing: 35 | web: 36 | denom: uakt 37 | amount: 10 38 | deployment: 39 | web: 40 | global: 41 | profile: web 42 | count: 1 43 | -------------------------------------------------------------------------------- /x/deployment/testdata/deployment-v2-storage-updateC.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.0" 3 | 4 | services: 5 | web: 6 | image: ghcr.io/akash-network/demo-app 7 | expose: 8 | - port: 80 9 | to: 10 | - global: true 11 | accept: 12 | - testupdatea.localhost 13 | - testupdateb.localhost 14 | params: 15 | storage: 16 | data: 17 | mount: /var/lib/e2e-test 18 | profiles: 19 | compute: 20 | web: 21 | resources: 22 | cpu: 23 | units: "0.01" 24 | memory: 25 | size: "128Mi" 26 | storage: 27 | - size: "512Mi" 28 | - name: data 29 | size: "256Mi" 30 | attributes: 31 | persistent: "true" 32 | placement: 33 | global: 34 | pricing: 35 | web: 36 | denom: uakt 37 | amount: 10 38 | 39 | deployment: 40 | web: 41 | global: 42 | profile: web 43 | count: 1 44 | -------------------------------------------------------------------------------- /x/cert/handler/handler.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/baseapp" 5 | sdk "github.com/cosmos/cosmos-sdk/types" 6 | sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" 7 | 8 | types "pkg.akt.dev/go/node/cert/v1" 9 | 10 | "pkg.akt.dev/node/x/cert/keeper" 11 | ) 12 | 13 | // NewHandler returns a handler for "provider" type messages. 14 | func NewHandler(keeper keeper.Keeper) baseapp.MsgServiceHandler { 15 | ms := NewMsgServerImpl(keeper) 16 | 17 | return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { 18 | switch msg := msg.(type) { 19 | case *types.MsgCreateCertificate: 20 | res, err := ms.CreateCertificate(ctx, msg) 21 | return sdk.WrapServiceResult(ctx, res, err) 22 | case *types.MsgRevokeCertificate: 23 | res, err := ms.RevokeCertificate(ctx, msg) 24 | return sdk.WrapServiceResult(ctx, res, err) 25 | } 26 | 27 | return nil, sdkerrors.ErrUnknownRequest.Wrapf("unrecognized message type: %T", msg) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /util/wsutil/wsutil.go: -------------------------------------------------------------------------------- 1 | package wsutil 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | "sync" 7 | 8 | "github.com/gorilla/websocket" 9 | ) 10 | 11 | // This type exposes the single method that this wrapper uses 12 | type wrappedConnection interface { 13 | WriteMessage(int, []byte) error 14 | } 15 | 16 | type wsWriterWrapper struct { 17 | connection wrappedConnection 18 | 19 | id byte 20 | buf bytes.Buffer 21 | l sync.Locker 22 | } 23 | 24 | func NewWsWriterWrapper(conn wrappedConnection, id byte, l sync.Locker) io.Writer { 25 | return &wsWriterWrapper{ 26 | connection: conn, 27 | l: l, 28 | id: id, 29 | } 30 | } 31 | 32 | func (wsw *wsWriterWrapper) Write(data []byte) (int, error) { 33 | myBuf := &wsw.buf 34 | myBuf.Reset() 35 | _ = myBuf.WriteByte(wsw.id) 36 | _, _ = myBuf.Write(data) 37 | 38 | wsw.l.Lock() 39 | defer wsw.l.Unlock() 40 | err := wsw.connection.WriteMessage(websocket.BinaryMessage, myBuf.Bytes()) 41 | 42 | return len(data), err 43 | } 44 | -------------------------------------------------------------------------------- /.github/workflows/dispatch.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: dispatch 3 | 4 | defaults: 5 | run: 6 | shell: bash 7 | 8 | on: 9 | push: 10 | 11 | jobs: 12 | dispatch-akash: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: notify goreleaser-cross with new release 16 | uses: benc-uk/workflow-dispatch@v1 17 | with: 18 | token: ${{ secrets.GORELEASER_ACCESS_TOKEN }} 19 | repo: akash-network/homebrew-tap 20 | workflow: akash 21 | ref: refs/heads/main 22 | inputs: '{ "tag" : "${{ env.RELEASE_TAG }}" }' 23 | dispatch-provider: 24 | runs-on: ubuntu-latest 25 | steps: 26 | - name: notify homebrew with new release 27 | uses: benc-uk/workflow-dispatch@v1 28 | with: 29 | token: ${{ secrets.GORELEASER_ACCESS_TOKEN }} 30 | repo: akash-network/homebrew-tap 31 | workflow: provider-services 32 | ref: refs/heads/main 33 | inputs: '{"tag": "${{ env.RELEASE_TAG }}"}' 34 | -------------------------------------------------------------------------------- /tools/upgrade-info/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "log" 7 | "os" 8 | 9 | "github.com/spf13/cobra" 10 | 11 | utilcli "pkg.akt.dev/node/util/cli" 12 | ) 13 | 14 | func main() { 15 | cmd := cobra.Command{ 16 | Use: "upgrade-info", 17 | Example: "upgrade-info ", 18 | Args: cobra.RangeArgs(1, 2), 19 | RunE: func(cmd *cobra.Command, args []string) error { 20 | info, err := utilcli.UpgradeInfoFromTag(cmd.Context(), args[0], true) 21 | if err != nil { 22 | return err 23 | } 24 | 25 | if len(args) == 1 { 26 | fmt.Printf("%s\n", info) 27 | return nil 28 | } 29 | 30 | file, err := os.Create(args[1]) 31 | if err != nil { 32 | return err 33 | } 34 | defer func() { 35 | _ = file.Close() 36 | }() 37 | 38 | if _, err = file.WriteString(info); err != nil { 39 | return err 40 | } 41 | return nil 42 | }, 43 | } 44 | if err := cmd.ExecuteContext(context.Background()); err != nil { 45 | log.Fatal(err) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /upgrades/software/v1.0.0/init.go: -------------------------------------------------------------------------------- 1 | // Package v1_0_0 2 | // nolint revive 3 | package v1_0_0 4 | 5 | import ( 6 | av1 "pkg.akt.dev/go/node/audit/v1" 7 | cv1 "pkg.akt.dev/go/node/cert/v1" 8 | dv1 "pkg.akt.dev/go/node/deployment/v1" 9 | emodule "pkg.akt.dev/go/node/escrow/module" 10 | mv1 "pkg.akt.dev/go/node/market/v1" 11 | pv1 "pkg.akt.dev/go/node/provider/v1beta4" 12 | tv1 "pkg.akt.dev/go/node/take/v1" 13 | 14 | utypes "pkg.akt.dev/node/upgrades/types" 15 | ) 16 | 17 | func init() { 18 | utypes.RegisterUpgrade(UpgradeName, initUpgrade) 19 | 20 | utypes.RegisterMigration(av1.ModuleName, 2, newAuditMigration) 21 | utypes.RegisterMigration(cv1.ModuleName, 3, newCertsMigration) 22 | utypes.RegisterMigration(dv1.ModuleName, 4, newDeploymentsMigration) 23 | utypes.RegisterMigration(emodule.ModuleName, 2, newEscrowMigration) 24 | utypes.RegisterMigration(mv1.ModuleName, 6, newMarketMigration) 25 | utypes.RegisterMigration(pv1.ModuleName, 2, newProviderMigration) 26 | utypes.RegisterMigration(tv1.ModuleName, 2, newTakeMigration) 27 | } 28 | -------------------------------------------------------------------------------- /make/test-integration.mk: -------------------------------------------------------------------------------- 1 | COVER_PACKAGES = $(shell go list ./... | grep -v mock | paste -sd, -) 2 | 3 | TEST_MODULES ?= $(shell $(GO) list ./... | grep -v '/mocks') 4 | 5 | ############################################################################### 6 | ### Misc tests ### 7 | ############################################################################### 8 | 9 | .PHONY: test 10 | test: 11 | $(GO_TEST) -v -timeout 600s $(TEST_MODULES) 12 | 13 | .PHONY: test-nocache 14 | test-nocache: 15 | $(GO_TEST) -count=1 $(TEST_MODULES) 16 | 17 | .PHONY: test-full 18 | test-full: 19 | $(GO_TEST) -v -tags=$(BUILD_TAGS) $(TEST_MODULES) 20 | 21 | .PHONY: test-integration 22 | test-integration: 23 | $(GO_TEST) -v -tags="e2e.integration" $(TEST_MODULES) 24 | 25 | .PHONY: test-coverage 26 | test-coverage: 27 | $(GO_TEST) -tags=$(BUILD_MAINNET) -coverprofile=coverage.txt \ 28 | -covermode=count \ 29 | -coverpkg="$(COVER_PACKAGES)" \ 30 | ./... 31 | 32 | .PHONY: test-vet 33 | test-vet: 34 | $(GO_VET) ./... 35 | -------------------------------------------------------------------------------- /x/audit/handler/handler.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | errorsmod "cosmossdk.io/errors" 5 | "github.com/cosmos/cosmos-sdk/baseapp" 6 | 7 | sdk "github.com/cosmos/cosmos-sdk/types" 8 | sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" 9 | 10 | types "pkg.akt.dev/go/node/audit/v1" 11 | 12 | "pkg.akt.dev/node/x/audit/keeper" 13 | ) 14 | 15 | // NewHandler returns a handler for "provider" type messages. 16 | func NewHandler(keeper keeper.Keeper) baseapp.MsgServiceHandler { 17 | ms := NewMsgServerImpl(keeper) 18 | 19 | return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { 20 | switch msg := msg.(type) { 21 | case *types.MsgSignProviderAttributes: 22 | res, err := ms.SignProviderAttributes(ctx, msg) 23 | return sdk.WrapServiceResult(ctx, res, err) 24 | case *types.MsgDeleteProviderAttributes: 25 | res, err := ms.DeleteProviderAttributes(ctx, msg) 26 | return sdk.WrapServiceResult(ctx, res, err) 27 | } 28 | 29 | return nil, errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized message type: %T", msg) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /upgrades/types/helpers.go: -------------------------------------------------------------------------------- 1 | //nolint: revive 2 | 3 | package types 4 | 5 | import ( 6 | "cosmossdk.io/store/prefix" 7 | storetypes "cosmossdk.io/store/types" 8 | "github.com/cosmos/cosmos-sdk/codec" 9 | "github.com/cosmos/gogoproto/proto" 10 | ) 11 | 12 | // ValueMigrator migrates a value to the new protobuf type given its old protobuf serialized bytes. 13 | type ValueMigrator func(fromBz []byte, cdc codec.BinaryCodec) proto.Message 14 | 15 | // MigrateValue is a helper function that migrates values stored in a KV store for the given 16 | // key prefix using the given value migrator function. 17 | func MigrateValue(store storetypes.KVStore, cdc codec.BinaryCodec, prefixBz []byte, pStart, pEnd []byte, migrator ValueMigrator) (err error) { 18 | pStore := prefix.NewStore(store, prefixBz) 19 | 20 | iter := pStore.Iterator(pStart, pEnd) 21 | defer func() { 22 | err = iter.Close() 23 | }() 24 | 25 | for ; iter.Valid(); iter.Next() { 26 | nVal := migrator(iter.Value(), cdc) 27 | bz := cdc.MustMarshal(nVal) 28 | 29 | pStore.Set(iter.Key(), bz) 30 | } 31 | 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /x/provider/query/types.go: -------------------------------------------------------------------------------- 1 | package query 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | 7 | sdk "github.com/cosmos/cosmos-sdk/types" 8 | 9 | types "pkg.akt.dev/go/node/provider/v1beta4" 10 | ) 11 | 12 | type ( 13 | // Provider type 14 | Provider types.Provider 15 | // Providers - Slice of Provider Struct 16 | Providers []Provider 17 | ) 18 | 19 | func (p Provider) String() string { 20 | return fmt.Sprintf(`Deployment 21 | Owner: %s 22 | HostURI: %s 23 | Attributes: %v 24 | `, p.Owner, p.HostURI, p.Attributes) 25 | } 26 | 27 | func (obj Providers) String() string { 28 | var buf bytes.Buffer 29 | 30 | const sep = "\n\n" 31 | 32 | for _, p := range obj { 33 | buf.WriteString(p.String()) 34 | buf.WriteString(sep) 35 | } 36 | 37 | if len(obj) > 0 { 38 | buf.Truncate(buf.Len() - len(sep)) 39 | } 40 | 41 | return buf.String() 42 | } 43 | 44 | // Address implements provider and returns owner of provider 45 | func (p *Provider) Address() sdk.AccAddress { 46 | owner, err := sdk.AccAddressFromBech32(p.Owner) 47 | if err != nil { 48 | panic(err) 49 | } 50 | 51 | return owner 52 | } 53 | -------------------------------------------------------------------------------- /x/provider/query/client.go: -------------------------------------------------------------------------------- 1 | package query 2 | 3 | import ( 4 | sdkclient "github.com/cosmos/cosmos-sdk/client" 5 | sdk "github.com/cosmos/cosmos-sdk/types" 6 | ) 7 | 8 | // Client interface 9 | type Client interface { 10 | Providers() (Providers, error) 11 | Provider(sdk.AccAddress) (*Provider, error) 12 | } 13 | 14 | // NewClient creates a client instance with provided context and key 15 | func NewClient(ctx sdkclient.Context, key string) Client { 16 | return &client{ctx: ctx, key: key} 17 | } 18 | 19 | type client struct { 20 | ctx sdkclient.Context 21 | key string 22 | } 23 | 24 | func (c *client) Providers() (Providers, error) { 25 | var obj Providers 26 | buf, err := NewRawClient(c.ctx, c.key).Providers() 27 | if err != nil { 28 | return obj, err 29 | } 30 | return obj, c.ctx.LegacyAmino.UnmarshalJSON(buf, &obj) 31 | } 32 | 33 | func (c *client) Provider(id sdk.AccAddress) (*Provider, error) { 34 | var obj Provider 35 | buf, err := NewRawClient(c.ctx, c.key).Provider(id) 36 | if err != nil { 37 | return nil, err 38 | } 39 | return &obj, c.ctx.LegacyAmino.UnmarshalJSON(buf, &obj) 40 | } 41 | -------------------------------------------------------------------------------- /x/provider/query/rawclient.go: -------------------------------------------------------------------------------- 1 | package query 2 | 3 | import ( 4 | "fmt" 5 | 6 | sdkclient "github.com/cosmos/cosmos-sdk/client" 7 | sdk "github.com/cosmos/cosmos-sdk/types" 8 | ) 9 | 10 | // RawClient interface 11 | type RawClient interface { 12 | Providers() ([]byte, error) 13 | Provider(sdk.AccAddress) ([]byte, error) 14 | } 15 | 16 | // NewRawClient creates a client instance with provided context and key 17 | func NewRawClient(ctx sdkclient.Context, key string) RawClient { 18 | return &rawclient{ctx: ctx, key: key} 19 | } 20 | 21 | type rawclient struct { 22 | ctx sdkclient.Context 23 | key string 24 | } 25 | 26 | func (c *rawclient) Providers() ([]byte, error) { 27 | buf, _, err := c.ctx.QueryWithData(fmt.Sprintf("custom/%s/%s", c.key, getProvidersPath()), nil) 28 | if err != nil { 29 | return []byte{}, err 30 | } 31 | return buf, err 32 | } 33 | 34 | func (c *rawclient) Provider(id sdk.AccAddress) ([]byte, error) { 35 | buf, _, err := c.ctx.QueryWithData(fmt.Sprintf("custom/%s/%s", c.key, getProviderPath(id)), nil) 36 | if err != nil { 37 | return []byte{}, err 38 | } 39 | return buf, err 40 | } 41 | -------------------------------------------------------------------------------- /util/server/utils.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "context" 5 | "os" 6 | "os/signal" 7 | "syscall" 8 | 9 | "cosmossdk.io/log" 10 | "golang.org/x/sync/errgroup" 11 | ) 12 | 13 | // ListenForQuitSignals listens for SIGINT and SIGTERM. When a signal is received, 14 | // the cleanup function is called, indicating the caller can gracefully exit or 15 | // return. 16 | // 17 | // Note, the blocking behavior of this depends on the block argument. 18 | // The caller must ensure the corresponding context derived from the cancelFn is used correctly. 19 | func ListenForQuitSignals(ctx context.Context, cancelFn context.CancelFunc, g *errgroup.Group, block bool, logger log.Logger) { 20 | sigCh := make(chan os.Signal, 1) 21 | signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM) 22 | 23 | f := func() { 24 | select { 25 | case sig := <-sigCh: 26 | logger.Info("caught signal", "signal", sig.String()) 27 | case <-ctx.Done(): 28 | logger.Info("context canceled") 29 | } 30 | 31 | cancelFn() 32 | } 33 | 34 | if block { 35 | g.Go(func() error { 36 | f() 37 | return nil 38 | }) 39 | } else { 40 | go f() 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /x/deployment/testdata/deployment-v2-shared-ip-endpoint.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.0" 3 | 4 | services: 5 | web: 6 | image: ghcr.io/akash-network/demo-app 7 | expose: 8 | - port: 80 9 | to: 10 | - global: true 11 | ip: "meow" 12 | accept: 13 | - test.localhost 14 | anotherweb: 15 | image: ghcr.io/akash-network/demo-app 16 | expose: 17 | - port: 80 18 | as: 81 19 | to: 20 | - global: true 21 | ip: "meow" 22 | accept: 23 | - extratest.localhost 24 | 25 | profiles: 26 | compute: 27 | web: 28 | resources: 29 | cpu: 30 | units: "0.01" 31 | memory: 32 | size: "128Mi" 33 | storage: 34 | size: "512Mi" 35 | 36 | placement: 37 | global: 38 | pricing: 39 | web: 40 | denom: uakt 41 | amount: 10 42 | 43 | deployment: 44 | web: 45 | global: 46 | profile: web 47 | count: 1 48 | anotherweb: 49 | global: 50 | profile: web 51 | count: 3 52 | 53 | endpoints: 54 | meow: 55 | kind: "ip" 56 | -------------------------------------------------------------------------------- /x/deployment/testdata/deployment-v2.1-shared-ip-endpoint.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.1" 3 | 4 | services: 5 | web: 6 | image: ghcr.io/akash-network/demo-app 7 | expose: 8 | - port: 80 9 | to: 10 | - global: true 11 | ip: "meow" 12 | accept: 13 | - test.localhost 14 | anotherweb: 15 | image: ghcr.io/akash-network/demo-app 16 | expose: 17 | - port: 80 18 | as: 81 19 | to: 20 | - global: true 21 | ip: "meow" 22 | accept: 23 | - extratest.localhost 24 | 25 | profiles: 26 | compute: 27 | web: 28 | resources: 29 | cpu: 30 | units: "0.01" 31 | memory: 32 | size: "128Mi" 33 | storage: 34 | size: "512Mi" 35 | 36 | placement: 37 | global: 38 | pricing: 39 | web: 40 | denom: uakt 41 | amount: 10 42 | 43 | deployment: 44 | web: 45 | global: 46 | profile: web 47 | count: 1 48 | anotherweb: 49 | global: 50 | profile: web 51 | count: 3 52 | 53 | endpoints: 54 | meow: 55 | kind: "ip" 56 | -------------------------------------------------------------------------------- /x/take/handler/server.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "context" 5 | 6 | sdk "github.com/cosmos/cosmos-sdk/types" 7 | govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" 8 | 9 | types "pkg.akt.dev/go/node/take/v1" 10 | 11 | "pkg.akt.dev/node/x/take/keeper" 12 | ) 13 | 14 | var _ types.MsgServer = msgServer{} 15 | 16 | type msgServer struct { 17 | keeper keeper.IKeeper 18 | } 19 | 20 | // NewMsgServerImpl returns an implementation of the akash staking MsgServer interface 21 | // for the provided Keeper. 22 | func NewMsgServerImpl(k keeper.IKeeper) types.MsgServer { 23 | return &msgServer{ 24 | keeper: k, 25 | } 26 | } 27 | 28 | func (ms msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { 29 | if ms.keeper.GetAuthority() != req.Authority { 30 | return nil, govtypes.ErrInvalidSigner.Wrapf("invalid authority; expected %s, got %s", ms.keeper.GetAuthority(), req.Authority) 31 | } 32 | 33 | ctx := sdk.UnwrapSDKContext(goCtx) 34 | if err := ms.keeper.SetParams(ctx, req.Params); err != nil { 35 | return nil, err 36 | } 37 | 38 | return &types.MsgUpdateParamsResponse{}, nil 39 | } 40 | -------------------------------------------------------------------------------- /x/deployment/testdata/deployment-v2-multi-ip-endpoint.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.0" 3 | 4 | services: 5 | web: 6 | image: ghcr.io/akash-network/demo-app 7 | expose: 8 | - port: 80 9 | to: 10 | - global: true 11 | ip: "meow" 12 | accept: 13 | - test.localhost 14 | anotherweb: 15 | image: ghcr.io/akash-network/demo-app 16 | expose: 17 | - port: 80 18 | to: 19 | - global: true 20 | ip: "kittens" 21 | accept: 22 | - extratest.localhost 23 | 24 | profiles: 25 | compute: 26 | web: 27 | resources: 28 | cpu: 29 | units: "0.01" 30 | memory: 31 | size: "128Mi" 32 | storage: 33 | size: "512Mi" 34 | 35 | placement: 36 | global: 37 | pricing: 38 | web: 39 | denom: uakt 40 | amount: 10 41 | 42 | deployment: 43 | web: 44 | global: 45 | profile: web 46 | count: 1 47 | anotherweb: 48 | global: 49 | profile: web 50 | count: 3 51 | 52 | endpoints: 53 | meow: 54 | kind: "ip" 55 | kittens: 56 | kind: "ip" 57 | -------------------------------------------------------------------------------- /x/deployment/testdata/deployment-v2.1-multi-ip-endpoint.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.1" 3 | 4 | services: 5 | web: 6 | image: ghcr.io/akash-network/demo-app 7 | expose: 8 | - port: 80 9 | to: 10 | - global: true 11 | ip: "meow" 12 | accept: 13 | - test.localhost 14 | anotherweb: 15 | image: ghcr.io/akash-network/demo-app 16 | expose: 17 | - port: 80 18 | to: 19 | - global: true 20 | ip: "kittens" 21 | accept: 22 | - extratest.localhost 23 | 24 | profiles: 25 | compute: 26 | web: 27 | resources: 28 | cpu: 29 | units: "0.01" 30 | memory: 31 | size: "128Mi" 32 | storage: 33 | size: "512Mi" 34 | 35 | placement: 36 | global: 37 | pricing: 38 | web: 39 | denom: uakt 40 | amount: 10 41 | 42 | deployment: 43 | web: 44 | global: 45 | profile: web 46 | count: 1 47 | anotherweb: 48 | global: 49 | profile: web 50 | count: 3 51 | 52 | endpoints: 53 | meow: 54 | kind: "ip" 55 | kittens: 56 | kind: "ip" 57 | -------------------------------------------------------------------------------- /x/take/genesis.go: -------------------------------------------------------------------------------- 1 | package take 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | 6 | types "pkg.akt.dev/go/node/take/v1" 7 | 8 | "pkg.akt.dev/node/x/take/keeper" 9 | ) 10 | 11 | // ValidateGenesis does validation check of the Genesis and return error incase of failure 12 | func ValidateGenesis(data *types.GenesisState) error { 13 | return data.Params.Validate() 14 | } 15 | 16 | // DefaultGenesisState returns default genesis state as raw bytes for the deployment 17 | // module. 18 | func DefaultGenesisState() *types.GenesisState { 19 | return &types.GenesisState{ 20 | Params: types.DefaultParams(), 21 | } 22 | } 23 | 24 | // InitGenesis initiate genesis state and return updated validator details 25 | func InitGenesis(ctx sdk.Context, keeper keeper.IKeeper, data *types.GenesisState) { 26 | err := keeper.SetParams(ctx, data.Params) 27 | if err != nil { 28 | panic(err.Error()) 29 | } 30 | } 31 | 32 | // ExportGenesis returns genesis state for the deployment module 33 | func ExportGenesis(ctx sdk.Context, k keeper.IKeeper) *types.GenesisState { 34 | params := k.GetParams(ctx) 35 | return &types.GenesisState{ 36 | Params: params, 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /_build/single-node.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | CHAINID=$1 4 | GENACCT=$2 5 | 6 | if [ -z "$1" ]; then 7 | echo "Need to input chain id..." 8 | exit 1 9 | fi 10 | 11 | if [ -z "$2" ]; then 12 | echo "Need to input genesis account address..." 13 | exit 1 14 | fi 15 | 16 | # Build genesis file incl account for passed address 17 | coins="10000000000uakt" 18 | akash init --chain-id "$CHAINID" "$CHAINID" 19 | akash keys add validator --keyring-backend="test" 20 | akash add-genesis-account "$(akash keys show validator -a --keyring-backend="test")" $coins 21 | akash add-genesis-account "$GENACCT" $coins 22 | akash gentx validator 10000000000uakt --keyring-backend="test" --chain-id "$CHAINID" 23 | akash collect-gentxs 24 | 25 | # Set proper defaults and change ports 26 | sed -i 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:26657"#g' ~/.akash/config/config.toml 27 | sed -i 's/timeout_commit = "5s"/timeout_commit = "1s"/g' ~/.akash/config/config.toml 28 | sed -i 's/timeout_propose = "3s"/timeout_propose = "1s"/g' ~/.akash/config/config.toml 29 | sed -i 's/index_all_keys = false/index_all_keys = true/g' ~/.akash/config/config.toml 30 | 31 | # Start the akash 32 | akash start --pruning=nothing 33 | -------------------------------------------------------------------------------- /x/market/hooks/external.go: -------------------------------------------------------------------------------- 1 | package hooks 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | 6 | dv1 "pkg.akt.dev/go/node/deployment/v1" 7 | dtypes "pkg.akt.dev/go/node/deployment/v1beta4" 8 | mv1 "pkg.akt.dev/go/node/market/v1" 9 | mtypes "pkg.akt.dev/go/node/market/v1beta5" 10 | ) 11 | 12 | type DeploymentKeeper interface { 13 | GetDeployment(ctx sdk.Context, id dv1.DeploymentID) (dv1.Deployment, bool) 14 | GetGroups(ctx sdk.Context, id dv1.DeploymentID) dtypes.Groups 15 | CloseDeployment(ctx sdk.Context, deployment dv1.Deployment) error 16 | OnCloseGroup(ctx sdk.Context, group dtypes.Group, state dtypes.Group_State) error 17 | } 18 | 19 | type MarketKeeper interface { 20 | GetOrder(ctx sdk.Context, id mv1.OrderID) (mtypes.Order, bool) 21 | GetBid(ctx sdk.Context, id mv1.BidID) (mtypes.Bid, bool) 22 | GetLease(ctx sdk.Context, id mv1.LeaseID) (mv1.Lease, bool) 23 | OnGroupClosed(ctx sdk.Context, id dv1.GroupID) error 24 | OnOrderClosed(ctx sdk.Context, order mtypes.Order) error 25 | OnBidClosed(ctx sdk.Context, bid mtypes.Bid) error 26 | OnLeaseClosed(ctx sdk.Context, lease mv1.Lease, state mv1.Lease_State, reason mv1.LeaseClosedReason) error 27 | } 28 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | This is the requirements for reporting a bug on the Akash project. If you need general 2 | help, please make a post on [our Discourse](https://forum.akash.network). 3 | 4 | Please provide as much information as possible. Please do not post screenshots of terminal 5 | sessions. Instead, copy & paste the terminal session text into the report 6 | 7 | # What you are trying to do 8 | 9 | # What you expected to happen 10 | 11 | # What actually happens 12 | 13 | # Steps to reproduce 14 | 15 | Please describe the steps necessary to reproduce this bug 16 | 17 | 1. 18 | 2. 19 | 3. 20 | 21 | # Blockchain details (if it applies) 22 | 23 | Please include blockchain details if it applies, this section is not require 24 | 25 | * **wallet address** - 26 | * **deployment sequence number** - 27 | * **transaction hash** - 28 | * **RPC node you are using** - 29 | 30 | # Operation system & environment 31 | 32 | # Akash version 33 | 34 | Please paste the output of the `akash version` command here. If you built from source, 35 | please include the branch & the commit SHA you compiled from. 36 | 37 | # Other information 38 | 39 | Please include any other information you feel is helpful -------------------------------------------------------------------------------- /app/option.go: -------------------------------------------------------------------------------- 1 | package app 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/codec" 5 | 6 | "pkg.akt.dev/go/sdkutil" 7 | ) 8 | 9 | type SetupGenesisFn func(cdc codec.Codec) GenesisState 10 | 11 | type setupAppOptions struct { 12 | encCfg sdkutil.EncodingConfig 13 | home string 14 | chainID string 15 | checkTx bool 16 | genesisFn SetupGenesisFn 17 | } 18 | 19 | type SetupAppOption func(*setupAppOptions) 20 | 21 | // WithHome sets home dir for app 22 | func WithHome(val string) SetupAppOption { 23 | return func(t *setupAppOptions) { 24 | t.home = val 25 | } 26 | } 27 | 28 | // WithChainID sets home dir for app 29 | func WithChainID(val string) SetupAppOption { 30 | return func(t *setupAppOptions) { 31 | t.chainID = val 32 | } 33 | } 34 | 35 | // WithCheckTx sets home dir for app 36 | func WithCheckTx(val bool) SetupAppOption { 37 | return func(t *setupAppOptions) { 38 | t.checkTx = val 39 | } 40 | } 41 | 42 | func WithGenesis(val SetupGenesisFn) SetupAppOption { 43 | return func(t *setupAppOptions) { 44 | t.genesisFn = val 45 | } 46 | } 47 | 48 | func WithEncConfig(val sdkutil.EncodingConfig) SetupAppOption { 49 | return func(t *setupAppOptions) { 50 | t.encCfg = val 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /x/deployment/testdata/deployment-v2-c2c.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.0" 3 | 4 | services: 5 | web: 6 | image: anapsix/webdis 7 | env: 8 | - REDIS_HOST=redis-server 9 | expose: 10 | - port: 7379 11 | as: 80 12 | to: 13 | - global: true 14 | accept: 15 | - webdistest.localhost 16 | 17 | redis-server: 18 | image: redis:rc-alpine3.12 19 | expose: 20 | - port: 6379 21 | 22 | profiles: 23 | compute: 24 | web: 25 | resources: 26 | cpu: 27 | units: 0.1 28 | memory: 29 | size: 16Mi 30 | storage: 31 | size: 128Mi 32 | redis-server: 33 | resources: 34 | cpu: 35 | units: 0.1 36 | memory: 37 | size: 64Mi 38 | storage: 39 | size: 128Mi 40 | placement: 41 | global: 42 | pricing: 43 | web: 44 | denom: uakt 45 | amount: 9000 46 | redis-server: 47 | denom: uakt 48 | amount: 9000 49 | 50 | deployment: 51 | web: 52 | global: 53 | profile: web 54 | count: 1 55 | redis-server: 56 | global: 57 | profile: redis-server 58 | count: 1 59 | -------------------------------------------------------------------------------- /x/deployment/testdata/deployment-v2-escrow.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.0" 3 | 4 | services: 5 | web: 6 | image: anapsix/webdis 7 | env: 8 | - REDIS_HOST=redis-server 9 | expose: 10 | - port: 7379 11 | as: 80 12 | to: 13 | - global: true 14 | accept: 15 | - webdistest.localhost 16 | 17 | redis-server: 18 | image: redis:rc-alpine3.12 19 | expose: 20 | - port: 6379 21 | 22 | profiles: 23 | compute: 24 | web: 25 | resources: 26 | cpu: 27 | units: 0.1 28 | memory: 29 | size: 16Mi 30 | storage: 31 | size: 128Mi 32 | redis-server: 33 | resources: 34 | cpu: 35 | units: 0.1 36 | memory: 37 | size: 64Mi 38 | storage: 39 | size: 128Mi 40 | placement: 41 | global: 42 | pricing: 43 | web: 44 | denom: uakt 45 | amount: 10000000 46 | redis-server: 47 | denom: uakt 48 | amount: 10000000 49 | 50 | deployment: 51 | web: 52 | global: 53 | profile: web 54 | count: 1 55 | redis-server: 56 | global: 57 | profile: redis-server 58 | count: 1 59 | -------------------------------------------------------------------------------- /_build/Dockerfile.test: -------------------------------------------------------------------------------- 1 | # Simple usage with a mounted data directory: 2 | # > docker build -t gaia . 3 | # > docker run -it -p 46657:46657 -p 46656:46656 -v ~/.gaiad:/root/.gaiad -v ~/.gaiacli:/root/.gaiacli gaia gaiad init 4 | # > docker run -it -p 46657:46657 -p 46656:46656 -v ~/.gaiad:/root/.gaiad -v ~/.gaiacli:/root/.gaiacli gaia gaiad start 5 | FROM golang:alpine AS build-env 6 | 7 | # Set up dependencies 8 | ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python2 9 | 10 | # Set working directory for the build 11 | WORKDIR /go/src/github.com/akash-network/node 12 | 13 | # Add source files 14 | COPY . . 15 | 16 | # Install minimum necessary dependencies, build Cosmos SDK, remove packages 17 | RUN apk add --no-cache $PACKAGES && \ 18 | make install 19 | 20 | # Final image 21 | FROM alpine:edge 22 | 23 | # Install ca-certificates 24 | RUN apk add --update ca-certificates 25 | WORKDIR /root 26 | 27 | # Copy over binaries from the build-env 28 | COPY --from=build-env /go/bin/akash /usr/bin/akash 29 | 30 | COPY ./_build/single-node.sh . 31 | 32 | EXPOSE 26657 33 | 34 | ENTRYPOINT [ "./single-node.sh" ] 35 | # NOTE: to run this image, docker run -d -p 26657:26657 ./single-node.sh {{chain_id}} {{genesis_account}} 36 | -------------------------------------------------------------------------------- /x/provider/handler/handler.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/baseapp" 5 | sdk "github.com/cosmos/cosmos-sdk/types" 6 | sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" 7 | 8 | types "pkg.akt.dev/go/node/provider/v1beta4" 9 | 10 | mkeeper "pkg.akt.dev/node/x/market/keeper" 11 | "pkg.akt.dev/node/x/provider/keeper" 12 | ) 13 | 14 | // NewHandler returns a handler for "provider" type messages. 15 | func NewHandler(keeper keeper.IKeeper, mkeeper mkeeper.IKeeper) baseapp.MsgServiceHandler { 16 | ms := NewMsgServerImpl(keeper, mkeeper) 17 | 18 | return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { 19 | switch msg := msg.(type) { 20 | case *types.MsgCreateProvider: 21 | res, err := ms.CreateProvider(ctx, msg) 22 | return sdk.WrapServiceResult(ctx, res, err) 23 | 24 | case *types.MsgUpdateProvider: 25 | res, err := ms.UpdateProvider(ctx, msg) 26 | return sdk.WrapServiceResult(ctx, res, err) 27 | 28 | case *types.MsgDeleteProvider: 29 | res, err := ms.DeleteProvider(ctx, msg) 30 | return sdk.WrapServiceResult(ctx, res, err) 31 | 32 | default: 33 | return nil, sdkerrors.ErrUnknownRequest.Wrapf("unrecognized bank message type: %T", msg) 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tests/upgrade/config-v0.24.0.tmpl.json: -------------------------------------------------------------------------------- 1 | { 2 | "chain_id": "localakash", 3 | "accounts": { 4 | "add": [ 5 | { 6 | "address": "{{ (ds "account_address") }}", 7 | "pubkey": {{ (ds "account_pubkey") }}, 8 | "coins": [ 9 | "2000000000000000uakt" 10 | ] 11 | } 12 | ] 13 | }, 14 | "validators": { 15 | "add": [ 16 | { 17 | "name": "upgrade-tester", 18 | "pubkey": {{ (ds "validator_pubkey") }}, 19 | "rates": { 20 | "rate": "0.05", 21 | "maxRate": "0.8", 22 | "maxChangeRate": "0.1" 23 | }, 24 | "bonded": true, 25 | "delegators": [ 26 | { 27 | "address": "{{ (ds "account_address") }}", 28 | "coins": [ 29 | "1950000000000000uakt" 30 | ] 31 | } 32 | ] 33 | } 34 | ] 35 | }, 36 | "gov": { 37 | "voting_params": { 38 | "voting_period": "60s" 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /x/market/handler/handler.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/baseapp" 5 | sdk "github.com/cosmos/cosmos-sdk/types" 6 | sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" 7 | 8 | types "pkg.akt.dev/go/node/market/v1beta5" 9 | ) 10 | 11 | // NewHandler returns a handler for "market" type messages 12 | func NewHandler(keepers Keepers) baseapp.MsgServiceHandler { 13 | ms := NewServer(keepers) 14 | 15 | return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { 16 | switch msg := msg.(type) { 17 | case *types.MsgCreateBid: 18 | res, err := ms.CreateBid(ctx, msg) 19 | return sdk.WrapServiceResult(ctx, res, err) 20 | case *types.MsgCloseBid: 21 | res, err := ms.CloseBid(ctx, msg) 22 | return sdk.WrapServiceResult(ctx, res, err) 23 | case *types.MsgWithdrawLease: 24 | res, err := ms.WithdrawLease(ctx, msg) 25 | return sdk.WrapServiceResult(ctx, res, err) 26 | case *types.MsgCreateLease: 27 | res, err := ms.CreateLease(ctx, msg) 28 | return sdk.WrapServiceResult(ctx, res, err) 29 | case *types.MsgCloseLease: 30 | res, err := ms.CloseLease(ctx, msg) 31 | return sdk.WrapServiceResult(ctx, res, err) 32 | default: 33 | return nil, sdkerrors.ErrUnknownRequest 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /x/escrow/handler/server.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "context" 5 | 6 | sdk "github.com/cosmos/cosmos-sdk/types" 7 | types "pkg.akt.dev/go/node/escrow/v1" 8 | 9 | "pkg.akt.dev/node/x/escrow/keeper" 10 | ) 11 | 12 | var _ types.MsgServer = msgServer{} 13 | 14 | type msgServer struct { 15 | keeper keeper.Keeper 16 | authzKeeper AuthzKeeper 17 | bkeeper BankKeeper 18 | } 19 | 20 | // NewServer returns an implementation of the deployment MsgServer interface 21 | // for the provided Keeper. 22 | func NewServer(k keeper.Keeper, authzKeeper AuthzKeeper, bkeeper BankKeeper) types.MsgServer { 23 | return &msgServer{ 24 | keeper: k, 25 | authzKeeper: authzKeeper, 26 | bkeeper: bkeeper, 27 | } 28 | } 29 | 30 | func (ms msgServer) AccountDeposit(goCtx context.Context, msg *types.MsgAccountDeposit) (*types.MsgAccountDepositResponse, error) { 31 | ctx := sdk.UnwrapSDKContext(goCtx) 32 | 33 | deposits, err := ms.keeper.AuthorizeDeposits(ctx, msg) 34 | if err != nil { 35 | return &types.MsgAccountDepositResponse{}, err 36 | } 37 | 38 | if err := ms.keeper.AccountDeposit(ctx, msg.ID, deposits); err != nil { 39 | return &types.MsgAccountDepositResponse{}, err 40 | } 41 | 42 | return &types.MsgAccountDepositResponse{}, nil 43 | } 44 | -------------------------------------------------------------------------------- /util/metrics/metrics.go: -------------------------------------------------------------------------------- 1 | package metrics 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/prometheus/client_golang/prometheus" 7 | "pkg.akt.dev/go/util/runner" 8 | ) 9 | 10 | const SuccessLabel = "success" 11 | const FailLabel = "fail" 12 | const OpenLabel = "open" 13 | 14 | func IncCounterVecWithLabelValues(counter *prometheus.CounterVec, name string, err error) { 15 | label := SuccessLabel 16 | if err != nil { 17 | label = FailLabel 18 | } 19 | counter.WithLabelValues(name, label).Inc() 20 | } 21 | 22 | func IncCounterVecWithLabelValuesFiltered(counter *prometheus.CounterVec, name string, err error, filters ...func(error) bool) { 23 | label := SuccessLabel 24 | if err != nil { 25 | flipLabel := true 26 | for _, filter := range filters { 27 | if filter(err) { 28 | flipLabel = false 29 | break 30 | } 31 | } 32 | if flipLabel { 33 | label = FailLabel 34 | } 35 | } 36 | counter.WithLabelValues(name, label).Inc() 37 | } 38 | 39 | func ObserveRunner(f func() runner.Result, observer prometheus.Histogram) func() runner.Result { 40 | return func() runner.Result { 41 | startAt := time.Now() 42 | result := f() 43 | elapsed := time.Since(startAt) 44 | observer.Observe(float64(elapsed.Microseconds())) 45 | return result 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /util/wsutil/wsutil_test.go: -------------------------------------------------------------------------------- 1 | package wsutil 2 | 3 | import ( 4 | "io" 5 | "sync" 6 | "testing" 7 | 8 | "github.com/gorilla/websocket" 9 | "github.com/stretchr/testify/require" 10 | ) 11 | 12 | type dummyConnection struct { 13 | messageType int 14 | data []byte 15 | 16 | returns error 17 | } 18 | 19 | func (dc *dummyConnection) WriteMessage(mt int, data []byte) error { 20 | dc.messageType = mt 21 | dc.data = data 22 | return dc.returns 23 | } 24 | 25 | func TestWebsocketWriterWrapperWritesPrefix(t *testing.T) { 26 | const testID = 0xab 27 | l := &sync.Mutex{} 28 | conn := &dummyConnection{} 29 | 30 | wrapper := NewWsWriterWrapper(conn, testID, l) 31 | 32 | n, err := wrapper.Write([]byte{0x1, 0x2, 0x3}) 33 | require.NoError(t, err) 34 | require.Equal(t, n, 3) 35 | 36 | require.Equal(t, conn.messageType, websocket.BinaryMessage) 37 | require.Equal(t, conn.data, []byte{testID, 0x1, 0x2, 0x3}) 38 | } 39 | 40 | func TestWebsocketWriterWrapperReturnsError(t *testing.T) { 41 | const testID = 0xab 42 | l := &sync.Mutex{} 43 | conn := &dummyConnection{} 44 | conn.returns = io.EOF // Any error works 45 | 46 | wrapper := NewWsWriterWrapper(conn, testID, l) 47 | 48 | _, err := wrapper.Write([]byte{0x1, 0x2, 0x3}) 49 | require.Error(t, err) 50 | require.Equal(t, io.EOF, err) 51 | } 52 | -------------------------------------------------------------------------------- /app/mac.go: -------------------------------------------------------------------------------- 1 | package app 2 | 3 | import ( 4 | authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" 5 | distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" 6 | govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" 7 | minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" 8 | stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" 9 | ibctransfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types" 10 | emodule "pkg.akt.dev/go/node/escrow/module" 11 | ) 12 | 13 | func ModuleAccountPerms() map[string][]string { 14 | return map[string][]string{ 15 | authtypes.FeeCollectorName: nil, 16 | emodule.ModuleName: nil, 17 | distrtypes.ModuleName: nil, 18 | minttypes.ModuleName: {authtypes.Minter}, 19 | stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, 20 | stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, 21 | govtypes.ModuleName: {authtypes.Burner}, 22 | ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, 23 | } 24 | } 25 | 26 | func ModuleAccountAddrs() map[string]bool { 27 | perms := ModuleAccountPerms() 28 | addrs := make(map[string]bool, len(perms)) 29 | for k := range perms { 30 | addrs[authtypes.NewModuleAddress(k).String()] = true 31 | } 32 | return addrs 33 | } 34 | -------------------------------------------------------------------------------- /cmd/akash/cmd/bech32.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/types/bech32" 5 | "github.com/spf13/cobra" 6 | "pkg.akt.dev/go/sdkutil" 7 | ) 8 | 9 | var flagBech32Prefix = "prefix" 10 | 11 | // ConvertBech32Cmd get cmd to convert any bech32 address to an akash prefix. 12 | func ConvertBech32Cmd() *cobra.Command { 13 | cmd := &cobra.Command{ 14 | Use: "bech32-convert [bech32 string]", 15 | Short: "Convert any bech32 string to the akash prefix", 16 | Long: `Convert any bech32 string to the akash prefix 17 | Especially useful for converting cosmos addresses to akash addresses 18 | Example: 19 | akash bech32-convert akash1ey69r37gfxvxg62sh4r0ktpuc46pzjrmz29g45 20 | `, 21 | Args: cobra.ExactArgs(1), 22 | RunE: func(cmd *cobra.Command, args []string) error { 23 | bech32prefix, err := cmd.Flags().GetString(flagBech32Prefix) 24 | if err != nil { 25 | return err 26 | } 27 | 28 | _, bz, err := bech32.DecodeAndConvert(args[0]) 29 | if err != nil { 30 | return err 31 | } 32 | 33 | bech32Addr, err := bech32.ConvertAndEncode(bech32prefix, bz) 34 | if err != nil { 35 | panic(err) 36 | } 37 | 38 | cmd.Println(bech32Addr) 39 | 40 | return nil 41 | }, 42 | } 43 | 44 | cmd.Flags().StringP(flagBech32Prefix, "p", sdkutil.Bech32PrefixAccAddr, "Bech32 Prefix to encode to") 45 | 46 | return cmd 47 | } 48 | -------------------------------------------------------------------------------- /.github/actions/setup-ubuntu/action.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: setup-ubuntu 3 | runs: 4 | using: 'composite' 5 | steps: 6 | - name: Fetch all tags 7 | shell: bash 8 | run: | 9 | if git rev-parse --is-shallow-repository | grep -qxF true; then 10 | git fetch --prune --unshallow 11 | else 12 | git fetch --prune --tags 13 | fi 14 | - name: Install dependencies 15 | # Shell must explicitly specify the shell for each step. https://github.com/orgs/community/discussions/18597 16 | shell: bash 17 | run: sudo apt install -y make direnv unzip lz4 wget curl npm jq pv coreutils libudev-dev 18 | - name: Setup npm 19 | uses: actions/setup-node@v4 20 | with: 21 | node-version: 18 22 | - name: Detect required Go version 23 | shell: bash 24 | run: | 25 | toolchain=$(./script/tools.sh gotoolchain | sed 's/^go//') 26 | if [ -z "$toolchain" ]; then 27 | echo "Error: Failed to detect Go version from script/tools.sh" >&2 28 | exit 1 29 | fi 30 | echo "GOVERSION=${toolchain}" >> $GITHUB_ENV 31 | - uses: actions/setup-go@v5 32 | with: 33 | go-version: "${{ env.GOVERSION }}" 34 | check-latest: true 35 | - name: set environment 36 | uses: HatsuneMiku3939/direnv-action@v1 37 | with: 38 | masks: '' 39 | -------------------------------------------------------------------------------- /make/test-simulation.mk: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | ### Simulation ### 3 | ############################################################################### 4 | 5 | test-sim-fullapp: 6 | echo "Running app simulation test..." 7 | go test -mod=readonly $(APP_DIR) -run=TestFullAppSimulation -Enabled=true \ 8 | -NumBlocks=50 -BlockSize=100 -Commit=true -Seed=99 -Period=5 -v -timeout 10m 9 | 10 | test-sim-nondeterminism: 11 | echo "Running non-determinism test. This may take several minutes..." 12 | go test -mod=readonly $(APP_DIR) -run TestAppStateDeterminism -Enabled=true \ 13 | -NumBlocks=50 -BlockSize=100 -Commit=true -Period=0 -v -timeout 24h 14 | 15 | test-sim-import-export: 16 | echo "Running application import/export simulation..." 17 | go test -mod=readonly $(APP_DIR) -run=TestAppImportExport -Enabled=true \ 18 | -NumBlocks=50 -BlockSize=100 -Commit=true -Seed=99 -Period=5 -v -timeout 10m 19 | 20 | test-sim-after-import: 21 | echo "Running application simulation-after-import..." 22 | go test -mod=readonly $(APP_DIR) -run=TestAppSimulationAfterImport -Enabled=true \ 23 | -NumBlocks=50 -BlockSize=100 -Commit=true -Seed=99 -Period=5 -v -timeout 10m 24 | 25 | test-sims: test-sim-fullapp test-sim-nondeterminism test-sim-import-export test-sim-after-import 26 | -------------------------------------------------------------------------------- /util/validation/address.go: -------------------------------------------------------------------------------- 1 | package validation 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func KeyAtLeastLength(bz []byte, length int) error { 8 | if len(bz) < length { 9 | return fmt.Errorf("expected key of length at least %d, got %d", length, len(bz)) 10 | } 11 | 12 | return nil 13 | } 14 | 15 | // AssertKeyAtLeastLength panics when store key length is less than the given length. 16 | func AssertKeyAtLeastLength(bz []byte, length int) { 17 | err := KeyAtLeastLength(bz, length) 18 | if err != nil { 19 | panic(err) 20 | } 21 | } 22 | 23 | func KeyLength(bz []byte, length int) error { 24 | if len(bz) != length { 25 | return fmt.Errorf("unexpected key length; got: %d, expected: %d", len(bz), length) 26 | } 27 | 28 | return nil 29 | } 30 | 31 | // AssertKeyLength panics when store key length is not equal to the given length. 32 | func AssertKeyLength(bz []byte, length int) { 33 | err := KeyLength(bz, length) 34 | if err != nil { 35 | panic(err) 36 | } 37 | } 38 | 39 | func EncodeWithLengthPrefix(bz []byte) ([]byte, error) { 40 | if len(bz) > 255 { 41 | return nil, fmt.Errorf("length-prefixed address too long") 42 | } 43 | 44 | return append([]byte{byte(len(bz))}, bz...), nil 45 | } 46 | 47 | func MustEncodeWithLengthPrefix(bz []byte) []byte { 48 | res, err := EncodeWithLengthPrefix(bz) 49 | if err != nil { 50 | panic(err) 51 | } 52 | 53 | return res 54 | } 55 | -------------------------------------------------------------------------------- /tests/upgrade/types/types.go: -------------------------------------------------------------------------------- 1 | package types //nolint: revive 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "testing" 7 | 8 | sdk "github.com/cosmos/cosmos-sdk/types" 9 | ) 10 | 11 | type TestParams struct { 12 | Home string 13 | Node string 14 | SourceDir string 15 | ChainID string 16 | KeyringBackend string 17 | From string 18 | FromAddress sdk.AccAddress 19 | } 20 | 21 | type TestWorker interface { 22 | Run(ctx context.Context, t *testing.T, params TestParams) 23 | } 24 | 25 | var ( 26 | preUpgradeWorkers = map[string]TestWorker{} 27 | postUpgradeWorkers = map[string]TestWorker{} 28 | ) 29 | 30 | func RegisterPreUpgradeWorker(name string, worker TestWorker) { 31 | if _, exists := preUpgradeWorkers[name]; exists { 32 | panic(fmt.Sprintf("pre-upgrade worker for upgrade \"%s\" already exists", name)) 33 | } 34 | 35 | preUpgradeWorkers[name] = worker 36 | } 37 | 38 | func RegisterPostUpgradeWorker(name string, worker TestWorker) { 39 | if _, exists := postUpgradeWorkers[name]; exists { 40 | panic(fmt.Sprintf("post-upgrade worker for upgrade \"%s\" already exists", name)) 41 | } 42 | 43 | postUpgradeWorkers[name] = worker 44 | } 45 | 46 | func GetPreUpgradeWorker(name string) TestWorker { 47 | return preUpgradeWorkers[name] 48 | } 49 | 50 | func GetPostUpgradeWorker(name string) TestWorker { 51 | return postUpgradeWorkers[name] 52 | } 53 | -------------------------------------------------------------------------------- /x/provider/config/config.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "os" 7 | 8 | "gopkg.in/yaml.v3" 9 | 10 | ptypes "pkg.akt.dev/go/node/provider/v1beta4" 11 | tattr "pkg.akt.dev/go/node/types/attributes/v1" 12 | ) 13 | 14 | var ( 15 | ErrDuplicatedAttribute = errors.New("provider: duplicated attribute") 16 | ) 17 | 18 | // Config is the struct that stores provider config 19 | type Config struct { 20 | Host string `json:"host" yaml:"host"` 21 | Info ptypes.Info `json:"info" yaml:"info"` 22 | Attributes tattr.Attributes `json:"attributes" yaml:"attributes"` 23 | } 24 | 25 | // GetAttributes returns config attributes into key value pairs 26 | func (c Config) GetAttributes() tattr.Attributes { 27 | return c.Attributes 28 | } 29 | 30 | // ReadConfigPath reads and parses file 31 | func ReadConfigPath(path string) (Config, error) { 32 | buf, err := os.ReadFile(path) //nolint: gosec 33 | if err != nil { 34 | return Config{}, err 35 | } 36 | var val Config 37 | if err := yaml.Unmarshal(buf, &val); err != nil { 38 | return Config{}, err 39 | } 40 | 41 | dups := make(map[string]string) 42 | for _, attr := range val.Attributes { 43 | if _, exists := dups[attr.Key]; exists { 44 | return Config{}, fmt.Errorf("%w: %s", ErrDuplicatedAttribute, attr.Key) 45 | } 46 | 47 | dups[attr.Key] = attr.Value 48 | } 49 | 50 | return val, err 51 | } 52 | -------------------------------------------------------------------------------- /x/deployment/simulation/genesis.go: -------------------------------------------------------------------------------- 1 | package simulation 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | "github.com/cosmos/cosmos-sdk/types/module" 6 | "pkg.akt.dev/go/node/deployment/v1" 7 | types "pkg.akt.dev/go/node/deployment/v1beta4" 8 | ) 9 | 10 | var ( 11 | minDeposit, _ = types.DefaultParams().MinDepositFor("uakt") 12 | ) 13 | 14 | // RandomizedGenState generates a random GenesisState for supply 15 | func RandomizedGenState(simState *module.SimulationState) { 16 | // numDeployments := simulation.RandIntBetween(simState.Rand, 0, len(simState.Accounts)) 17 | 18 | deploymentGenesis := &types.GenesisState{ 19 | Params: types.Params{ 20 | MinDeposits: sdk.Coins{ 21 | minDeposit, 22 | }, 23 | }, 24 | // Deployments: make([]types.GenesisDeployment, 0, numDeployments), 25 | } 26 | 27 | // for range cap(deploymentGenesis.Deployments) { 28 | // acc, _ := simtypes.RandomAcc(simState.Rand, simState.Accounts) 29 | // 30 | // t := &testing.T{} 31 | // 32 | // depl := testutil.Deployment(t) 33 | // depl.ID.Owner = acc.Address.String() 34 | // 35 | // dgroups := testutil.DeploymentGroups(t, depl.ID, 1) 36 | // 37 | // deploymentGenesis.Deployments = append(deploymentGenesis.Deployments, types.GenesisDeployment{ 38 | // Deployment: depl, 39 | // Groups: dgroups, 40 | // }) 41 | // } 42 | 43 | simState.GenState[v1.ModuleName] = simState.Cdc.MustMarshalJSON(deploymentGenesis) 44 | } 45 | -------------------------------------------------------------------------------- /x/deployment/testdata/deployment-v2-multi-groups-ip-endpoint.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.0" 3 | 4 | services: 5 | web: 6 | image: ghcr.io/akash-network/demo-app 7 | expose: 8 | - port: 80 9 | to: 10 | - global: true 11 | ip: "meow" 12 | accept: 13 | - test.localhost 14 | anotherweb: 15 | image: ghcr.io/akash-network/demo-app 16 | expose: 17 | - port: 80 18 | to: 19 | - global: true 20 | ip: "kittens" 21 | accept: 22 | - extratest.localhost 23 | 24 | profiles: 25 | compute: 26 | web: 27 | resources: 28 | cpu: 29 | units: "0.01" 30 | memory: 31 | size: "128Mi" 32 | storage: 33 | size: "512Mi" 34 | bob: 35 | resources: 36 | cpu: 37 | units: "0.13" 38 | memory: 39 | size: "256Mi" 40 | storage: 41 | size: "99Mi" 42 | 43 | placement: 44 | global: 45 | pricing: 46 | web: 47 | denom: uakt 48 | amount: 10 49 | bob: 50 | pricing: 51 | bob: 52 | denom: uakt 53 | amount: 99 54 | 55 | deployment: 56 | web: 57 | global: 58 | profile: web 59 | count: 1 60 | anotherweb: 61 | bob: 62 | profile: bob 63 | count: 3 64 | 65 | endpoints: 66 | meow: 67 | kind: "ip" 68 | kittens: 69 | kind: "ip" 70 | -------------------------------------------------------------------------------- /upgrades/software/v1.0.0/cert.go: -------------------------------------------------------------------------------- 1 | // Package v1_0_0 2 | // nolint revive 3 | package v1_0_0 4 | 5 | import ( 6 | "cosmossdk.io/store/prefix" 7 | sdk "github.com/cosmos/cosmos-sdk/types" 8 | sdkmodule "github.com/cosmos/cosmos-sdk/types/module" 9 | "pkg.akt.dev/go/node/migrate" 10 | 11 | utypes "pkg.akt.dev/node/upgrades/types" 12 | ckeeper "pkg.akt.dev/node/x/cert/keeper" 13 | ) 14 | 15 | type certsMigrations struct { 16 | utypes.Migrator 17 | } 18 | 19 | func newCertsMigration(m utypes.Migrator) utypes.Migration { 20 | return certsMigrations{Migrator: m} 21 | } 22 | 23 | func (m certsMigrations) GetHandler() sdkmodule.MigrationHandler { 24 | return m.handler 25 | } 26 | 27 | // handler migrates certificates store from version 2 to 3. 28 | func (m certsMigrations) handler(ctx sdk.Context) (err error) { 29 | cdc := m.Codec() 30 | 31 | store := ctx.KVStore(m.StoreKey()) 32 | oStore := prefix.NewStore(store, migrate.CertV1beta3Prefix()) 33 | 34 | iter := oStore.Iterator(nil, nil) 35 | defer func() { 36 | err = iter.Close() 37 | }() 38 | 39 | for ; iter.Valid(); iter.Next() { 40 | val := migrate.CertFromV1beta3(cdc, iter.Value()) 41 | 42 | id, err := ckeeper.ParseCertID(nil, iter.Key()) 43 | if err != nil { 44 | return err 45 | } 46 | 47 | bz := cdc.MustMarshal(&val) 48 | key := ckeeper.MustCertificateKey(val.State, id) 49 | oStore.Delete(iter.Key()) 50 | store.Set(key, bz) 51 | } 52 | 53 | return nil 54 | } 55 | -------------------------------------------------------------------------------- /x/deployment/testdata/deployment-v2.1-multi-groups-ip-endpoint.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.0" 3 | 4 | services: 5 | web: 6 | image: ghcr.io/akash-network/demo-app 7 | expose: 8 | - port: 80 9 | to: 10 | - global: true 11 | ip: "meow" 12 | accept: 13 | - test.localhost 14 | anotherweb: 15 | image: ghcr.io/akash-network/demo-app 16 | expose: 17 | - port: 80 18 | to: 19 | - global: true 20 | ip: "kittens" 21 | accept: 22 | - extratest.localhost 23 | 24 | profiles: 25 | compute: 26 | web: 27 | resources: 28 | cpu: 29 | units: "0.01" 30 | memory: 31 | size: "128Mi" 32 | storage: 33 | size: "512Mi" 34 | bob: 35 | resources: 36 | cpu: 37 | units: "0.13" 38 | memory: 39 | size: "256Mi" 40 | storage: 41 | size: "99Mi" 42 | 43 | placement: 44 | global: 45 | pricing: 46 | web: 47 | denom: uakt 48 | amount: 10 49 | bob: 50 | pricing: 51 | bob: 52 | denom: uakt 53 | amount: 99 54 | 55 | deployment: 56 | web: 57 | global: 58 | profile: web 59 | count: 1 60 | anotherweb: 61 | bob: 62 | profile: bob 63 | count: 3 64 | 65 | endpoints: 66 | meow: 67 | kind: "ip" 68 | kittens: 69 | kind: "ip" 70 | -------------------------------------------------------------------------------- /x/market/simulation/proposals.go: -------------------------------------------------------------------------------- 1 | package simulation 2 | 3 | import ( 4 | "math/rand" 5 | 6 | sdk "github.com/cosmos/cosmos-sdk/types" 7 | "github.com/cosmos/cosmos-sdk/types/address" 8 | simtypes "github.com/cosmos/cosmos-sdk/types/simulation" 9 | "github.com/cosmos/cosmos-sdk/x/simulation" 10 | 11 | types "pkg.akt.dev/go/node/market/v1beta5" 12 | ) 13 | 14 | // Simulation operation weights constants 15 | const ( 16 | DefaultWeightMsgUpdateParams int = 100 17 | 18 | OpWeightMsgUpdateParams = "op_weight_msg_update_params" //nolint:gosec 19 | ) 20 | 21 | // ProposalMsgs defines the module weighted proposals' contents 22 | func ProposalMsgs() []simtypes.WeightedProposalMsg { 23 | return []simtypes.WeightedProposalMsg{ 24 | simulation.NewWeightedProposalMsg( 25 | OpWeightMsgUpdateParams, 26 | DefaultWeightMsgUpdateParams, 27 | SimulateMsgUpdateParams, 28 | ), 29 | } 30 | } 31 | 32 | func SimulateMsgUpdateParams(r *rand.Rand, _ sdk.Context, _ []simtypes.Account) sdk.Msg { 33 | // use the default gov module account address as authority 34 | var authority sdk.AccAddress = address.Module("gov") 35 | 36 | params := types.DefaultParams() 37 | params.BidMinDeposit = sdk.NewInt64Coin("uakt", int64(simtypes.RandIntBetween(r, 500000, 50000000))) 38 | params.OrderMaxBids = uint32(simtypes.RandIntBetween(r, 20, 500)) // nolint gosec 39 | 40 | return &types.MsgUpdateParams{ 41 | Authority: authority.String(), 42 | Params: params, 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /x/deployment/query/client.go: -------------------------------------------------------------------------------- 1 | package query 2 | 3 | import ( 4 | sdkclient "github.com/cosmos/cosmos-sdk/client" 5 | 6 | types "pkg.akt.dev/go/node/deployment/v1" 7 | ) 8 | 9 | // Client interface 10 | type Client interface { 11 | Deployments(DeploymentFilters) (Deployments, error) 12 | Deployment(types.DeploymentID) (Deployment, error) 13 | Group(types.GroupID) (Group, error) 14 | } 15 | 16 | // NewClient creates a client instance with provided context and key 17 | func NewClient(ctx sdkclient.Context, key string) Client { 18 | return &client{ctx: ctx, key: key} 19 | } 20 | 21 | type client struct { 22 | ctx sdkclient.Context 23 | key string 24 | } 25 | 26 | func (c *client) Deployments(dfilters DeploymentFilters) (Deployments, error) { 27 | var obj Deployments 28 | buf, err := NewRawClient(c.ctx, c.key).Deployments(dfilters) 29 | if err != nil { 30 | return obj, err 31 | } 32 | return obj, c.ctx.LegacyAmino.UnmarshalJSON(buf, &obj) 33 | } 34 | 35 | func (c *client) Deployment(id types.DeploymentID) (Deployment, error) { 36 | var obj Deployment 37 | buf, err := NewRawClient(c.ctx, c.key).Deployment(id) 38 | if err != nil { 39 | return obj, err 40 | } 41 | return obj, c.ctx.LegacyAmino.UnmarshalJSON(buf, &obj) 42 | } 43 | 44 | func (c *client) Group(id types.GroupID) (Group, error) { 45 | var obj Group 46 | buf, err := NewRawClient(c.ctx, c.key).Group(id) 47 | if err != nil { 48 | return obj, err 49 | } 50 | return obj, c.ctx.LegacyAmino.UnmarshalJSON(buf, &obj) 51 | } 52 | -------------------------------------------------------------------------------- /x/deployment/query/rawclient.go: -------------------------------------------------------------------------------- 1 | package query 2 | 3 | import ( 4 | "fmt" 5 | 6 | sdkclient "github.com/cosmos/cosmos-sdk/client" 7 | 8 | types "pkg.akt.dev/go/node/deployment/v1" 9 | ) 10 | 11 | // RawClient interface 12 | type RawClient interface { 13 | Deployments(DeploymentFilters) ([]byte, error) 14 | Deployment(types.DeploymentID) ([]byte, error) 15 | Group(types.GroupID) ([]byte, error) 16 | } 17 | 18 | // NewRawClient creates a raw client instance with provided context and key 19 | func NewRawClient(ctx sdkclient.Context, key string) RawClient { 20 | return &rawclient{ctx: ctx, key: key} 21 | } 22 | 23 | type rawclient struct { 24 | ctx sdkclient.Context 25 | key string 26 | } 27 | 28 | func (c *rawclient) Deployments(dfilters DeploymentFilters) ([]byte, error) { 29 | buf, _, err := c.ctx.QueryWithData(fmt.Sprintf("custom/%s/%s", c.key, getDeploymentsPath(dfilters)), nil) 30 | if err != nil { 31 | return []byte{}, err 32 | } 33 | return buf, nil 34 | } 35 | 36 | func (c *rawclient) Deployment(id types.DeploymentID) ([]byte, error) { 37 | buf, _, err := c.ctx.QueryWithData(fmt.Sprintf("custom/%s/%s", c.key, DeploymentPath(id)), nil) 38 | if err != nil { 39 | return []byte{}, err 40 | } 41 | return buf, nil 42 | } 43 | 44 | func (c *rawclient) Group(id types.GroupID) ([]byte, error) { 45 | buf, _, err := c.ctx.QueryWithData(fmt.Sprintf("custom/%s/%s", c.key, getGroupPath(id)), nil) 46 | if err != nil { 47 | return []byte{}, err 48 | } 49 | return buf, nil 50 | } 51 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 7 | 8 | ## Description 9 | 10 | Closes: #XXXX 11 | 12 | 14 | 15 | --- 16 | 17 | ### Author Checklist 18 | 19 | *All items are required. Please add a note to the item if the item is not applicable and 20 | please add links to any relevant follow-up issues.* 21 | 22 | I have... 23 | 24 | - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title 25 | - [ ] added `!` to the type prefix if API or client breaking change 26 | - [ ] targeted the correct branch (see [PR Targeting](https://github.com/akash-network/node/blob/main/CONTRIBUTING.md#paperwork-for-pull-requests)) 27 | - [ ] provided a link to the relevant issue or specification 28 | - [ ] included the necessary unit and integration [tests](https://github.com/akash-network/blob/main/CONTRIBUTING.md#testing) 29 | - [ ] added a changelog entry to `CHANGELOG.md` 30 | - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) 31 | - [ ] updated the relevant documentation or specification 32 | - [ ] reviewed "Files changed" and left comments if necessary 33 | - [ ] confirmed all CI checks have passed 34 | -------------------------------------------------------------------------------- /x/cert/handler/msg_server.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "context" 5 | 6 | sdk "github.com/cosmos/cosmos-sdk/types" 7 | 8 | types "pkg.akt.dev/go/node/cert/v1" 9 | 10 | "pkg.akt.dev/node/x/cert/keeper" 11 | ) 12 | 13 | type msgServer struct { 14 | keeper keeper.Keeper 15 | } 16 | 17 | var _ types.MsgServer = msgServer{} 18 | 19 | // NewMsgServerImpl returns an implementation of the market MsgServer interface 20 | // for the provided Keeper. 21 | func NewMsgServerImpl(k keeper.Keeper) types.MsgServer { 22 | return &msgServer{keeper: k} 23 | } 24 | 25 | func (m msgServer) CreateCertificate(goCtx context.Context, req *types.MsgCreateCertificate) (*types.MsgCreateCertificateResponse, error) { 26 | ctx := sdk.UnwrapSDKContext(goCtx) 27 | 28 | owner, err := sdk.AccAddressFromBech32(req.Owner) 29 | if err != nil { 30 | return nil, err 31 | } 32 | 33 | err = m.keeper.CreateCertificate(ctx, owner, req.Cert, req.Pubkey) 34 | if err != nil { 35 | return nil, err 36 | } 37 | 38 | return &types.MsgCreateCertificateResponse{}, nil 39 | } 40 | 41 | func (m msgServer) RevokeCertificate(goCtx context.Context, req *types.MsgRevokeCertificate) (*types.MsgRevokeCertificateResponse, error) { 42 | ctx := sdk.UnwrapSDKContext(goCtx) 43 | 44 | id, err := types.ToCertID(req.ID) 45 | if err != nil { 46 | return nil, err 47 | } 48 | 49 | err = m.keeper.RevokeCertificate(ctx, id) 50 | if err != nil { 51 | return nil, err 52 | } 53 | 54 | return &types.MsgRevokeCertificateResponse{}, nil 55 | } 56 | -------------------------------------------------------------------------------- /x/deployment/handler/handler.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/baseapp" 5 | sdk "github.com/cosmos/cosmos-sdk/types" 6 | sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" 7 | 8 | types "pkg.akt.dev/go/node/deployment/v1beta4" 9 | 10 | "pkg.akt.dev/node/x/deployment/keeper" 11 | ) 12 | 13 | // NewHandler returns a handler for "deployment" type messages 14 | func NewHandler(keeper keeper.IKeeper, mkeeper MarketKeeper, ekeeper EscrowKeeper) baseapp.MsgServiceHandler { 15 | ms := NewServer(keeper, mkeeper, ekeeper) 16 | 17 | return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { 18 | switch msg := msg.(type) { 19 | case *types.MsgCreateDeployment: 20 | res, err := ms.CreateDeployment(ctx, msg) 21 | return sdk.WrapServiceResult(ctx, res, err) 22 | case *types.MsgUpdateDeployment: 23 | res, err := ms.UpdateDeployment(ctx, msg) 24 | return sdk.WrapServiceResult(ctx, res, err) 25 | case *types.MsgCloseDeployment: 26 | res, err := ms.CloseDeployment(ctx, msg) 27 | return sdk.WrapServiceResult(ctx, res, err) 28 | case *types.MsgCloseGroup: 29 | res, err := ms.CloseGroup(ctx, msg) 30 | return sdk.WrapServiceResult(ctx, res, err) 31 | case *types.MsgPauseGroup: 32 | res, err := ms.PauseGroup(ctx, msg) 33 | return sdk.WrapServiceResult(ctx, res, err) 34 | case *types.MsgStartGroup: 35 | res, err := ms.StartGroup(ctx, msg) 36 | return sdk.WrapServiceResult(ctx, res, err) 37 | default: 38 | return nil, sdkerrors.ErrUnknownRequest 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/types/app_test.go: -------------------------------------------------------------------------------- 1 | package types //nolint: revive 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | ) 8 | 9 | func TestFindStructFieldEmptyField(t *testing.T) { 10 | type testType struct { 11 | Val string 12 | } 13 | testStruct := testType{} 14 | 15 | _, err := FindStructField[string](testStruct, "") 16 | require.EqualError(t, err, ErrEmptyFieldName.Error()) 17 | } 18 | 19 | func TestFindStructFieldObjectAsValue(t *testing.T) { 20 | type testType struct { 21 | Val string 22 | } 23 | testStruct := testType{} 24 | 25 | val, err := FindStructField[string](testStruct, "Val") 26 | require.NoError(t, err) 27 | require.Equal(t, "", val) 28 | } 29 | 30 | func TestFindStructFieldObjectAsPointer(t *testing.T) { 31 | type testType struct { 32 | Val string 33 | } 34 | testStruct := testType{ 35 | Val: "testVal", 36 | } 37 | 38 | val, err := FindStructField[string](&testStruct, "Val") 39 | require.NoError(t, err) 40 | require.Equal(t, "testVal", val) 41 | } 42 | 43 | func TestFindStructFieldUnknownField(t *testing.T) { 44 | type testType struct { 45 | Val string 46 | } 47 | testStruct := testType{ 48 | Val: "testVal", 49 | } 50 | 51 | _, err := FindStructField[string](&testStruct, "Vals") 52 | require.Error(t, err) 53 | } 54 | 55 | func TestFindStructFieldNonMatchingType(t *testing.T) { 56 | type testType struct { 57 | Val string 58 | } 59 | testStruct := testType{ 60 | Val: "testVal", 61 | } 62 | 63 | _, err := FindStructField[int](&testStruct, "Vals") 64 | require.Error(t, err) 65 | } 66 | -------------------------------------------------------------------------------- /client/utils.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | b64 "encoding/base64" 5 | 6 | "github.com/spf13/pflag" 7 | 8 | errorsmod "cosmossdk.io/errors" 9 | 10 | "github.com/cosmos/cosmos-sdk/client/flags" 11 | sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" 12 | "github.com/cosmos/cosmos-sdk/types/query" 13 | ) 14 | 15 | // ReadPageRequest reads and builds the necessary page request flags for pagination. 16 | func ReadPageRequest(flagSet *pflag.FlagSet) (*query.PageRequest, error) { 17 | pageKeyStr, _ := flagSet.GetString(flags.FlagPageKey) 18 | offset, _ := flagSet.GetUint64(flags.FlagOffset) 19 | limit, _ := flagSet.GetUint64(flags.FlagLimit) 20 | countTotal, _ := flagSet.GetBool(flags.FlagCountTotal) 21 | page, _ := flagSet.GetUint64(flags.FlagPage) 22 | reverse, _ := flagSet.GetBool(flags.FlagReverse) 23 | 24 | if page > 1 && offset > 0 { 25 | return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "page and offset cannot be used together") 26 | } 27 | 28 | // Clear page key if using page numbers (page and key are mutually exclusive) 29 | if page > 1 { 30 | offset = (page - 1) * limit 31 | } 32 | 33 | var pageKey []byte 34 | if pageKeyStr != "" { 35 | var err error 36 | pageKey, err = b64.StdEncoding.DecodeString(pageKeyStr) 37 | if err != nil { 38 | return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "invalid pagination key") 39 | } 40 | } 41 | 42 | return &query.PageRequest{ 43 | Key: pageKey, 44 | Offset: offset, 45 | Limit: limit, 46 | CountTotal: countTotal, 47 | Reverse: reverse, 48 | }, nil 49 | } 50 | -------------------------------------------------------------------------------- /x/provider/client/rest/rest.go: -------------------------------------------------------------------------------- 1 | package rest 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | 7 | "github.com/cosmos/cosmos-sdk/client" 8 | "github.com/gorilla/mux" 9 | ) 10 | 11 | // RegisterRoutes registers all query routes 12 | func RegisterRoutes(ctx client.Context, r *mux.Router, ns string) { 13 | // Get providers list 14 | r.HandleFunc(fmt.Sprintf("/%s/list", ns), listProvidersHandler(ctx, ns)).Methods("GET") 15 | 16 | // Get single provider info 17 | r.HandleFunc(fmt.Sprintf("/%s/info/{providerOwner}", ns), getProviderHandler(ctx, ns)).Methods("GET") 18 | } 19 | 20 | func listProvidersHandler(_ client.Context, _ string) http.HandlerFunc { 21 | return func(_ http.ResponseWriter, _ *http.Request) { 22 | // res, err := query.NewRawClient(ctx, ns).Providers() 23 | // if err != nil { 24 | // rest.WriteErrorResponse(w, http.StatusNotFound, "Not Found") 25 | // return 26 | // } 27 | // rest.PostProcessResponse(w, ctx, res) 28 | } 29 | } 30 | 31 | func getProviderHandler(_ client.Context, _ string) http.HandlerFunc { 32 | return func(_ http.ResponseWriter, _ *http.Request) { 33 | // bech32Addr := mux.Vars(r)["providerOwner"] 34 | // 35 | // id, err := sdk.AccAddressFromBech32(bech32Addr) 36 | // if err != nil { 37 | // rest.WriteErrorResponse(w, http.StatusBadRequest, "Invalid address") 38 | // return 39 | // } 40 | // res, err := query.NewRawClient(ctx, ns).Provider(id) 41 | // if err != nil { 42 | // rest.WriteErrorResponse(w, http.StatusNotFound, "Not Found") 43 | // return 44 | // } 45 | // rest.PostProcessResponse(w, ctx, res) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /.github/labeler.yaml: -------------------------------------------------------------------------------- 1 | "C:x/audit": 2 | - changed-files: 3 | - any-glob-to-any-file: x/audit/**/* 4 | "C:x/cert": 5 | - changed-files: 6 | - any-glob-to-any-file: x/cert/**/* 7 | "C:x/deployment": 8 | - changed-files: 9 | - any-glob-to-any-file: x/deployment/**/* 10 | "C:x/escrow": 11 | - changed-files: 12 | - any-glob-to-any-file: x/escrow/**/* 13 | "C:x/gov": 14 | - changed-files: 15 | - any-glob-to-any-file: x/gov/**/* 16 | "C:x/inflation": 17 | - changed-files: 18 | - any-glob-to-any-file: x/inflation/**/* 19 | "C:x/market": 20 | - changed-files: 21 | - any-glob-to-any-file: x/market/**/* 22 | "C:x/provider": 23 | - changed-files: 24 | - any-glob-to-any-file: x/provider/**/* 25 | "C:x/staking": 26 | - changed-files: 27 | - any-glob-to-any-file: x/staking/**/* 28 | "C:x/take": 29 | - changed-files: 30 | - any-glob-to-any-file: x/take/**/* 31 | "C:CLI": 32 | - changed-files: 33 | - any-glob-to-any-file: cmd/**/* 34 | - changed-files: 35 | - any-glob-to-any-file: x/*/client/cli/* 36 | "C:upgrades": 37 | - changed-files: 38 | - any-glob-to-any-file: upgrades/**/* 39 | "Type: Build": 40 | - changed-files: 41 | - any-glob-to-any-file: Makefile 42 | - changed-files: 43 | - any-glob-to-any-file: Dockerfile 44 | - changed-files: 45 | - any-glob-to-any-file: script/* 46 | - changed-files: 47 | - any-glob-to-any-file: make/* 48 | - changed-files: 49 | - any-glob-to-any-file: .goreleaser* 50 | "Type: CI": 51 | - changed-files: 52 | - any-glob-to-any-file: .github/**/* 53 | -------------------------------------------------------------------------------- /upgrades/software/v1.0.0/audit.go: -------------------------------------------------------------------------------- 1 | // Package v1_0_0 2 | // nolint revive 3 | package v1_0_0 4 | 5 | import ( 6 | "cosmossdk.io/store/prefix" 7 | sdk "github.com/cosmos/cosmos-sdk/types" 8 | sdkmodule "github.com/cosmos/cosmos-sdk/types/module" 9 | types "pkg.akt.dev/go/node/audit/v1" 10 | 11 | "pkg.akt.dev/go/node/migrate" 12 | 13 | utypes "pkg.akt.dev/node/upgrades/types" 14 | akeeper "pkg.akt.dev/node/x/audit/keeper" 15 | ) 16 | 17 | type auditMigrations struct { 18 | utypes.Migrator 19 | } 20 | 21 | func newAuditMigration(m utypes.Migrator) utypes.Migration { 22 | return auditMigrations{Migrator: m} 23 | } 24 | 25 | func (m auditMigrations) GetHandler() sdkmodule.MigrationHandler { 26 | return m.handler 27 | } 28 | 29 | // handler migrates audit store from version 2 to 3. 30 | func (m auditMigrations) handler(ctx sdk.Context) (err error) { 31 | cdc := m.Codec() 32 | 33 | store := ctx.KVStore(m.StoreKey()) 34 | oStore := prefix.NewStore(store, migrate.AuditedAttributesV1beta3Prefix()) 35 | 36 | iter := oStore.Iterator(nil, nil) 37 | defer func() { 38 | err = iter.Close() 39 | }() 40 | 41 | for ; iter.Valid(); iter.Next() { 42 | val := migrate.AuditedProviderFromV1beta3(cdc, iter.Value()) 43 | 44 | owner := sdk.MustAccAddressFromBech32(val.Owner) 45 | auditor := sdk.MustAccAddressFromBech32(val.Auditor) 46 | 47 | key := akeeper.ProviderKey(types.ProviderID{Owner: owner, Auditor: auditor}) 48 | 49 | bz := cdc.MustMarshal(&types.AuditedAttributesStore{Attributes: val.Attributes}) 50 | 51 | oStore.Delete(iter.Key()) 52 | store.Set(key, bz) 53 | } 54 | 55 | return nil 56 | } 57 | -------------------------------------------------------------------------------- /testutil/cosmos/keepers.go: -------------------------------------------------------------------------------- 1 | package keeper 2 | 3 | import ( 4 | "context" 5 | "time" 6 | 7 | sdk "github.com/cosmos/cosmos-sdk/types" 8 | "github.com/cosmos/cosmos-sdk/x/authz" 9 | authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" 10 | ) 11 | 12 | type BankKeeper interface { 13 | SpendableCoins(ctx context.Context, addr sdk.AccAddress) sdk.Coins 14 | SpendableCoin(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin 15 | SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error 16 | SendCoinsFromModuleToModule(ctx context.Context, senderModule, recipientModule string, amt sdk.Coins) error 17 | SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error 18 | } 19 | 20 | type TakeKeeper interface { 21 | SubtractFees(ctx sdk.Context, amt sdk.Coin) (sdk.Coin, sdk.Coin, error) 22 | } 23 | 24 | type AuthzKeeper interface { 25 | DeleteGrant(ctx context.Context, grantee sdk.AccAddress, granter sdk.AccAddress, msgType string) error 26 | GetAuthorization(ctx context.Context, grantee sdk.AccAddress, granter sdk.AccAddress, msgType string) (authz.Authorization, *time.Time) 27 | SaveGrant(ctx context.Context, grantee sdk.AccAddress, granter sdk.AccAddress, authorization authz.Authorization, expiration *time.Time) error 28 | IterateGrants(ctx context.Context, handler func(granterAddr sdk.AccAddress, granteeAddr sdk.AccAddress, grant authz.Grant) bool) 29 | GetGranteeGrantsByMsgType(ctx context.Context, grantee sdk.AccAddress, msgType string, onGrant authzkeeper.OnGrantFn) 30 | } 31 | -------------------------------------------------------------------------------- /x/escrow/keeper/external.go: -------------------------------------------------------------------------------- 1 | package keeper 2 | 3 | import ( 4 | "context" 5 | "time" 6 | 7 | sdk "github.com/cosmos/cosmos-sdk/types" 8 | "github.com/cosmos/cosmos-sdk/x/authz" 9 | authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" 10 | ) 11 | 12 | type BankKeeper interface { 13 | SpendableCoins(ctx context.Context, addr sdk.AccAddress) sdk.Coins 14 | SpendableCoin(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin 15 | SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error 16 | SendCoinsFromModuleToModule(ctx context.Context, senderModule, recipientModule string, amt sdk.Coins) error 17 | SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error 18 | } 19 | 20 | type TakeKeeper interface { 21 | SubtractFees(ctx sdk.Context, amt sdk.Coin) (sdk.Coin, sdk.Coin, error) 22 | } 23 | 24 | type AuthzKeeper interface { 25 | DeleteGrant(ctx context.Context, grantee sdk.AccAddress, granter sdk.AccAddress, msgType string) error 26 | GetAuthorization(ctx context.Context, grantee sdk.AccAddress, granter sdk.AccAddress, msgType string) (authz.Authorization, *time.Time) 27 | SaveGrant(ctx context.Context, grantee sdk.AccAddress, granter sdk.AccAddress, authorization authz.Authorization, expiration *time.Time) error 28 | IterateGrants(ctx context.Context, handler func(granterAddr sdk.AccAddress, granteeAddr sdk.AccAddress, grant authz.Grant) bool) 29 | GetGranteeGrantsByMsgType(ctx context.Context, grantee sdk.AccAddress, msgType string, onGrant authzkeeper.OnGrantFn) 30 | } 31 | -------------------------------------------------------------------------------- /meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "upgrades": { 3 | "v0.24.0": { 4 | "skipped": false, 5 | "from_binary": "v0.22.8", 6 | "from_version": "v0.22.0" 7 | }, 8 | "v0.26.0": { 9 | "skipped": false, 10 | "from_binary": "v0.24.2", 11 | "from_version": "v0.24.0" 12 | }, 13 | "v0.28.0": { 14 | "skipped": false, 15 | "from_binary": "v0.26.2", 16 | "from_version": "v0.26.0" 17 | }, 18 | "v0.30.0": { 19 | "skipped": false, 20 | "from_binary": "v0.28.2", 21 | "from_version": "v0.28.0" 22 | }, 23 | "v0.32.0": { 24 | "skipped": false, 25 | "from_binary": "v0.30.3", 26 | "from_version": "v0.30.0" 27 | }, 28 | "v0.34.0": { 29 | "skipped": false, 30 | "from_binary": "v0.32.3", 31 | "from_version": "v0.32.0" 32 | }, 33 | "v0.36.0": { 34 | "skipped": false, 35 | "from_binary": "v0.34.1", 36 | "from_version": "v0.34.0" 37 | }, 38 | "v0.38.0": { 39 | "skipped": false, 40 | "from_binary": "v0.36.3-rc9", 41 | "from_version": "v0.36.0" 42 | }, 43 | "v1.0.0": { 44 | "skipped": false, 45 | "from_binary": "v0.38.6-rc2", 46 | "from_version": "v0.38.0" 47 | }, 48 | "v1.1.0": { 49 | "skipped": false, 50 | "from_binary": "v1.0.4", 51 | "from_version": "v1.0.0" 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /upgrades/software/v1.0.0/provider.go: -------------------------------------------------------------------------------- 1 | // Package v1_0_0 2 | // nolint revive 3 | package v1_0_0 4 | 5 | import ( 6 | "fmt" 7 | 8 | sdk "github.com/cosmos/cosmos-sdk/types" 9 | "github.com/cosmos/cosmos-sdk/types/address" 10 | sdkmodule "github.com/cosmos/cosmos-sdk/types/module" 11 | "pkg.akt.dev/go/node/migrate" 12 | "pkg.akt.dev/go/sdkutil" 13 | 14 | utypes "pkg.akt.dev/node/upgrades/types" 15 | pkeeper "pkg.akt.dev/node/x/provider/keeper" 16 | ) 17 | 18 | type providerMigrations struct { 19 | utypes.Migrator 20 | } 21 | 22 | func newProviderMigration(m utypes.Migrator) utypes.Migration { 23 | return providerMigrations{Migrator: m} 24 | } 25 | 26 | func (m providerMigrations) GetHandler() sdkmodule.MigrationHandler { 27 | return m.handler 28 | } 29 | 30 | func ProviderKey(id sdk.Address) []byte { 31 | return address.MustLengthPrefix(id.Bytes()) 32 | } 33 | 34 | // handler migrates provider store from version 2 to 3. 35 | func (m providerMigrations) handler(ctx sdk.Context) (err error) { 36 | store := ctx.KVStore(m.StoreKey()) 37 | 38 | iter := store.Iterator(nil, nil) 39 | defer func() { 40 | err = iter.Close() 41 | }() 42 | 43 | cdc := m.Codec() 44 | 45 | var providersTotal uint64 46 | 47 | for ; iter.Valid(); iter.Next() { 48 | to := migrate.ProviderFromV1beta3(cdc, iter.Value()) 49 | 50 | id := sdkutil.MustAccAddressFromBech32(to.Owner) 51 | bz := cdc.MustMarshal(&to) 52 | 53 | providersTotal++ 54 | 55 | store.Delete(iter.Key()) 56 | store.Set(pkeeper.ProviderKey(id), bz) 57 | } 58 | 59 | ctx.Logger().Info(fmt.Sprintf("[upgrade %s]: updated x/provider store keys:"+ 60 | "\n\tproviders total: %d", 61 | UpgradeName, 62 | providersTotal)) 63 | 64 | return nil 65 | } 66 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | 36 | 37 | # Changelog 38 | 39 | ## [Unreleased] 40 | 41 | * (ibc-go) Use ibc v4.4.0 https://pkg.akt.dev/node/pull/1825 42 | 43 | ### Improvements 44 | 45 | * (sdk) Bump Cosmos SDK version to [v0.38.3](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.38.3) 46 | 47 | ### Bug Fixes 48 | 49 | * Fix bug in ditribution and querying rewards 50 | -------------------------------------------------------------------------------- /x/deployment/query/path.go: -------------------------------------------------------------------------------- 1 | package query 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "strconv" 7 | 8 | types "pkg.akt.dev/go/node/deployment/v1" 9 | ) 10 | 11 | const ( 12 | deploymentsPath = "deployments" 13 | deploymentPath = "deployment" 14 | groupPath = "group" 15 | ) 16 | 17 | var ( 18 | ErrInvalidPath = errors.New("query: invalid path") 19 | ) 20 | 21 | // getDeploymentsPath returns deployments path for queries 22 | func getDeploymentsPath(dfilters DeploymentFilters) string { 23 | return fmt.Sprintf("%s/%s/%v", deploymentsPath, dfilters.Owner, dfilters.StateFlagVal) 24 | } 25 | 26 | // DeploymentPath return deployment path of given deployment id for queries 27 | func DeploymentPath(id types.DeploymentID) string { 28 | return fmt.Sprintf("%s/%s", deploymentPath, deploymentParts(id)) 29 | } 30 | 31 | // getGroupPath return group path of given group id for queries 32 | func getGroupPath(id types.GroupID) string { 33 | return fmt.Sprintf("%s/%s/%v/%v", groupPath, id.Owner, id.DSeq, id.GSeq) 34 | } 35 | 36 | // ParseGroupPath returns GroupID details with provided queries, and return 37 | // error if occurred due to wrong query 38 | func ParseGroupPath(parts []string) (types.GroupID, error) { 39 | if len(parts) < 3 { 40 | return types.GroupID{}, ErrInvalidPath 41 | } 42 | 43 | did, err := types.ParseDeploymentPath(parts[0:2]) 44 | if err != nil { 45 | return types.GroupID{}, err 46 | } 47 | 48 | gseq, err := strconv.ParseUint(parts[2], 10, 32) 49 | if err != nil { 50 | return types.GroupID{}, err 51 | } 52 | 53 | return types.MakeGroupID(did, uint32(gseq)), nil 54 | } 55 | 56 | func deploymentParts(id types.DeploymentID) string { 57 | return fmt.Sprintf("%s/%v", id.Owner, id.DSeq) 58 | } 59 | -------------------------------------------------------------------------------- /tests/upgrade/sdktypes.go: -------------------------------------------------------------------------------- 1 | package upgrade 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | upgradetypes "cosmossdk.io/x/upgrade/types" 7 | sdk "github.com/cosmos/cosmos-sdk/types" 8 | ) 9 | 10 | // These files defines sdk specific types necessary to perform upgrade simulation. 11 | // we're not using SDK generated types to prevent import of different types of cosmos sdk 12 | 13 | type nodeStatus struct { 14 | SyncInfo struct { 15 | LatestBlockHeight string `json:"latest_block_height"` 16 | CatchingUp bool `json:"catching_up"` 17 | } `json:"sync_info"` 18 | } 19 | 20 | type votingParams struct { 21 | VotingPeriod string `json:"voting_period"` 22 | } 23 | 24 | type depositParams struct { 25 | MinDeposit sdk.Coins `json:"min_deposit"` 26 | } 27 | 28 | type govParams struct { 29 | VotingParams votingParams `json:"voting_params"` 30 | DepositParams depositParams `json:"deposit_params"` 31 | } 32 | 33 | type proposalResp struct { 34 | ID string `json:"id"` 35 | Title string `json:"title"` 36 | } 37 | 38 | type proposalsResp struct { 39 | Proposals []proposalResp `json:"proposals"` 40 | } 41 | 42 | type SoftwareUpgradeProposal struct { 43 | Type string `json:"@type"` 44 | Authority string `json:"authority"` 45 | Plan upgradetypes.Plan `json:"plan"` 46 | } 47 | 48 | type ProposalMsg struct { 49 | // Msgs defines an array of sdk.Msgs proto-JSON-encoded as Anys. 50 | Messages []json.RawMessage `json:"messages,omitempty"` 51 | Metadata string `json:"metadata"` 52 | Deposit string `json:"deposit"` 53 | Title string `json:"title"` 54 | Summary string `json:"summary"` 55 | Expedited bool `json:"expedited"` 56 | } 57 | -------------------------------------------------------------------------------- /x/audit/query/rawclient.go: -------------------------------------------------------------------------------- 1 | package query 2 | 3 | import ( 4 | "fmt" 5 | 6 | sdkclient "github.com/cosmos/cosmos-sdk/client" 7 | sdk "github.com/cosmos/cosmos-sdk/types" 8 | 9 | types "pkg.akt.dev/go/node/audit/v1" 10 | ) 11 | 12 | // RawClient interface 13 | type RawClient interface { 14 | AllProviders() ([]byte, error) 15 | Provider(sdk.AccAddress) ([]byte, error) 16 | ProviderID(types.ProviderID) ([]byte, error) 17 | Auditor(sdk.AccAddress) ([]byte, error) 18 | } 19 | 20 | // NewRawClient creates a client instance with provided context and key 21 | func NewRawClient(ctx sdkclient.Context, key string) RawClient { 22 | return &rawclient{ctx: ctx, key: key} 23 | } 24 | 25 | type rawclient struct { 26 | ctx sdkclient.Context 27 | key string 28 | } 29 | 30 | func (c *rawclient) AllProviders() ([]byte, error) { 31 | buf, _, err := c.ctx.QueryWithData(fmt.Sprintf("custom/%s/attributes/list", c.key), nil) 32 | if err != nil { 33 | return []byte{}, err 34 | } 35 | return buf, err 36 | } 37 | 38 | func (c *rawclient) Provider(id sdk.AccAddress) ([]byte, error) { 39 | buf, _, err := c.ctx.QueryWithData(fmt.Sprintf("custom/%s/attributes/owner/%s/list", c.key, id), nil) 40 | if err != nil { 41 | return []byte{}, err 42 | } 43 | return buf, err 44 | } 45 | 46 | func (c *rawclient) ProviderID(id types.ProviderID) ([]byte, error) { 47 | buf, _, err := c.ctx.QueryWithData(fmt.Sprintf("custom/%s/attributes/auditor/%s/%s", c.key, id.Auditor, id.Owner), nil) 48 | if err != nil { 49 | return []byte{}, err 50 | } 51 | return buf, err 52 | } 53 | 54 | func (c *rawclient) Auditor(id sdk.AccAddress) ([]byte, error) { 55 | buf, _, err := c.ctx.QueryWithData(fmt.Sprintf("custom/%s/attributes/auditor/%s/list", c.key, id), nil) 56 | if err != nil { 57 | return []byte{}, err 58 | } 59 | return buf, err 60 | } 61 | -------------------------------------------------------------------------------- /x/deployment/handler/keepers.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "context" 5 | "time" 6 | 7 | sdk "github.com/cosmos/cosmos-sdk/types" 8 | "github.com/cosmos/cosmos-sdk/x/authz" 9 | authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" 10 | 11 | types "pkg.akt.dev/go/node/deployment/v1" 12 | "pkg.akt.dev/go/node/deployment/v1beta4" 13 | escrowid "pkg.akt.dev/go/node/escrow/id/v1" 14 | etypes "pkg.akt.dev/go/node/escrow/types/v1" 15 | mtypes "pkg.akt.dev/go/node/market/v1beta5" 16 | ) 17 | 18 | // MarketKeeper Interface includes market methods 19 | type MarketKeeper interface { 20 | CreateOrder(ctx sdk.Context, id types.GroupID, spec v1beta4.GroupSpec) (mtypes.Order, error) 21 | OnGroupClosed(ctx sdk.Context, id types.GroupID) error 22 | } 23 | 24 | type EscrowKeeper interface { 25 | AccountCreate(ctx sdk.Context, id escrowid.Account, owner sdk.AccAddress, deposits []etypes.Depositor) error 26 | AccountDeposit(ctx sdk.Context, id escrowid.Account, deposits []etypes.Depositor) error 27 | AccountClose(ctx sdk.Context, id escrowid.Account) error 28 | AuthorizeDeposits(sctx sdk.Context, msg sdk.Msg) ([]etypes.Depositor, error) 29 | } 30 | 31 | type AuthzKeeper interface { 32 | DeleteGrant(ctx context.Context, grantee sdk.AccAddress, granter sdk.AccAddress, msgType string) error 33 | GetAuthorization(ctx context.Context, grantee sdk.AccAddress, granter sdk.AccAddress, msgType string) (authz.Authorization, *time.Time) 34 | SaveGrant(ctx context.Context, grantee sdk.AccAddress, granter sdk.AccAddress, authorization authz.Authorization, expiration *time.Time) error 35 | GetGranteeGrantsByMsgType(ctx context.Context, grantee sdk.AccAddress, msgType string, onGrant authzkeeper.OnGrantFn) 36 | } 37 | 38 | type BankKeeper interface { 39 | SpendableCoin(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin 40 | } 41 | -------------------------------------------------------------------------------- /app/upgrades.go: -------------------------------------------------------------------------------- 1 | package app 2 | 3 | import ( 4 | "fmt" 5 | 6 | upgradetypes "cosmossdk.io/x/upgrade/types" 7 | 8 | utypes "pkg.akt.dev/node/upgrades/types" 9 | // nolint: revive 10 | _ "pkg.akt.dev/node/upgrades" 11 | ) 12 | 13 | func (app *AkashApp) registerUpgradeHandlers() error { 14 | upgradeInfo, err := app.Keepers.Cosmos.Upgrade.ReadUpgradeInfoFromDisk() 15 | if err != nil { 16 | return err 17 | } 18 | 19 | if app.Keepers.Cosmos.Upgrade.IsSkipHeight(upgradeInfo.Height) { 20 | return nil 21 | } 22 | 23 | currentHeight := app.CommitMultiStore().LastCommitID().Version 24 | 25 | if upgradeInfo.Height == currentHeight+1 { 26 | app.customPreUpgradeHandler(upgradeInfo) 27 | } 28 | 29 | for name, fn := range utypes.GetUpgradesList() { 30 | upgrade, err := fn(app.Logger(), app.App) 31 | if err != nil { 32 | return fmt.Errorf("unable to unitialize upgrade `%s`: %w", name, err) 33 | } 34 | 35 | app.Keepers.Cosmos.Upgrade.SetUpgradeHandler(name, upgrade.UpgradeHandler()) 36 | 37 | if upgradeInfo.Name == name { 38 | app.Logger().Info(fmt.Sprintf("configuring upgrade `%s`", name)) 39 | if storeUpgrades := upgrade.StoreLoader(); storeUpgrades != nil && upgradeInfo.Name == name { 40 | app.Logger().Info(fmt.Sprintf("setting up store upgrades for `%s`", name)) 41 | app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, storeUpgrades)) 42 | } 43 | } 44 | } 45 | 46 | utypes.IterateMigrations(func(module string, version uint64, initfn utypes.NewMigrationFn) { 47 | migrator := initfn(utypes.NewMigrator(app.cdc, app.GetKey(module))) 48 | if err := app.Configurator.RegisterMigration(module, version, migrator.GetHandler()); err != nil { 49 | panic(err) 50 | } 51 | }) 52 | 53 | return nil 54 | } 55 | 56 | func (app *AkashApp) customPreUpgradeHandler(_ upgradetypes.Plan) { 57 | } 58 | -------------------------------------------------------------------------------- /cmd/akash/cmd/testnetify/utils.go: -------------------------------------------------------------------------------- 1 | package testnetify 2 | 3 | import ( 4 | "context" 5 | "io" 6 | "os" 7 | "path/filepath" 8 | 9 | dbm "github.com/cosmos/cosmos-db" 10 | sdksrv "github.com/cosmos/cosmos-sdk/server" 11 | "golang.org/x/sync/errgroup" 12 | cflags "pkg.akt.dev/go/cli/flags" 13 | 14 | "pkg.akt.dev/node/util/server" 15 | ) 16 | 17 | func openDB(rootDir string, backendType dbm.BackendType) (dbm.DB, error) { 18 | dataDir := filepath.Join(rootDir, "data") 19 | return dbm.NewDB("application", backendType, dataDir) 20 | } 21 | 22 | func setupTraceWriter(svrCtx *sdksrv.Context) (traceWriter io.WriteCloser, cleanup func(), err error) { 23 | // clean up the traceWriter when the server is shutting down 24 | cleanup = func() {} 25 | 26 | traceWriterFile := svrCtx.Viper.GetString(cflags.FlagTraceStore) 27 | traceWriter, err = openTraceWriter(traceWriterFile) 28 | if err != nil { 29 | return traceWriter, cleanup, err 30 | } 31 | 32 | // if flagTraceStore is not used, then traceWriter is nil 33 | if traceWriter != nil { 34 | cleanup = func() { 35 | if err = traceWriter.Close(); err != nil { 36 | svrCtx.Logger.Error("failed to close trace writer", "err", err) 37 | } 38 | } 39 | } 40 | 41 | return traceWriter, cleanup, nil 42 | } 43 | 44 | func openTraceWriter(traceWriterFile string) (w io.WriteCloser, err error) { 45 | if traceWriterFile == "" { 46 | return 47 | } 48 | return os.OpenFile( //nolint: gosec 49 | traceWriterFile, 50 | os.O_WRONLY|os.O_APPEND|os.O_CREATE, 51 | 0o666, 52 | ) 53 | } 54 | 55 | func getCtx(sctx *sdksrv.Context, block bool) (*errgroup.Group, context.Context) { 56 | ctx, cancelFn := context.WithCancel(context.Background()) 57 | g, ctx := errgroup.WithContext(ctx) 58 | // listen for quit signals so the calling parent process can gracefully exit 59 | server.ListenForQuitSignals(ctx, cancelFn, g, block, sctx.Logger) 60 | 61 | return g, ctx 62 | } 63 | -------------------------------------------------------------------------------- /x/audit/keeper/key.go: -------------------------------------------------------------------------------- 1 | package keeper 2 | 3 | import ( 4 | "bytes" 5 | "encoding/hex" 6 | "fmt" 7 | 8 | sdk "github.com/cosmos/cosmos-sdk/types" 9 | "github.com/cosmos/cosmos-sdk/types/address" 10 | 11 | types "pkg.akt.dev/go/node/audit/v1" 12 | 13 | "pkg.akt.dev/node/util/validation" 14 | ) 15 | 16 | func ProviderKey(id types.ProviderID) []byte { 17 | buf := bytes.NewBuffer(types.PrefixProviderID()) 18 | if _, err := buf.Write(address.MustLengthPrefix(id.Owner.Bytes())); err != nil { 19 | panic(err) 20 | } 21 | 22 | if _, err := buf.Write(address.MustLengthPrefix(id.Auditor.Bytes())); err != nil { 23 | panic(err) 24 | } 25 | 26 | return buf.Bytes() 27 | } 28 | 29 | func ProviderPrefix(id sdk.Address) []byte { 30 | buf := bytes.NewBuffer(types.PrefixProviderID()) 31 | if _, err := buf.Write(address.MustLengthPrefix(id.Bytes())); err != nil { 32 | panic(err) 33 | } 34 | 35 | return buf.Bytes() 36 | } 37 | 38 | func ParseIDFromKey(key []byte) types.ProviderID { 39 | // skip prefix if set 40 | 41 | validation.AssertKeyAtLeastLength(key, len(types.PrefixProviderID())+1) 42 | if !bytes.HasPrefix(key, types.PrefixProviderID()) { 43 | panic(fmt.Sprintf("invalid key prefix. expected 0x%s, actual 0x%s", hex.EncodeToString(key[:1]), types.PrefixProviderID())) 44 | } 45 | 46 | // remove a prefix key 47 | key = key[len(types.PrefixProviderID()):] 48 | 49 | dataLen := int(key[0]) 50 | key = key[1:] 51 | validation.AssertKeyAtLeastLength(key, dataLen) 52 | 53 | owner := make([]byte, dataLen) 54 | copy(owner, key[:dataLen]) 55 | key = key[dataLen:] 56 | validation.AssertKeyAtLeastLength(key, 1) 57 | 58 | dataLen = int(key[0]) 59 | key = key[1:] 60 | validation.AssertKeyLength(key, dataLen) 61 | auditor := make([]byte, dataLen) 62 | copy(auditor, key[:dataLen]) 63 | 64 | return types.ProviderID{ 65 | Owner: sdk.AccAddress(owner), 66 | Auditor: sdk.AccAddress(auditor), 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /script/genchangelog.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # generated changelog depends on the tag type 4 | # only SEMVER tags are accounted 5 | # there are two type of tag distinguished by minor part of the semver: 6 | # - even number: mainnet 7 | # - odd number: testnet 8 | # net detection is done in section s1 9 | 10 | # there are two type release notes generated 11 | # - prerelease: changelog between current and nearest lower prerelease (or previous release) 12 | # for example current tag v0.1.1-rc.10 and previous was v0.1.1-rc.9, so changelog is generated between 13 | # - release: changelog between current and previous release tags 14 | # mainnet status is taken care as well. if current tag is edgenet (e.g. v0.1.1-rc.10) it 15 | # will be generated to edgenet changes only 16 | 17 | PATH=$PATH:$(pwd)/.cache/bin 18 | export PATH=$PATH 19 | 20 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" 21 | 22 | if [[ $# -ne 2 ]]; then 23 | echo "illegal number of parameters" 24 | exit 1 25 | fi 26 | 27 | to_tag=$1 28 | 29 | # s1 30 | # shellcheck disable=SC1073 31 | if ! "${SCRIPT_DIR}"/mainnet-from-tag.sh "$to_tag" ; then 32 | version_rel="^[v|V]?(0|[1-9][0-9]*)\\.(\\d*[13579])\\.(0|[1-9][0-9]*)$" 33 | version_prerel="^[v|V]?(0|[1-9][0-9]*)\\.(\\d*[13579])\\.(0|[1-9][0-9]*)(\\-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$" 34 | else 35 | version_rel="^[v|V]?(0|[1-9][0-9]*)\.(\d*[02468])\.(0|[1-9][0-9]*)$" 36 | version_prerel="^[v|V]?(0|[1-9][0-9]*)\.(\d*[02468])\.(0|[1-9][0-9]*)(\-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$" 37 | fi 38 | 39 | # s2 40 | if [[ -z $("${SCRIPT_DIR}"/semver.sh get prerel "$to_tag") ]]; then 41 | tag_regexp=$version_rel 42 | else 43 | tag_regexp=$version_prerel 44 | fi 45 | 46 | query_string="$to_tag" 47 | git-chglog --config .chglog/config.yaml --tag-filter-pattern="$tag_regexp" --output "$2" "$query_string" 48 | -------------------------------------------------------------------------------- /x/cert/utils/utils.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "context" 5 | "crypto/tls" 6 | "fmt" 7 | "io" 8 | "time" 9 | 10 | certerrors "pkg.akt.dev/node/x/cert/errors" 11 | 12 | "github.com/cosmos/cosmos-sdk/client" 13 | 14 | ctypes "pkg.akt.dev/go/node/cert/v1" 15 | ) 16 | 17 | // LoadAndQueryCertificateForAccount wraps LoadAndQueryPEMForAccount and tls.X509KeyPair 18 | func LoadAndQueryCertificateForAccount(ctx context.Context, cctx client.Context, fin io.Reader) (tls.Certificate, error) { 19 | kpm, err := NewKeyPairManager(cctx, cctx.FromAddress) 20 | if err != nil { 21 | return tls.Certificate{}, err 22 | } 23 | 24 | x509cert, tlsCert, err := kpm.ReadX509KeyPair(fin) 25 | if err != nil { 26 | return tls.Certificate{}, err 27 | } 28 | 29 | // Check if valid according to time 30 | if x509cert.NotBefore.After(time.Now().UTC()) { 31 | return tls.Certificate{}, fmt.Errorf("%w: certificate is not yet active, start ts %s", certerrors.ErrCertificate, x509cert.NotBefore) 32 | } 33 | 34 | if time.Now().UTC().After(x509cert.NotAfter) { 35 | return tls.Certificate{}, fmt.Errorf("%w: certificate has been expired since %s", certerrors.ErrCertificate, x509cert.NotAfter) 36 | } 37 | 38 | params := &ctypes.QueryCertificatesRequest{ 39 | Filter: ctypes.CertificateFilter{ 40 | Owner: x509cert.Subject.CommonName, 41 | Serial: x509cert.SerialNumber.String(), 42 | }, 43 | } 44 | 45 | certs, err := ctypes.NewQueryClient(cctx).Certificates(ctx, params) 46 | if err != nil { 47 | return tls.Certificate{}, err 48 | } 49 | 50 | if len(certs.Certificates) == 0 { 51 | return tls.Certificate{}, fmt.Errorf("%w: certificate has not been committed to blockchain", certerrors.ErrCertificate) 52 | } 53 | 54 | foundCert := certs.Certificates[0] 55 | if foundCert.GetCertificate().State != ctypes.CertificateValid { 56 | return tls.Certificate{}, fmt.Errorf("%w: certificate is not valid", certerrors.ErrCertificate) 57 | } 58 | 59 | return tlsCert, nil 60 | } 61 | -------------------------------------------------------------------------------- /x/provider/keeper/grpc_query.go: -------------------------------------------------------------------------------- 1 | package keeper 2 | 3 | import ( 4 | "context" 5 | 6 | "google.golang.org/grpc/codes" 7 | "google.golang.org/grpc/status" 8 | 9 | sdk "github.com/cosmos/cosmos-sdk/types" 10 | sdkquery "github.com/cosmos/cosmos-sdk/types/query" 11 | 12 | types "pkg.akt.dev/go/node/provider/v1beta4" 13 | ) 14 | 15 | // Querier is used as Keeper will have duplicate methods if used directly, and gRPC names take precedence over keeper 16 | type Querier struct { 17 | Keeper 18 | } 19 | 20 | var _ types.QueryServer = Querier{} 21 | 22 | // Providers returns providers list 23 | func (k Querier) Providers(c context.Context, req *types.QueryProvidersRequest) (*types.QueryProvidersResponse, error) { 24 | if req == nil { 25 | return nil, status.Error(codes.InvalidArgument, "empty request") 26 | } 27 | 28 | var providers types.Providers 29 | ctx := sdk.UnwrapSDKContext(c) 30 | 31 | store := ctx.KVStore(k.skey) 32 | 33 | pageRes, err := sdkquery.Paginate(store, req.Pagination, func(_ []byte, value []byte) error { 34 | var provider types.Provider 35 | 36 | err := k.cdc.Unmarshal(value, &provider) 37 | if err != nil { 38 | return err 39 | } 40 | 41 | providers = append(providers, provider) 42 | return nil 43 | }) 44 | if err != nil { 45 | return nil, status.Error(codes.Internal, err.Error()) 46 | } 47 | 48 | return &types.QueryProvidersResponse{ 49 | Providers: providers, 50 | Pagination: pageRes, 51 | }, nil 52 | } 53 | 54 | // Provider returns provider details based on owner address 55 | func (k Querier) Provider(c context.Context, req *types.QueryProviderRequest) (*types.QueryProviderResponse, error) { 56 | if req == nil { 57 | return nil, status.Error(codes.InvalidArgument, "empty request") 58 | } 59 | 60 | owner, err := sdk.AccAddressFromBech32(req.Owner) 61 | if err != nil { 62 | return nil, types.ErrInvalidAddress 63 | } 64 | 65 | ctx := sdk.UnwrapSDKContext(c) 66 | 67 | provider, found := k.Get(ctx, owner) 68 | if !found { 69 | return nil, types.ErrProviderNotFound 70 | } 71 | 72 | return &types.QueryProviderResponse{Provider: provider}, nil 73 | } 74 | -------------------------------------------------------------------------------- /testutil/types.go: -------------------------------------------------------------------------------- 1 | package testutil 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "cosmossdk.io/log" 8 | pruningtypes "cosmossdk.io/store/pruning/types" 9 | dbm "github.com/cosmos/cosmos-db" 10 | bam "github.com/cosmos/cosmos-sdk/baseapp" 11 | servertypes "github.com/cosmos/cosmos-sdk/server/types" 12 | simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" 13 | 14 | cflags "pkg.akt.dev/go/cli/flags" 15 | "pkg.akt.dev/go/sdkutil" 16 | 17 | "pkg.akt.dev/node/app" 18 | "pkg.akt.dev/node/testutil/network" 19 | ) 20 | 21 | // NewTestNetworkFixture returns a new simapp AppConstructor for network simulation tests 22 | func NewTestNetworkFixture(opts ...network.TestnetFixtureOption) network.TestFixture { 23 | dir, err := os.MkdirTemp("", "simapp") 24 | if err != nil { 25 | panic(fmt.Sprintf("failed creating temporary directory: %v", err)) 26 | } 27 | defer func() { 28 | _ = os.RemoveAll(dir) 29 | }() 30 | 31 | cfgOpts := &network.TestnetFixtureOptions{} 32 | 33 | for _, opt := range opts { 34 | opt(cfgOpts) 35 | } 36 | 37 | if cfgOpts.EncCfg.InterfaceRegistry == nil { 38 | cfgOpts.EncCfg = sdkutil.MakeEncodingConfig() 39 | app.ModuleBasics().RegisterInterfaces(cfgOpts.EncCfg.InterfaceRegistry) 40 | } 41 | 42 | tapp := app.NewApp( 43 | log.NewNopLogger(), 44 | dbm.NewMemDB(), 45 | nil, 46 | true, 47 | 0, 48 | make(map[int64]bool), 49 | cfgOpts.EncCfg, 50 | simtestutil.NewAppOptionsWithFlagHome(dir), 51 | ) 52 | 53 | appCtr := func(val network.ValidatorI) servertypes.Application { 54 | return app.NewApp( 55 | val.GetCtx().Logger, 56 | dbm.NewMemDB(), 57 | nil, 58 | true, 59 | 0, 60 | make(map[int64]bool), 61 | cfgOpts.EncCfg, 62 | simtestutil.NewAppOptionsWithFlagHome(val.GetCtx().Config.RootDir), 63 | bam.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)), 64 | bam.SetMinGasPrices(val.GetAppConfig().MinGasPrices), 65 | bam.SetChainID(val.GetCtx().Viper.GetString(cflags.FlagChainID)), 66 | ) 67 | } 68 | 69 | return network.TestFixture{ 70 | AppConstructor: appCtr, 71 | GenesisState: app.NewDefaultGenesisState(tapp.AppCodec()), 72 | EncodingConfig: cfgOpts.EncCfg, 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /x/deployment/query/types.go: -------------------------------------------------------------------------------- 1 | package query 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | 7 | sdk "github.com/cosmos/cosmos-sdk/types" 8 | 9 | "pkg.akt.dev/go/node/deployment/v1" 10 | "pkg.akt.dev/go/node/deployment/v1beta4" 11 | ) 12 | 13 | // DeploymentFilters defines flags for deployment list filter 14 | type DeploymentFilters struct { 15 | Owner sdk.AccAddress 16 | // State flag value given 17 | StateFlagVal string 18 | // Actual state value decoded from DeploymentStateMap 19 | State v1.Deployment_State 20 | } 21 | 22 | // Accept returns whether deployment filters valid or not 23 | func (filters DeploymentFilters) Accept(obj v1.Deployment, isValidState bool) bool { 24 | if (filters.Owner.Empty() && !isValidState) || 25 | (filters.Owner.Empty() && (obj.State == filters.State)) || 26 | (!isValidState && (obj.ID.Owner == filters.Owner.String())) || 27 | (obj.ID.Owner == filters.Owner.String() && obj.State == filters.State) { 28 | return true 29 | } 30 | 31 | return false 32 | } 33 | 34 | // Deployment stores deployment and groups details 35 | type Deployment struct { 36 | v1.Deployment `json:"deployment"` 37 | Groups v1beta4.Groups `json:"groups"` 38 | } 39 | 40 | func (d Deployment) String() string { 41 | return fmt.Sprintf(`Deployment 42 | Owner: %s 43 | DSeq: %d 44 | State: %v 45 | Version: %s 46 | Num Groups: %d 47 | `, d.ID.Owner, d.ID.DSeq, d.State, d.Hash, len(d.Groups)) 48 | } 49 | 50 | // Deployments represents slice of deployment struct 51 | type Deployments []Deployment 52 | 53 | func (ds Deployments) String() string { 54 | var buf bytes.Buffer 55 | 56 | const sep = "\n\n" 57 | 58 | for _, d := range ds { 59 | buf.WriteString(d.String()) 60 | buf.WriteString(sep) 61 | } 62 | 63 | if len(ds) > 0 { 64 | buf.Truncate(buf.Len() - len(sep)) 65 | } 66 | 67 | return buf.String() 68 | } 69 | 70 | // Group stores group ID, state and other specifications 71 | type Group v1beta4.Group 72 | 73 | // GroupFilters defines flags for group list filter 74 | type GroupFilters struct { 75 | Owner sdk.AccAddress 76 | // State flag value given 77 | StateFlagVal string 78 | // Actual state value decoded from GroupStateMap 79 | State v1beta4.Group_State 80 | } 81 | -------------------------------------------------------------------------------- /x/audit/handler/msg_server.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "context" 5 | 6 | sdk "github.com/cosmos/cosmos-sdk/types" 7 | 8 | types "pkg.akt.dev/go/node/audit/v1" 9 | 10 | "pkg.akt.dev/node/x/audit/keeper" 11 | ) 12 | 13 | type msgServer struct { 14 | keeper keeper.Keeper 15 | } 16 | 17 | // NewMsgServerImpl returns an implementation of the market MsgServer interface 18 | // for the provided Keeper. 19 | func NewMsgServerImpl(k keeper.Keeper) types.MsgServer { 20 | return &msgServer{keeper: k} 21 | } 22 | 23 | var _ types.MsgServer = msgServer{} 24 | 25 | // SignProviderAttributes defines a method that signs provider attributes 26 | func (ms msgServer) SignProviderAttributes(goCtx context.Context, msg *types.MsgSignProviderAttributes) (*types.MsgSignProviderAttributesResponse, error) { 27 | ctx := sdk.UnwrapSDKContext(goCtx) 28 | 29 | auditor, err := sdk.AccAddressFromBech32(msg.Auditor) 30 | if err != nil { 31 | return nil, err 32 | } 33 | 34 | var owner sdk.AccAddress 35 | if owner, err = sdk.AccAddressFromBech32(msg.Owner); err != nil { 36 | return nil, err 37 | } 38 | 39 | provID := types.ProviderID{ 40 | Owner: owner, 41 | Auditor: auditor, 42 | } 43 | 44 | if err = ms.keeper.CreateOrUpdateProviderAttributes(ctx, provID, msg.Attributes); err != nil { 45 | return nil, err 46 | } 47 | 48 | return &types.MsgSignProviderAttributesResponse{}, nil 49 | } 50 | 51 | // DeleteProviderAttributes defines a method that deletes provider attributes 52 | func (ms msgServer) DeleteProviderAttributes(goCtx context.Context, msg *types.MsgDeleteProviderAttributes) (*types.MsgDeleteProviderAttributesResponse, error) { 53 | ctx := sdk.UnwrapSDKContext(goCtx) 54 | 55 | auditor, err := sdk.AccAddressFromBech32(msg.Auditor) 56 | if err != nil { 57 | return nil, err 58 | } 59 | 60 | var owner sdk.AccAddress 61 | if owner, err = sdk.AccAddressFromBech32(msg.Owner); err != nil { 62 | return nil, err 63 | } 64 | 65 | provID := types.ProviderID{ 66 | Owner: owner, 67 | Auditor: auditor, 68 | } 69 | 70 | if err = ms.keeper.DeleteProviderAttributes(ctx, provID, msg.Keys); err != nil { 71 | return nil, err 72 | } 73 | 74 | return &types.MsgDeleteProviderAttributesResponse{}, nil 75 | } 76 | -------------------------------------------------------------------------------- /x/market/query/rawclient.go: -------------------------------------------------------------------------------- 1 | package query 2 | 3 | import ( 4 | "fmt" 5 | 6 | sdkclient "github.com/cosmos/cosmos-sdk/client" 7 | v1 "pkg.akt.dev/go/node/market/v1" 8 | ) 9 | 10 | // RawClient interface 11 | type RawClient interface { 12 | Orders(filters OrderFilters) ([]byte, error) 13 | Order(id v1.OrderID) ([]byte, error) 14 | Bids(filters BidFilters) ([]byte, error) 15 | Bid(id v1.BidID) ([]byte, error) 16 | Leases(filters LeaseFilters) ([]byte, error) 17 | Lease(id v1.LeaseID) ([]byte, error) 18 | } 19 | 20 | // NewRawClient creates a raw client instance with provided context and key 21 | func NewRawClient(ctx sdkclient.Context, key string) RawClient { 22 | return &rawclient{ctx: ctx, key: key} 23 | } 24 | 25 | type rawclient struct { 26 | ctx sdkclient.Context 27 | key string 28 | } 29 | 30 | func (c *rawclient) Orders(ofilters OrderFilters) ([]byte, error) { 31 | buf, _, err := c.ctx.QueryWithData(fmt.Sprintf("custom/%s/%s", c.key, getOrdersPath(ofilters)), nil) 32 | if err != nil { 33 | return []byte{}, err 34 | } 35 | return buf, nil 36 | } 37 | 38 | func (c *rawclient) Order(id v1.OrderID) ([]byte, error) { 39 | buf, _, err := c.ctx.QueryWithData(fmt.Sprintf("custom/%s/%s", c.key, OrderPath(id)), nil) 40 | if err != nil { 41 | return []byte{}, err 42 | } 43 | return buf, nil 44 | } 45 | 46 | func (c *rawclient) Bids(bfilters BidFilters) ([]byte, error) { 47 | buf, _, err := c.ctx.QueryWithData(fmt.Sprintf("custom/%s/%s", c.key, getBidsPath(bfilters)), nil) 48 | if err != nil { 49 | return []byte{}, err 50 | } 51 | return buf, nil 52 | } 53 | 54 | func (c *rawclient) Bid(id v1.BidID) ([]byte, error) { 55 | buf, _, err := c.ctx.QueryWithData(fmt.Sprintf("custom/%s/%s", c.key, getBidPath(id)), nil) 56 | if err != nil { 57 | return []byte{}, err 58 | } 59 | return buf, nil 60 | } 61 | 62 | func (c *rawclient) Leases(lfilters LeaseFilters) ([]byte, error) { 63 | buf, _, err := c.ctx.QueryWithData(fmt.Sprintf("custom/%s/%s", c.key, getLeasesPath(lfilters)), nil) 64 | if err != nil { 65 | return []byte{}, err 66 | } 67 | return buf, nil 68 | } 69 | 70 | func (c *rawclient) Lease(id v1.LeaseID) ([]byte, error) { 71 | buf, _, err := c.ctx.QueryWithData(fmt.Sprintf("custom/%s/%s", c.key, LeasePath(id)), nil) 72 | if err != nil { 73 | return []byte{}, err 74 | } 75 | return buf, nil 76 | } 77 | -------------------------------------------------------------------------------- /make/setup-cache.mk: -------------------------------------------------------------------------------- 1 | $(AKASH_DEVCACHE): 2 | @echo "creating .cache dir structure..." 3 | mkdir -p $@ 4 | mkdir -p $(AKASH_DEVCACHE_BIN) 5 | mkdir -p $(AKASH_DEVCACHE_INCLUDE) 6 | mkdir -p $(AKASH_DEVCACHE_VERSIONS) 7 | mkdir -p $(AKASH_DEVCACHE_NODE_MODULES) 8 | mkdir -p $(AKASH_RUN_BIN) 9 | cache: $(AKASH_DEVCACHE) 10 | 11 | $(GIT_CHGLOG_VERSION_FILE): $(AKASH_DEVCACHE) 12 | @echo "installing git-chglog $(GIT_CHGLOG_VERSION) ..." 13 | rm -f $(GIT_CHGLOG) 14 | GOBIN=$(AKASH_DEVCACHE_BIN) go install github.com/git-chglog/git-chglog/cmd/git-chglog@$(GIT_CHGLOG_VERSION) 15 | rm -rf "$(dir $@)" 16 | mkdir -p "$(dir $@)" 17 | touch $@ 18 | $(GIT_CHGLOG): $(GIT_CHGLOG_VERSION_FILE) 19 | 20 | MOCKERY_MAJOR=$(shell $(SEMVER) get major $(MOCKERY_VERSION)) 21 | $(MOCKERY_VERSION_FILE): $(AKASH_DEVCACHE) 22 | @echo "installing mockery $(MOCKERY_VERSION) ..." 23 | rm -f $(MOCKERY) 24 | GOBIN=$(AKASH_DEVCACHE_BIN) go install -ldflags '-s -w -X github.com/vektra/mockery/v$(MOCKERY_MAJOR)/pkg/config.SemVer=$(MOCKERY_VERSION)' github.com/vektra/mockery/v$(MOCKERY_MAJOR)@v$(MOCKERY_VERSION) 25 | rm -rf "$(dir $@)" 26 | mkdir -p "$(dir $@)" 27 | touch $@ 28 | $(MOCKERY): $(MOCKERY_VERSION_FILE) 29 | 30 | GOLANGCI_LINT_MAJOR=$(shell $(SEMVER) get major $(GOLANGCI_LINT_VERSION)) 31 | $(GOLANGCI_LINT_VERSION_FILE): $(AKASH_DEVCACHE) 32 | @echo "installing golangci-lint $(GOLANGCI_LINT_VERSION) ..." 33 | rm -f $(GOLANGCI_LINT) 34 | GOBIN=$(AKASH_DEVCACHE_BIN) go install github.com/golangci/golangci-lint/v$(GOLANGCI_LINT_MAJOR)/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) 35 | rm -rf "$(dir $@)" 36 | mkdir -p "$(dir $@)" 37 | touch $@ 38 | $(GOLANGCI_LINT): $(GOLANGCI_LINT_VERSION_FILE) 39 | 40 | $(STATIK_VERSION_FILE): $(AKASH_DEVCACHE) 41 | @echo "Installing statik $(STATIK_VERSION) ..." 42 | rm -f $(STATIK) 43 | GOBIN=$(AKASH_DEVCACHE_BIN) $(GO) install github.com/rakyll/statik@$(STATIK_VERSION) 44 | rm -rf "$(dir $@)" 45 | mkdir -p "$(dir $@)" 46 | touch $@ 47 | $(STATIK): $(STATIK_VERSION_FILE) 48 | 49 | $(COSMOVISOR_VERSION_FILE): $(AKASH_DEVCACHE) 50 | @echo "installing cosmovisor $(COSMOVISOR_VERSION) ..." 51 | rm -f $(COSMOVISOR) 52 | GOBIN=$(AKASH_DEVCACHE_BIN) $(GO) install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@$(COSMOVISOR_VERSION) 53 | rm -rf "$(dir $@)" 54 | mkdir -p "$(dir $@)" 55 | touch $@ 56 | $(COSMOVISOR): $(COSMOVISOR_VERSION_FILE) 57 | 58 | cache-clean: 59 | rm -rf $(AKASH_DEVCACHE) 60 | -------------------------------------------------------------------------------- /app/config.go: -------------------------------------------------------------------------------- 1 | package app 2 | 3 | import ( 4 | "cosmossdk.io/x/evidence" 5 | feegrantmodule "cosmossdk.io/x/feegrant/module" 6 | "cosmossdk.io/x/upgrade" 7 | "github.com/cosmos/cosmos-sdk/types/module" 8 | "github.com/cosmos/cosmos-sdk/x/auth" 9 | "github.com/cosmos/cosmos-sdk/x/auth/vesting" 10 | authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module" 11 | "github.com/cosmos/cosmos-sdk/x/bank" 12 | "github.com/cosmos/cosmos-sdk/x/consensus" 13 | "github.com/cosmos/cosmos-sdk/x/crisis" 14 | distr "github.com/cosmos/cosmos-sdk/x/distribution" 15 | "github.com/cosmos/cosmos-sdk/x/genutil" 16 | genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" 17 | "github.com/cosmos/cosmos-sdk/x/gov" 18 | govclient "github.com/cosmos/cosmos-sdk/x/gov/client" 19 | "github.com/cosmos/cosmos-sdk/x/mint" 20 | "github.com/cosmos/cosmos-sdk/x/params" 21 | paramsclient "github.com/cosmos/cosmos-sdk/x/params/client" 22 | "github.com/cosmos/cosmos-sdk/x/slashing" 23 | "github.com/cosmos/cosmos-sdk/x/staking" 24 | "github.com/cosmos/ibc-go/v10/modules/apps/transfer" 25 | ibc "github.com/cosmos/ibc-go/v10/modules/core" 26 | ibclightclient "github.com/cosmos/ibc-go/v10/modules/light-clients/07-tendermint" 27 | ) 28 | 29 | var mbasics = module.NewBasicManager( 30 | append([]module.AppModuleBasic{ 31 | // accounts, fees. 32 | auth.AppModuleBasic{}, 33 | // authorizations 34 | authzmodule.AppModuleBasic{}, 35 | // genesis utilities 36 | genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), 37 | // tokens, token balance. 38 | bank.AppModuleBasic{}, 39 | // validator staking 40 | staking.AppModuleBasic{}, 41 | // inflation 42 | mint.AppModuleBasic{}, 43 | // distribution of fees and inflation 44 | distr.AppModuleBasic{}, 45 | // governance functionality (voting) 46 | gov.NewAppModuleBasic( 47 | []govclient.ProposalHandler{ 48 | paramsclient.ProposalHandler, 49 | }, 50 | ), 51 | // chain parameters 52 | params.AppModuleBasic{}, 53 | consensus.AppModuleBasic{}, 54 | crisis.AppModuleBasic{}, 55 | slashing.AppModuleBasic{}, 56 | ibclightclient.AppModuleBasic{}, 57 | ibc.AppModuleBasic{}, 58 | upgrade.AppModuleBasic{}, 59 | evidence.AppModuleBasic{}, 60 | transfer.AppModuleBasic{}, 61 | vesting.AppModuleBasic{}, 62 | feegrantmodule.AppModuleBasic{}, 63 | }, 64 | // akash 65 | akashModuleBasics()..., 66 | )..., 67 | ) 68 | 69 | // ModuleBasics returns all app modules basics 70 | func ModuleBasics() module.BasicManager { 71 | return mbasics 72 | } 73 | -------------------------------------------------------------------------------- /tests/upgrade/testnet.json: -------------------------------------------------------------------------------- 1 | { 2 | "chain_id": "localakash", 3 | "gov": { 4 | "voting_params": { 5 | "voting_period": "60s", 6 | "expedited_vote_period": "60s" 7 | } 8 | }, 9 | "accounts": [ 10 | { 11 | "address": "akash1dge0lcc5rqxkw52rgav4q0fyhx7arcufmrkyww", 12 | "balances": [ 13 | { 14 | "denom": "uakt", 15 | "amount": "1000000000000000" 16 | }, 17 | { 18 | "denom": "ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D84", 19 | "amount": "1000000000000" 20 | } 21 | ] 22 | }, 23 | { 24 | "address": "akash18tdthhtcvfmzl60r0r6gvjdcelc0wtwfumqsdz", 25 | "balances": [ 26 | { 27 | "denom": "uakt", 28 | "amount": "1000000000000000" 29 | }, 30 | { 31 | "denom": "ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D84", 32 | "amount": "1000000000000" 33 | } 34 | ] 35 | }, 36 | { 37 | "address": "akash1sdv7sz7y4j2z9l6nyrk9g4ztjh9dvml75gfgra", 38 | "balances": [ 39 | { 40 | "denom": "uakt", 41 | "amount": "1000000000000000" 42 | }, 43 | { 44 | "denom": "ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D84", 45 | "amount": "1000000000000" 46 | } 47 | ] 48 | } 49 | ], 50 | "validators": [ 51 | { 52 | "moniker": "upgrade-tester-1", 53 | "operator": "akash1dge0lcc5rqxkw52rgav4q0fyhx7arcufmrkyww", 54 | "status": 3, 55 | "home": ".akash0", 56 | "commission": { 57 | "rate": "0.05", 58 | "maxRate": "0.8", 59 | "maxChangeRate": "0.1" 60 | }, 61 | "min_self_delegation": "1", 62 | "delegations": [ 63 | { 64 | "address": "akash1dge0lcc5rqxkw52rgav4q0fyhx7arcufmrkyww", 65 | "amount": { 66 | "denom": "uakt", 67 | "amount": "900000000000000" 68 | } 69 | } 70 | ] 71 | } 72 | ] 73 | } 74 | -------------------------------------------------------------------------------- /x/provider/genesis.go: -------------------------------------------------------------------------------- 1 | package provider 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | 7 | "github.com/cosmos/cosmos-sdk/codec" 8 | sdk "github.com/cosmos/cosmos-sdk/types" 9 | 10 | types "pkg.akt.dev/go/node/provider/v1beta4" 11 | 12 | "pkg.akt.dev/node/x/provider/keeper" 13 | ) 14 | 15 | // ValidateGenesis does validation check of the Genesis and returns error in case of failure 16 | 17 | func ValidateGenesis(data *types.GenesisState) error { 18 | for _, record := range data.Providers { 19 | msg := &types.MsgCreateProvider{ 20 | Owner: record.Owner, 21 | HostURI: record.HostURI, 22 | Attributes: record.Attributes, 23 | Info: record.Info, 24 | } 25 | 26 | if err := msg.ValidateBasic(); err != nil { 27 | return err 28 | } 29 | 30 | } 31 | 32 | return nil 33 | } 34 | 35 | // InitGenesis initiate genesis state and return updated validator details 36 | func InitGenesis(ctx sdk.Context, kpr keeper.IKeeper, data *types.GenesisState) { 37 | store := ctx.KVStore(kpr.StoreKey()) 38 | cdc := kpr.Codec() 39 | 40 | for _, record := range data.Providers { 41 | owner, err := sdk.AccAddressFromBech32(record.Owner) 42 | if err != nil { 43 | panic(fmt.Sprintf("provider genesis init: %s", err.Error())) 44 | } 45 | 46 | key := keeper.ProviderKey(owner) 47 | 48 | if store.Has(key) { 49 | panic(fmt.Sprintf("provider genesis init: %s", types.ErrProviderExists.Error())) 50 | } 51 | 52 | store.Set(key, cdc.MustMarshal(&record)) 53 | } 54 | } 55 | 56 | // ExportGenesis returns genesis state as raw bytes for the provider module 57 | func ExportGenesis(ctx sdk.Context, k keeper.IKeeper) *types.GenesisState { 58 | var providers []types.Provider 59 | 60 | k.WithProviders(ctx, func(provider types.Provider) bool { 61 | providers = append(providers, provider) 62 | return false 63 | }) 64 | 65 | return &types.GenesisState{ 66 | Providers: providers, 67 | } 68 | } 69 | 70 | // DefaultGenesisState returns default genesis state as raw bytes for the provider 71 | // module. 72 | func DefaultGenesisState() *types.GenesisState { 73 | return &types.GenesisState{} 74 | } 75 | 76 | // GetGenesisStateFromAppState returns x/provider GenesisState given raw application 77 | // genesis state. 78 | func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.RawMessage) *types.GenesisState { 79 | var genesisState types.GenesisState 80 | 81 | if appState[ModuleName] != nil { 82 | cdc.MustUnmarshalJSON(appState[ModuleName], &genesisState) 83 | } 84 | 85 | return &genesisState 86 | } 87 | -------------------------------------------------------------------------------- /_docs/adr/adr-002-manifest-v2beta2.md: -------------------------------------------------------------------------------- 1 | # ADR 002: Manifest v2beta2 2 | 3 | ## Changelog 4 | 5 | * 2023/07/26: Initial implementation @troian 6 | 7 | ## Status 8 | 9 | InProgress 10 | 11 | ## Brief 12 | This manifest is using `v1beta3 API` 13 | 14 | ## Version 15 | 16 | Manifest version is SHA256 of sorted json. Check reference [Go implementation](https://github.com/akash-network/akash-api/blob/60498f7c84cfef78ebbfce97a818bf7610c94805/go/manifest/v2beta2/manifest.go#L53) 17 | 18 | ## Validation 19 | [Reference implementation](https://github.com/akash-network/akash-api/blob/60498f7c84cfef78ebbfce97a818bf7610c94805/go/manifest/v2beta2/manifest.go#L28C1-L28C1) 20 | 21 | ### Global 22 | - Total amount of global service must be [> 0](https://github.com/akash-network/akash-api/blob/60498f7c84cfef78ebbfce97a818bf7610c94805/go/manifest/v2beta2/groups.go#L29) 23 | 24 | ### Groups 25 | - Group names must be [unique](https://github.com/akash-network/akash-api/blob/60498f7c84cfef78ebbfce97a818bf7610c94805/go/manifest/v2beta2/groups.go#L22C22-L22C22) 26 | 27 | ### Group 28 | - Group must have at least [one service](https://github.com/akash-network/akash-api/blob/60498f7c84cfef78ebbfce97a818bf7610c94805/go/manifest/v2beta2/group.go#L41) 29 | - Services must be sorted in ascending order [by name](https://github.com/akash-network/akash-api/blob/60498f7c84cfef78ebbfce97a818bf7610c94805/go/manifest/v2beta2/group.go#L45) 30 | 31 | #### Service 32 | - `Name` must [not be empty](https://github.com/akash-network/akash-api/blob/60498f7c84cfef78ebbfce97a818bf7610c94805/go/manifest/v2beta2/service.go#L14) 33 | - `Name` must match regex `^[a-z]([-a-z0-9]*[a-z0-9])?$` 34 | - `Image` must not be empty 35 | 36 | ##### Env var 37 | Env must be in format `NAME<=VALUE>`, where `NAME` is mandatory, and value including `=` is optional 38 | 39 | Name must comply with regex `^[-._a-zA-Z][-._a-zA-Z0-9]*$` 40 | 41 | ##### Expose 42 | Expose list must be sorted. Reference [implementation](https://github.com/akash-network/akash-api/blob/60498f7c84cfef78ebbfce97a818bf7610c94805/go/manifest/v2beta2/serviceexposes.go#L13..L41) 43 | Sort priorities are: 44 | 1. Name 45 | 2. Port 46 | 3. Proto 47 | 4. Global 48 | 49 | Each expose member: 50 | `Port` - `0 > port > 65535` 51 | `Proto` - TCP or UDP 52 | `Hosts` - each host must: 53 | - len <= 255 characters (UTF-8) 54 | - complies with **RFC 1123** 55 | 56 | ## CheckAgainstDeployment 57 | 58 | [Reference implementation](https://github.com/akash-network/akash-api/blob/60498f7c84cfef78ebbfce97a818bf7610c94805/go/manifest/v2beta2/manifest.go#L47) 59 | -------------------------------------------------------------------------------- /.envrc: -------------------------------------------------------------------------------- 1 | direnv_version_major=$(direnv version | cut -d "." -f1 | tr -d '\n') 2 | direnv_version_minor=$(direnv version | cut -d "." -f2 | tr -d '\n') 3 | 4 | if [[ $direnv_version_major -lt 2 ]] || [[ $direnv_version_major -eq 2 ]] && [[ $direnv_version_minor -lt 32 ]]; then 5 | echo -e "\033[31munsupported direnv version $(direnv version) < 2.32.x" 6 | exit 1 7 | fi 8 | 9 | if [[ "$(ps -p "$$" -o 'comm=')" =~ "bash" ]]; then 10 | if [ "${BASH_VERSINFO:-0}" -lt 4 ]; then 11 | echo -e "\033[31mthe environment needs BASH 4 or above" >&2 12 | exit 1 13 | fi 14 | fi 15 | 16 | if ! has make; then 17 | echo "make is not installed" 18 | exit 1 19 | fi 20 | 21 | if ! has unzip; then 22 | echo "unzip is not installed" 23 | exit 1 24 | fi 25 | 26 | if ! has wget; then 27 | echo "wget is not installed" 28 | exit 1 29 | fi 30 | 31 | if ! has curl; then 32 | echo "curl is not installed" 33 | exit 1 34 | fi 35 | 36 | if ! has npm; then 37 | echo "npm is not installed" 38 | exit 1 39 | fi 40 | 41 | if ! has jq; then 42 | echo "jq is not installed" 43 | exit 1 44 | fi 45 | 46 | if ! has readlink; then 47 | echo "readlink is not installed" 48 | exit 1 49 | fi 50 | 51 | if ! has pv; then 52 | echo "pv is not installed" 53 | exit 1 54 | fi 55 | 56 | if ! has lz4; then 57 | echo "lz4 is not installed" 58 | exit 1 59 | fi 60 | 61 | if [ -z "$GOPATH" ]; then 62 | GOPATH=$(go env GOPATH) 63 | export GOPATH 64 | fi 65 | 66 | AKASH_ROOT=$(pwd) 67 | export AKASH_ROOT 68 | 69 | dotenv 70 | 71 | TOOLS=${AKASH_ROOT}/script/tools.sh 72 | SEMVER=${AKASH_ROOT}/script/semver.sh 73 | 74 | GOTOOLCHAIN=$(${TOOLS} gotoolchain) 75 | GOTOOLCHAIN_SEMVER=$(echo "${GOTOOLCHAIN}" | sed 's/go*/v/' | tr -d '\n') 76 | 77 | dotenv_if_exists dev.env 78 | 79 | if [[ ${GOWORK} != "off" ]] && [[ -f go.work ]]; then 80 | GOWORK=${AKASH_ROOT}/go.work 81 | else 82 | GOWORK=off 83 | fi 84 | 85 | if [[ "$OSTYPE" == "darwin"* ]]; then 86 | # on MacOS disable deprecation warnings security framework 87 | CGO_CFLAGS=-Wno-deprecated-declarations 88 | 89 | export CGO_CFLAGS 90 | fi 91 | 92 | if [ -z "${GOARCH}" ]; then 93 | GOARCH=$(go env GOARCH) 94 | export GOARCH 95 | fi 96 | 97 | export SEMVER 98 | export GOTOOLCHAIN 99 | export GOTOOLCHAIN_SEMVER 100 | export GOWORK 101 | 102 | PATH_add "$AKASH_DEVCACHE_NODE_BIN" 103 | PATH_add "$AKASH_DEVCACHE_BIN" 104 | 105 | AKASH_DIRENV_SET=1 106 | AKASH=$AKASH_DEVCACHE_BIN/akash 107 | 108 | export AKASH_DIRENV_SET 109 | export AKASH 110 | 111 | make cache 112 | -------------------------------------------------------------------------------- /app/ante.go: -------------------------------------------------------------------------------- 1 | package app 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/codec" 5 | sdk "github.com/cosmos/cosmos-sdk/types" 6 | sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" 7 | "github.com/cosmos/cosmos-sdk/x/auth/ante" 8 | govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" 9 | ) 10 | 11 | // HandlerOptions extends the SDK's AnteHandler options 12 | type HandlerOptions struct { 13 | ante.HandlerOptions 14 | CDC codec.BinaryCodec 15 | GovKeeper *govkeeper.Keeper 16 | } 17 | 18 | // NewAnteHandler returns an AnteHandler that checks and increments sequence 19 | // numbers, checks signatures & account numbers, and deducts fees from the first 20 | // signer. 21 | func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { 22 | if options.AccountKeeper == nil { 23 | return nil, sdkerrors.ErrLogic.Wrap("account keeper is required for ante builder") 24 | } 25 | 26 | if options.BankKeeper == nil { 27 | return nil, sdkerrors.ErrLogic.Wrap("bank keeper is required for ante builder") 28 | } 29 | 30 | if options.SignModeHandler == nil { 31 | return nil, sdkerrors.ErrLogic.Wrap("sign mode handler is required for ante builder") 32 | } 33 | 34 | if options.SigGasConsumer == nil { 35 | return nil, sdkerrors.ErrLogic.Wrap("sig gas consumer handler is required for ante builder") 36 | } 37 | 38 | if options.GovKeeper == nil { 39 | return nil, sdkerrors.ErrLogic.Wrap("akash governance keeper is required for ante builder") 40 | } 41 | 42 | if options.FeegrantKeeper == nil { 43 | return nil, sdkerrors.ErrLogic.Wrap("akash feegrant keeper is required for ante builder") 44 | } 45 | 46 | anteDecorators := []sdk.AnteDecorator{ 47 | ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first 48 | ante.NewValidateBasicDecorator(), 49 | ante.NewTxTimeoutHeightDecorator(), 50 | ante.NewValidateMemoDecorator(options.AccountKeeper), 51 | ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper), 52 | ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, nil), 53 | ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators 54 | ante.NewValidateSigCountDecorator(options.AccountKeeper), 55 | ante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer), 56 | ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler), 57 | ante.NewIncrementSequenceDecorator(options.AccountKeeper), 58 | } 59 | 60 | return sdk.ChainAnteDecorators(anteDecorators...), nil 61 | } 62 | -------------------------------------------------------------------------------- /x/deployment/simulation/proposals.go: -------------------------------------------------------------------------------- 1 | package simulation 2 | 3 | import ( 4 | "math/rand" 5 | 6 | sdk "github.com/cosmos/cosmos-sdk/types" 7 | "github.com/cosmos/cosmos-sdk/types/address" 8 | simtypes "github.com/cosmos/cosmos-sdk/types/simulation" 9 | "github.com/cosmos/cosmos-sdk/x/simulation" 10 | 11 | types "pkg.akt.dev/go/node/deployment/v1beta4" 12 | ) 13 | 14 | // Simulation operation weights constants 15 | const ( 16 | DefaultWeightMsgUpdateParams int = 100 17 | 18 | OpWeightMsgUpdateParams = "op_weight_msg_update_params" //nolint:gosec 19 | ) 20 | 21 | // ProposalMsgs defines the module weighted proposals' contents 22 | func ProposalMsgs() []simtypes.WeightedProposalMsg { 23 | return []simtypes.WeightedProposalMsg{ 24 | simulation.NewWeightedProposalMsg( 25 | OpWeightMsgUpdateParams, 26 | DefaultWeightMsgUpdateParams, 27 | SimulateMsgUpdateParams, 28 | ), 29 | } 30 | } 31 | 32 | func SimulateMsgUpdateParams(r *rand.Rand, _ sdk.Context, _ []simtypes.Account) sdk.Msg { 33 | // use the default gov module account address as authority 34 | var authority sdk.AccAddress = address.Module("gov") 35 | 36 | coins := simtypes.RandSubsetCoins(r, sdk.Coins{ 37 | sdk.NewInt64Coin("ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D84", int64(simtypes.RandIntBetween(r, 500000, 50000000))), 38 | sdk.NewInt64Coin("ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D85", int64(simtypes.RandIntBetween(r, 500000, 50000000))), 39 | sdk.NewInt64Coin("ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D86", int64(simtypes.RandIntBetween(r, 500000, 50000000))), 40 | sdk.NewInt64Coin("ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D87", int64(simtypes.RandIntBetween(r, 500000, 50000000))), 41 | sdk.NewInt64Coin("ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D88", int64(simtypes.RandIntBetween(r, 500000, 50000000))), 42 | sdk.NewInt64Coin("ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D89", int64(simtypes.RandIntBetween(r, 500000, 50000000))), 43 | sdk.NewInt64Coin("ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D8A", int64(simtypes.RandIntBetween(r, 500000, 50000000))), 44 | sdk.NewInt64Coin("ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D8B", int64(simtypes.RandIntBetween(r, 500000, 50000000))), 45 | }) 46 | 47 | // uakt must always be present 48 | coins = append(coins, sdk.NewInt64Coin("uakt", int64(simtypes.RandIntBetween(r, 500000, 50000000)))) 49 | 50 | params := types.DefaultParams() 51 | params.MinDeposits = coins 52 | 53 | return &types.MsgUpdateParams{ 54 | Authority: authority.String(), 55 | Params: params, 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /x/provider/handler/server.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "context" 5 | 6 | errorsmod "cosmossdk.io/errors" 7 | 8 | sdk "github.com/cosmos/cosmos-sdk/types" 9 | types "pkg.akt.dev/go/node/provider/v1beta4" 10 | 11 | mkeeper "pkg.akt.dev/node/x/market/keeper" 12 | "pkg.akt.dev/node/x/provider/keeper" 13 | ) 14 | 15 | var ( 16 | // ErrInternal defines registered error code for internal error 17 | ErrInternal = errorsmod.Register(types.ModuleName, 10, "internal error") 18 | ) 19 | 20 | type msgServer struct { 21 | provider keeper.IKeeper 22 | market mkeeper.IKeeper 23 | } 24 | 25 | // NewMsgServerImpl returns an implementation of the market MsgServer interface 26 | // for the provided Keeper. 27 | func NewMsgServerImpl(k keeper.IKeeper, mk mkeeper.IKeeper) types.MsgServer { 28 | return &msgServer{provider: k, market: mk} 29 | } 30 | 31 | var _ types.MsgServer = msgServer{} 32 | 33 | func (ms msgServer) CreateProvider(goCtx context.Context, msg *types.MsgCreateProvider) (*types.MsgCreateProviderResponse, error) { 34 | ctx := sdk.UnwrapSDKContext(goCtx) 35 | 36 | if err := msg.ValidateBasic(); err != nil { 37 | return nil, err 38 | } 39 | 40 | owner, _ := sdk.AccAddressFromBech32(msg.Owner) 41 | 42 | if _, ok := ms.provider.Get(ctx, owner); ok { 43 | return nil, types.ErrProviderExists.Wrapf("id: %s", msg.Owner) 44 | } 45 | 46 | if err := ms.provider.Create(ctx, types.Provider(*msg)); err != nil { 47 | return nil, ErrInternal.Wrapf("err: %v", err) 48 | } 49 | 50 | return &types.MsgCreateProviderResponse{}, nil 51 | } 52 | 53 | func (ms msgServer) UpdateProvider(goCtx context.Context, msg *types.MsgUpdateProvider) (*types.MsgUpdateProviderResponse, error) { 54 | ctx := sdk.UnwrapSDKContext(goCtx) 55 | 56 | err := msg.ValidateBasic() 57 | if err != nil { 58 | return nil, err 59 | } 60 | 61 | owner, _ := sdk.AccAddressFromBech32(msg.Owner) 62 | _, found := ms.provider.Get(ctx, owner) 63 | if !found { 64 | return nil, types.ErrProviderNotFound.Wrapf("id: %s", msg.Owner) 65 | } 66 | 67 | if err := ms.provider.Update(ctx, types.Provider(*msg)); err != nil { 68 | return nil, errorsmod.Wrapf(ErrInternal, "err: %v", err) 69 | } 70 | 71 | return &types.MsgUpdateProviderResponse{}, nil 72 | } 73 | 74 | func (ms msgServer) DeleteProvider(goCtx context.Context, msg *types.MsgDeleteProvider) (*types.MsgDeleteProviderResponse, error) { 75 | ctx := sdk.UnwrapSDKContext(goCtx) 76 | 77 | owner, err := sdk.AccAddressFromBech32(msg.Owner) 78 | if err != nil { 79 | return nil, err 80 | } 81 | 82 | if _, ok := ms.provider.Get(ctx, owner); !ok { 83 | return nil, types.ErrProviderNotFound 84 | } 85 | 86 | // TODO: cancel leases 87 | return nil, ErrInternal.Wrap("NOTIMPLEMENTED") 88 | } 89 | -------------------------------------------------------------------------------- /util/partialord/partialord_test.go: -------------------------------------------------------------------------------- 1 | package partialord_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | 8 | "pkg.akt.dev/node/util/partialord" 9 | ) 10 | 11 | func TestAPI(t *testing.T) { 12 | // begin block use case, we have a dozen modules, but only care about a couple orders. 13 | // In practice this will be gotten from some API, e.g. app.AllModuleNames() 14 | moduleNames := []string{ 15 | "auth", "authz", "bank", "capabilities", 16 | "staking", "distribution", "epochs", "mint", "upgrades", "wasm", "ibc", 17 | "ibctransfers", 18 | } 19 | beginBlockOrd := partialord.NewPartialOrdering(moduleNames) 20 | beginBlockOrd.FirstElements("upgrades", "epochs", "capabilities") 21 | beginBlockOrd.After("ibctransfers", "ibc") 22 | beginBlockOrd.Before("mint", "distribution") 23 | // This is purely just to test last functionality, doesn't make sense in context 24 | beginBlockOrd.LastElements("auth", "authz", "wasm") 25 | 26 | totalOrd := beginBlockOrd.TotalOrdering() 27 | expTotalOrd := []string{ 28 | "upgrades", "epochs", "capabilities", 29 | "bank", "ibc", "mint", "staking", "ibctransfers", "distribution", 30 | "auth", "authz", "wasm", 31 | } 32 | require.Equal(t, expTotalOrd, totalOrd) 33 | } 34 | 35 | func TestNonStandardAPIOrder(t *testing.T) { 36 | // This test uses direct ordering before First, and after Last 37 | names := []string{"A", "B", "C", "D", "E", "F", "G"} 38 | ord := partialord.NewPartialOrdering(names) 39 | ord.After("A", "C") 40 | ord.After("A", "D") 41 | ord.After("E", "B") 42 | // overrides the "A" after "C" & "A" after "D" constraints 43 | ord.FirstElements("A", "B", "C") 44 | expOrdering := []string{"A", "B", "C", "D", "E", "F", "G"} 45 | require.Equal(t, expOrdering, ord.TotalOrdering()) 46 | 47 | ord.After("E", "D") 48 | expOrdering = []string{"A", "B", "C", "D", "F", "G", "E"} 49 | require.Equal(t, expOrdering, ord.TotalOrdering()) 50 | 51 | ord.LastElements("G") 52 | ord.After("F", "E") 53 | expOrdering = []string{"A", "B", "C", "D", "E", "F", "G"} 54 | require.Equal(t, expOrdering, ord.TotalOrdering()) 55 | } 56 | 57 | // This test ad-hocly tests combination of multiple sequences, first elements, and an After 58 | // invocation. 59 | func TestSequence(t *testing.T) { 60 | // This test uses direct ordering before First, and after Last 61 | names := []string{"A", "B", "C", "D", "E", "F", "G"} 62 | ord := partialord.NewPartialOrdering(names) 63 | // Make B A C a sequence 64 | ord.Sequence("B", "A", "C") 65 | // Make A G E a sub-sequence 66 | ord.Sequence("A", "G", "E") 67 | // make first elements D B F 68 | ord.FirstElements("D", "B", "F") 69 | // make C come after E 70 | ord.After("C", "G") 71 | 72 | expOrdering := []string{"D", "B", "F", "A", "G", "C", "E"} 73 | require.Equal(t, expOrdering, ord.TotalOrdering()) 74 | } 75 | -------------------------------------------------------------------------------- /.goreleaser-docker.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 2 3 | dist: ./.cache/goreleaser/docker 4 | env: 5 | - GO111MODULE=on 6 | - CGO_ENABLED=1 7 | before: 8 | hooks: 9 | - apt update 10 | - apt install -y pkg-config libudev-dev:amd64 libudev-dev:arm64 11 | builds: 12 | - id: akash-linux-amd64 13 | binary: akash 14 | main: ./cmd/akash 15 | env: 16 | - CC=x86_64-linux-gnu-gcc 17 | - CXX=x86_64-linux-gnu-g++ 18 | goarch: 19 | - amd64 20 | goos: 21 | - linux 22 | flags: 23 | - "-mod={{ .Env.MOD }}" 24 | - "-tags={{ .Env.BUILD_TAGS }}" 25 | - -trimpath 26 | ldflags: 27 | - "{{ .Env.BUILD_VARS }}" 28 | - "{{ .Env.STRIP_FLAGS }}" 29 | - "-linkmode={{ .Env.LINKMODE }}" 30 | - -extldflags "-lc -lrt -lpthread" 31 | - id: akash-linux-arm64 32 | binary: akash 33 | main: ./cmd/akash 34 | goarch: 35 | - arm64 36 | goos: 37 | - linux 38 | env: 39 | - CC=aarch64-linux-gnu-gcc 40 | - CXX=aarch64-linux-gnu-g++ 41 | flags: 42 | - "-mod={{ .Env.MOD }}" 43 | - "-tags={{ .Env.BUILD_TAGS }}" 44 | - -trimpath 45 | ldflags: 46 | - "{{ .Env.BUILD_VARS }}" 47 | - "{{ .Env.STRIP_FLAGS }}" 48 | - "-linkmode={{ .Env.LINKMODE }}" 49 | - -extldflags "-lc -lrt -lpthread" 50 | dockers: 51 | - dockerfile: _build/Dockerfile.akash 52 | use: buildx 53 | goarch: amd64 54 | goos: linux 55 | build_flag_templates: 56 | - --platform=linux/amd64 57 | - --label=org.opencontainers.image.title={{ .ProjectName }} 58 | - --label=org.opencontainers.image.description={{ .ProjectName }} 59 | - --label=org.opencontainers.image.url={{.GitURL}} 60 | - --label=org.opencontainers.image.source={{.GitURL}} 61 | - --label=org.opencontainers.image.version={{ .Version }} 62 | - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} 63 | - --label=org.opencontainers.image.revision={{ .FullCommit }} 64 | image_templates: 65 | - '{{ .Env.DOCKER_IMAGE }}:latest-amd64' 66 | - dockerfile: _build/Dockerfile.akash 67 | use: buildx 68 | goarch: arm64 69 | goos: linux 70 | build_flag_templates: 71 | - --platform=linux/arm64 72 | - --label=org.opencontainers.image.title={{ .ProjectName }} 73 | - --label=org.opencontainers.image.description={{ .ProjectName }} 74 | - --label=org.opencontainers.image.url={{.GitURL}} 75 | - --label=org.opencontainers.image.source={{.GitURL}} 76 | - --label=org.opencontainers.image.version={{ .Version }} 77 | - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }} 78 | - --label=org.opencontainers.image.revision={{ .FullCommit }} 79 | image_templates: 80 | - '{{ .Env.DOCKER_IMAGE }}:latest-arm64' 81 | 82 | archives: 83 | - formats: 84 | - binary 85 | -------------------------------------------------------------------------------- /.goreleaser-test-bins.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | project_name: node 3 | version: 2 4 | dist: ./.cache/goreleaser/test-bins 5 | before: 6 | hooks: 7 | - apt update 8 | - apt install -y pkg-config libudev-dev:amd64 libudev-dev:arm64 9 | env: 10 | - GO111MODULE=on 11 | - CGO_ENABLED=1 12 | builds: 13 | - id: akash-darwin-amd64 14 | binary: akash 15 | main: ./cmd/akash 16 | goarch: 17 | - amd64 18 | goos: 19 | - darwin 20 | env: 21 | - CC=o64-clang 22 | - CXX=o64-clang++ 23 | flags: 24 | - "-mod={{ .Env.MOD }}" 25 | - "-tags={{ .Env.BUILD_TAGS }}" 26 | - -trimpath 27 | ldflags: 28 | - "{{ .Env.BUILD_VARS }}" 29 | - "{{ .Env.STRIP_FLAGS }}" 30 | - "-linkmode={{ .Env.LINKMODE }}" 31 | - id: akash-darwin-arm64 32 | binary: akash 33 | main: ./cmd/akash 34 | goarch: 35 | - arm64 36 | goos: 37 | - darwin 38 | env: 39 | - CC=oa64-clang 40 | - CXX=oa64-clang++ 41 | flags: 42 | - "-mod={{ .Env.MOD }}" 43 | - "-tags={{ .Env.BUILD_TAGS }}" 44 | - -trimpath 45 | ldflags: 46 | - "{{ .Env.BUILD_VARS }}" 47 | - "{{ .Env.STRIP_FLAGS }}" 48 | - "-linkmode={{ .Env.LINKMODE }}" 49 | - id: akash-linux-amd64 50 | binary: akash 51 | main: ./cmd/akash 52 | env: 53 | - CC=x86_64-linux-gnu-gcc 54 | - CXX=x86_64-linux-gnu-g++ 55 | goarch: 56 | - amd64 57 | goos: 58 | - linux 59 | flags: 60 | - "-mod={{ .Env.MOD }}" 61 | - "-tags={{ .Env.BUILD_TAGS }}" 62 | - -trimpath 63 | ldflags: 64 | - "{{ .Env.BUILD_VARS }}" 65 | - "{{ .Env.STRIP_FLAGS }}" 66 | - "-linkmode={{ .Env.LINKMODE }}" 67 | - -extldflags "-lc -lrt -lpthread" 68 | - id: akash-linux-arm64 69 | binary: akash 70 | main: ./cmd/akash 71 | goarch: 72 | - arm64 73 | goos: 74 | - linux 75 | env: 76 | - CC=aarch64-linux-gnu-gcc 77 | - CXX=aarch64-linux-gnu-g++ 78 | flags: 79 | - "-mod={{ .Env.MOD }}" 80 | - "-tags={{ .Env.BUILD_TAGS }}" 81 | - -trimpath 82 | ldflags: 83 | - "{{ .Env.BUILD_VARS }}" 84 | - "{{ .Env.STRIP_FLAGS }}" 85 | - "-linkmode={{ .Env.LINKMODE }}" 86 | - -extldflags "-lc -lrt -lpthread" 87 | universal_binaries: 88 | - id: akash-darwin-universal 89 | ids: 90 | - akash-darwin-amd64 91 | - akash-darwin-arm64 92 | replace: true 93 | name_template: "akash" 94 | 95 | archives: 96 | - id: wo/version 97 | ids: 98 | - akash-darwin-universal 99 | - akash-linux-amd64 100 | - akash-linux-arm64 101 | name_template: "akash_{{ .Os }}_{{ .Arch }}" 102 | wrap_in_directory: false 103 | formats: 104 | - zip 105 | files: 106 | - none* 107 | -------------------------------------------------------------------------------- /cmd/akash/cmd/testnetify/cmt_abci.go: -------------------------------------------------------------------------------- 1 | package testnetify 2 | 3 | import ( 4 | "context" 5 | 6 | abci "github.com/cometbft/cometbft/abci/types" 7 | 8 | servertypes "github.com/cosmos/cosmos-sdk/server/types" 9 | ) 10 | 11 | type cometABCIWrapper struct { 12 | app servertypes.ABCI 13 | } 14 | 15 | func NewCometABCIWrapper(app servertypes.ABCI) abci.Application { 16 | return cometABCIWrapper{app: app} 17 | } 18 | 19 | func (w cometABCIWrapper) Info(_ context.Context, req *abci.RequestInfo) (*abci.ResponseInfo, error) { 20 | return w.app.Info(req) 21 | } 22 | 23 | func (w cometABCIWrapper) Query(ctx context.Context, req *abci.RequestQuery) (*abci.ResponseQuery, error) { 24 | return w.app.Query(ctx, req) 25 | } 26 | 27 | func (w cometABCIWrapper) CheckTx(_ context.Context, req *abci.RequestCheckTx) (*abci.ResponseCheckTx, error) { 28 | return w.app.CheckTx(req) 29 | } 30 | 31 | func (w cometABCIWrapper) InitChain(_ context.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { 32 | return w.app.InitChain(req) 33 | } 34 | 35 | func (w cometABCIWrapper) PrepareProposal(_ context.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) { 36 | return w.app.PrepareProposal(req) 37 | } 38 | 39 | func (w cometABCIWrapper) ProcessProposal(_ context.Context, req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error) { 40 | return w.app.ProcessProposal(req) 41 | } 42 | 43 | func (w cometABCIWrapper) FinalizeBlock(_ context.Context, req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) { 44 | return w.app.FinalizeBlock(req) 45 | } 46 | 47 | func (w cometABCIWrapper) ExtendVote(ctx context.Context, req *abci.RequestExtendVote) (*abci.ResponseExtendVote, error) { 48 | return w.app.ExtendVote(ctx, req) 49 | } 50 | 51 | func (w cometABCIWrapper) VerifyVoteExtension(_ context.Context, req *abci.RequestVerifyVoteExtension) (*abci.ResponseVerifyVoteExtension, error) { 52 | return w.app.VerifyVoteExtension(req) 53 | } 54 | 55 | func (w cometABCIWrapper) Commit(_ context.Context, _ *abci.RequestCommit) (*abci.ResponseCommit, error) { 56 | return w.app.Commit() 57 | } 58 | 59 | func (w cometABCIWrapper) ListSnapshots(_ context.Context, req *abci.RequestListSnapshots) (*abci.ResponseListSnapshots, error) { 60 | return w.app.ListSnapshots(req) 61 | } 62 | 63 | func (w cometABCIWrapper) OfferSnapshot(_ context.Context, req *abci.RequestOfferSnapshot) (*abci.ResponseOfferSnapshot, error) { 64 | return w.app.OfferSnapshot(req) 65 | } 66 | 67 | func (w cometABCIWrapper) LoadSnapshotChunk(_ context.Context, req *abci.RequestLoadSnapshotChunk) (*abci.ResponseLoadSnapshotChunk, error) { 68 | return w.app.LoadSnapshotChunk(req) 69 | } 70 | 71 | func (w cometABCIWrapper) ApplySnapshotChunk(_ context.Context, req *abci.RequestApplySnapshotChunk) (*abci.ResponseApplySnapshotChunk, error) { 72 | return w.app.ApplySnapshotChunk(req) 73 | } 74 | -------------------------------------------------------------------------------- /x/take/simulation/proposals.go: -------------------------------------------------------------------------------- 1 | package simulation 2 | 3 | import ( 4 | "math/rand" 5 | 6 | sdk "github.com/cosmos/cosmos-sdk/types" 7 | "github.com/cosmos/cosmos-sdk/types/address" 8 | simtypes "github.com/cosmos/cosmos-sdk/types/simulation" 9 | "github.com/cosmos/cosmos-sdk/x/simulation" 10 | 11 | types "pkg.akt.dev/go/node/take/v1" 12 | ) 13 | 14 | // Simulation operation weights constants 15 | const ( 16 | DefaultWeightMsgUpdateParams int = 100 17 | 18 | OpWeightMsgUpdateParams = "op_weight_msg_update_params" //nolint:gosec 19 | ) 20 | 21 | // ProposalMsgs defines the module weighted proposals' contents 22 | func ProposalMsgs() []simtypes.WeightedProposalMsg { 23 | return []simtypes.WeightedProposalMsg{ 24 | simulation.NewWeightedProposalMsg( 25 | OpWeightMsgUpdateParams, 26 | DefaultWeightMsgUpdateParams, 27 | SimulateMsgUpdateParams, 28 | ), 29 | } 30 | } 31 | 32 | func SimulateMsgUpdateParams(r *rand.Rand, _ sdk.Context, _ []simtypes.Account) sdk.Msg { 33 | // use the default gov module account address as authority 34 | var authority sdk.AccAddress = address.Module("gov") 35 | 36 | params := types.DefaultParams() 37 | 38 | coins := simtypes.RandSubsetCoins(r, sdk.Coins{ 39 | sdk.NewInt64Coin("ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D84", int64(simtypes.RandIntBetween(r, 500000, 50000000))), 40 | sdk.NewInt64Coin("ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D85", int64(simtypes.RandIntBetween(r, 500000, 50000000))), 41 | sdk.NewInt64Coin("ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D86", int64(simtypes.RandIntBetween(r, 500000, 50000000))), 42 | sdk.NewInt64Coin("ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D87", int64(simtypes.RandIntBetween(r, 500000, 50000000))), 43 | sdk.NewInt64Coin("ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D88", int64(simtypes.RandIntBetween(r, 500000, 50000000))), 44 | sdk.NewInt64Coin("ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D89", int64(simtypes.RandIntBetween(r, 500000, 50000000))), 45 | sdk.NewInt64Coin("ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D8A", int64(simtypes.RandIntBetween(r, 500000, 50000000))), 46 | sdk.NewInt64Coin("ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D8B", int64(simtypes.RandIntBetween(r, 500000, 50000000))), 47 | }) 48 | 49 | // uakt must always be present 50 | coins = append(coins, sdk.NewInt64Coin("uakt", int64(simtypes.RandIntBetween(r, 500000, 50000000)))) 51 | 52 | params.DenomTakeRates = make(types.DenomTakeRates, 0, len(coins)) 53 | 54 | for _, coin := range coins { 55 | params.DenomTakeRates = append(params.DenomTakeRates, types.DenomTakeRate{ 56 | Denom: coin.Denom, 57 | Rate: uint32(simtypes.RandIntBetween(r, 0, 100)), // nolint gosec 58 | }) 59 | } 60 | 61 | return &types.MsgUpdateParams{ 62 | Authority: authority.String(), 63 | Params: params, 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /_docs/img/logo-label-black.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | ]> 8 | 10 | 11 | 13 | 14 | 15 | 17 | 20 | 23 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /x/deployment/genesis.go: -------------------------------------------------------------------------------- 1 | package deployment 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | 7 | "github.com/cosmos/cosmos-sdk/codec" 8 | sdk "github.com/cosmos/cosmos-sdk/types" 9 | 10 | "pkg.akt.dev/go/node/deployment/v1" 11 | "pkg.akt.dev/go/node/deployment/v1beta4" 12 | 13 | "pkg.akt.dev/node/x/deployment/keeper" 14 | ) 15 | 16 | // ValidateGenesis does validation check of the Genesis and return error in case of failure 17 | func ValidateGenesis(data *v1beta4.GenesisState) error { 18 | for _, record := range data.Deployments { 19 | if err := record.Deployment.ID.Validate(); err != nil { 20 | return fmt.Errorf("%w: %s", err, v1.ErrInvalidDeployment.Error()) 21 | } 22 | } 23 | return data.Params.Validate() 24 | } 25 | 26 | // DefaultGenesisState returns default genesis state as raw bytes for the deployment 27 | // module. 28 | func DefaultGenesisState() *v1beta4.GenesisState { 29 | return &v1beta4.GenesisState{ 30 | Params: v1beta4.DefaultParams(), 31 | } 32 | } 33 | 34 | // InitGenesis initiate genesis state and return updated validator details 35 | func InitGenesis(ctx sdk.Context, kpr keeper.IKeeper, data *v1beta4.GenesisState) { 36 | cdc := kpr.Codec() 37 | store := ctx.KVStore(kpr.StoreKey()) 38 | 39 | for _, record := range data.Deployments { 40 | key := keeper.MustDeploymentKey(keeper.DeploymentStateToPrefix(record.Deployment.State), record.Deployment.ID) 41 | 42 | store.Set(key, cdc.MustMarshal(&record.Deployment)) 43 | 44 | for idx := range record.Groups { 45 | group := record.Groups[idx] 46 | 47 | if !group.ID.DeploymentID().Equals(record.Deployment.ID) { 48 | panic(v1.ErrInvalidGroupID) 49 | } 50 | 51 | gkey := keeper.MustGroupKey(keeper.GroupStateToPrefix(group.State), group.ID) 52 | store.Set(gkey, cdc.MustMarshal(&group)) 53 | } 54 | } 55 | 56 | err := kpr.SetParams(ctx, data.Params) 57 | if err != nil { 58 | panic(err.Error()) 59 | } 60 | } 61 | 62 | // ExportGenesis returns genesis state for the deployment module 63 | func ExportGenesis(ctx sdk.Context, k keeper.IKeeper) *v1beta4.GenesisState { 64 | var records []v1beta4.GenesisDeployment 65 | k.WithDeployments(ctx, func(deployment v1.Deployment) bool { 66 | groups := k.GetGroups(ctx, deployment.ID) 67 | 68 | records = append(records, v1beta4.GenesisDeployment{ 69 | Deployment: deployment, 70 | Groups: groups, 71 | }) 72 | return false 73 | }) 74 | 75 | params := k.GetParams(ctx) 76 | return &v1beta4.GenesisState{ 77 | Deployments: records, 78 | Params: params, 79 | } 80 | } 81 | 82 | // GetGenesisStateFromAppState returns x/deployment GenesisState given raw application 83 | // genesis state. 84 | func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.RawMessage) *v1beta4.GenesisState { 85 | var genesisState v1beta4.GenesisState 86 | 87 | if appState[ModuleName] != nil { 88 | cdc.MustUnmarshalJSON(appState[ModuleName], &genesisState) 89 | } 90 | 91 | return &genesisState 92 | } 93 | -------------------------------------------------------------------------------- /util/cli/upgrade_info.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | import ( 4 | "bufio" 5 | "context" 6 | "encoding/json" 7 | "fmt" 8 | "net/http" 9 | "os" 10 | "strings" 11 | 12 | "github.com/google/go-github/v62/github" 13 | "github.com/gregjones/httpcache" 14 | "golang.org/x/oauth2" 15 | ) 16 | 17 | // UpgradeInfo is expected format for the info field to allow auto-download 18 | type UpgradeInfo struct { 19 | Binaries map[string]string `json:"binaries"` 20 | Configs map[string]string `json:"configs,omitempty"` 21 | } 22 | 23 | // UpgradeInfoFromTag generate upgrade info from give tag 24 | // tag - release tag 25 | // pretty - either prettify (true) json output or not (false) 26 | func UpgradeInfoFromTag(ctx context.Context, tag string, pretty bool) (string, error) { 27 | tc := &http.Client{ 28 | Transport: &oauth2.Transport{ 29 | Base: httpcache.NewMemoryCacheTransport(), 30 | Source: oauth2.StaticTokenSource( 31 | &oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")}, 32 | ), 33 | }, 34 | } 35 | 36 | gh := github.NewClient(tc) 37 | 38 | rel, resp, err := gh.Repositories.GetReleaseByTag(ctx, "akash-network", "node", tag) 39 | if err != nil { 40 | return "", err 41 | } 42 | 43 | if resp.StatusCode != http.StatusOK { 44 | return "", fmt.Errorf("no release for tag %s", tag) 45 | } 46 | 47 | sTag := strings.TrimPrefix(tag, "v") 48 | checksumsAsset := fmt.Sprintf("akash_%s_checksums.txt", sTag) 49 | var checksumsID int64 50 | for _, asset := range rel.Assets { 51 | if asset.GetName() == checksumsAsset { 52 | checksumsID = asset.GetID() 53 | } 54 | } 55 | 56 | body, _, err := gh.Repositories.DownloadReleaseAsset(ctx, "akash-network", "node", checksumsID, http.DefaultClient) 57 | if err != nil { 58 | return "", err 59 | } 60 | defer func() { 61 | _ = body.Close() 62 | }() 63 | 64 | info := &UpgradeInfo{ 65 | Binaries: make(map[string]string), 66 | } 67 | 68 | urlBase := fmt.Sprintf("https://github.com/akash-network/node/releases/download/%s", tag) 69 | scanner := bufio.NewScanner(body) 70 | for scanner.Scan() { 71 | tuple := strings.Split(scanner.Text(), " ") 72 | if len(tuple) != 2 { 73 | return "", fmt.Errorf("invalid checksum format") 74 | } 75 | 76 | link := fmt.Sprintf("%s/%s?checksum=sha256:%s", urlBase, tuple[1], tuple[0]) 77 | 78 | switch tuple[1] { 79 | case "akash_linux_amd64.zip": 80 | info.Binaries["linux/amd64"] = link 81 | case "akash_linux_arm64.zip": 82 | info.Binaries["linux/arm64"] = link 83 | case "akash_darwin_all.zip": 84 | info.Binaries["darwin/amd64"] = link 85 | info.Binaries["darwin/arm64"] = link 86 | } 87 | } 88 | 89 | var res []byte 90 | 91 | if pretty { 92 | res, err = json.MarshalIndent(info, "", " ") 93 | } else { 94 | res, err = json.Marshal(info) 95 | } 96 | 97 | if err != nil { 98 | return "", err 99 | } 100 | 101 | return string(res), nil 102 | } 103 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | APP_DIR := ./app 2 | 3 | GOBIN ?= $(shell go env GOPATH)/bin 4 | 5 | KIND_APP_IP ?= $(shell make -sC _run/kube kind-k8s-ip) 6 | KIND_APP_PORT ?= $(shell make -sC _run/kube app-http-port) 7 | KIND_VARS ?= KUBE_INGRESS_IP="$(KIND_APP_IP)" KUBE_INGRESS_PORT="$(KIND_APP_PORT)" 8 | 9 | include make/init.mk 10 | 11 | .DEFAULT_GOAL := bins 12 | 13 | DOCKER_RUN := docker run --rm -v $(shell pwd):/workspace -w /workspace 14 | GOLANGCI_LINT_RUN := $(GOLANGCI_LINT) run 15 | LINT = $(GOLANGCI_LINT_RUN) ./... --disable-all --deadline=5m --enable 16 | 17 | GORELEASER_CONFIG ?= .goreleaser.yaml 18 | 19 | GIT_HEAD_COMMIT_LONG := $(shell git log -1 --format='%H') 20 | GIT_HEAD_COMMIT_SHORT := $(shell git rev-parse --short HEAD) 21 | GIT_HEAD_ABBREV := $(shell git rev-parse --abbrev-ref HEAD) 22 | 23 | IS_PREREL := $(shell $(ROOT_DIR)/script/is_prerelease.sh "$(RELEASE_TAG)" && echo "true" || echo "false") 24 | IS_MAINNET := $(shell $(ROOT_DIR)/script/mainnet-from-tag.sh "$(RELEASE_TAG)" && echo "true" || echo "false") 25 | IS_STABLE ?= false 26 | 27 | GO_LINKMODE ?= external 28 | GOMOD ?= readonly 29 | BUILD_TAGS ?= osusergo,netgo,hidraw,ledger 30 | GORELEASER_STRIP_FLAGS ?= 31 | 32 | ifeq ($(IS_MAINNET), true) 33 | ifeq ($(IS_PREREL), false) 34 | IS_STABLE := true 35 | endif 36 | endif 37 | 38 | ifneq (,$(findstring cgotrace,$(BUILD_OPTIONS))) 39 | BUILD_TAGS := $(BUILD_TAGS),cgotrace 40 | endif 41 | 42 | GORELEASER_BUILD_VARS := \ 43 | -X github.com/cosmos/cosmos-sdk/version.Name=akash \ 44 | -X github.com/cosmos/cosmos-sdk/version.AppName=akash \ 45 | -X github.com/cosmos/cosmos-sdk/version.BuildTags=\"$(BUILD_TAGS)\" \ 46 | -X github.com/cosmos/cosmos-sdk/version.Version=$(RELEASE_TAG) \ 47 | -X github.com/cosmos/cosmos-sdk/version.Commit=$(GIT_HEAD_COMMIT_LONG) 48 | 49 | ldflags = -linkmode=$(GO_LINKMODE) -X github.com/cosmos/cosmos-sdk/version.Name=akash \ 50 | -X github.com/cosmos/cosmos-sdk/version.AppName=akash \ 51 | -X github.com/cosmos/cosmos-sdk/version.BuildTags="$(BUILD_TAGS)" \ 52 | -X github.com/cosmos/cosmos-sdk/version.Version=$(shell git describe --tags | sed 's/^v//') \ 53 | -X github.com/cosmos/cosmos-sdk/version.Commit=$(GIT_HEAD_COMMIT_LONG) 54 | 55 | # check for nostrip option 56 | ifeq (,$(findstring nostrip,$(BUILD_OPTIONS))) 57 | ldflags += -s -w 58 | GORELEASER_STRIP_FLAGS += -s -w 59 | endif 60 | 61 | ldflags += $(LDFLAGS) 62 | ldflags := $(strip $(ldflags)) 63 | 64 | BUILD_FLAGS := -mod=$(GOMOD) -tags='$(BUILD_TAGS)' -ldflags '$(ldflags)' 65 | 66 | .PHONY: all 67 | all: build bins 68 | 69 | .PHONY: clean 70 | clean: cache-clean 71 | rm -f $(BINS) 72 | 73 | include make/releasing.mk 74 | include make/mod.mk 75 | include make/lint.mk 76 | include make/test-integration.mk 77 | include make/test-simulation.mk 78 | include make/tools.mk 79 | include make/codegen.mk 80 | -------------------------------------------------------------------------------- /tests/e2e/provider_cli_test.go: -------------------------------------------------------------------------------- 1 | //go:build e2e.integration 2 | 3 | package e2e 4 | 5 | import ( 6 | "context" 7 | "path/filepath" 8 | 9 | "pkg.akt.dev/go/cli" 10 | clitestutil "pkg.akt.dev/go/cli/testutil" 11 | 12 | types "pkg.akt.dev/go/node/provider/v1beta4" 13 | 14 | "pkg.akt.dev/node/testutil" 15 | ) 16 | 17 | type providerIntegrationTestSuite struct { 18 | *testutil.NetworkTestSuite 19 | } 20 | 21 | func (s *providerIntegrationTestSuite) TestProvider() { 22 | cctx := s.ClientContextForTest() 23 | addr := s.WalletForTest() 24 | 25 | providerPath, err := filepath.Abs("../../x/provider/testdata/provider.yaml") 26 | s.Require().NoError(err) 27 | 28 | providerPath2, err := filepath.Abs("../../x/provider/testdata/provider2.yaml") 29 | s.Require().NoError(err) 30 | 31 | ctx := context.Background() 32 | 33 | // create provider 34 | _, err = clitestutil.TxCreateProviderExec( 35 | ctx, 36 | cctx, 37 | providerPath, 38 | cli.TestFlags(). 39 | WithFrom(addr.String()). 40 | WithGasAutoFlags(). 41 | WithSkipConfirm(). 42 | WithBroadcastModeBlock()..., 43 | ) 44 | s.Require().NoError(err) 45 | s.Require().NoError(s.Network().WaitForNextBlock()) 46 | 47 | // test query providers 48 | resp, err := clitestutil.QueryProvidersExec( 49 | ctx, 50 | cctx, 51 | cli.TestFlags(). 52 | WithOutputJSON()..., 53 | ) 54 | s.Require().NoError(err) 55 | 56 | out := &types.QueryProvidersResponse{} 57 | err = cctx.Codec.UnmarshalJSON(resp.Bytes(), out) 58 | s.Require().NoError(err) 59 | s.Require().Len(out.Providers, 1, "Provider Creation Failed") 60 | providers := out.Providers 61 | s.Require().Equal(addr.String(), providers[0].Owner) 62 | 63 | // test query provider 64 | createdProvider := providers[0] 65 | resp, err = clitestutil.QueryProviderExec( 66 | ctx, 67 | cctx, 68 | cli.TestFlags(). 69 | With(createdProvider.Owner). 70 | WithOutputJSON()..., 71 | ) 72 | s.Require().NoError(err) 73 | 74 | var provider types.Provider 75 | err = cctx.Codec.UnmarshalJSON(resp.Bytes(), &provider) 76 | s.Require().NoError(err) 77 | s.Require().Equal(createdProvider, provider) 78 | 79 | // test updating provider 80 | _, err = clitestutil.TxUpdateProviderExec( 81 | ctx, 82 | cctx, 83 | providerPath2, 84 | cli.TestFlags(). 85 | WithFrom(addr.String()). 86 | WithGasAutoFlags(). 87 | WithSkipConfirm(). 88 | WithBroadcastModeBlock()..., 89 | ) 90 | s.Require().NoError(err) 91 | 92 | s.Require().NoError(s.Network().WaitForNextBlock()) 93 | 94 | resp, err = clitestutil.QueryProviderExec( 95 | ctx, 96 | cctx, 97 | cli.TestFlags(). 98 | With(createdProvider.Owner). 99 | WithOutputJSON()..., 100 | ) 101 | s.Require().NoError(err) 102 | 103 | var providerV2 types.Provider 104 | err = cctx.Codec.UnmarshalJSON(resp.Bytes(), &providerV2) 105 | s.Require().NoError(err) 106 | s.Require().NotEqual(provider.HostURI, providerV2.HostURI) 107 | } 108 | -------------------------------------------------------------------------------- /x/market/handler/keepers.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "context" 5 | "time" 6 | 7 | sdk "github.com/cosmos/cosmos-sdk/types" 8 | "github.com/cosmos/cosmos-sdk/x/authz" 9 | authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" 10 | govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" 11 | 12 | atypes "pkg.akt.dev/go/node/audit/v1" 13 | dtypes "pkg.akt.dev/go/node/deployment/v1" 14 | dbeta "pkg.akt.dev/go/node/deployment/v1beta4" 15 | escrowid "pkg.akt.dev/go/node/escrow/id/v1" 16 | etypes "pkg.akt.dev/go/node/escrow/types/v1" 17 | ptypes "pkg.akt.dev/go/node/provider/v1beta4" 18 | 19 | "pkg.akt.dev/node/x/market/keeper" 20 | ) 21 | 22 | type EscrowKeeper interface { 23 | AccountCreate(ctx sdk.Context, id escrowid.Account, owner sdk.AccAddress, deposits []etypes.Depositor) error 24 | AccountDeposit(ctx sdk.Context, id escrowid.Account, deposits []etypes.Depositor) error 25 | AccountClose(ctx sdk.Context, id escrowid.Account) error 26 | PaymentCreate(ctx sdk.Context, id escrowid.Payment, provider sdk.AccAddress, rate sdk.DecCoin) error 27 | PaymentWithdraw(ctx sdk.Context, id escrowid.Payment) error 28 | PaymentClose(ctx sdk.Context, id escrowid.Payment) error 29 | AuthorizeDeposits(sctx sdk.Context, msg sdk.Msg) ([]etypes.Depositor, error) 30 | } 31 | 32 | // ProviderKeeper Interface includes provider methods 33 | type ProviderKeeper interface { 34 | Get(ctx sdk.Context, id sdk.Address) (ptypes.Provider, bool) 35 | WithProviders(ctx sdk.Context, fn func(ptypes.Provider) bool) 36 | } 37 | 38 | type AuditKeeper interface { 39 | GetProviderAttributes(ctx sdk.Context, id sdk.Address) (atypes.AuditedProviders, bool) 40 | } 41 | 42 | // DeploymentKeeper Interface includes deployment methods 43 | type DeploymentKeeper interface { 44 | GetGroup(ctx sdk.Context, id dtypes.GroupID) (dbeta.Group, bool) 45 | OnBidClosed(ctx sdk.Context, id dtypes.GroupID) error 46 | OnLeaseClosed(ctx sdk.Context, id dtypes.GroupID) (dbeta.Group, error) 47 | } 48 | 49 | type AuthzKeeper interface { 50 | DeleteGrant(ctx context.Context, grantee sdk.AccAddress, granter sdk.AccAddress, msgType string) error 51 | GetAuthorization(ctx context.Context, grantee sdk.AccAddress, granter sdk.AccAddress, msgType string) (authz.Authorization, *time.Time) 52 | SaveGrant(ctx context.Context, grantee sdk.AccAddress, granter sdk.AccAddress, authorization authz.Authorization, expiration *time.Time) error 53 | GetGranteeGrantsByMsgType(ctx context.Context, grantee sdk.AccAddress, msgType string, onGrant authzkeeper.OnGrantFn) 54 | } 55 | 56 | type BankKeeper interface { 57 | SpendableCoins(ctx context.Context, addr sdk.AccAddress) sdk.Coins 58 | SpendableCoin(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin 59 | } 60 | 61 | // Keepers include all modules keepers 62 | type Keepers struct { 63 | Escrow EscrowKeeper 64 | Market keeper.IKeeper 65 | Deployment DeploymentKeeper 66 | Provider ProviderKeeper 67 | Audit AuditKeeper 68 | Account govtypes.AccountKeeper 69 | Authz AuthzKeeper 70 | Bank BankKeeper 71 | } 72 | --------------------------------------------------------------------------------