Skip to content

Commit

Permalink
solved merge conflict for PR #300
Browse files Browse the repository at this point in the history
  • Loading branch information
arnabghose997 committed Nov 25, 2023
2 parents 3fdeade + bbe698d commit 291a7ce
Show file tree
Hide file tree
Showing 161 changed files with 19,496 additions and 9,723 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: 1.18.5
go-version: 1.20.11
id: go

- name: Check out code into the Go module directory
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/gosec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Gosec
on:
pull_request:

jobs:
tests:
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- name: Checkout Source
uses: actions/checkout@v2

- name: Run Gosec Security Scanner
uses: cosmos/gosec@master
with:
args: -exclude=G705 ./...
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
jobs:
release-binaries-github:
name: Release Binaries to Github
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -22,7 +22,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.20

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
Expand All @@ -49,7 +49,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.20

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.dll
*.so
*.dylib
*.wasm

# Test binary, built with `go test -c`
*.test
Expand All @@ -29,3 +30,8 @@ dist/

# Misc
.cache/
__pycache__
artifacts
node_modules
package-lock.json
generated-ts
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ env:

before:
hooks:
- go mod tidy -compat=1.18
- go mod tidy -compat=1.19

builds:
- id: ubuntu-amd64
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.18
FROM golang:1.20

# Set up dependencies
ENV PACKAGES curl make git libc-dev bash gcc python3 jq
Expand Down
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2022 Hypermine Limited
Copyright 2023 Hypermine Limited

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -198,4 +198,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
44 changes: 34 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ COMMIT := $(shell git rev-parse --short HEAD)

BUILD_DIR ?= $(CURDIR)/build
HIDNODE_CMD_DIR := $(CURDIR)/cmd/hid-noded
GO_MINOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)

GOBIN = $(shell go env GOPATH)/bin
GOOS = $(shell go env GOOS)
Expand All @@ -17,7 +18,8 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=hid-node \
-X github.com/cosmos/cosmos-sdk/version.AppName=hid-node \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TM_VERSION)
-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TM_VERSION) \
-X github.com/hypersign-protocol/hid-node/app.ProposalsEnabled=true # enable x/wasm based proposals

BUILD_FLAGS := -ldflags '$(ldflags)'

Expand All @@ -28,30 +30,52 @@ export GO111MODULE=on
###############################################################################
.PHONY: build install

all: proto-gen swagger-docs-gen build
all: proto-gen-go proto-gen-swagger build

go-version-check:
ifneq ($(GO_MINOR_VERSION),20)
@echo "ERROR: Go version 1.20 is required to build hid-noded binary"
exit 1
endif

go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
@go mod verify

install: go.sum
install: go-version-check go.sum
go install -mod=readonly $(BUILD_FLAGS) $(HIDNODE_CMD_DIR)

build:
build: go-version-check
go build -mod=readonly $(BUILD_FLAGS) -o $(BUILD_DIR)/hid-noded $(HIDNODE_CMD_DIR)

###############################################################################
### Proto ###
###############################################################################

proto-gen:
proto-gen-go:
@echo "Generating golang code from protobuf"
./scripts/protocgen.sh
./scripts/protocgen-go.sh

proto-gen-swagger:
@echo "Generating swagger docs"
./scripts/protoc-swagger-gen.sh

proto-gen-ts:
@echo "Generating typescript code from protobuf"
./scripts/protocgen-ts.sh

###############################################################################
### Docs ###
### Docker ###
###############################################################################
DOCKER_IMAGE_NAME := hid-node-image

swagger-docs-gen:
@echo "Generating swagger docs"
./scripts/protoc-swagger-gen.sh
docker-all: docker-build docker-run

docker-build:
docker build -t $(DOCKER_IMAGE_NAME) .

docker-run:
docker run --rm -d \
-p 26657:26657 -p 1317:1317 -p 26656:26656 -p 9090:9090 \
--name hid-node-container \
$(DOCKER_IMAGE_NAME) start
53 changes: 26 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,51 +21,48 @@ The Hypersign Identity Network is a permissionless blockchain network to manage

Following are the prerequisites that needs to be installed:

- Golang (Installation Guide: https://go.dev/doc/install) (version: 1.18+)
- Golang (Installation Guide: https://go.dev/doc/install) (version: 1.20)
- make
- jq

## Get started

### Local
### Local Binary

Clone the repository and install the binary:

```sh
git clone https://github.com/hypersign-protocol/hid-node.git
cd hid-node
make install
```

The binary `hid-noded` will be generated in `$GO_PATH/bin` directory. To explore its functionalities, type `hid-noded --help` in a seperate terminal window.

#### Running the Blockchain

To start a single-node blockchain, run the following command to initialize the node:

```sh
sh ./scripts/localnet-single-node/setup.sh
```
1. Clone this repository and install the binary:
```sh
git clone https://github.com/hypersign-protocol/hid-node.git
cd hid-node
make install
```

> Note: The above script requires `jq` to be installed.
> The binary `hid-noded` is usually generated in `$HOME/go/bin` directory. Run `hid-noded --help` to explore its functionalities
Run the hid-node:
2. Run the following script to setup a single-node blockchain. Please note that the following script requires `jq` to be installed.
```sh
bash ./scripts/localnet-single-node/setup.sh
```

```sh
hid-noded start --home ~/.hid-node
```
3. Start `hid-noded`:
```sh
hid-noded start
```

### Docker

To run a single node `hid-node` docker container, run the following:
To run a single node `hid-node` docker container, follow the below steps:

1. Pull the image:
```sh
docker pull ghcr.io/hypersign-protocol/hid-node:latest
```

2. Open a separate terminal window. Run the node:
2. Run the following:
```sh
docker run -it ghcr.io/hypersign-protocol/hid-node start
docker run --rm -d \
-p 26657:26657 -p 1317:1317 -p 26656:26656 -p 9090:9090 \
--name hid-node-container \
ghcr.io/hypersign-protocol/hid-node start
```

## Documentation
Expand All @@ -76,3 +73,5 @@ To run a single node `hid-node` docker container, run the following:
| Credential Schema | https://docs.hypersign.id/self-sovereign-identity-ssi/schema |
| Verifiable Credential Status | https://docs.hypersign.id/self-sovereign-identity-ssi/verifiable-credential-vc/credential-revocation-registry |


Please contact [[email protected]](mailto:[email protected]) for consulting and integration
72 changes: 72 additions & 0 deletions app/ante.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package app

import (
"github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/ibc-go/v4/modules/core/keeper"

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
ibcante "github.com/cosmos/ibc-go/v4/modules/core/ante"
ssiante "github.com/hypersign-protocol/hid-node/x/ssi/ante"
)

// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
// channel keeper.
type HandlerOptions struct {
ante.HandlerOptions

IBCKeeper *keeper.Keeper
WasmConfig *wasmTypes.WasmConfig
TXCounterStoreKey sdk.StoreKey
SsiKeeper ssiante.SsiKeeper
}

func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
if options.AccountKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler")
}
if options.BankKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler")
}
if options.SignModeHandler == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
}
if options.WasmConfig == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "wasm config is required for ante builder")
}
if options.TXCounterStoreKey == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "tx counter key is required for ante builder")
}
if options.SsiKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "ssi keeper is required for ante builder")
}

sigGasConsumer := options.SigGasConsumer
if sigGasConsumer == nil {
sigGasConsumer = ante.DefaultSigVerificationGasConsumer
}

anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(),
wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit), // after setup context to enforce limits early
wasmkeeper.NewCountTXDecorator(options.TXCounterStoreKey),
ante.NewRejectExtensionOptionsDecorator(),
ssiante.NewSSITxDecorator(), // SSITxDecorator MUST always be called before MempoolFeeDecorator
ssiante.NewMempoolFeeDecorator(), // MempoolFeeDecorator MUST always be called before DeductFeeDecorator
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
ssiante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.SsiKeeper),
ante.NewSetPubKeyDecorator(options.AccountKeeper),
ante.NewValidateSigCountDecorator(options.AccountKeeper),
ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer),
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
ibcante.NewAnteDecorator(options.IBCKeeper),
}

return sdk.ChainAnteDecorators(anteDecorators...), nil
}
Loading

0 comments on commit 291a7ce

Please sign in to comment.