Skip to content

Bug fixes and tidying up #799

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 135 commits into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 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
06d5664
setter and recipient must be the same person (#755)
astaphobia Apr 15, 2020
d36ded2
Fix: P2P - Can't Add UnresolvedPeers (#757)
andy-shi88 Apr 15, 2020
b277190
remove duplicate removal query (#758)
andy-shi88 Apr 16, 2020
2220101
Optimize database transaction (#756)
astaphobia Apr 20, 2020
f96417c
CMD fix and addition (#762)
capt4ce Apr 21, 2020
1fefc0e
Use QueryRow instead of Query when getting single record (#764)
astaphobia Apr 21, 2020
d66b362
fix query and the unit tests (#765)
capt4ce Apr 21, 2020
3dc7662
Confirm the state of download finish if the whole network stuck (#770)
capt4ce Apr 22, 2020
c685aef
Unit Test Transaction Core Service (#767)
nawikart Apr 23, 2020
b72db3a
GetBlockByHeight: Query row instead of Query (#768)
astaphobia Apr 23, 2020
3dc78ed
fix finish download (#771)
capt4ce Apr 23, 2020
910ef07
reset db automatically and also snapshots stuff (#772)
astaphobia Apr 23, 2020
d69c16b
Fix manifest rollback (#773)
andy-shi88 Apr 23, 2020
8b6ccb7
#777 update validate block function signature : remove timestamp (#779)
andy-shi88 Apr 24, 2020
b853785
move the validation of download finish if the block height is 0 (#781)
capt4ce Apr 24, 2020
7bb216e
Bug limit receipt selection when select by root 774 (#776)
nawikart Apr 27, 2020
a9783fd
782 missing blocks fix (#783)
andy-shi88 Apr 27, 2020
fa9b6ad
Getting own public ip (#784)
astaphobia Apr 29, 2020
2b7825d
Fixing error nil pointer when accessing sql.Tx Executor (#786)
sukrawidhyawan Apr 29, 2020
704083f
Sort poppedBlocks by height ascending (#787)
astaphobia Apr 29, 2020
f151c43
#792 replace spendable with balance (#793)
andy-shi88 Apr 29, 2020
d970492
04302020 ignored whitespace
astaphobia Apr 30, 2020
03557bc
Genesis generate command: Code Refactoring and adding new feature to …
iltoga May 4, 2020
d15670c
Limiter must be 2*MinRollbackHeight (#795)
astaphobia May 5, 2020
4fc25df
789 multisig pending transaction Apply-Flow (#798)
andy-shi88 May 5, 2020
08d73cc
Tech: GetAccountBalances #785 (#788)
nawikart May 5, 2020
b476890
fix the status for easier debug (#803)
capt4ce May 6, 2020
666b006
Bug: Limit Receipt Selection When Select By Root (#808)
nawikart May 6, 2020
26babb5
UnitTest-ApiService-GetBalances (#804)
nawikart May 8, 2020
df40d92
first commit (#807)
nawikart May 8, 2020
48ed2ab
#800 do mempool backup before executing derived query Rollback() meth…
andy-shi88 May 8, 2020
4d6d207
remove key from badger db after mempools backup restored (#811)
astaphobia May 11, 2020
90108c8
Merge branch 'develop' of github.com:zoobc/zoobc-core into 04302020
astaphobia May 11, 2020
8373443
add badger metrics to prometheus (#815)
capt4ce May 11, 2020
8eaf3f7
enhance error logging for pushBlock and validateBlock process (#818)
capt4ce May 11, 2020
d7de5ab
change block_height to reference_block_height (#820)
nawikart May 11, 2020
e1c0c6f
Bug: Missing Rollback When BackupMempool Fail in PoppedOffBlock #802 …
nawikart May 14, 2020
e391d9c
Unit test api handler account dataset (#821)
nawikart May 14, 2020
b475b71
Expire musig pending transaction (#828)
astaphobia May 14, 2020
bd7da4c
Unit test api block handler (#830)
nawikart May 14, 2020
625cd5e
Unit test api mempool handler (#831)
nawikart May 14, 2020
c20ba7b
829 download escrow transaction (#834)
andy-shi88 May 14, 2020
da5d08e
Hotfix deepcopy broadcast block (#837)
andy-shi88 May 14, 2020
cf44429
merge develop and fix conflicts
astaphobia May 14, 2020
c02fdc4
use map to reduce loop complexity (#838)
andy-shi88 May 14, 2020
005dcd3
Merge branch 'develop' of github.com:zoobc/zoobc-core into 04302020
astaphobia May 14, 2020
b0fbdba
get the latest account balances (#839)
astaphobia May 14, 2020
62641ac
Merge branch 'develop' of github.com:zoobc/zoobc-core into 04302020
astaphobia May 14, 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
13 changes: 10 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@ 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
for host in $ln1 $ln2 $ln3; do
echo "Trying to reset db on $host"
ssh root@$host 'cd /root/zoobc/resource && for f in *.db; do mv -- "$f" "_$f"; done && rm -rf snapshots* *_kv';
done;
else
echo "All good without reset db";
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';
echo "Trying to reset db on ${ln4}"
ssh root@$ln4 'cd /root/zoobc/resource && for f in *.db; do mv -- "$f" "_$f"; done && rm -rf snapsnots* *_kv';
else
echo "All good without reset db"
fi

jobs:
prepare:
<<: *defaults
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ resource/zoobc_*
resource/snapshots*
resource_cluster/zoobc_*
resource/*.prof
resource/generated
cmd/*.new
accounts.txt
.editorconfig
.manual
release/
github.token
*.back
*.bak
48 changes: 48 additions & 0 deletions api/client/GetAccountBalances/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package main

import (
"context"
"fmt"

log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
rpc_model "github.com/zoobc/zoobc-core/common/model"
rpc_service "github.com/zoobc/zoobc-core/common/service"
"github.com/zoobc/zoobc-core/common/util"
"google.golang.org/grpc"
)

func main() {
var apiRPCPort int
if err := util.LoadConfig("../../../resource", "config", "toml"); err != nil {
log.Fatal(err)
} else {
apiRPCPort = viper.GetInt("apiRPCPort")
if apiRPCPort == 0 {
apiRPCPort = 8080
}
}

conn, err := grpc.Dial(fmt.Sprintf(":%d", apiRPCPort), grpc.WithInsecure())
if err != nil {
log.Fatalf("did not connect: %s", err)
}
defer conn.Close()

c := rpc_service.NewAccountBalanceServiceClient(conn)

response, err := c.GetAccountBalances(context.Background(), &rpc_model.GetAccountBalancesRequest{
AccountAddresses: []string{
"OnEYzI-EMV6UTfoUEzpQUjkSlnqB82-SyRN7469lJTWH",
"BCZEGOb3WNx3fDOVf9ZS4EjvOIv_UeW4TVBQJ_6tHKlE",
"iSJt3H8wFOzlWKsy_UoEWF_OjF6oymHMqthyUMDKSyxb",
},
})

if err != nil {
log.Fatalf("error calling rpc_service.GetAccountBalance: %s", err)
}

log.Printf("response from remote rpc_service.GetBlockByID(): %s", response)

}
18 changes: 13 additions & 5 deletions api/handler/accountBalanceHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ import (

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

type AccountBalanceHandler struct {
Service service.AccountBalanceServiceInterface
}
type (
AccountBalanceHandler struct {
Service service.AccountBalanceServiceInterface
}
)

func (abh *AccountBalanceHandler) GetAccountBalance(ctx context.Context,
request *model.GetAccountBalanceRequest) (*model.GetAccountBalanceResponse, error) {
Expand All @@ -22,6 +26,10 @@ func (abh *AccountBalanceHandler) GetAccountBalance(ctx context.Context,

func (abh *AccountBalanceHandler) GetAccountBalances(ctx context.Context,
request *model.GetAccountBalancesRequest) (*model.GetAccountBalancesResponse, error) {
// todo: implement this after have filter
return nil, nil

if len(request.AccountAddresses) == 0 {
return nil, status.Error(codes.InvalidArgument, "At least 1 address is required")
}

return abh.Service.GetAccountBalances(request)
}
161 changes: 161 additions & 0 deletions api/handler/accountBalanceHandler_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
package handler

import (
"context"
"errors"
"reflect"
"testing"

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

type (
mockGetAccountBalanceError struct {
service.AccountBalanceServiceInterface
}
mockGetAccountBalanceSuccess struct {
service.AccountBalanceServiceInterface
}
)

func (*mockGetAccountBalanceError) GetAccountBalance(request *model.GetAccountBalanceRequest) (*model.GetAccountBalanceResponse, error) {
return nil, errors.New("error GetAccountBalance")
}
func (*mockGetAccountBalanceSuccess) GetAccountBalance(request *model.GetAccountBalanceRequest) (*model.GetAccountBalanceResponse, error) {
return &model.GetAccountBalanceResponse{
AccountBalance: &model.AccountBalance{
AccountAddress: request.AccountAddress,
},
}, nil
}

func TestAccountBalanceHandler_GetAccountBalance(t *testing.T) {
type fields struct {
Service service.AccountBalanceServiceInterface
}
type args struct {
ctx context.Context
request *model.GetAccountBalanceRequest
}
tests := []struct {
name string
fields fields
args args
want *model.GetAccountBalanceResponse
wantErr bool
}{
{
name: "GetAccountBalance:fail",
fields: fields{
Service: &mockGetAccountBalanceError{},
},
want: nil,
wantErr: true,
},
{
name: "GetAccountBalance:success",
fields: fields{
Service: &mockGetAccountBalanceSuccess{},
},
args: args{
request: &model.GetAccountBalanceRequest{
AccountAddress: "BCZnSfqpP5tqFQlMTYkDeBVFWnbyVK7vLr5ORFpTjgtN",
},
},
want: &model.GetAccountBalanceResponse{
AccountBalance: &model.AccountBalance{
AccountAddress: "BCZnSfqpP5tqFQlMTYkDeBVFWnbyVK7vLr5ORFpTjgtN",
},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
abh := &AccountBalanceHandler{
Service: tt.fields.Service,
}
got, err := abh.GetAccountBalance(tt.args.ctx, tt.args.request)
if (err != nil) != tt.wantErr {
t.Errorf("AccountBalanceHandler.GetAccountBalance() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("AccountBalanceHandler.GetAccountBalance() = %v, want %v", got, tt.want)
}
})
}
}

type (
mockGetAccountBalancesSuccess struct {
service.AccountBalanceServiceInterface
}
)

func (*mockGetAccountBalancesSuccess) GetAccountBalances(request *model.GetAccountBalancesRequest) (*model.GetAccountBalancesResponse, error) {
return &model.GetAccountBalancesResponse{
AccountBalances: []*model.AccountBalance{},
}, nil
}

func TestAccountBalanceHandler_GetAccountBalances(t *testing.T) {
type fields struct {
Service service.AccountBalanceServiceInterface
}
type args struct {
ctx context.Context
request *model.GetAccountBalancesRequest
}
tests := []struct {
name string
fields fields
args args
want *model.GetAccountBalancesResponse
wantErr bool
}{
{
name: "GetAccountBalancesHandler:fail",
args: args{
request: &model.GetAccountBalancesRequest{
AccountAddresses: []string{},
},
},
want: nil,
wantErr: true,
},
{
name: "GetAccountBalancesHandler:success",
args: args{
request: &model.GetAccountBalancesRequest{
AccountAddresses: []string{
"BCZnSfqpP5tqFQlMTYkDeBVFWnbyVK7vLr5ORFpTjgtN",
},
},
},
fields: fields{
Service: &mockGetAccountBalancesSuccess{},
},
want: &model.GetAccountBalancesResponse{
AccountBalances: []*model.AccountBalance{},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
abh := &AccountBalanceHandler{
Service: tt.fields.Service,
}
got, err := abh.GetAccountBalances(tt.args.ctx, tt.args.request)
if (err != nil) != tt.wantErr {
t.Errorf("AccountBalanceHandler.GetAccountBalances() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("AccountBalanceHandler.GetAccountBalances() = %v, want %v", got, tt.want)
}
})
}
}
Loading