From bf6521b385ef60102f8f820a149b94c134604a6f Mon Sep 17 00:00:00 2001 From: astaphobia Date: Wed, 26 Feb 2020 16:01:35 +0800 Subject: [PATCH 1/5] no need to validate current block height --- common/transaction/sendMoney.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/common/transaction/sendMoney.go b/common/transaction/sendMoney.go index 3c2ca882c..d10ff5a1b 100644 --- a/common/transaction/sendMoney.go +++ b/common/transaction/sendMoney.go @@ -292,7 +292,6 @@ Escrow Part func (tx *SendMoney) EscrowValidate(dbTx bool) error { var ( accountBalance model.AccountBalance - block *model.Block err error row *sql.Row ) @@ -310,14 +309,6 @@ func (tx *SendMoney) EscrowValidate(dbTx bool) error { return blocker.NewBlocker(blocker.ValidationErr, "RecipientAddressRequired") } - block, err = util.GetLastBlock(tx.QueryExecutor, tx.BlockQuery) - if err != nil { - return blocker.NewBlocker(blocker.ValidationErr, err.Error()) - } - if uint64(block.GetHeight()) >= tx.Escrow.GetTimeout() { - return blocker.NewBlocker(blocker.ValidationErr, "TransactionExpired") - } - // todo: this is temporary solution, later we should depend on coinbase, so no genesis transaction exclusion in // validation needed if tx.SenderAddress != constant.MainchainGenesisAccountAddress { From bde5785ded4cbf95a260f80799e3b576c0375ca8 Mon Sep 17 00:00:00 2001 From: astaphobia Date: Tue, 10 Mar 2020 11:00:28 +0800 Subject: [PATCH 2/5] testing new ci configuration --- .circleci/config.yml | 213 +++++++++++++++++++++++++++---------------- 1 file changed, 134 insertions(+), 79 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 29e763742..c8c3d65da 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,29 +3,29 @@ jobs: prepare: working_directory: ~/zoobc docker: - - image: circleci/golang:1.14.0 + - image: circleci/golang:1.14.0-buster steps: - run: - name: SSH - command: git config --global url.ssh://git@github.com/zoobc.insteadOf https://github.com/zoobc + name: SSH + command: git config --global url.ssh://git@github.com/zoobc.insteadOf https://github.com/zoobc - checkout - restore_cache: - key: gopkg-{{ .Branch }}-{{ checksum "go.sum" }} - - run: - name: GOMOD - command: | - if [ ! -d ls | grep go.mod ]; then - go mod init - fi - go mod download + key: gopkg-{{ .Branch }}-{{ checksum "go.sum" }} + - run: + name: GOMOD + command: | + if [ ! -d ls | grep go.mod ]; then + go mod init + fi + go mod download - save_cache: - key: gopkg-{{ .Branch }}-{{ checksum "go.sum" }} - paths: - - /go/pkg/mod + key: gopkg-{{ .Branch }}-{{ checksum "go.sum" }} + paths: + - /go/pkg/mod test: working_directory: ~/zoobc docker: - - image: circleci/golang:1.14.0 + - image: circleci/golang:1.14.0-buster environment: - GOLANGCI_LINT: 1.20.0 steps: @@ -33,101 +33,156 @@ jobs: - restore_cache: key: gopkg-{{ .Branch }}-{{ checksum "go.sum" }} - run: - name: ↓ GOLANGCI-LINT - command: | - curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v${GOLANGCI_LINT} + name: ↓ GOLANGCI-LINT + command: | + curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v${GOLANGCI_LINT} - run: - name: ↓ GOLINT - command: go get -u golang.org/x/lint/golint + name: ↓ GOLINT + command: go get -u golang.org/x/lint/golint - run: - name: TEST - command: go test `go list ./... | egrep -v 'common/model|common/service'` --short + name: TEST + command: go test `go list ./... | egrep -v 'common/model|common/service'` --short - run: - name: GO FMT - command: go fmt `go list ./... | egrep -v 'common/model|common/service|vendor'` + name: GO FMT + command: go fmt `go list ./... | egrep -v 'common/model|common/service|vendor'` - run: - name: GOLANGCI-LINT RUN - command: golangci-lint run + name: GOLANGCI-LINT RUN + command: golangci-lint run - run: - name: GOLINT RUN - command: golint `go list ./... | egrep -v 'vendor|common/model|common/service'` + name: GOLINT RUN + command: golint `go list ./... | egrep -v 'vendor|common/model|common/service'` - save_cache: - key: gopkg-{{ .Branch }}-{{ checksum "go.sum" }} - paths: - - /go/pkg/mod + key: gopkg-{{ .Branch }}-{{ checksum "go.sum" }} + paths: + - /go/pkg/mod build: working_directory: ~/zoobc docker: - - image: circleci/golang:1.14.0 + - image: circleci/golang:1.14.0-buster steps: - checkout - restore_cache: - key: gopkg-{{ .Branch }}-{{ checksum "go.sum" }} + key: gopkg-{{ .Branch }}-{{ checksum "go.sum" }} - restore_cache: - key: build-cache-{{ .Branch }}-{{ .Environment.CIRCLE_PREVIOUS_BUILD_NUM }} - paths: - - ./dist - - run: - name: ↓ RSYNC - command: | - if [ ! -d rsync ]; then - sudo apt-get update && sudo apt-get install rsync - fi - - run: - name: BUILD - command: | - go build -o ./dist/zoobc -# rsync -va --exclude='*.db' ./resource ./dist + key: build-cache-{{ .Branch }}-{{ .Environment.CIRCLE_PREVIOUS_BUILD_NUM }} + paths: + - ./dist + - run: + name: ↓ RSYNC + command: | + if [ ! -d rsync ]; then + sudo apt-get update && sudo apt-get install rsync + fi + - run: + name: BUILD + command: | + go build -o ./dist/zoobc + # rsync -va --exclude='*.db' ./resource ./dist + - run: + name: ADD HOSTS + command: for host in $ln1 $ln2 $ln3; do ssh-keyscan $host >> ~/.ssh/known_hosts; done + - run: + name: DOWN SERVICES + command: | + for host in $ln1 $ln2 $ln3; do ssh root@$host 'sudo systemctl stop zoobc.service'; done + - run: + name: DEPLOY + command: | + for host in $ln1 $ln2 $ln3; do rsync -vae ssh ./dist/ root@$host:/root/zoobc --exclude='*.db'; done + - run: + name: UP SERVICES + command: | + for host in $ln1 $ln2 $ln3; do ssh root@$host 'sudo systemctl start zoobc.service'; done + - save_cache: - key: build-cache-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }} - paths: - - ./dist + key: build-cache-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }} + paths: + - ./dist deploy-develop: working_directory: ~/zoobc docker: - - image: circleci/golang:1.14.0 + - image: circleci/golang:1.14.0-buster + steps: + - checkout + - add_ssh_keys + - run: + name: ↓ RSYNC + command: | + if [ ! -d rsync ]; then + sudo apt-get update && sudo apt-get install rsync + fi + - restore_cache: + key: build-cache-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }} + paths: + - ./dist + - run: + name: ADD HOSTS + command: for host in $ln1 $ln2 $ln3; do ssh-keyscan $host >> ~/.ssh/known_hosts; done + - run: + name: DOWN SERVICES + command: | + for host in $ln1 $ln2 $ln3; do ssh root@$host 'sudo systemctl stop zoobc.service'; done + - run: + name: DEPLOY + command: | + for host in $ln1 $ln2 $ln3; do rsync -vae ssh ./dist/ root@$host:/root/zoobc --exclude='*.db'; done + - run: + name: UP SERVICES + command: | + for host in $ln1 $ln2 $ln3; do ssh root@$host 'sudo systemctl start zoobc.service'; done + deploy-staging: + working_directory: ~/zoobc + docker: + - image: circleci/golang:1.14.0-buster steps: - checkout - add_ssh_keys - run: - name: ↓ RSYNC - command: | - if [ ! -d rsync ]; then - sudo apt-get update && sudo apt-get install rsync - fi + name: ↓ RSYNC + command: | + if [ ! -d rsync ]; then + sudo apt-get update && sudo apt-get install rsync + fi - restore_cache: - key: build-cache-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }} - paths: - - ./dist + key: build-cache-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }} + paths: + - ./dist - run: - name: ADD HOSTS - command: for host in $ln1 $ln2 $ln3 $ln4; do ssh-keyscan $host >> ~/.ssh/known_hosts; done + name: ADD HOST + command: | + ssh-keyscan $ln4 >> ~/.ssh/known_hosts - run: - name: DOWN SERVICES - command: | - for host in $ln1 $ln2 $ln3 $ln4; do ssh root@$host 'sudo systemctl stop zoobc.service'; done + name: DOWN SERVICE + command: | + ssh root@$ln4 'sudo systemctl stop zoobc.service' - run: - name: DEPLOY - command: | - for host in $ln1 $ln2 $ln3 $ln4; do rsync -vae ssh ./dist/ root@$host:/root/zoobc --exclude='*.db'; done + name: DEPLOY APP + command: | + rsync -vae ssh ./dist/ root@$ln4:/root/zoobc --exclude='*.db' - run: - name: UP SERVICES - command: | - for host in $ln1 $ln2 $ln3 $ln4; do ssh root@$host 'sudo systemctl start zoobc.service'; done + name: UP SERVICE + command: | + ssh root@$ln4 'sudo systemctl start zoobc.service' workflows: version: 2 prepare-deploy: jobs: - prepare - test: - requires: - - prepare + requires: + - prepare - build: - requires: - - test + requires: + - test - deploy-develop: - requires: - - build - filters: - branches: - only: develop \ No newline at end of file + requires: + - build + filters: + branches: + only: develop + - deploy-staging: + required: + - build + filters: + branches: + only: staging \ No newline at end of file From 7bfade019982ba6dde42663246b516f726251f30 Mon Sep 17 00:00:00 2001 From: astaphobia Date: Tue, 10 Mar 2020 11:03:49 +0800 Subject: [PATCH 3/5] fixed invalid config --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c8c3d65da..884380dd8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -181,7 +181,7 @@ workflows: branches: only: develop - deploy-staging: - required: + requires: - build filters: branches: From 8109ecadb8f750be0575830a632bf2783d3f27eb Mon Sep 17 00:00:00 2001 From: astaphobia Date: Tue, 10 Mar 2020 11:11:12 +0800 Subject: [PATCH 4/5] change image version to stretch --- .circleci/config.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 884380dd8..8502744ee 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ jobs: prepare: working_directory: ~/zoobc docker: - - image: circleci/golang:1.14.0-buster + - image: circleci/golang:1.14.0-stretch steps: - run: name: SSH @@ -25,7 +25,7 @@ jobs: test: working_directory: ~/zoobc docker: - - image: circleci/golang:1.14.0-buster + - image: circleci/golang:1.14.0-stretch environment: - GOLANGCI_LINT: 1.20.0 steps: @@ -58,7 +58,7 @@ jobs: build: working_directory: ~/zoobc docker: - - image: circleci/golang:1.14.0-buster + - image: circleci/golang:1.14.0-stretch steps: - checkout - restore_cache: @@ -101,7 +101,7 @@ jobs: deploy-develop: working_directory: ~/zoobc docker: - - image: circleci/golang:1.14.0-buster + - image: circleci/golang:1.14.0-strech steps: - checkout - add_ssh_keys @@ -133,7 +133,7 @@ jobs: deploy-staging: working_directory: ~/zoobc docker: - - image: circleci/golang:1.14.0-buster + - image: circleci/golang:1.14.0-stretch steps: - checkout - add_ssh_keys From 35c40c23becf4660e31a87c89c9ac9a4769b7a27 Mon Sep 17 00:00:00 2001 From: astaphobia Date: Tue, 10 Mar 2020 11:18:29 +0800 Subject: [PATCH 5/5] remove configuration for test purposes --- .circleci/config.yml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8502744ee..672cff8be 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -78,22 +78,6 @@ jobs: command: | go build -o ./dist/zoobc # rsync -va --exclude='*.db' ./resource ./dist - - run: - name: ADD HOSTS - command: for host in $ln1 $ln2 $ln3; do ssh-keyscan $host >> ~/.ssh/known_hosts; done - - run: - name: DOWN SERVICES - command: | - for host in $ln1 $ln2 $ln3; do ssh root@$host 'sudo systemctl stop zoobc.service'; done - - run: - name: DEPLOY - command: | - for host in $ln1 $ln2 $ln3; do rsync -vae ssh ./dist/ root@$host:/root/zoobc --exclude='*.db'; done - - run: - name: UP SERVICES - command: | - for host in $ln1 $ln2 $ln3; do ssh root@$host 'sudo systemctl start zoobc.service'; done - - save_cache: key: build-cache-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }} paths: