Skip to content

Commit e1fc323

Browse files
authored
Merge pull request #1312 from zoobc/experimental
[ Stabilize ] Optimization and bug fixes
2 parents d43f237 + 2265f8e commit e1fc323

File tree

337 files changed

+20587
-13690
lines changed

Some content is hidden

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

337 files changed

+20587
-13690
lines changed

.circleci/config.yml

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ defaults: &defaults
33
working_directory: ~/zoobc
44
docker:
55
- image: circleci/golang:1.14.0-stretch
6+
# - image: cimg/go:1.14
67
reset_dbs: &reset_dbs
78
name: RESET DBs
89
command: |
@@ -23,14 +24,19 @@ reset_db: &reset_db
2324
else
2425
echo "All good without reset db"
2526
fi
27+
github_cof: &github_conf
28+
name: GIT CONF
29+
command: |
30+
git config --global url."https://github:$github_token@github.com".insteadOf "https://github.com"
2631
jobs:
2732
prepare:
2833
<<: *defaults
2934
steps:
30-
- run:
31-
name: GIT CONF
32-
command: |
33-
git config --global url."https://github:$github_token@github.com".insteadOf "https://github.com"
35+
# - run:
36+
# name: GIT CONF
37+
# command: |
38+
# git config --global url."https://github:$github_token@github.com".insteadOf "https://github.com"
39+
- run: *github_conf
3440
- checkout
3541
- add_ssh_keys
3642
- run:
@@ -56,42 +62,44 @@ jobs:
5662
GOMAXPROCS: 2
5763
# https://support.circleci.com/hc/en-us/articles/360034684273-Common-GoLang-memory-issues:
5864
steps:
65+
- run: *github_conf
5966
- checkout
6067
- restore_cache:
6168
key: gopkg-{{ .Branch }}-{{ checksum "go.sum" }}
62-
- run:
63-
name: ↓ GOLINT
64-
command: go get -u golang.org/x/lint/golint
69+
# - run:
70+
# name: ↓ GOLINT
71+
# command: go get -u golang.org/x/lint/golint
6572
- run:
6673
name: GO FMT
6774
command: make go-fmt
6875
- run:
6976
name: GOCI
7077
command: make golangci-lint
71-
# command: make test
7278
- run:
73-
name: GOLINT RUN
74-
command: golint `go list ./... | egrep -v 'vendor|common/model|common/service'`
79+
name: GOTEST
80+
command: go test `go list ./... | egrep -v 'common/model|common/service'` --short -count=1 -p=1
81+
# - run:
82+
# name: GOLINT RUN
83+
# command: golint `go list ./... | egrep -v 'vendor|common/model|common/service'`
84+
- run:
85+
name: TEST MAKE GEN
86+
command: |
87+
make generate-gen gen-target=develop
7588
- save_cache:
7689
key: gopkg-{{ .Branch }}-{{ checksum "go.sum" }}
7790
paths:
7891
- /go/pkg/mod
7992
build:
8093
<<: *defaults
8194
steps:
95+
- run: *github_conf
8296
- checkout
8397
- restore_cache:
8498
key: gopkg-{{ .Branch }}-{{ checksum "go.sum" }}
8599
- restore_cache:
86100
key: build-cache-{{ .Branch }}-{{ .Environment.CIRCLE_PREVIOUS_BUILD_NUM }}
87101
paths:
88102
- ./dist
89-
- run:
90-
name: ↓ RSYNC
91-
command: |
92-
if [ ! -d rsync ]; then
93-
sudo apt-get update && sudo apt-get install rsync
94-
fi
95103
- run:
96104
name: GENERATING GENESIS
97105
command: |
@@ -101,15 +109,15 @@ jobs:
101109
- run:
102110
name: BUILD
103111
command: |
104-
go build -o ./dist/zoobc
105-
# rsync -va --exclude='*.db' ./resource ./dist
112+
GOOS=linux GOARCH=amd64 go build -o ./dist/zoobc
106113
- save_cache:
107114
key: build-cache-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
108115
paths:
109116
- ./dist
110117
deploy-develop:
111118
<<: *defaults
112119
steps:
120+
- run: *github_conf
113121
- checkout
114122
- add_ssh_keys
115123
- run:
@@ -124,23 +132,29 @@ jobs:
124132
- ./dist
125133
- run:
126134
name: ADD HOSTS
127-
command: for host in $ln1 $ln2 $ln3; do ssh-keyscan $host >> ~/.ssh/known_hosts; done
135+
command: |
136+
ssh-keyscan $ln4 >> ~/.ssh/known_hosts
137+
# for host in $ln1 $ln2 $ln3; do ssh-keyscan $host >> ~/.ssh/known_hosts; done
128138
- run:
129139
name: DOWN SERVICES
130140
command: |
131-
for host in $ln1 $ln2 $ln3; do ssh root@$host 'sudo systemctl stop zoobc.service'; done
141+
ssh root@$ln4 'sudo systemctl stop zoobc.service'
142+
# for host in $ln1 $ln2 $ln3; do ssh root@$host 'sudo systemctl stop zoobc.service'; done
132143
- run: *reset_dbs
133144
- run:
134145
name: DEPLOY
135146
command: |
136-
for host in $ln1 $ln2 $ln3; do rsync -vae ssh ./dist/ root@$host:/root/zoobc --exclude='*.db' --exclude='generated'; done
147+
rsync -vae ssh ./dist/ root@$ln4:/root/zoobc --exclude='*.db' --exclude='generated'
148+
# for host in $ln1 $ln2 $ln3; do rsync -vae ssh ./dist/ root@$host:/root/zoobc --exclude='*.db' --exclude='generated'; done
137149
- run:
138150
name: UP SERVICES
139151
command: |
140-
for host in $ln1 $ln2 $ln3; do ssh root@$host 'sudo systemctl start zoobc.service'; done
152+
ssh root@$ln4 'sudo systemctl start zoobc.service'
153+
# for host in $ln1 $ln2 $ln3; do ssh root@$host 'sudo systemctl start zoobc.service'; done
141154
deploy-staging:
142155
<<: *defaults
143156
steps:
157+
- run: *github_conf
144158
- checkout
145159
- add_ssh_keys
146160
- run:
@@ -173,6 +187,7 @@ jobs:
173187
deploy-experimental:
174188
<<: *defaults
175189
steps:
190+
- run: *github_conf
176191
- checkout
177192
- add_ssh_keys
178193
- run:

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,7 @@ github.token
3232
dist/
3333
local.preRegisteredNodes.json
3434
core/service/testdata/snapshots/
35-
_*
35+
_*
36+
37+
*.db-shm
38+
*.db-wal

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ core-linux: $(XGO)
5858
mkdir -p $(ZBCPATH)
5959
xgo --targets=linux/amd64 -out=$(CORE_OUPUT) --go-private=github.com/zoobc/* --github-token=$(GITHUB_TOKEN) ./
6060

61+
.PHONY: core-arm
62+
core-arm: $(XGO)
63+
$(info build core with linux/arm as target...)
64+
mkdir -p $(ZBCPATH)
65+
xgo --targets=linux/arm -out=$(CORE_OUPUT) --go-private=github.com/zoobc/* --github-token=$(GITHUB_TOKEN) ./
66+
6167
.PHONY: core-windows
6268
core-windows: $(XGO)
6369
$(info build core with windows as target...)
@@ -82,6 +88,12 @@ cmd-linux: $(XGO)
8288
mkdir -p $(ZBCPATH)
8389
xgo --targets=linux/amd64 -out=$(CLI_OUPUT) --go-private=github.com/zoobc/* --github-token=$(GITHUB_TOKEN) ./cmd/
8490

91+
.PHONY: cmd-arm
92+
cmd-arm: $(XGO)
93+
$(info build cmd with linux/arm as target...)
94+
mkdir -p $(ZBCPATH)
95+
xgo --targets=linux/arm -out=$(CLI_OUPUT) --go-private=github.com/zoobc/* --github-token=$(GITHUB_TOKEN) ./cmd/
96+
8597
.PHONY: cmd-windows
8698
cmd-windows: $(XGO)
8799
$(info build cmd with windows as target...)
@@ -120,4 +132,4 @@ release-cmd: cmd-linux
120132

121133
.PHONY: reset-data
122134
reset-data:
123-
rm -rf resource/*db resource/*kv resource/snapshots*
135+
rm -rf resource/*db resource/snapshots*

api/api.go

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,20 @@ package api
22

33
import (
44
"fmt"
5-
"github.com/zoobc/zoobc-core/common/constant"
6-
"github.com/zoobc/zoobc-core/common/monitoring"
5+
"github.com/zoobc/zoobc-core/common/crypto"
76
"html/template"
87
"net"
98
"net/http"
109

1110
grpcMiddleware "github.com/grpc-ecosystem/go-grpc-middleware"
1211
"github.com/improbable-eng/grpc-web/go/grpcweb"
1312
log "github.com/sirupsen/logrus"
14-
"golang.org/x/net/http2"
15-
"golang.org/x/net/http2/h2c"
16-
"google.golang.org/grpc"
17-
"google.golang.org/grpc/codes"
18-
1913
"github.com/zoobc/zoobc-core/api/handler"
2014
"github.com/zoobc/zoobc-core/api/service"
2115
"github.com/zoobc/zoobc-core/common/chaintype"
22-
"github.com/zoobc/zoobc-core/common/crypto"
16+
"github.com/zoobc/zoobc-core/common/constant"
2317
"github.com/zoobc/zoobc-core/common/interceptor"
18+
"github.com/zoobc/zoobc-core/common/monitoring"
2419
"github.com/zoobc/zoobc-core/common/query"
2520
rpcService "github.com/zoobc/zoobc-core/common/service"
2621
"github.com/zoobc/zoobc-core/common/storage"
@@ -29,19 +24,26 @@ import (
2924
coreUtil "github.com/zoobc/zoobc-core/core/util"
3025
"github.com/zoobc/zoobc-core/observer"
3126
"github.com/zoobc/zoobc-core/p2p"
27+
"golang.org/x/net/http2"
28+
"golang.org/x/net/http2/h2c"
29+
"google.golang.org/grpc"
30+
"google.golang.org/grpc/codes"
3231
)
3332

3433
func startGrpcServer(
3534
queryExecutor query.ExecutorInterface,
3635
p2pHostService p2p.Peer2PeerServiceInterface,
3736
blockServices map[int32]coreService.BlockServiceInterface,
3837
nodeRegistrationService coreService.NodeRegistrationServiceInterface,
38+
nodeAddressInfoService coreService.NodeAddressInfoServiceInterface,
3939
mempoolService coreService.MempoolServiceInterface,
40+
scrambleNodeService coreService.ScrambleNodeServiceInterface,
4041
transactionUtil transaction.UtilInterface,
4142
actionTypeSwitcher transaction.TypeActionSwitcher,
4243
blockStateStorages map[int32]storage.CacheStorageInterface,
4344
rpcPort, httpPort int,
44-
ownerAccountAddress, nodefilePath string,
45+
ownerAccountAddress []byte,
46+
nodefilePath string,
4547
logger *log.Logger,
4648
isDebugMode bool,
4749
apiCertFile, apiKeyFile string,
@@ -83,7 +85,8 @@ func startGrpcServer(
8385
// Set GRPC handler for Transactions requests
8486
rpcService.RegisterTransactionServiceServer(grpcServer, &handler.TransactionHandler{
8587
Service: service.NewTransactionService(
86-
queryExecutor, crypto.NewSignature(),
88+
queryExecutor,
89+
crypto.NewSignature(),
8790
actionTypeSwitcher,
8891
mempoolService,
8992
observer.NewObserver(),
@@ -92,7 +95,7 @@ func startGrpcServer(
9295
})
9396
// Set GRPC handler for Transactions requests
9497
rpcService.RegisterHostServiceServer(grpcServer, &handler.HostHandler{
95-
Service: service.NewHostService(queryExecutor, p2pHostService, blockServices, nodeRegistrationService, blockStateStorages),
98+
Service: service.NewHostService(queryExecutor, p2pHostService, blockServices, nodeRegistrationService, scrambleNodeService, blockStateStorages),
9699
})
97100
// Set GRPC handler for account balance requests
98101
rpcService.RegisterAccountBalanceServiceServer(grpcServer, &handler.AccountBalanceHandler{
@@ -119,7 +122,7 @@ func startGrpcServer(
119122
// Set GRPC handler for node address info requests
120123
rpcService.RegisterNodeAddressInfoServiceServer(grpcServer, &handler.NodeAddressInfoHandler{
121124
Service: service.NewNodeAddressInfoAPIService(
122-
nodeRegistrationService,
125+
nodeAddressInfoService,
123126
),
124127
})
125128
// Set GRPC handler for node registry request
@@ -232,11 +235,14 @@ func Start(
232235
p2pHostService p2p.Peer2PeerServiceInterface,
233236
blockServices map[int32]coreService.BlockServiceInterface,
234237
nodeRegistrationService coreService.NodeRegistrationServiceInterface,
238+
nodeAddressInfoService coreService.NodeAddressInfoServiceInterface,
235239
mempoolService coreService.MempoolServiceInterface,
240+
scrambleNodeService coreService.ScrambleNodeServiceInterface,
236241
transactionUtil transaction.UtilInterface,
237242
actionTypeSwitcher transaction.TypeActionSwitcher,
238243
blockStateStorages map[int32]storage.CacheStorageInterface,
239-
grpcPort, httpPort int, ownerAccountAddress,
244+
grpcPort, httpPort int,
245+
ownerAccountAddress []byte,
240246
nodefilePath string,
241247
logger *log.Logger,
242248
isDebugMode bool,
@@ -249,7 +255,9 @@ func Start(
249255
p2pHostService,
250256
blockServices,
251257
nodeRegistrationService,
258+
nodeAddressInfoService,
252259
mempoolService,
260+
scrambleNodeService,
253261
transactionUtil,
254262
actionTypeSwitcher,
255263
blockStateStorages,

api/client/GenerateNodeKey/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import (
77
"encoding/json"
88
"flag"
99
"fmt"
10+
"github.com/zoobc/zoobc-core/common/crypto"
1011
"time"
1112

1213
log "github.com/sirupsen/logrus"
1314
"github.com/spf13/viper"
14-
"github.com/zoobc/zoobc-core/common/crypto"
1515
rpcModel "github.com/zoobc/zoobc-core/common/model"
1616
rpcService "github.com/zoobc/zoobc-core/common/service"
1717
"github.com/zoobc/zoobc-core/common/util"
@@ -50,7 +50,7 @@ func main() {
5050
buffer.Write(util.ConvertUint32ToBytes(uint32(rpcModel.RequestType_GeneratetNodeKey)))
5151
sig, err := signature.Sign(
5252
buffer.Bytes(),
53-
rpcModel.SignatureType_DefaultSignature,
53+
rpcModel.AccountType_ZbcAccountType,
5454
accountSeed,
5555
)
5656
if err != nil {

api/client/GetAccountBalance/client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ func main() {
3737
c := rpc_service.NewAccountBalanceServiceClient(conn)
3838

3939
response, err := c.GetAccountBalance(context.Background(), &rpc_model.GetAccountBalanceRequest{
40-
AccountAddress: "BCZnSfqpP5tqFQlMTYkDeBVFWnbyVK7vLr5ORFpTjgtN",
40+
AccountAddress: []byte{0, 0, 0, 0, 98, 118, 38, 51, 199, 143, 112, 175, 220, 74, 221, 170, 56, 103, 159, 209, 242, 132, 219, 155,
41+
169, 123, 104, 77, 139, 18, 224, 166, 162, 83, 125, 96},
4142
})
4243

4344
if err != nil {

api/client/GetAccountBalances/client.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,13 @@ func main() {
3737
c := rpc_service.NewAccountBalanceServiceClient(conn)
3838

3939
response, err := c.GetAccountBalances(context.Background(), &rpc_model.GetAccountBalancesRequest{
40-
AccountAddresses: []string{
41-
"OnEYzI-EMV6UTfoUEzpQUjkSlnqB82-SyRN7469lJTWH",
42-
"BCZEGOb3WNx3fDOVf9ZS4EjvOIv_UeW4TVBQJ_6tHKlE",
43-
"iSJt3H8wFOzlWKsy_UoEWF_OjF6oymHMqthyUMDKSyxb",
40+
AccountAddresses: [][]byte{
41+
{0, 0, 0, 0, 98, 118, 38, 51, 199, 143, 112, 175, 220, 74, 221, 170, 56, 103, 159, 209, 242, 132, 219, 155,
42+
169, 123, 104, 77, 139, 18, 224, 166, 162, 83, 125, 96},
43+
{0, 0, 0, 0, 27, 175, 195, 164, 131, 47, 248, 249, 105, 108, 85, 109, 152, 244, 63, 212, 143, 10, 227, 1, 190, 31, 63,
44+
64, 219, 176, 99, 37, 78, 130, 27, 40},
45+
{0, 0, 0, 0, 192, 124, 122, 102, 248, 101, 1, 230, 239, 101, 6, 87, 182, 13, 221, 113, 69, 154, 170, 121, 179, 223, 171,
46+
177, 193, 38, 101, 24, 132, 147, 122, 9},
4447
},
4548
})
4649

api/client/GetAccountDataset/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ func main() {
3636

3737
c := rpcService.NewAccountDatasetServiceClient(conn)
3838
response, err := c.GetAccountDataset(context.Background(), &model.GetAccountDatasetRequest{
39-
RecipientAccountAddress: "H1ftvv3n6CF5NDzdjmZKLRrBg6yPKHXpmatVUhQ5NWYx",
39+
RecipientAccountAddress: []byte{0, 0, 0, 0, 98, 118, 38, 51, 199, 143, 112, 175, 220, 74, 221, 170, 56, 103, 159, 209, 242, 132, 219,
40+
155, 169, 123, 104, 77, 139, 18, 224, 166, 162, 83, 125, 96},
4041
})
4142
if err != nil {
4243
log.Fatalf("error calling grpc GetAccountDatasets: %s", err.Error())

api/client/GetAccountDatasets/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ func main() {
3030

3131
c := rpcService.NewAccountDatasetServiceClient(conn)
3232
response, err := c.GetAccountDatasets(context.Background(), &model.GetAccountDatasetsRequest{
33-
SetterAccountAddress: "HlZLh3VcnNlvByWoAzXOQ2jAlwFOiyO9_njI3oq5Ygha",
34-
RecipientAccountAddress: "H1ftvv3n6CF5NDzdjmZKLRrBg6yPKHXpmatVUhQ5NWYx",
33+
SetterAccountAddress: []byte{0, 0, 0, 0, 98, 118, 38, 51, 199, 143, 112, 175, 220, 74, 221, 170, 56, 103, 159, 209, 242, 132, 219,
34+
155, 169, 123, 104, 77, 139, 18, 224, 166, 162, 83, 125, 96},
35+
RecipientAccountAddress: []byte{0, 0, 0, 0, 27, 175, 195, 164, 131, 47, 248, 249, 105, 108, 85, 109, 152, 244, 63, 212, 143, 10,
36+
227, 1, 190, 31, 63, 64, 219, 176, 99, 37, 78, 130, 27, 40},
3537
})
3638
if err != nil {
3739
log.Fatalf("error calling grpc GetAccountDatasets: %s", err.Error())

api/client/GetAccountLedgers/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ func main() {
4141

4242
res, err := rpcService.NewAccountLedgerServiceClient(conn).
4343
GetAccountLedgers(context.Background(), &model.GetAccountLedgersRequest{
44-
AccountAddress: "OnEYzI-EMV6UTfoUEzpQUjkSlnqB82-SyRN7469lJTWH",
44+
AccountAddress: []byte{0, 0, 0, 0, 98, 118, 38, 51, 199, 143, 112, 175, 220, 74, 221, 170, 56, 103, 159, 209, 242, 132, 219, 155,
45+
169, 123, 104, 77, 139, 18, 224, 166, 162, 83, 125, 96},
4546
// EventType: model.EventType_EventAny,
4647
TimestampStart: 1578548985,
4748
TimestampEnd: 1578549075,

api/client/GetEscrowTransactions/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ func main() {
3434
c := rpcService.NewEscrowTransactionServiceClient(conn)
3535

3636
response, err := c.GetEscrowTransactions(context.Background(), &rpcModel.GetEscrowTransactionsRequest{
37-
ApproverAddress: "BCZEGOb3WNx3fDOVf9ZS4EjvOIv_UeW4TVBQJ_6tHKlE",
37+
ApproverAddress: []byte{0, 0, 0, 0, 98, 118, 38, 51, 199, 143, 112, 175, 220, 74, 221, 170, 56, 103, 159, 209, 242, 132, 219,
38+
155, 169, 123, 104, 77, 139, 18, 224, 166, 162, 83, 125, 96},
3839
Statuses: []rpcModel.EscrowStatus{
3940
rpcModel.EscrowStatus_Approved,
4041
},

0 commit comments

Comments
 (0)