Skip to content

Commit

Permalink
Merge pull request #119 from SigmaGmbH/develop
Browse files Browse the repository at this point in the history
Update `master` branch with v1.0.3
  • Loading branch information
MikkySnow authored Jul 23, 2024
2 parents 59e829e + 3f8969c commit dd8428f
Show file tree
Hide file tree
Showing 380 changed files with 45,275 additions and 32,584 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build-ci-multiplatform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Build CI multiplatform

on:
push:
tags:
- "*"
# Allows you to run this workflow manually from the Actions tab
branches: [ develop, '**-release', 'feat/sdi-changes' ]
workflow_dispatch:
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}


jobs:
Expand All @@ -25,7 +25,7 @@ jobs:
path: build/swisstronikcli-linux-amd64

macos-amd64:
runs-on: macos-latest
runs-on: macos-13
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
Expand All @@ -40,7 +40,7 @@ jobs:
path: build/swisstronikcli-macos-amd64

macos-arm64:
runs-on: macos-latest-xlarge
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
Expand Down
26 changes: 19 additions & 7 deletions .github/workflows/build-deb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,29 @@ name: Build Deb

on:
push:
tags:
- "*"
branches: [ develop, '**-release', 'release-**' ]
workflow_dispatch:
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}

jobs:
build-deb:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
SGX_MODE: HW
VERSION: "1.0.3"
PRODUCTION_MODE: true
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Retrieve the secret and decode it to a file
env:
ENCLAVE_PK_BASE64: ${{ secrets.ENCLAVE_PK_BASE64 }}
run: |
rm sgxvm/Enclave_dev_private.pem || true
rm sgxvm/Enclave_private.pem || true
echo $ENCLAVE_PK_BASE64 | base64 --decode > sgxvm/Enclave_private.pem
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

Expand All @@ -40,12 +51,13 @@ jobs:
build-args: |
SGX_MODE=HW
ENCLAVE_HOME="/usr/lib/"
PRODUCTION_MODE=true
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
docker run -e VERSION=${{ env.VERSION }} -v $GITHUB_WORKSPACE/build:/build deb_build
cp build/swisstronik_${{ env.VERSION }}_amd64.deb swisstronik_${{ env.VERSION }}_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
name: swisstronik_${{ env.VERSION }}_amd64.deb
path: swisstronik_${{ env.VERSION }}_amd64.deb
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@ release/
.DS_Store
*swtr_seed
build/
.testnets/
.testnets/
**.uuid
vendor
**quote.dat
sgxvm/Enclave_private.pem

# Dynamic libraries
**libsgx_wrapper**
**libsgx_attestation_wrapper**
27 changes: 24 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
VERSION := v1.0.1
VERSION := v1.0.3
COMMIT := $(shell git log -1 --format='%H')
ENCLAVE_HOME ?= $(HOME)/.swisstronik-enclave
PRODUCTION_MODE ?= false

ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=swisstronik \
-X github.com/cosmos/cosmos-sdk/version.ServerName=swisstronikd \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT)

ldflags_static = -X github.com/cosmos/cosmos-sdk/version.Name=swisstronik \
-X github.com/cosmos/cosmos-sdk/version.ServerName=swisstronikd \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-w -s -linkmode 'external' -extldflags=-static

BUILD_FLAGS := -ldflags '$(ldflags)'
BUILD_FLAGS_STATIC := -ldflags "$(ldflags_static)"
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)
Expand Down Expand Up @@ -79,13 +87,26 @@ build: go.sum
$(MAKE) -C go-sgxvm build
go build -mod=mod $(BUILD_FLAGS) -tags osusergo,netgo -o build/swisstronikd ./cmd/swisstronikd

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

build_attestation_server: go.sum
AS_MODE=true $(MAKE) -C go-sgxvm build_AS

build_attestation_server_d: go.sum
AS_MODE=true $(MAKE) -C go-sgxvm build_AS_d

###############################################################################
### 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-cli-linux-static: go.sum
CGO_ENABLED=1 go build -mod=mod $(BUILD_FLAGS_STATIC) -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

Expand All @@ -96,10 +117,10 @@ 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
BINARY_NAME=swisstronikcli-linux-amd64 GOOS=linux GOARCH=amd64 $(MAKE) build-cli-linux-static

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

build-windows-cli:
BINARY_NAME=swisstronikcli-windows GOOS=windows GOARCH=amd64 $(MAKE) build-cli
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,9 @@ Update target with address of your node in `monitoring/prometheus.yml`. This wil
You can start docker containers with prometheus and grafana using docker-compose. To do it, run:
```sh
docker-compose run up -d
```
```


## License

GNU GPL v3, except for "x/compliance" module - please see separate included LICENSE file in "x/compliance" folder for details.
7 changes: 2 additions & 5 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,16 @@ import (
"fmt"
"runtime/debug"

tmlog "github.com/cometbft/cometbft/libs/log"

errorsmod "cosmossdk.io/errors"
tmlog "github.com/cometbft/cometbft/libs/log"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/crypto/types/multisig"
sdk "github.com/cosmos/cosmos-sdk/types"
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"

"swisstronik/crypto/ethsecp256k1"

"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
)

const (
Expand Down
49 changes: 22 additions & 27 deletions app/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ import (
"strings"

sdkmath "cosmossdk.io/math"
kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig"

"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256r1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/crypto/types/multisig"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"

authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"

sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/ethereum/go-ethereum/core/types"
ethparams "github.com/ethereum/go-ethereum/params"

"swisstronik/app"
"swisstronik/app/ante"
Expand All @@ -27,15 +28,9 @@ import (
"swisstronik/tests"
"swisstronik/utils"
evmtypes "swisstronik/x/evm/types"

"github.com/ethereum/go-ethereum/core/types"
ethparams "github.com/ethereum/go-ethereum/params"

banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
)

func (suite AnteTestSuite) TestAnteHandler() {
func (suite *AnteTestSuite) TestAnteHandler() {
var acc authtypes.AccountI
addr, privKey := tests.RandomEthAddressWithPrivateKey()
to := tests.RandomEthAddress()
Expand All @@ -48,7 +43,7 @@ func (suite AnteTestSuite) TestAnteHandler() {
suite.Require().NoError(acc.SetSequence(1))
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)

suite.app.EvmKeeper.SetBalance(suite.ctx, addr, big.NewInt(10000000000))
_ = suite.app.EvmKeeper.SetBalance(suite.ctx, addr, big.NewInt(10000000000))

suite.app.FeeMarketKeeper.SetBaseFee(suite.ctx, big.NewInt(100))
}
Expand Down Expand Up @@ -576,7 +571,7 @@ func (suite AnteTestSuite) TestAnteHandler() {
)

msg.Amount[0].Amount = sdk.NewInt(5)
txBuilder.SetMsgs(msg)
_ = txBuilder.SetMsgs(msg)

return txBuilder.GetTx()
}, false, false, false,
Expand Down Expand Up @@ -609,7 +604,7 @@ func (suite AnteTestSuite) TestAnteHandler() {
)

// Duplicate
txBuilder.SetMsgs(msg, msg)
_ = txBuilder.SetMsgs(msg, msg)

return txBuilder.GetTx()
}, false, false, false,
Expand Down Expand Up @@ -637,7 +632,7 @@ func (suite AnteTestSuite) TestAnteHandler() {
"EIP-712",
)

txBuilder.SetMsgs(msg, msg)
_ = txBuilder.SetMsgs(msg, msg)

return txBuilder.GetTx()
}, false, false, false,
Expand Down Expand Up @@ -669,7 +664,7 @@ func (suite AnteTestSuite) TestAnteHandler() {
}
}

func (suite AnteTestSuite) TestAnteHandlerWithDynamicTxFee() {
func (suite *AnteTestSuite) TestAnteHandlerWithDynamicTxFee() {
addr, privKey := tests.RandomEthAddressWithPrivateKey()
to := tests.RandomEthAddress()

Expand Down Expand Up @@ -929,7 +924,7 @@ func (suite AnteTestSuite) TestAnteHandlerWithDynamicTxFee() {
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)

suite.ctx = suite.ctx.WithIsCheckTx(tc.checkTx).WithIsReCheckTx(tc.reCheckTx)
suite.app.EvmKeeper.SetBalance(suite.ctx, addr, big.NewInt((ethparams.InitialBaseFee+10)*100000))
_ = suite.app.EvmKeeper.SetBalance(suite.ctx, addr, big.NewInt((ethparams.InitialBaseFee+10)*100000))
_, err := suite.anteHandler(suite.ctx, tc.txFn(), false)
if tc.expPass {
suite.Require().NoError(err)
Expand All @@ -942,7 +937,7 @@ func (suite AnteTestSuite) TestAnteHandlerWithDynamicTxFee() {
suite.enableLondonHF = true
}

func (suite AnteTestSuite) TestAnteHandlerWithParams() {
func (suite *AnteTestSuite) TestAnteHandlerWithParams() {
addr, privKey := tests.RandomEthAddressWithPrivateKey()
to := tests.RandomEthAddress()

Expand Down Expand Up @@ -1060,7 +1055,7 @@ func (suite AnteTestSuite) TestAnteHandlerWithParams() {
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)

suite.ctx = suite.ctx.WithIsCheckTx(true)
suite.app.EvmKeeper.SetBalance(suite.ctx, addr, big.NewInt((ethparams.InitialBaseFee+10)*100000))
_ = suite.app.EvmKeeper.SetBalance(suite.ctx, addr, big.NewInt((ethparams.InitialBaseFee+10)*100000))
_, err := suite.anteHandler(suite.ctx, tc.txFn(), false)
if tc.expErr == nil {
suite.Require().NoError(err)
Expand Down Expand Up @@ -1102,7 +1097,7 @@ func (suite *AnteTestSuite) TestConsumeSignatureVerificationGas() {
pubkey cryptotypes.PubKey
params authtypes.Params
}
tests := []struct {
testCases := []struct {
name string
args args
gasConsumed uint64
Expand All @@ -1114,19 +1109,19 @@ func (suite *AnteTestSuite) TestConsumeSignatureVerificationGas() {
{"Multisig", args{sdk.NewInfiniteGasMeter(), multisignature1, multisigKey1, params}, expectedCost1, false},
{"unknown key", args{sdk.NewInfiniteGasMeter(), nil, nil, params}, 0, true},
}
for _, tt := range tests {
for _, tc := range testCases {
sigV2 := signing.SignatureV2{
PubKey: tt.args.pubkey,
Data: tt.args.sig,
PubKey: tc.args.pubkey,
Data: tc.args.sig,
Sequence: 0, // Arbitrary account sequence
}
err := ante.DefaultSigVerificationGasConsumer(tt.args.meter, sigV2, tt.args.params)
err := ante.DefaultSigVerificationGasConsumer(tc.args.meter, sigV2, tc.args.params)

if tt.shouldErr {
if tc.shouldErr {
suite.Require().NotNil(err)
} else {
suite.Require().Nil(err)
suite.Require().Equal(tt.gasConsumed, tt.args.meter.GasConsumed(), fmt.Sprintf("%d != %d", tt.gasConsumed, tt.args.meter.GasConsumed()))
suite.Require().Equal(tc.gasConsumed, tc.args.meter.GasConsumed(), fmt.Sprintf("%d != %d", tc.gasConsumed, tc.args.meter.GasConsumed()))
}
}
}
Expand Down
10 changes: 4 additions & 6 deletions app/ante/eip712.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,17 @@ import (
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"

"swisstronik/crypto/ethsecp256k1"
"swisstronik/ethereum/eip712"
ethermint "swisstronik/types"

ethcrypto "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto/secp256k1"
"github.com/ethereum/go-ethereum/signer/core/apitypes"

evmtypes "swisstronik/x/evm/types"

stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"swisstronik/crypto/ethsecp256k1"
"swisstronik/ethereum/eip712"
ethermint "swisstronik/types"
)

var ethermintCodec codec.ProtoCodecMarshaler
Expand Down
Loading

0 comments on commit dd8428f

Please sign in to comment.