Skip to content

Bug fixes, golangci-lint update version #754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 92 commits into from
Apr 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
bbb7580
Code Refactoring (#587)
iltoga Feb 12, 2020
69b8cfb
Get escrow transactions with filter fields and pagination (#590)
astaphobia Feb 13, 2020
dd11961
#588 decouple published receipt and participation score from block ma…
andy-shi88 Feb 14, 2020
92d4251
592 fee model (#595)
andy-shi88 Feb 19, 2020
7ed964b
578 snapshot file creation (#593)
iltoga Feb 21, 2020
d4c01b5
596 multisig skeleton (#597)
andy-shi88 Feb 24, 2020
dfab596
599 snapshot chunk strategy (#605)
iltoga Feb 25, 2020
d7423d8
600 multisig queries (#607)
andy-shi88 Feb 26, 2020
9418243
602 generate multisig address (#609)
astaphobia Feb 26, 2020
f68f6bd
no need to validate current block height (#610)
astaphobia Feb 26, 2020
61a470d
inhibit spine blocks smithing process during main blocks first downlo…
iltoga Feb 26, 2020
0a8f8ab
Fixed transaction generator affected by fee (#611)
astaphobia Feb 27, 2020
31247e6
Code Refactoring and Bug Fixing (#613)
iltoga Feb 27, 2020
da6f66e
601 multisig validation (#615)
andy-shi88 Feb 27, 2020
c26349b
Optimize GRPC duration (#616)
astaphobia Feb 27, 2020
7824924
GRPC endpoint get single escrow transaction by ID (#620)
astaphobia Mar 4, 2020
9cf61e2
Download snapshot chunks (#614)
iltoga Mar 6, 2020
018651e
594 add bitcoin signature (#618)
sukrawidhyawan Mar 9, 2020
132c293
629 - Use gomod consistently (#630)
astaphobia Mar 9, 2020
28bb9c3
603 multisig apply (#623)
andy-shi88 Mar 10, 2020
c2424ba
CI delivery image version (#632)
astaphobia Mar 10, 2020
882ba0e
Ci delivery image version (#633)
astaphobia Mar 10, 2020
77954b4
604 api rate limit (#625)
capt4ce Mar 10, 2020
232caac
621 - Respecting escrow expiration on Push Block (#626)
astaphobia Mar 10, 2020
1f9edbe
Spine block manifest and spine public keys validation when downloadin…
iltoga Mar 10, 2020
3cdcd68
Bug Fixing (#636)
iltoga Mar 10, 2020
e18c39e
Bug Fixing (#639)
iltoga Mar 11, 2020
093bee8
Escrow query test fail fixed (#640)
astaphobia Mar 11, 2020
24a3d03
Bug Fixing (#642)
iltoga Mar 11, 2020
79e3ff4
Escrow query test fail fixed (#647)
astaphobia Mar 11, 2020
44605f7
634 multisig api (#645)
andy-shi88 Mar 12, 2020
6d56373
634 multisig api (#653)
andy-shi88 Mar 12, 2020
246c913
#651 fix multisig_address signature validation (#652)
andy-shi88 Mar 12, 2020
83dea8b
656 incorrect account ledger balance changes (#657)
astaphobia Mar 13, 2020
3373f6c
654 account ledger multisig (#658)
andy-shi88 Mar 13, 2020
c7be929
660 api get multisig info (#661)
andy-shi88 Mar 17, 2020
6c1c9c2
650 - CMD HD wallet generate account (#668)
astaphobia Mar 18, 2020
adad659
fix uninitialized metrics (#662)
capt4ce Mar 18, 2020
66a5ab5
bitcoin sig: add public key into signature (#670)
sukrawidhyawan Mar 19, 2020
848681b
handle multiple rows in a function (#675)
capt4ce Mar 19, 2020
e7cc42b
SelectReceipt Limit (#676)
nawikart Mar 19, 2020
e2eb870
Circleci GitHub token (#677)
astaphobia Mar 19, 2020
c402bfa
628 apply snapshot (#667)
iltoga Mar 23, 2020
bea56e9
672 makefile binary built (#678)
andy-shi88 Mar 24, 2020
0fc668f
665-Enhance CMD Database Init (#680)
sukrawidhyawan Mar 24, 2020
443dfd0
handle nil value (#682)
andy-shi88 Mar 24, 2020
6abd538
throw error on over limit get blocks (#684)
nawikart Mar 24, 2020
cc9f024
remove pending tx status change, it has been updated in apply confirm…
andy-shi88 Mar 24, 2020
c87b264
686: Cmd, enhance generate account (#687)
sukrawidhyawan Mar 24, 2020
3c21ae0
655 escrow receipt approval (#688)
astaphobia Mar 26, 2020
31570d4
getHostInfo unit testing (#689)
nawikart Mar 26, 2020
cf76f34
adding database status metrics (#693)
capt4ce Mar 27, 2020
8902947
Bug Fixing snapshot selection queries and enhancing rollback queries …
iltoga Mar 27, 2020
e9adf78
681 disable smithing non registered node (#694)
andy-shi88 Mar 27, 2020
17b127e
unit testing for GetBlockQueue (#698)
nawikart Mar 27, 2020
4f354ef
Bug Fixing (#706)
iltoga Mar 30, 2020
864d94d
691 grpc account dataset (#699)
astaphobia Mar 30, 2020
f36bbff
690 empty block smith (#703)
andy-shi88 Mar 30, 2020
4e1ce34
adding function for HD wallet testing (#683)
KevinH2810 Mar 30, 2020
f58b6ad
P2P: Add unit test on server service (#707)
sukrawidhyawan Mar 30, 2020
a5ae192
added skippedblocksmith to snapshot (generate/apply) (#710)
iltoga Mar 30, 2020
dca5676
Adding runtime cpu profiling for core node (#712)
iltoga Mar 31, 2020
45d7392
add more info in log (#713)
capt4ce Mar 31, 2020
6506b28
fixed inconsistance block height on escrowed transaction (#717)
astaphobia Mar 31, 2020
59faaf6
Code Refactoring (#716)
iltoga Apr 1, 2020
4e220d1
Code Refactoring (#719)
iltoga Apr 1, 2020
9058495
Cleaning redundant function (#714)
KevinH2810 Apr 1, 2020
13d35f2
Bug Fixing (#724)
iltoga Apr 2, 2020
0125182
Code Refactoring (#728)
iltoga Apr 3, 2020
b7d92fd
722 blockchain orchestrator (#726)
capt4ce Apr 6, 2020
54654ca
709 Smithing All Blocksmith Skipped (#725)
andy-shi88 Apr 7, 2020
d9e8f45
add index on block table and update sql connnection number (#729)
sukrawidhyawan Apr 7, 2020
6d3e3bb
scale down the common block jump (#731)
capt4ce Apr 7, 2020
6e90aeb
721 - Remove Account Dataset Expiration (#732)
astaphobia Apr 7, 2020
a997a8d
Add node registry partial history to snapshots (#734)
iltoga Apr 7, 2020
9b1f2e2
making the download process less restrictive to failures in catching …
capt4ce Apr 7, 2020
d576806
TestBlockIncompleteQueueService_AddTransaction (#720)
nawikart Apr 8, 2020
fb90e7b
fix return type to use blocker (#742)
capt4ce Apr 9, 2020
a0cbf74
Update golangci to 1.24.0 (#743)
astaphobia Apr 9, 2020
25a51a0
#740 index receipt fields for better query time (#744)
andy-shi88 Apr 9, 2020
9f0e5d6
fix error casting (#747)
capt4ce Apr 13, 2020
149070c
downgrade golangci-lint version (#748)
andy-shi88 Apr 13, 2020
b946f54
Hotfix rows immediate release (#749)
andy-shi88 Apr 13, 2020
1bc5caa
Unit Testing core service BlockPoolService (#739)
nawikart Apr 13, 2020
c1dc9ca
Add optional Params on Sign function (#746)
sukrawidhyawan Apr 13, 2020
6c84f97
handle error from block push and validation (#751)
capt4ce Apr 13, 2020
d0c1fe1
fix block validation and smith time calculation (#752)
andy-shi88 Apr 14, 2020
9ead2eb
fixes conflict files
astaphobia Apr 14, 2020
9c32252
Merge branch 'develop' of github.com:zoobc/zoobc-core into april-14-2020
astaphobia Apr 14, 2020
1f63bab
fix genesis files
astaphobia Apr 14, 2020
06d5664
setter and recipient must be the same person (#755)
astaphobia Apr 15, 2020
96a8e42
Merge branch 'develop' of github.com:zoobc/zoobc-core into april-14-n…
astaphobia Apr 15, 2020
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
15 changes: 15 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ defaults: &defaults
working_directory: ~/zoobc
docker:
- image: circleci/golang:1.14.0-stretch
reset_dbs: &reset_dbs
name: RESET DBs
command: |
if [[ ${CIRCLE_BRANCH} == *"reset-db"* ]]; then
for host in $ln1 $ln2 $ln3; do ssh root@$host 'for f in *.db; do mv -- "$f" "_$f"; done'; done
fi
reset_db: &reset_db
name: RESET DB
command: |
if [[ ${CIRCLE_BRANCH} == *"reset-db"* ]]; then
ssh root@$ln4 'for f in *.db; do mv -- "$f" "_$f"; done';
fi

jobs:
prepare:
<<: *defaults
Expand Down Expand Up @@ -96,6 +109,7 @@ jobs:
name: DOWN SERVICES
command: |
for host in $ln1 $ln2 $ln3; do ssh root@$host 'sudo systemctl stop zoobc.service'; done
- run: *reset_dbs
- run:
name: DEPLOY
command: |
Expand Down Expand Up @@ -127,6 +141,7 @@ jobs:
name: DOWN SERVICE
command: |
ssh root@$ln4 'sudo systemctl stop zoobc.service'
- run: *reset_db
- run:
name: DEPLOY APP
command: |
Expand Down
7 changes: 6 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ linters-settings:
- zoobc
- multisig
lll:
line-length: 140
line-length: 150
goimports:
local-prefixes: github.com/zoobc/zoobc-core
gocritic:
Expand All @@ -52,6 +52,7 @@ linters-settings:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- exitAfterDefer
- importShadow
- appendAssign
funlen:
l: 50
s: 55
Expand All @@ -65,6 +66,7 @@ linters:
- gochecknoglobals
- gochecknoinits
- gocognit
- ineffassign
fast: false
run:
skip-dirs:
Expand Down Expand Up @@ -124,6 +126,9 @@ issues:
- text: "G202: SQL string concatenation"
linters:
- gosec
- text: "G108: Profiling endpoint is automatically exposed on /debug/pprof"
linters:
- gosec
- text: "is too long"
linters:
- funlen
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BIN_DIR := $(GOPATH)/bin
GOLANGCILINT := $(BIN_DIR)/golangci-lint
GOLANGCILINT_VERSION := v1.20.0
GOLANGCILINT_VERSION := v1.23.8
XGO := $(BIN_DIR)/xgo
VERSION ?= latest
BINARY_CORE := zoobc
Expand All @@ -23,7 +23,7 @@ $(XGO):
.PHONY: golangci-lint
golangci-lint: $(GOLANGCILINT)
$(info running linter...)
golangci-lint run
golangci-lint run --timeout=20m -v

.PHONY: go-fmt
go-fmt:
Expand Down
6 changes: 4 additions & 2 deletions api/handler/multisigHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package handler
import (
"context"

"github.com/zoobc/zoobc-core/api/service"
"github.com/zoobc/zoobc-core/common/model"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/zoobc/zoobc-core/api/service"

"github.com/zoobc/zoobc-core/common/model"
)

type (
Expand Down
4 changes: 3 additions & 1 deletion api/service/multisigService.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import (
"database/sql"
"encoding/hex"

"github.com/sirupsen/logrus"
"github.com/zoobc/zoobc-core/common/constant"

"github.com/sirupsen/logrus"

"github.com/zoobc/zoobc-core/common/model"
"github.com/zoobc/zoobc-core/common/query"
coreService "github.com/zoobc/zoobc-core/core/service"
Expand Down
10 changes: 10 additions & 0 deletions cmd/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,13 @@ go run main.go generate poow --node-seed "concur vocalist rotten busload gap quo
```bash
go run main.go rollback blockchain --to-height 10 --db-path "../resource" --db-name "zoobc.db"
```

### Signature Signing data using Ed25519
```bash
go run main.go signature sign ed25519 --data-bytes='1, 222, 54, 12, 32' --use-slip10=true
```

### Signature Verifying data
```bash
go run main.go signature verify --data-bytes='1, 222, 54, 12, 32' --signature-hex=0000000063851d61318eaf923ff72457fd9b5716db9904aacbe53eb1bc25cd8a7bf2816c61402b0c52d4324e1336bae4ea28194d6f5c531292fd266e63a293519f20c20b --account-address=WI-u0jyKMGsPHk6K7eT1Utnxc6WiKehkIEs87Zf3fIsH
```
167 changes: 147 additions & 20 deletions cmd/signature/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,58 +12,185 @@ import (
"golang.org/x/crypto/sha3"
)

type (
// GeneratorCommands represent struct of signature generator commands
GeneratorCommands struct {
Signature crypto.SignatureInterface
}
)

var (
signatureCmdInstance *GeneratorCommands
/*
Signer command line tools
*/
signatureCmd = &cobra.Command{
Use: "signature",
Short: "signature command is a parent command for signature stuffs",
}
signerCmd = &cobra.Command{
Use: "sign",
Short: "sign provided data",
Long: "sign any provided data by using the --seed parameter",
}

ed25519SignerCmd = &cobra.Command{
Use: "ed25519",
Short: "sign using ed25519 algoritmn",
Long: "sign any provided data by using the --seed parameter",
}

verifyCmd = &cobra.Command{
Use: "verify",
Short: "verify provided signature ",
Long: "verify provided signature against provided data using public key",
}
)

func init() {
signerCmd.Flags().StringVar(&dataHex, "data-hex", "", "hex string of the data to sign")
signerCmd.Flags().StringVar(&dataBytes, "data-bytes", "", "data bytes separated by `, `. eg:"+
signatureCmd.PersistentFlags().StringVar(&dataHex, "data-hex", "", "hex string of the data to sign")
signatureCmd.PersistentFlags().StringVar(&dataBytes, "data-bytes", "", "data bytes separated by `, `. eg:"+
"--data-bytes='1, 222, 54, 12, 32'")
signerCmd.Flags().StringVar(&seed, "seed", "", "your secret phrase")
signerCmd.Flags().BoolVar(&hash, "hash", false, "turn this flag on to hash the data before signing")

signerCmd.PersistentFlags().StringVar(&seed, "seed", "", "your secret phrase")
signerCmd.PersistentFlags().BoolVar(&hash, "hash", false, "turn this flag on to hash the data before signing")
ed25519SignerCmd.Flags().BoolVar(&ed25519UseSlip10, "use-slip10", false, "use slip10 to generate ed25519 private key for signing")

verifyCmd.Flags().StringVar(&signatureHex, "signature-hex", "", "hex string of the signature")
verifyCmd.Flags().StringVar(&signatureBytes, "signature-bytes", "", "signature bytes stseparated by `, `. eg:"+
"--signature-bytes='1, 222, 54, 12, 32'")
verifyCmd.Flags().StringVar(&accountAddress, "account-address", "", "the address who sign the data")

}

// Commands return main command of signature
func Commands() *cobra.Command {
signerCmd.Run = SignData
return signerCmd
if signatureCmdInstance == nil {
signatureCmdInstance = &GeneratorCommands{
Signature: &crypto.Signature{},
}
}
ed25519SignerCmd.Run = signatureCmdInstance.SignEd25519
signerCmd.AddCommand(ed25519SignerCmd)
signerCmd.Run = signatureCmdInstance.SignEd25519
signatureCmd.AddCommand(signerCmd)

verifyCmd.Run = signatureCmdInstance.VerySignature
signatureCmd.AddCommand(verifyCmd)
return signatureCmd
}

func SignData(*cobra.Command, []string) {
// SignEd25519 is sign command handler using Ed25519 algorithm
func (gc *GeneratorCommands) SignEd25519(*cobra.Command, []string) {
var (
unsignedBytes []byte
hashedUnsignedBytes [32]byte
accountAddress string
signature []byte
err error
)

if dataHex != "" {
unsignedBytes, _ = hex.DecodeString(dataHex)
unsignedBytes, err = hex.DecodeString(dataHex)
if err != nil {
panic("failed to decode data hex")
}
} else {
txByteCharSlice := strings.Split(dataBytes, ", ")
for _, v := range txByteCharSlice {
byteValue, err := strconv.Atoi(v)
if err != nil {
panic("failed to parse transaction bytes")
}
unsignedBytes = append(unsignedBytes, byte(byteValue))
unsignedBytes, err = parseBytesArgs(dataBytes, ", ")
if err != nil {
panic("failed to parse data bytes")
}
}
_, _, _, accountAddress, err = gc.Signature.GenerateAccountFromSeed(
model.SignatureType_DefaultSignature,
seed,
ed25519UseSlip10,
)
if err != nil {
panic(err.Error())
}
if hash {
hashedUnsignedBytes = sha3.Sum256(unsignedBytes)
signature, _ = (&crypto.Signature{}).Sign(hashedUnsignedBytes[:], model.SignatureType_DefaultSignature, seed)
} else {
signature, _ = (&crypto.Signature{}).Sign(unsignedBytes, model.SignatureType_DefaultSignature, seed)
unsignedBytes = hashedUnsignedBytes[:]
}
signature, err = gc.Signature.Sign(
unsignedBytes,
model.SignatureType_DefaultSignature,
seed,
ed25519UseSlip10,
)
if err != nil {
panic(err.Error())
}
edUtil := crypto.NewEd25519Signature()
fmt.Printf("account-address:\t%v\n", edUtil.GetAddressFromSeed(seed))

fmt.Printf("account-address:\t%v\n", accountAddress)
fmt.Printf("transaction-bytes:\t%v\n", unsignedBytes)
fmt.Printf("transaction-hash:\t%v\n", hex.EncodeToString(hashedUnsignedBytes[:]))
fmt.Printf("signature-bytes:\t%v\n", signature)
fmt.Printf("signature-hex:\t%v\n", hex.EncodeToString(signature))
}

// VerySignature is verify signature command hendler
func (gc *GeneratorCommands) VerySignature(*cobra.Command, []string) {
var (
unsignedBytes []byte
signature []byte
failedVerifyCause = "none"
isVerified = true
err error
)
if dataHex != "" {
unsignedBytes, err = hex.DecodeString(dataHex)
if err != nil {
panic("failed to decode data hex")
}
} else {
unsignedBytes, err = parseBytesArgs(dataBytes, ", ")
if err != nil {
panic("failed to parse data bytes")
}
}

if signatureHex != "" {
signature, err = hex.DecodeString(signatureHex)
if err != nil {
panic("failed to decode signature hex")
}
} else {
signature, err = parseBytesArgs(signatureBytes, ", ")
if err != nil {
panic("failed to parse data bytes")
}
}

err = gc.Signature.VerifySignature(unsignedBytes, signature, accountAddress)
if err != nil {
failedVerifyCause = err.Error()
isVerified = false
}

fmt.Printf("verify-status:\t%v\n", isVerified)
fmt.Printf("failed-causes:\t%v\n", failedVerifyCause)
fmt.Printf("address:\t%v\n", accountAddress)
fmt.Printf("payload-bytes:\t%v\n", unsignedBytes)
fmt.Printf("payload-hex:\t%v\n", hex.EncodeToString(unsignedBytes))

fmt.Printf("signature-hex:\t%v\n", hex.EncodeToString(signature))
fmt.Printf("signature-bytes:%v\n", signature)

}

func parseBytesArgs(argsBytesString, separated string) ([]byte, error) {
var (
parsedByte []byte
byteCharSlice = strings.Split(argsBytesString, separated)
)
for _, v := range byteCharSlice {
byteValue, err := strconv.Atoi(v)
if err != nil {
return nil, err
}
parsedByte = append(parsedByte, byte(byteValue))
}
return parsedByte, nil
}
15 changes: 11 additions & 4 deletions cmd/signature/const.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package signature

var (
seed string
dataHex string
dataBytes string
hash bool
// sign
seed string
dataHex string
dataBytes string
hash bool
ed25519UseSlip10 bool

// verify
signatureBytes string
signatureHex string
accountAddress string
)
Loading