From d96ed334e160cfab8670520a1855ad3e0da91711 Mon Sep 17 00:00:00 2001 From: astaphobia Date: Tue, 2 Jun 2020 07:39:05 +0800 Subject: [PATCH 01/12] cmd genesis generator and update circleci config --- .circleci/config.yml | 9 ++++- .gitignore | 1 + Makefile | 12 ++++++ cmd/genesisblock/cmd.go | 38 +++++++++++++------ cmd/genesisblock/const.go | 26 +++++++++++++ ...son => alpha.genesisAccountAddresses.json} | 2 +- ... => alpha.preRegisteredNodes.json.example} | 0 .../templates/develop.preRegisteredNodes.json | 32 ++++++++++++++++ .../templates/staging.preRegisteredNodes.json | 12 ++++++ cmd/readme.md | 21 +++++++++- readme.md | 23 ++++++----- 11 files changed, 147 insertions(+), 29 deletions(-) rename cmd/genesisblock/templates/{genesisAccountAddresses.json => alpha.genesisAccountAddresses.json} (98%) rename cmd/genesisblock/templates/{preRegisteredNodes.json.example => alpha.preRegisteredNodes.json.example} (100%) create mode 100644 cmd/genesisblock/templates/develop.preRegisteredNodes.json create mode 100644 cmd/genesisblock/templates/staging.preRegisteredNodes.json diff --git a/.circleci/config.yml b/.circleci/config.yml index 08d3127b7..6d8c3b6d9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -85,6 +85,11 @@ jobs: if [ ! -d rsync ]; then sudo apt-get update && sudo apt-get install rsync fi + - run: + name: GENERATING GENESIS + command: | + go run cmd/main.go genesis -e ${CIRLE_BRANCH} -o dist \ + && cp ./dist/generated/genesis/genesis.go ./common/constant/genesis.go - run: name: BUILD command: | @@ -120,7 +125,7 @@ jobs: - run: name: DEPLOY command: | - for host in $ln1 $ln2 $ln3; do rsync -vae ssh ./dist/ root@$host:/root/zoobc --exclude='*.db'; done + for host in $ln1 $ln2 $ln3; do rsync -vae ssh ./dist/ root@$host:/root/zoobc --exclude='*.db' --exclude='generated'; done - run: name: UP SERVICES command: | @@ -152,7 +157,7 @@ jobs: - run: name: DEPLOY APP command: | - rsync -vae ssh ./dist/ root@$ln4:/root/zoobc --exclude='*.db' + rsync -vae ssh ./dist/ root@$ln4:/root/zoobc --exclude='*.db' --exclude='generated' - run: name: UP SERVICE command: | diff --git a/.gitignore b/.gitignore index 3ee901e98..cf3c4e096 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ accounts.txt .editorconfig .manual release/ +dist/ github.token *.back *.bak diff --git a/Makefile b/Makefile index c3a72e053..120c06861 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,9 @@ VERSION ?= latest BINARY_CORE := zoobc BINARY_CLI := zoomd GITHUB_TOKEN ?= $(shell cat github.token) +genesis := false +gen-target:= alpha +gen-output := resource .PHONY: test test: go-fmt golangci-lint @@ -30,8 +33,17 @@ go-fmt: $(info running go-fmt...) go fmt `go list ./... | egrep -v 'common/model|common/service|vendor'` +.PHONY: generate-gen +generate-gen: + $(info generating new genesis file and replace old genesis file ...) + go run cmd/main.go genesis generate -e ${gen-target} -o ${gen-output} + mv ./${gen-output}/generated/genesis/genesis.go ./common/constant/genesis.go + .PHONY: build build: +ifdef genesis + $(MAKE) generate-gen +endif $(info build core with host os as target...) mkdir -p release go build -o release/$(BINARY_CORE)-$(VERSION) diff --git a/cmd/genesisblock/cmd.go b/cmd/genesisblock/cmd.go index f66057720..ef62f2af7 100644 --- a/cmd/genesisblock/cmd.go +++ b/cmd/genesisblock/cmd.go @@ -8,6 +8,8 @@ import ( "io/ioutil" "log" "os" + "path" + "strings" "text/template" "time" @@ -56,6 +58,9 @@ var ( Short: "genesis generate command used to generate a new genesis.go and cluster_config.json file", Long: `genesis generate command generate a genesis.go file from a list of accounts and/or from current database.`, Run: func(cmd *cobra.Command, args []string) { + if _, ok := envTarget_value[envTarget]; !ok { + log.Fatal("Invalid env-target flag given, only: develop,staging,alpha") + } generateGenesisFiles(withDbLastState, dbPath, extraNodesCount) }, } @@ -82,9 +87,11 @@ func init() { genesisGeneratorCmd.Flags().StringVar(&deploymentName, "deploymentName", "zoobc-alpha", "nomad task name associated to this deployment") genesisGeneratorCmd.Flags().StringVar(&kvFileCustomConfigFile, "kvFileCustomConfigFile", "", - "(optional) full path (path + fileNane) of a custom cluster_config.json file to use to generate consulKvInitScript."+ + "(optional) full path (path + fileName) of a custom cluster_config.json file to use to generate consulKvInitScript."+ "sh instead of the automatically generated in resource/generated/genesis directory") + genesisGeneratorCmd.Flags().StringVarP(&envTarget, "env-target", "e", "alpha", "env mode indeed a.k.a develop,staging,alpha") + genesisGeneratorCmd.Flags().StringVarP(&output, "output", "o", "resource", "output generated files target") genesisCmd.AddCommand(genesisGeneratorCmd) } @@ -116,8 +123,7 @@ func generateGenesisFiles(withDbLastState bool, dbPath string, extraNodesCount i log.Fatal(err) } } - - file, err := ioutil.ReadFile("./genesisblock/templates/preRegisteredNodes.json") + file, err := ioutil.ReadFile(path.Join(getRootPath(), fmt.Sprintf("./cmd/genesisblock/templates/%s.preRegisteredNodes.json", envTarget))) if err == nil { err = json.Unmarshal(file, &preRegisteredNodes) if err != nil { @@ -158,7 +164,7 @@ func generateGenesisFiles(withDbLastState bool, dbPath string, extraNodesCount i } // generate extra nodes from a json file containing only account addresses - file, err = ioutil.ReadFile("./genesisblock/templates/genesisAccountAddresses.json") + file, err = ioutil.ReadFile(path.Join(getRootPath(), fmt.Sprintf("./cmd/genesisblock/templates/%s.genesisAccountAddresses.json", envTarget))) if err == nil { // read custom addresses from file err = json.Unmarshal(file, &preRegisteredAccountAddresses) @@ -175,7 +181,8 @@ func generateGenesisFiles(withDbLastState bool, dbPath string, extraNodesCount i } // append to preRegistered nodes/accounts previous entries from a blockchain db file - outPath := "../resource/generated/genesis" + var outPath = path.Join(getRootPath(), fmt.Sprintf("%s/generated/genesis", output)) + if err := os.MkdirAll(outPath, os.ModePerm); err != nil { log.Fatalf("can't create folder %s. error: %s", outPath, err) } @@ -194,14 +201,14 @@ func generateGenesisFiles(withDbLastState bool, dbPath string, extraNodesCount i accountNodes = append(accountNodes, newEntry) } generateAccountNodesFile(accountNodes, fmt.Sprintf("%s/accountNodes.json", outPath)) - fmt.Println("Command executed successfully\ngenesis.go.new has been generated in resource/generated/genesis") - fmt.Println("to apply new genesis to the core-node, please overwrite common/constant/genesis." + - "go with the new one: resource/generated/genesis/genesis.go") + fmt.Printf("Command executed successfully\ngenesis.go.new has been generated in %s\n", outPath) + fmt.Printf("to apply new genesis to the core-node, please overwrite common/constant/genesis."+ + "go with the new one: %s/genesis.go", outPath) } // generateRandomGenesisEntry randomly generates a genesis node entry // note: the account address is mandatory for the node registration, but as there is no wallet connected to it -// and we are not storing the relaitve seed, needed to sign transactions, these nodes can smith but their owners +// and we are not storing the relative seed, needed to sign transactions, these nodes can smith but their owners // can't perform any transaction. // This is only useful to test multiple smithing-nodes, for instence in a network stress test of tens of nodes connected together func generateRandomGenesisEntry(nodeIdx int, accountAddress string) genesisEntry { @@ -333,8 +340,7 @@ func getDbLastState(dbPath string) (bcEntries []genesisEntry, err error) { // generateGenesisFile generates a genesis file with given entries, starting from a template func generateGenesisFile(genesisEntries []genesisEntry, newGenesisFilePath string) { // read and execute genesis template, outputting the genesis.go to stdout - // genesisTmpl, err := helpers.ReadTemplateFile("./genesis.tmpl") - tmpl, err := template.ParseFiles("./genesisblock/templates/genesis.tmpl") + tmpl, err := template.ParseFiles(path.Join(getRootPath(), "./cmd/genesisblock/templates/genesis.tmpl")) if err != nil { log.Fatalf("Error while reading genesis.tmpl file: %s", err) } @@ -464,7 +470,7 @@ func generateAccountNodesFile(accountNodeEntris []accountNodeEntry, configFilePa func generateConsulKvInitScript(clusterConfigEntries []clusterConfigEntry, consulKvInitScriptPath string) { // read and execute genesis template, outputting the genesis.go to stdout // genesisTmpl, err := helpers.ReadTemplateFile("./genesis.tmpl") - tmpl, err := template.ParseFiles("./genesisblock/templates/consulKvInit.tmpl") + tmpl, err := template.ParseFiles(path.Join(getRootPath(), "./cmd/genesisblock/templates/consulKvInit.tmpl")) if err != nil { log.Fatalf("Error while reading consulKvInit.tmpl file: %s", err) } @@ -506,6 +512,14 @@ func generateConsulKvInitScript(clusterConfigEntries []clusterConfigEntry, consu } } +func getRootPath() string { + wd, _ := os.Getwd() + if strings.Contains(wd, "zoobc-core") { + return wd + } + return path.Join(wd, "../") +} + func (ge *genesisEntry) FormatPubKeyByteString() string { if ge.NodePublicKeyB64 == "" { return "" diff --git a/cmd/genesisblock/const.go b/cmd/genesisblock/const.go index f2af218bf..69bd4d03f 100644 --- a/cmd/genesisblock/const.go +++ b/cmd/genesisblock/const.go @@ -2,6 +2,20 @@ package genesisblock import "github.com/spf13/cobra" +const ( + envTargetDevelop envTargetType = 0 + envTargetStaging envTargetType = 1 + envTargetAlpha envTargetType = 2 + envTargetLocal envTargetType = 3 +) + +type ( + /* + ENV Target enum + */ + envTargetType uint32 +) + var ( genesisCmd = &cobra.Command{ Use: "genesis", @@ -22,4 +36,16 @@ var ( wellKnownPeers string deploymentName string kvFileCustomConfigFile string + + /* + ENV Target + */ + envTarget string + output string + envTarget_value = map[string]uint32{ + "develop": 0, + "staging": 1, + "alpha": 2, + "local": 3, + } ) diff --git a/cmd/genesisblock/templates/genesisAccountAddresses.json b/cmd/genesisblock/templates/alpha.genesisAccountAddresses.json similarity index 98% rename from cmd/genesisblock/templates/genesisAccountAddresses.json rename to cmd/genesisblock/templates/alpha.genesisAccountAddresses.json index a9ca741db..756140b3f 100644 --- a/cmd/genesisblock/templates/genesisAccountAddresses.json +++ b/cmd/genesisblock/templates/alpha.genesisAccountAddresses.json @@ -7,7 +7,7 @@ }, { "AccountAddress": "9GeYVrSS5-Apt5CtCYiZ8RVtHprENoRfdAiVO213PGN0" - }, + } { "AccountAddress": "XTkJNxs3qi2bjcB0jCkgo2SWTAidgmdC38zn4dugCjIT" }, diff --git a/cmd/genesisblock/templates/preRegisteredNodes.json.example b/cmd/genesisblock/templates/alpha.preRegisteredNodes.json.example similarity index 100% rename from cmd/genesisblock/templates/preRegisteredNodes.json.example rename to cmd/genesisblock/templates/alpha.preRegisteredNodes.json.example diff --git a/cmd/genesisblock/templates/develop.preRegisteredNodes.json b/cmd/genesisblock/templates/develop.preRegisteredNodes.json new file mode 100644 index 000000000..3933a1b2d --- /dev/null +++ b/cmd/genesisblock/templates/develop.preRegisteredNodes.json @@ -0,0 +1,32 @@ +[ + { + "AccountAddress": "BCZEGOb3WNx3fDOVf9ZS4EjvOIv_UeW4TVBQJ_6tHKlE", + "AccountBalance": 0, + "NodeSeed": "sprinkled sneak species pork outpost thrift unwind cheesy vexingly dizzy neurology neatness", + "NodePublicKeyB64": "mToyyAc9bOXMMMeRFWN9SzEtdmHbUPL0ZIaQ9iWQ1Yc=", + "LockedBalance": 0, + "NodeAddress": "172.104.34.10:8080", + "ParticipationScore": 0, + "Smithing": true + }, + { + "AccountAddress": "OnEYzI-EMV6UTfoUEzpQUjkSlnqB82-SyRN7469lJTWH", + "AccountBalance": 0, + "NodeSeed": "demanding unlined hazard neuter condone anime asleep ascent capitol sitter marathon armband", + "NodePublicKeyB64": "AA4G2qo2PDICQoJ34ut+ywUMmMKqkis/4GV/8T6Yu/8=", + "LockedBalance": 0, + "NodeAddress": "45.79.39.58:8080", + "ParticipationScore": 0, + "Smithing": true + }, + { + "AccountAddress": "AFiTqqX99kYXjLFJJ2AWuzKK5zxYUT1Pn0p3s6lutkai", + "AccountBalance": 100000000000, + "NodeSeed": "merge plug donor drop cancel inherit extra toss cabbage awkward destroy rail", + "NodePublicKeyB64": "WyTkRmVeuva6BE6OraK7rcpR81yNeJTcKaDQXq6mPs8=", + "LockedBalance": 0, + "NodeAddress": "85.90.246.90:8080", + "ParticipationScore": 0, + "Smithing": true + } +] \ No newline at end of file diff --git a/cmd/genesisblock/templates/staging.preRegisteredNodes.json b/cmd/genesisblock/templates/staging.preRegisteredNodes.json new file mode 100644 index 000000000..d0fde1f5e --- /dev/null +++ b/cmd/genesisblock/templates/staging.preRegisteredNodes.json @@ -0,0 +1,12 @@ +[ + { + "AccountAddress": "iSJt3H8wFOzlWKsy_UoEWF_OjF6oymHMqthyUMDKSyxb", + "AccountBalance": 100000000000, + "NodeSeed": "merge plug donor drop cancel inherit extra toss cabbage awkward destroy rail", + "NodePublicKeyB64": "WyTkRmVeuva6BE6OraK7rcpR81yNeJTcKaDQXq6mPs8=", + "LockedBalance": 0, + "NodeAddress": "172.104.47.168:8080", + "ParticipationScore": 0, + "Smithing": true + } +] \ No newline at end of file diff --git a/cmd/readme.md b/cmd/readme.md index ba9f6ce3e..d81d3965b 100644 --- a/cmd/readme.md +++ b/cmd/readme.md @@ -139,10 +139,27 @@ go run main.go generate account multisig --addresses "BCZnSfqpP5tqFQlMTYkDeBVFWn ``` ## Other Commands +### Genesis ```bash -go run main.go genesis generate +Usage: + zoobc genesis generate [flags] + +Flags: + -f, --dbPath string path of blockchain's database to be used as data source in case the -w flag is used. If not set, the default resource folder is used (default "../resource/") + --deploymentName string nomad task name associated to this deployment (default "zoobc-alpha") + -e, --env-target string env mode indeed a.k.a develop,staging,alpha (default "alpha") + -n, --extraNodes int number of 'extra' autogenerated nodes to be deployed using cluster_config.json + -h, --help help for generate + --kvFileCustomConfigFile string (optional) full path (path + fileName) of a custom cluster_config.json file to use to generate consulKvInitScript.sh instead of the automatically generated in resource/generated/genesis directory + --logLevels string default log levels for all nodes (for kvConsulScript.sh). example: 'warn info fatal error panic' (default "fatal error panic") + -o, --output string output generated files target (default "resource") + --wellKnownPeers string default wellKnownPeers for all nodes (for kvConsulScript.sh). example: 'n0.alpha.proofofparticipation.network n1.alpha.proofofparticipation.network n2.alpha.proofofparticipation.network' (default "127.0.0.1:8001") ``` -outputs cmd/genesis.go.new and cmd/cluster_config.json + +```bash +go run main.go genesis generate -e {local,staging,develop,alpa} -o dist +``` +It will generate files such as genesis.go consul script and more, you can check these inside `${-o}/generated/genesis` directory. ```bash ### Genesis Generate From cmd/genesisblock/preRegisteredNodes.json and resource/zoobc.db diff --git a/readme.md b/readme.md index 45fae91a3..32fc54fbb 100644 --- a/readme.md +++ b/readme.md @@ -16,14 +16,14 @@ Table of Contents: -- [Environments](#environments) -- [Install](#install) -- [Build](#build) -- [Run](#run) -- [Tests](#tests) -- [Swagger](#swagger) -- [Contributing](#contributing) -- [GRPC web proxy for browser](#grpc-web-proxy-for-browser) +- [Environments](#environments) +- [Install](#install) +- [Build](#build) +- [Run](#run) +- [Tests](#tests) +- [Swagger](#swagger) +- [Contributing](#contributing) +- [GRPC web proxy for browser](#grpc-web-proxy-for-browser) ### Environments @@ -52,16 +52,15 @@ Table of Contents: To make use of the `Makefile` please rename `github.token.example` to `github.token` and place your github token there. This is required since we are accessing private repository for one of our dependencies. - Core - - note: For cross compilation please install and activate docker. - + > note: For cross compilation please install and activate docker. For: - host: `go build -o zoobc` - darwin: `make VERSION=v1.10.1 core-darwin` - linux (386 & amd64): `make VERSION=v1.10.1 core-linux` - windows (32 & 64bit): `make VERSION=v1.10.1 core-windows` - + > With genesis replacement, you can add argument `genesis=true` and what your target is {develop,staging,alhpa(default),local}, like: + `make build genesis=true gen-target=develop gen-output=dist` for the local target you need create `local.preRegisteredNodes.json`. - CMD For: From 3392d8e4ca788fe93149b8c917f572839070b92f Mon Sep 17 00:00:00 2001 From: astaphobia Date: Tue, 2 Jun 2020 07:52:07 +0800 Subject: [PATCH 02/12] fix golangci warning --- cmd/genesisblock/cmd.go | 2 +- cmd/genesisblock/const.go | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/cmd/genesisblock/cmd.go b/cmd/genesisblock/cmd.go index ef62f2af7..806375c9e 100644 --- a/cmd/genesisblock/cmd.go +++ b/cmd/genesisblock/cmd.go @@ -58,7 +58,7 @@ var ( Short: "genesis generate command used to generate a new genesis.go and cluster_config.json file", Long: `genesis generate command generate a genesis.go file from a list of accounts and/or from current database.`, Run: func(cmd *cobra.Command, args []string) { - if _, ok := envTarget_value[envTarget]; !ok { + if _, ok := envTargetValue[envTarget]; !ok { log.Fatal("Invalid env-target flag given, only: develop,staging,alpha") } generateGenesisFiles(withDbLastState, dbPath, extraNodesCount) diff --git a/cmd/genesisblock/const.go b/cmd/genesisblock/const.go index 69bd4d03f..4b2c28678 100644 --- a/cmd/genesisblock/const.go +++ b/cmd/genesisblock/const.go @@ -2,13 +2,6 @@ package genesisblock import "github.com/spf13/cobra" -const ( - envTargetDevelop envTargetType = 0 - envTargetStaging envTargetType = 1 - envTargetAlpha envTargetType = 2 - envTargetLocal envTargetType = 3 -) - type ( /* ENV Target enum @@ -40,9 +33,9 @@ var ( /* ENV Target */ - envTarget string - output string - envTarget_value = map[string]uint32{ + envTarget string + output string + envTargetValue = map[string]uint32{ "develop": 0, "staging": 1, "alpha": 2, From e4bf60fb1dc57331a33e6237ec3b3a91de66ce21 Mon Sep 17 00:00:00 2001 From: astaphobia Date: Tue, 2 Jun 2020 07:56:05 +0800 Subject: [PATCH 03/12] remove unused constant --- cmd/genesisblock/const.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/cmd/genesisblock/const.go b/cmd/genesisblock/const.go index 4b2c28678..90d61ee7d 100644 --- a/cmd/genesisblock/const.go +++ b/cmd/genesisblock/const.go @@ -2,13 +2,6 @@ package genesisblock import "github.com/spf13/cobra" -type ( - /* - ENV Target enum - */ - envTargetType uint32 -) - var ( genesisCmd = &cobra.Command{ Use: "genesis", From f4102b19cd515daa1cde9a888d2b3eefe8e2679d Mon Sep 17 00:00:00 2001 From: astaphobia Date: Tue, 2 Jun 2020 08:11:53 +0800 Subject: [PATCH 04/12] build job only for staging and develop --- .circleci/config.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6d8c3b6d9..053f1f4a3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -88,7 +88,7 @@ jobs: - run: name: GENERATING GENESIS command: | - go run cmd/main.go genesis -e ${CIRLE_BRANCH} -o dist \ + go run cmd/main.go genesis generate -e ${CIRLE_BRANCH} -o dist \ && cp ./dist/generated/genesis/genesis.go ./common/constant/genesis.go - run: name: BUILD @@ -176,12 +176,14 @@ workflows: - test - deploy-develop: requires: + - test - build filters: branches: only: develop - deploy-staging: requires: + - test - build filters: branches: From 19358385a9c328d1c812ce843c78f305027b5081 Mon Sep 17 00:00:00 2001 From: astaphobia Date: Tue, 2 Jun 2020 08:17:46 +0800 Subject: [PATCH 05/12] build job only for staging and develop --- .circleci/config.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 053f1f4a3..dd974029c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -171,9 +171,6 @@ workflows: - test: requires: - prepare - - build: - requires: - - test - deploy-develop: requires: - test From 975d4fd424df4f2661f89a39dde754a7058ce7ef Mon Sep 17 00:00:00 2001 From: astaphobia Date: Tue, 2 Jun 2020 08:27:45 +0800 Subject: [PATCH 06/12] build job only for staging and develop --- .circleci/config.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index dd974029c..3f184716a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -165,23 +165,26 @@ jobs: workflows: version: 2 - prepare-deploy: + prepare_and_test: jobs: - prepare - test: requires: - prepare + deploy: + jobs: + - build: + requires: + - test - deploy-develop: requires: - test - - build filters: branches: only: develop - deploy-staging: requires: - test - - build filters: branches: only: staging From 4f8f9418d371d77ef0deed474b453e544aeeeacf Mon Sep 17 00:00:00 2001 From: astaphobia Date: Tue, 2 Jun 2020 08:37:49 +0800 Subject: [PATCH 07/12] build job only for staging and develop --- .circleci/config.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3f184716a..efdd6d7fb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -88,8 +88,10 @@ jobs: - run: name: GENERATING GENESIS command: | + if [[ ${CIRCLE_BRANCH} == *"develop staging"* ]]; then go run cmd/main.go genesis generate -e ${CIRLE_BRANCH} -o dist \ && cp ./dist/generated/genesis/genesis.go ./common/constant/genesis.go + fi - run: name: BUILD command: | @@ -165,26 +167,24 @@ jobs: workflows: version: 2 - prepare_and_test: + prepare-deploy: jobs: - prepare - test: requires: - prepare - deploy: - jobs: - build: requires: - test - deploy-develop: requires: - - test + - build filters: branches: only: develop - deploy-staging: requires: - - test + - build filters: branches: only: staging From 64004b67c63bf74a0e30e7cf4555d6cc907b8fe4 Mon Sep 17 00:00:00 2001 From: astaphobia Date: Tue, 2 Jun 2020 09:09:16 +0800 Subject: [PATCH 08/12] account balance 0 as default --- cmd/genesisblock/templates/alpha.genesisAccountAddresses.json | 2 +- .../templates/alpha.preRegisteredNodes.json.example | 4 ++-- cmd/genesisblock/templates/develop.preRegisteredNodes.json | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/genesisblock/templates/alpha.genesisAccountAddresses.json b/cmd/genesisblock/templates/alpha.genesisAccountAddresses.json index 756140b3f..a9ca741db 100644 --- a/cmd/genesisblock/templates/alpha.genesisAccountAddresses.json +++ b/cmd/genesisblock/templates/alpha.genesisAccountAddresses.json @@ -7,7 +7,7 @@ }, { "AccountAddress": "9GeYVrSS5-Apt5CtCYiZ8RVtHprENoRfdAiVO213PGN0" - } + }, { "AccountAddress": "XTkJNxs3qi2bjcB0jCkgo2SWTAidgmdC38zn4dugCjIT" }, diff --git a/cmd/genesisblock/templates/alpha.preRegisteredNodes.json.example b/cmd/genesisblock/templates/alpha.preRegisteredNodes.json.example index 718fe4093..005ba8015 100644 --- a/cmd/genesisblock/templates/alpha.preRegisteredNodes.json.example +++ b/cmd/genesisblock/templates/alpha.preRegisteredNodes.json.example @@ -24,7 +24,7 @@ "Smithing": true }, { - "AccountBalance": 100000000000, + "AccountBalance": 0, "AccountAddress": "nK_ouxdDDwuJiogiDAi_zs1LqeN7f5ZsXbFtXGqGc0Pd", "NodeSeed": "spree uplifted stapling quotable disfigure lair deduct untying timothy maggot cryptic unrigged", "NodePublicKeyB64": "Keu41kYXmVloKfr4MwdFWeq1ZKMtRZhGNMmTRgbyNNw=", @@ -32,7 +32,7 @@ "Smithing": true }, { - "AccountBalance": 100000000000, + "AccountBalance": 0, "AccountAddress": "iSJt3H8wFOzlWKsy_UoEWF_OjF6oymHMqthyUMDKSyxb", "NodeSeed": "merge plug donor drop cancel inherit extra toss cabbage awkward destroy rail", "NodePublicKeyB64": "WyTkRmVeuva6BE6OraK7rcpR81yNeJTcKaDQXq6mPs8=", diff --git a/cmd/genesisblock/templates/develop.preRegisteredNodes.json b/cmd/genesisblock/templates/develop.preRegisteredNodes.json index 3933a1b2d..41394ec82 100644 --- a/cmd/genesisblock/templates/develop.preRegisteredNodes.json +++ b/cmd/genesisblock/templates/develop.preRegisteredNodes.json @@ -20,8 +20,8 @@ "Smithing": true }, { - "AccountAddress": "AFiTqqX99kYXjLFJJ2AWuzKK5zxYUT1Pn0p3s6lutkai", - "AccountBalance": 100000000000, + "AccountAddress": "iSJt3H8wFOzlWKsy_UoEWF_OjF6oymHMqthyUMDKSyxb", + "AccountBalance": 0, "NodeSeed": "merge plug donor drop cancel inherit extra toss cabbage awkward destroy rail", "NodePublicKeyB64": "WyTkRmVeuva6BE6OraK7rcpR81yNeJTcKaDQXq6mPs8=", "LockedBalance": 0, From 0a7a3e001bbae7a5df664c4d6d93bcd17194bf63 Mon Sep 17 00:00:00 2001 From: astaphobia Date: Tue, 2 Jun 2020 09:10:42 +0800 Subject: [PATCH 09/12] account balance 0 as default --- cmd/genesisblock/templates/staging.preRegisteredNodes.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/genesisblock/templates/staging.preRegisteredNodes.json b/cmd/genesisblock/templates/staging.preRegisteredNodes.json index d0fde1f5e..1cbc35e76 100644 --- a/cmd/genesisblock/templates/staging.preRegisteredNodes.json +++ b/cmd/genesisblock/templates/staging.preRegisteredNodes.json @@ -1,7 +1,7 @@ [ { "AccountAddress": "iSJt3H8wFOzlWKsy_UoEWF_OjF6oymHMqthyUMDKSyxb", - "AccountBalance": 100000000000, + "AccountBalance": 0, "NodeSeed": "merge plug donor drop cancel inherit extra toss cabbage awkward destroy rail", "NodePublicKeyB64": "WyTkRmVeuva6BE6OraK7rcpR81yNeJTcKaDQXq6mPs8=", "LockedBalance": 0, From 8f9d92c09e18bd2a575639a257781343e1537588 Mon Sep 17 00:00:00 2001 From: astaphobia Date: Tue, 2 Jun 2020 09:17:45 +0800 Subject: [PATCH 10/12] build job only for staging and develop --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index efdd6d7fb..2645a666d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -88,7 +88,7 @@ jobs: - run: name: GENERATING GENESIS command: | - if [[ ${CIRCLE_BRANCH} == *"develop staging"* ]]; then + if [[ ${CIRCLE_BRANCH} == "develop" || ${CIRCLE_BRANCH} == "staging" ]]; then go run cmd/main.go genesis generate -e ${CIRLE_BRANCH} -o dist \ && cp ./dist/generated/genesis/genesis.go ./common/constant/genesis.go fi From cbd159c3dc803ea70d2049a2f2ee0577d47eb0da Mon Sep 17 00:00:00 2001 From: astaphobia Date: Tue, 2 Jun 2020 11:49:41 +0800 Subject: [PATCH 11/12] wrong path given when get root via wd --- cmd/genesisblock/cmd.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/genesisblock/cmd.go b/cmd/genesisblock/cmd.go index 806375c9e..da96e1d44 100644 --- a/cmd/genesisblock/cmd.go +++ b/cmd/genesisblock/cmd.go @@ -514,10 +514,10 @@ func generateConsulKvInitScript(clusterConfigEntries []clusterConfigEntry, consu func getRootPath() string { wd, _ := os.Getwd() - if strings.Contains(wd, "zoobc-core") { - return wd + if strings.Contains(wd, "zoobc-core/") { + return path.Join(wd, "../") } - return path.Join(wd, "../") + return wd } func (ge *genesisEntry) FormatPubKeyByteString() string { From ae419609a43ce780f9d46e8eebd1bb4d83115e76 Mon Sep 17 00:00:00 2001 From: astaphobia Date: Mon, 8 Jun 2020 09:08:31 +0800 Subject: [PATCH 12/12] fixing typo CIRCLECI_BRANCH --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2645a666d..a2008c558 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -89,7 +89,7 @@ jobs: name: GENERATING GENESIS command: | if [[ ${CIRCLE_BRANCH} == "develop" || ${CIRCLE_BRANCH} == "staging" ]]; then - go run cmd/main.go genesis generate -e ${CIRLE_BRANCH} -o dist \ + go run cmd/main.go genesis generate -e ${CIRCLE_BRANCH} -o dist \ && cp ./dist/generated/genesis/genesis.go ./common/constant/genesis.go fi - run: