Skip to content

Commit 776a5e3

Browse files
authored
feat!: hard-fork (#43)
* Hard-fork by renaming the repo. * Update gitignore * Update makefile * Update codegen * Update readme * Format codebase * Copy lint rules from node's repo * Fix linter [2] * Fix linter [3] * Fix linter [4] * Fix linter [5] * Match node's go version * Copy CI flow from node's repo * Fix linter & add CODEOWNERS * Disable leader-less test suite * Update go.mod to work with node's go.mod * update linter * Use dynamic free ports * Bump cosmos-sdk dep * Disable -race in CI
1 parent be92b20 commit 776a5e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1453
-1086
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* @zeta-chain/protocol-engineering
2+
3+
.github/** @zeta-chain/devops

.github/workflows/ci.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,25 @@ jobs:
2020
with:
2121
go-version: ${{ matrix.go-version }}
2222
- name: Test
23-
run: go test -race -timeout 25m ./...
23+
run: go test -timeout 25m ./...
2424
lint:
25-
name: lint
2625
runs-on: ubuntu-22.04
26+
timeout-minutes: 15
27+
env:
28+
GO111MODULE: on
2729
steps:
28-
- uses: actions/checkout@v4
29-
- uses: actions/setup-go@v5
30+
- name: Checkout Source
31+
uses: actions/checkout@v4
3032
with:
31-
go-version: 1.22
32-
- name: golangci-lint
33+
fetch-depth: 0
34+
35+
- name: Set up Go
36+
uses: actions/setup-go@v5
37+
with:
38+
go-version: '1.23'
39+
40+
- name: Run golangci-lint
3341
uses: golangci/golangci-lint-action@v6
3442
with:
35-
version: v1.56.2
43+
version: v1.63.4
44+
skip-cache: true

.gitignore

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,14 @@
22
.DS_Store
33
*.swp
44
*.swo
5-
.vscode
6-
.idea
75
.env*
86

9-
# Build
10-
vendor
11-
.vendor-new
12-
observe
13-
147
# IDE
8+
.vscode/
159
.idea/
16-
*.iml
1710

1811
bin/
1912
thord
20-
*.exe
2113
.testCoverage.txt
2214
c.out
2315
*.leveldb/

.gitlab-ci.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.golangci.yml

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,53 @@
1+
run:
2+
go: "1.22.11"
3+
timeout: 5m
4+
tests: false # exclude test from linting
5+
16
linters:
27
disable-all: true
38
enable:
4-
- deadcode
59
- errcheck
6-
- golint
10+
- revive
711
- ineffassign
812
- unconvert
913
- misspell
14+
- goimports
1015
- govet
16+
- stylecheck
17+
- typecheck
18+
- misspell
19+
# - prealloc not really useful imo
20+
- dogsled
21+
- goconst
22+
- bodyclose
23+
- unconvert
24+
- unused
25+
- gci
26+
- gofmt
27+
- whitespace
28+
1129
linters-settings:
1230
gocyclo:
1331
min-complexity: 11
1432
errcheck:
15-
ignore: fmt:.*,io/ioutil:^Read.*,github.com/spf13/cobra:MarkFlagRequired,github.com/spf13/viper:BindPFlag
16-
golint:
17-
min-confidence: 1.1
33+
exclude-functions:
34+
- fmt:.*
35+
- io/ioutil:^Read.*,
36+
- github.com/spf13/cobra:MarkFlagRequired
37+
- github.com/spf13/viper:BindPFlag
38+
exhaustive:
39+
check-generated: false
40+
gci:
41+
# Gci controls Go package import order and makes it always deterministic
42+
# https://golangci-lint.run/usage/linters/#gci
43+
sections:
44+
- standard
45+
- default
46+
- prefix(github.com/zeta-chain/go-tss)
47+
skip-generated: true
48+
1849
issues:
50+
exclude-generated: strict
1951
exclude:
2052
- composite
21-
run:
22-
tests: false
23-
deadline: 15m
24-
timeout: 5m
53+
exclude-dirs: [ ".git", ".github" ]

Makefile

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,42 @@
1-
module = gitlab.com/thorchain/tss/go-tss
1+
module = github.com/zeta-chain/go-tss
22

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

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

7-
clear:
8-
clear
9-
10-
tools:
10+
tools: ## Installs tss tools
1111
go install ./cmd/tss-recovery
1212
go install ./cmd/tss-benchgen
1313
go install ./cmd/tss-benchsign
1414

15-
install: go.sum
15+
install: go.sum ## Compiles & install go-tss binary
1616
go install ./cmd/tss
1717

18-
go.sum: go.mod
18+
go.sum: go.mod ## Go sum
1919
@echo "--> Ensure dependencies have not been modified"
2020
go mod verify
2121

22-
test:
23-
@go test --race -timeout 30m ./...
22+
test: ## Runs tests
23+
@go test -race -timeout 30m ./...
2424

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

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

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

37-
lint: lint-pre
36+
lint: lint-pre ## Runs linter
3837
@golangci-lint run
3938

40-
lint-verbose: lint-pre
41-
@golangci-lint run -v
42-
43-
protob:
39+
codegen: ## Generates proto
4440
protoc --go_out=module=$(module):. ./messages/*.proto
4541

46-
build: protob
47-
go build ./...
48-
49-
docker-build:
50-
docker build -t registry.gitlab.com/thorchain/tss/go-tss .
42+
.PHONY: deps tools install test fmt lint-pre lint codegen

README.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
# THORCHain TSS
1+
# Zetachain Threshold Signature Scheme (TSS) P2P server
22

3-
This repository wraps tss-lib with the networking level coordination code used in Thorchain.
4-
5-
### How to contribute
6-
7-
* Create an issue or find an existing issue on https://gitlab.com/thorchain/tss/go-tss/-/issues
8-
* Assign the issue to yourself
9-
* Raise a PR, making sure to include "Resolves #<issue number>" in the description
10-
* Make sure the pipeline is green
11-
* Once PR is approved, the team will merge it to master
3+
- Forked from https://gitlab.com/thorchain/tss/go-tss
4+
- Based on https://github.com/bnb-chain/tss-lib
5+
- Used by `zetaclientd`: https://github.com/zeta-chain/node

blame/manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func (m *Manager) SetPartyInfo(partyMap *sync.Map, partyIDMap map[string]*btss.P
9898
}
9999
m.partyInfo = partyInfo
100100
var localParty btss.Party
101-
m.partyInfo.PartyMap.Range(func(key, value interface{}) bool {
101+
m.partyInfo.PartyMap.Range(func(_, value any) bool {
102102
localParty = value.(btss.Party)
103103
return false
104104
})

blame/policy.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
mapset "github.com/deckarep/golang-set"
99
"github.com/libp2p/go-libp2p/core/peer"
1010

11-
"gitlab.com/thorchain/tss/go-tss/conversion"
12-
"gitlab.com/thorchain/tss/go-tss/messages"
11+
"github.com/zeta-chain/go-tss/conversion"
12+
"github.com/zeta-chain/go-tss/messages"
1313
)
1414

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

184184
default:
185-
m.logger.Error().Msgf("fail to find the algorithm for this keygen/keysign, set unicast as false by default")
185+
m.logger.Error().
186+
Msgf("fail to find the algorithm for this keygen/keysign, set unicast as false by default")
186187
isUnicast = false
187188
}
188189

blame/policy_helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package blame
22

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

55
// GetBlamePubKeysInList returns the nodes public key who are in the peer list
66
func (m *Manager) getBlamePubKeysInList(peers []string) ([]string, error) {

0 commit comments

Comments
 (0)