Skip to content

Commit

Permalink
v1.0.1 Rhine River (#52)
Browse files Browse the repository at this point in the history
* refactor: migrate files from evm-module

* refactor: migrate x/evm and x/feemarket to chain repo

* refactor: migrate files from evm-module repo

* refactor: migrate files from evm-module repo

* refactor: migrate files from evm-module repo

* refactor: migrate files from evm-module repo

* refactor: migrate files from evm-module repo

* refactor: migrate files from evm-module repo

* refactor: migrate librustgo into chain repo

* refactor: cleanup go-sgxvm

* refactor: add sgx-sdk as a submodule

* refactor: set sgx-sdk version

* WIP deb dir

* WIP deb dockerfile, bash script
Fix deb systemd run command

* fix: restore vesting test

* WIP build-deb pipeline

* Fix build_deb.sh #1

* Fix build_deb.sh #2

* fix: fix build and startup issues

* Version number does not start with digit

* artifact path

* Implement draft of x/did module

* tests: start adding tests for x/did module

* tests: add more tests for DID create

* tests: extend tests

* tests: add test for DID deactivation

* tests: add tests for updating DID

* tests: extend keeper tests

* chore: add did json rpc

* fix: comments

* refactor: remove redundant submodule

* fix: fix makefile

* refactor: remove evm-module

* feat: add debug commands

* fix: trying to fix issue with verification method

* refactor: sort imports

* add: add command to generate sample payload for DID document

* chore: add unit tests in did types

* chore: add unit tests for did document payload

* chore

* refactor: update constants

* feat: add proto file for did resource

* feat: add types/utils for DID resource

* feat: add keeper methods for DID resource

* fix: fix compilation issues

* feat: add query for did resource

* feat: extend genesis impl

* feat: add cli commands for did resources

* feat: register createResource command

* refactor: merge debug commands

* feat: add draft of sample resource debug cmd

* test: add basic test for did resource creation

* refactor: comment test

* refactor: refactor to remove redundant args

* feat: register sample did resource cmd

* feat: register codec for MsgCreateResource

* hotfix: remove empty submodule

* refactor: remove empty submodule

* feat: add `did` and `util` namespaces to default list

* refactor: add keeper methods

* feat: connect DIDKeeper to EVMKeeper

* feat: pass DIDKeeper to connector

* feat: add draft of identity precompile

* fix: fixing compilation issues

* fix: fixing complication issues

* fix: fix compilation issues

* refactor: add comments and merge small files into one

* refactor: remove unused crate

* fix: fix compilation issue

* refactoring: cleanup tx handler

* feat: provide querier to precompileset

* refactor: moving precompiles into sgxvm (in progress)

* refactor: moving precompiles into sgxvm (in progress)

* refactor: fix warnings

* fix: fix compilation issue

* fix: return datacopy precompile

* refactor: prettify

* feat: provide GoQuerier to Identity precompile

* feat: add function to encode request for credentials verification

* feat: add draft of precompile for VC verification

* feat: add request for obtaining verification material

* feat: pass GoQueroer

* feat: add query for verification methods

* feat: finish precompile part

* feat: add GetVerificationMethods function to connector

* feat: implement connector for DID

* test: prepare test for VC precompile

* test: add test for getting verification methods using connector

* chore: update mod reference

* chore: refactor reference to simapp

* chore: fix referencing issue

* test: add draft of credentials contract and test

* feat: increase default balances

* test: cleanup

* test: add basic test for interaction with VC.sol

* chore: reformat code

* test: add draft of integration test

* chore: uncomment

* refactor: remove unused precompile crates

* test: add actual data

* fix: fixed precompile issue

* refactor: remove todo's and reformat the code

* refactor: reduce code size

* refactor: remove unused derived trait

* refactor: remove unused submodule

* chore: fix app.go

* chore: upgrade library and module

* chore: upgrade testing library

* fix app.go to include consensus keeper

* chore: fix iavl && exp/slices error

* fix: ante handler

* test: update test contract for VC

* test: uncomment test for gas estimation

* chore: update moudles

* fix: fix protobuf issue

* chore: remove duplicate sethook for govkeeper

* refactor: add comments + reduce code size

* refactor: use ENCLAVE_HOME instead of CHAIN_HOME

* refactor: refactor tests

* refactor: resolve todo

* chore: fix vesting module unit testing

* chore: fix setupWithT

* chore: fix chain Id

* chore: add update to date eip712

* chore: set fees acount to be gas amount multiplied

* refactor: add nosgx build flag

* refactor: cleanup

* feat: add draft of command for macos build

* chore: fix unit test failure in ante handler

* chore: fix eip unit test issue

* chore: fix chainId issue

* fix: trying to fix issue with build tags

* fix: fix build issue for linux amd64

* feat: add command for build for windows

* refactor: remove sgx-related commands from swisstronikcli

* feat: add build instructions for arm64 and amd64

* fix: typo fix

* First CI try

* CI #2

* CI #3

* CI #4

* CI #5

* CI #6 Update upload-artifact to v3

* Added badge to README, switch to tag-only runs, enable manual triggers

* fix: quick fix for identity precompile

* refactor: remove redundant debug logs and comments

* refactor: create a separate directory for sgxvm enclave

* fix: fix compilation issues during refactor

* refactor: remove sgx-sdk submodule

* refactor: remove sgx-sdk submodule from go-sgxvm

* refactor: move sgx-sdk into sgxvm directory

* refactor: set submodule version

* refactor: wip: migrating to a new structure

* refactor: apply new structure

* chore: update README

* docs: update README

* refactor: simplify build process

* fix: trying to fix issue with protobuf generation

* fix: fix issue with cyclic import

* test: update sign_tx_test.go

* chore: update protobuf & enclave

* refactor: use cometbft instead of tendermint

* fix: fix build issue

* chore: add nbf validation

* chore: fix comparison of nbf date

* fix: fix build issues in tests

* feat: cache node public key

* chore: add issuer in identiy return RLP, decode it in VC.sol

* test: small test fixes

* refactor: use cometbft instead of tendermint

* refactor: update protobuf

* chore: update wrapper dyn lib

* refactor: remove unused import

* test: update VC.sol test contract

* test: add test for nbf field of JWT proof

* chore: update protobuf and dyn lib

* refactor: return data from precompile in ABI format

* test: add check for returned data from VC.sol

* chore: update protobuf

* fix: restore tests

* feat: add method to obtain controlled DIDs by provided verification material

* chore: set eth key type to legacy Cdc

* feat: add method to add and remove associated did

* feat: use AddDIDControlledBy and RemoveControlledDID calls

* feat: add query for controlled dids

* feat: add query for all controlled documents

* test: add basic test for indexing verification material

* test: update test to check verification method index

* feat: add did_documentsControlledBy request

* test: add test for adding and removing VM from index

* feat: add cli command to query all controlled docs

* fix: trying to fix docker build

* fix: revert Cargo.lock

* refactor: rename did tx commands

* fix: fix docker build

* chore: setup handler

* chore: add eip

* refactor: update version to v1.0.1

* Iterate on deb builds, port changes to Dockerfile

* Fix env

* Enclave home, remove /opt/swisstronik on rm

* feat: take ENCLAVE_HOME from runtime

* Enclave home in systemd file

* Remove SGX-breaking options from systemd

* Modify docs accordingly

* refactor: add SEED_HOME env var

* Added SEED_HOME env var to systemd service

* chore: add distribution param keeper and feemarket keeper module check consPram Block item

* chore: add default statement

* Fix deb pipeline to react to tags, get version from git tag

* feat: update dylib

* refactor: rename comments

* refactor: update comments and names

* fix: fix issue with path to enclave file

* fix: restore ibc tests

* refactor: refactor test utils

* refactor: remove redundant code

---------

Co-authored-by: Denis <[email protected]>
Co-authored-by: kenta92115 <[email protected]>
  • Loading branch information
3 people authored Nov 23, 2023
1 parent a7acc0f commit c9c6550
Show file tree
Hide file tree
Showing 550 changed files with 132,213 additions and 2,225 deletions.
6 changes: 5 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
./docker/
./.git/
./.git/
./build
./vscode
./idea
./github
72 changes: 72 additions & 0 deletions .github/workflows/build-ci-multiplatform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Build CI multiplatform

on:
push:
tags:
- "*"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:


jobs:
linux-amd64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: 'stable'
- name: "Build linux-amd64"
run: make build-linux-cli-amd
- name: "Upload file"
uses: actions/upload-artifact@v3
with:
name: swisstronikcli-linux-amd64
path: build/swisstronikcli-linux-amd64

macos-amd64:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: 'stable'
- name: "Build macos-amd64"
run: make build-macos-cli-amd
- name: "Upload file"
uses: actions/upload-artifact@v3
with:
name: swisstronikcli-macos-amd64
path: build/swisstronikcli-macos-amd64

macos-arm64:
runs-on: macos-latest-xlarge
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: 'stable'
- name: "Build macos-arm64"
run: make build-macos-cli-arm
- name: "Upload file"
uses: actions/upload-artifact@v3
with:
name: swisstronikcli-macos-arm64
path: build/swisstronikcli-macos-arm64



windows-amd64:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: 'stable'
- name: "Build windows-amd64"
run: make build-windows-cli
- name: "Upload file"
uses: actions/upload-artifact@v3
with:
name: swisstronikcli-windows
path: build/swisstronikcli-windows
51 changes: 51 additions & 0 deletions .github/workflows/build-deb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build Deb

on:
push:
tags:
- "*"

jobs:
build-deb:
runs-on: ubuntu-latest
env:
SGX_MODE: HW
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get version
id: get_version
uses: battila7/get-version-action@v2

- name: Build .deb Package Image
uses: docker/build-push-action@v4
with:
file: ./docker/node.Dockerfile
context: .
load: true
tags: deb_build
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
SGX_MODE=HW
ENCLAVE_HOME="/usr/lib/"
target: build-deb
- name: Run .deb Package Image
run: |
docker run -e VERSION=${{ steps.get_version.outputs.version-without-v }} -v $GITHUB_WORKSPACE/build:/build deb_build
cp build/swisstronik_${{ steps.get_version.outputs.version-without-v }}_amd64.deb swisstronik_${{ steps.get_version.outputs.version-without-v }}_amd64.deb
- uses: actions/upload-artifact@v3
with:
name: swisstronik_${{ steps.get_version.outputs.version-without-v }}_amd64.deb
path: swisstronik_${{ steps.get_version.outputs.version-without-v }}_amd64.deb
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "external/evm-module"]
path = external/evm-module
url = https://github.com/SigmaGmbH/swisstronik-evm-module.git
[submodule "sgxvm/sgx-sdk"]
path = sgxvm/sgx-sdk
url = https://github.com/apache/teaclave-sgx-sdk.git
119 changes: 111 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION := 1.0.0
VERSION := v1.0.1
COMMIT := $(shell git log -1 --format='%H')
ENCLAVE_HOME ?= $(HOME)/.swisstronik-enclave

Expand All @@ -7,14 +7,65 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=swisstronik \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT)

###############################################################################
### Build ###
###############################################################################

BUILD_FLAGS := -ldflags '$(ldflags)'
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf
PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git)
PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git)

###############################################################################
### Protobuf ###
###############################################################################

# ------
# NOTE: Link to the tendermintdev/sdk-proto-gen docker images:
# https://hub.docker.com/r/tendermintdev/sdk-proto-gen/tags
#
protoVer=0.11.6
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace --user 0 $(protoImageName)
# ------
# NOTE: cosmos/proto-builder image is needed because clang-format is not installed
# on the tendermintdev/sdk-proto-gen docker image.
# Link to the cosmos/proto-builder docker images:
# https://github.com/cosmos/cosmos-sdk/pkgs/container/proto-builder
#
protoCosmosVer=0.11.2
protoCosmosName=ghcr.io/cosmos/proto-builder:$(protoCosmosVer)
protoCosmosImage=$(DOCKER) run --network host --rm -v $(CURDIR):/workspace --workdir /workspace $(protoCosmosName)
# ------
# NOTE: Link to the yoheimuta/protolint docker images:
# https://hub.docker.com/r/yoheimuta/protolint/tags
#
protolintVer=0.42.2
protolintName=yoheimuta/protolint:$(protolintVer)
protolintImage=$(DOCKER) run --network host --rm -v $(CURDIR):/workspace --workdir /workspace $(protolintName)

proto-all: proto-format proto-lint proto-gen

proto-gen:
@echo "Generating Protobuf files"
$(protoImage) sh ./scripts/protocgen.sh


proto-format:
@echo "Formatting Protobuf files"
$(protoCosmosImage) find ./ -name *.proto -exec clang-format -i {} \;

# NOTE: The linter configuration lives in .protolint.yaml
proto-lint:
@echo "Linting Protobuf files"
$(protolintImage) lint ./proto

proto-check-breaking:
@echo "Checking Protobuf files for breaking changes"
$(protoImage) buf breaking --against $(HTTPS_GIT)#branch=main


.PHONY: proto-all proto-gen proto-gen-any proto-format proto-lint proto-check-breaking

###############################################################################
### Build ###
###############################################################################

all: install

Expand All @@ -25,13 +76,33 @@ install: go.sum
go install -mod=readonly $(BUILD_FLAGS) ./cmd/swisstronikd

build: go.sum
$(MAKE) -C go-sgxvm build
go build -mod=mod $(BUILD_FLAGS) -tags osusergo,netgo -o build/swisstronikd ./cmd/swisstronikd

###############################################################################
### Build commands for CLI (without SGX support) ###
###############################################################################

build-cli: go.sum
go build -mod=mod $(BUILD_FLAGS) -tags osusergo,netgo,nosgx -o build/$(BINARY_NAME) ./cmd/swisstronikd

build-linux:
GOOS=linux GOARCH=$(if $(findstring aarch64,$(shell uname -m)) || $(findstring arm64,$(shell uname -m)),arm64,amd64) $(MAKE) build

build-enclave:
$(MAKE) -C external/evm-module build-librustgo
build-macos-cli-amd:
BINARY_NAME=swisstronikcli-macos-amd64 GOOS=darwin GOARCH=amd64 $(MAKE) build-cli

build-macos-cli-arm:
BINARY_NAME=swisstronikcli-macos-arm64 GOOS=darwin GOARCH=arm64 $(MAKE) build-cli

build-linux-cli-amd:
BINARY_NAME=swisstronikcli-linux-amd64 GOOS=linux GOARCH=amd64 $(MAKE) build-cli

build-linux-cli-arm:
BINARY_NAME=swisstronikcli-linux-arm64 GOOS=linux GOARCH=arm64 $(MAKE) build-cli

build-windows-cli:
BINARY_NAME=swisstronikcli-windows GOOS=windows GOARCH=amd64 $(MAKE) build-cli

go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
Expand All @@ -44,3 +115,35 @@ build-docker-local:
docker build -f docker/node.Dockerfile -t swisstronik --target=local-node --build-arg SGX_MODE=SW .

.PHONY: all install build build-linux build-enclave test build-docker-local

###############################################################################
### Tests ###
###############################################################################

test: test-unit
test-all: test-unit test-race
PACKAGES_UNIT=$(shell go list ./... | grep -Ev 'vendor|importer')
TEST_PACKAGES=./...
TEST_TARGETS := test-unit test-unit-cover test-race

# Test runs-specific rules. To add a new test target, just add
# a new rule, customise ARGS or TEST_PACKAGES ad libitum, and
# append the new rule to the TEST_TARGETS list.
test-unit: ARGS=-timeout=10m -race
test-unit: TEST_PACKAGES=$(PACKAGES_UNIT)

test-race: ARGS=-race
test-race: TEST_PACKAGES=$(PACKAGES_NOSIMULATION)
$(TEST_TARGETS): run-tests

test-unit-cover: ARGS=-timeout=10m -race -coverprofile=coverage.txt -covermode=atomic
test-unit-cover: TEST_PACKAGES=$(PACKAGES_UNIT)

run-tests:
ifneq (,$(shell which tparse 2>/dev/null))
go test -mod=readonly -json $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES) | tparse
else
go test -mod=readonly $(ARGS) $(EXTRA_ARGS) $(TEST_PACKAGES)
endif

.PHONY: run-tests test test-all $(TEST_TARGETS)
39 changes: 35 additions & 4 deletions readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,55 @@ Swisstronik is an identity-based hybrid layer-1 blockchain ecosystem.
It lets Web 3.0 and traditional companies build KYC, AML and DPR compliant applications with enhanced data privacy

[![Build local node docker image](https://github.com/SigmaGmbH/swisstronik-chain/actions/workflows/docker-local.yml/badge.svg)](https://github.com/SigmaGmbH/swisstronik-chain/actions/workflows/docker-local.yml)
[![Build CLI multiplatform](https://github.com/SigmaGmbH/swisstronik-chain/actions/workflows/build-ci-multiplatform.yml/badge.svg)](https://github.com/SigmaGmbH/swisstronik-chain/actions/workflows/build-ci-multiplatform.yml)

## Build

### Prerequisites

Install submodules by running
```sh
make init
```

Build an enclave. For testing purposes you can build enclave in simulation mode by adding `SGX_MODE=SW`. To specify path for output with compiled enclave you can use `ENCLAVE_HOME` env arg.
### Build `swisstronikd` to run the node

To build `swisstronikd` binary, which can be used to run node and interact with SGX-dependent functionality, use the following command:
```sh
make build-enclave
make build
```

Build a chain
This command will build binary with SGX in hardware mode (your hardware should support SGX to run binary in this mode) and will put enclave file (`enclave.signed.so`) to `$HOME/.swisstronik-enclave` directory.

If you want to setup local node for testing purposes without possibility to connect to Swisstronik testnet as full node, you can build `swisstronikd` in simulation mode using the following command:
```sh
make build
SGX_MODE=SW make build
```

Also, if you want to put enclave file (`enclave.signed.so`) to other directory, you can specify `ENCLAVE_HOME` env variable. For example:
```sh
ENCLAVE_HOME=/tmp/enclave-directory make build
```

### Build `swisstronikdcli`

If your OS / hardware doesn't support SGX even in simulation mode, you can build CLI which will allow you:
- sending queries
- transactions
- manage your keys
- debug commands, such as address conversion

Below you can see table with build commands for each OS / CPU

| OS / arch | command |
|-----------------------|-----------------------------|
| linux amd64 | `make build-linux-cli-amd` |
| linux arm64 | `make build-macos-cli-arm` |
| macos with M1 chip | `make build-macos-cli-arm` |
| macos with Intel chip | `make build-macos-cli-amd` |
| windows | `make build-windows-cli` |


## Docker

### Local development node
Expand Down
Loading

0 comments on commit c9c6550

Please sign in to comment.