Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* @zeta-chain/protocol-engineering

.github/** @zeta-chain/devops
23 changes: 16 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,25 @@ jobs:
with:
go-version: ${{ matrix.go-version }}
- name: Test
run: go test -race -timeout 25m ./...
run: go test -timeout 25m ./...
lint:
name: lint
runs-on: ubuntu-22.04
timeout-minutes: 15
env:
GO111MODULE: on
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- name: Checkout Source
uses: actions/checkout@v4
with:
go-version: 1.22
- name: golangci-lint
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.56.2
version: v1.63.4
skip-cache: true
10 changes: 1 addition & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,14 @@
.DS_Store
*.swp
*.swo
.vscode
.idea
.env*

# Build
vendor
.vendor-new
observe

# IDE
.vscode/
.idea/
*.iml

bin/
thord
*.exe
.testCoverage.txt
c.out
*.leveldb/
Expand Down
27 changes: 0 additions & 27 deletions .gitlab-ci.yml

This file was deleted.

47 changes: 38 additions & 9 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,53 @@
run:
go: "1.22.11"
timeout: 5m
tests: false # exclude test from linting

linters:
disable-all: true
enable:
- deadcode
- errcheck
- golint
- revive
- ineffassign
- unconvert
- misspell
- goimports
- govet
- stylecheck
- typecheck
- misspell
# - prealloc not really useful imo
- dogsled
- goconst
- bodyclose
- unconvert
- unused
- gci
- gofmt
- whitespace

linters-settings:
gocyclo:
min-complexity: 11
errcheck:
ignore: fmt:.*,io/ioutil:^Read.*,github.com/spf13/cobra:MarkFlagRequired,github.com/spf13/viper:BindPFlag
golint:
min-confidence: 1.1
exclude-functions:
- fmt:.*
- io/ioutil:^Read.*,
- github.com/spf13/cobra:MarkFlagRequired
- github.com/spf13/viper:BindPFlag
exhaustive:
check-generated: false
gci:
# Gci controls Go package import order and makes it always deterministic
# https://golangci-lint.run/usage/linters/#gci
sections:
- standard
- default
- prefix(github.com/zeta-chain/go-tss)
skip-generated: true

issues:
exclude-generated: strict
exclude:
- composite
run:
tests: false
deadline: 15m
timeout: 5m
exclude-dirs: [ ".git", ".github" ]
52 changes: 22 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,50 +1,42 @@
module = gitlab.com/thorchain/tss/go-tss
module = github.com/zeta-chain/go-tss

.PHONY: clear tools install test test-watch lint-pre lint lint-verbose protob build docker-gitlab-login docker-gitlab-push docker-gitlab-build
help: ## List of commands
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

all: lint build
deps: ## Install required dev tooling:
go install github.com/golangci/golangci-lint/cmd/[email protected]
go install github.com/segmentio/[email protected]

clear:
clear

tools:
tools: ## Installs tss tools
go install ./cmd/tss-recovery
go install ./cmd/tss-benchgen
go install ./cmd/tss-benchsign

install: go.sum
install: go.sum ## Compiles & install go-tss binary
go install ./cmd/tss

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

test:
@go test --race -timeout 30m ./...
test: ## Runs tests
@go test -race -timeout 30m ./...

test-watch: clear
@gow -c test -tags testnet -mod=readonly ./...
fmt: ## Formats the code
@echo "Fixing long lines"
@golines -w --max-len=120 --ignore-generated --ignored-dirs=".git" --base-formatter="gofmt" .

unittest:
@go test --race -v -coverprofile=coverage.out -timeout 30m ./...
@go tool cover -func=coverage.out
@echo "Formatting code"
@golangci-lint run --enable-only 'gci' --enable-only 'gofmt' --enable-only 'whitespace' --fix

lint-pre:
@gofumpt -l cmd common keygen keysign messages p2p storage tss # for display
@test -z "$(shell gofumpt -l cmd common keygen keysign messages p2p storage tss)" # cause error
@go mod verify
lint-pre: ## Runs pre-lint check
@test -z $(gofmt -l .)
go mod verify

lint: lint-pre
lint: lint-pre ## Runs linter
@golangci-lint run

lint-verbose: lint-pre
@golangci-lint run -v

protob:
codegen: ## Generates proto
protoc --go_out=module=$(module):. ./messages/*.proto

build: protob
go build ./...

docker-build:
docker build -t registry.gitlab.com/thorchain/tss/go-tss .
.PHONY: deps tools install test fmt lint-pre lint codegen
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# THORCHain TSS
# Zetachain Threshold Signature Scheme (TSS) P2P server

This repository wraps tss-lib with the networking level coordination code used in Thorchain.

### How to contribute

* Create an issue or find an existing issue on https://gitlab.com/thorchain/tss/go-tss/-/issues
* Assign the issue to yourself
* Raise a PR, making sure to include "Resolves #<issue number>" in the description
* Make sure the pipeline is green
* Once PR is approved, the team will merge it to master
- Forked from https://gitlab.com/thorchain/tss/go-tss
- Based on https://github.com/bnb-chain/tss-lib
- Used by `zetaclientd`: https://github.com/zeta-chain/node
2 changes: 1 addition & 1 deletion blame/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (m *Manager) SetPartyInfo(partyMap *sync.Map, partyIDMap map[string]*btss.P
}
m.partyInfo = partyInfo
var localParty btss.Party
m.partyInfo.PartyMap.Range(func(key, value interface{}) bool {
m.partyInfo.PartyMap.Range(func(_, value any) bool {
localParty = value.(btss.Party)
return false
})
Expand Down
7 changes: 4 additions & 3 deletions blame/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
mapset "github.com/deckarep/golang-set"
"github.com/libp2p/go-libp2p/core/peer"

"gitlab.com/thorchain/tss/go-tss/conversion"
"gitlab.com/thorchain/tss/go-tss/messages"
"github.com/zeta-chain/go-tss/conversion"
"github.com/zeta-chain/go-tss/messages"
)

func (m *Manager) tssTimeoutBlame(lastMessageType string, partyIDMap map[string]*btss.PartyID) ([]string, error) {
Expand Down Expand Up @@ -182,7 +182,8 @@ func (m *Manager) TssMissingShareBlame(rounds int, algo messages.Algo) ([]Node,
isUnicast = false

default:
m.logger.Error().Msgf("fail to find the algorithm for this keygen/keysign, set unicast as false by default")
m.logger.Error().
Msgf("fail to find the algorithm for this keygen/keysign, set unicast as false by default")
isUnicast = false
}

Expand Down
2 changes: 1 addition & 1 deletion blame/policy_helper.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package blame

import "gitlab.com/thorchain/tss/go-tss/conversion"
import "github.com/zeta-chain/go-tss/conversion"

// GetBlamePubKeysInList returns the nodes public key who are in the peer list
func (m *Manager) getBlamePubKeysInList(peers []string) ([]string, error) {
Expand Down
11 changes: 8 additions & 3 deletions blame/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ import (
"github.com/libp2p/go-libp2p/core/peer"
. "gopkg.in/check.v1"

"gitlab.com/thorchain/tss/go-tss/conversion"
"gitlab.com/thorchain/tss/go-tss/messages"
"github.com/zeta-chain/go-tss/conversion"
"github.com/zeta-chain/go-tss/messages"
)

var (
testPubKeys = [...]string{"thorpub1addwnpepqtdklw8tf3anjz7nn5fly3uvq2e67w2apn560s4smmrt9e3x52nt2svmmu3", "thorpub1addwnpepqtspqyy6gk22u37ztra4hq3hdakc0w0k60sfy849mlml2vrpfr0wvm6uz09", "thorpub1addwnpepq2ryyje5zr09lq7gqptjwnxqsy2vcdngvwd6z7yt5yjcnyj8c8cn559xe69", "thorpub1addwnpepqfjcw5l4ay5t00c32mmlky7qrppepxzdlkcwfs2fd5u73qrwna0vzag3y4j"}
testPubKeys = [...]string{
"thorpub1addwnpepqtdklw8tf3anjz7nn5fly3uvq2e67w2apn560s4smmrt9e3x52nt2svmmu3",
"thorpub1addwnpepqtspqyy6gk22u37ztra4hq3hdakc0w0k60sfy849mlml2vrpfr0wvm6uz09",
"thorpub1addwnpepq2ryyje5zr09lq7gqptjwnxqsy2vcdngvwd6z7yt5yjcnyj8c8cn559xe69",
"thorpub1addwnpepqfjcw5l4ay5t00c32mmlky7qrppepxzdlkcwfs2fd5u73qrwna0vzag3y4j",
}

testPeers = []string{
"16Uiu2HAm4TmEzUqy3q3Dv7HvdoSboHk5sFj2FH3npiN5vDbJC6gh",
Expand Down
2 changes: 1 addition & 1 deletion blame/round_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package blame
import (
"sync"

"gitlab.com/thorchain/tss/go-tss/messages"
"github.com/zeta-chain/go-tss/messages"
)

type RoundInfo struct {
Expand Down
2 changes: 1 addition & 1 deletion blame/round_mgr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package blame
import (
. "gopkg.in/check.v1"

"gitlab.com/thorchain/tss/go-tss/messages"
"github.com/zeta-chain/go-tss/messages"
)

type RoundMgrSuite struct{}
Expand Down
13 changes: 10 additions & 3 deletions cmd/tss-benchsign/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ func main() {
os.Exit(1)
}
if _, err := os.Stat(makeKeyGenDataFilePath(dir, *endQuorum-1)); os.IsNotExist(err) {
fmt.Printf("Error: insufficient shares for the specified quorum; run tss-benchgen and generate at least %d shares.\n", *endQuorum)
fmt.Printf(
"Error: insufficient shares for the specified quorum; run tss-benchgen and generate at least %d shares.\n",
*endQuorum,
)
os.Exit(1)
}

Expand Down Expand Up @@ -228,7 +231,11 @@ func printSummary(results [][]result) {

// ----- //

func loadKeyGenData(dir string, qty int, optionalStart ...int) ([]keygen.LocalPartySaveData, tss.SortedPartyIDs, error) {
func loadKeyGenData(
dir string,
qty int,
optionalStart ...int,
) ([]keygen.LocalPartySaveData, tss.SortedPartyIDs, error) {
keys := make([]keygen.LocalPartySaveData, 0, qty)
start := 0
if 0 < len(optionalStart) {
Expand All @@ -239,7 +246,7 @@ func loadKeyGenData(dir string, qty int, optionalStart ...int) ([]keygen.LocalPa
bz, err := ioutil.ReadFile(fixtureFilePath)
if err != nil {
return nil, nil, errors.Wrapf(err,
"could not open the test fixture for party %d in the expected location: %s. run keygen tests first.",
"could not open the test fixture for party %d in the expected location: %s. run keygen tests first",
i, fixtureFilePath)
}
var key keygen.LocalPartySaveData
Expand Down
5 changes: 2 additions & 3 deletions cmd/tss-recovery/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/hex"

"gitlab.com/thorchain/binance-sdk/common/uuid"

"golang.org/x/crypto/pbkdf2"
"golang.org/x/crypto/sha3"
)
Expand All @@ -25,7 +24,7 @@ type CryptoJSON struct {

type EncryptedKey struct {
Crypto CryptoJSON `json:"crypto"`
Id string `json:"id"`
ID string `json:"id"`
Version int `json:"version"`
}

Expand Down Expand Up @@ -77,7 +76,7 @@ func exportKeyStore(privKey []byte, password string) (*EncryptedKey, error) {
}
return &EncryptedKey{
Crypto: cryptoStruct,
Id: id.String(),
ID: id.String(),
Version: 1,
}, nil
}
4 changes: 2 additions & 2 deletions cmd/tss-recovery/tss-recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/bnb-chain/tss-lib/crypto/vss"
"github.com/btcsuite/btcd/btcec/v2"
. "github.com/decred/dcrd/dcrec/secp256k1"
ecdsa "github.com/decred/dcrd/dcrec/secp256k1"
)

func main() {
Expand Down Expand Up @@ -46,7 +46,7 @@ func main() {
fmt.Printf("error in tss verify")
}

privKey := NewPrivateKey(tssPrivateKey)
privKey := ecdsa.NewPrivateKey(tssPrivateKey)

pk := privKey.PubKey()
thorchainpk, address, err := getTssPubKey(pk.X, pk.Y)
Expand Down
Loading
Loading