From 7db116589d5d9ff71c026b3060aa2785f331eecc Mon Sep 17 00:00:00 2001 From: Ryan Sears Date: Mon, 17 Apr 2023 00:54:06 -0400 Subject: [PATCH 1/5] QOL updates --- .gitignore | 3 +++ Dockerfile | 16 ++++++++++++++++ Makefile | 13 +++++++++++++ bootstrap.go | 3 ++- main.go | 34 +++++++++++++++++++++++++++------- quil_voucher.hex | 1 - 6 files changed, 61 insertions(+), 9 deletions(-) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 Makefile delete mode 100644 quil_voucher.hex diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3520d3e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.idea/ +ceremony-client +quil_voucher.hex \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a6fa3c8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM golang:1.18 + +WORKDIR /app + +COPY go.mod go.sum ./ + +RUN go mod download + +# Add an entry to .bash_history so we can just run `make dev` and hit up to test the cli +RUN echo 'go run ./... test-voucher.hex' >> ~/.bash_history + +COPY . . + +RUN CGO_ENABLED=0 GOOS=linux go build -o ceremony-client + +CMD ./ceremony-client \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9081699 --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +IMAGE_TAG := quillibrium-ceremony-client + +build-docker: + docker build -t $(IMAGE_TAG) . + +bash: + docker run --rm -it $(IMAGE_TAG) bash + +participate: + docker run --rm -it $(IMAGE_TAG) ./ceremony-client "quill-voucher-$(shell date +'%y.%m.%d-%H:%M:%S')" + +dev: + docker run --rm -it -v $(PWD):$(PWD) --workdir $(PWD) $(IMAGE_TAG) bash \ No newline at end of file diff --git a/bootstrap.go b/bootstrap.go index 23ae6a9..d56ec53 100644 --- a/bootstrap.go +++ b/bootstrap.go @@ -78,7 +78,8 @@ func JoinLobby() { client := http.DefaultClient resp, err := client.Do(req) - fmt.Println("connected") + + fmt.Println("Connected to sequencer!") if err != nil { panic(err) diff --git a/main.go b/main.go index 26f23d4..ba835cb 100644 --- a/main.go +++ b/main.go @@ -11,13 +11,7 @@ func main() { PrintLogo() PrintVersion() - fmt.Println("Checking sequencer...") - state := GetSequencerState() - for state != SEQUENCER_ACCEPTING { - fmt.Println("Sequencer currently not accepting new contributions, waiting...") - time.Sleep(1 * time.Second) - state = GetSequencerState() - } + WaitForSequencerToBeReady() JoinLobby() Bootstrap() @@ -26,6 +20,30 @@ func main() { ContributeAndGetVoucher() } +func WaitForSequencerToBeReady() { + spinnerChars := []string{"🌕", "🌖", "🌗", "🌘", "🌑", "🌒", "🌓", "🌔"} + spinnerIndex := 0 + attempts := 0 + removeLine := "\u001B[A\u001B[2K" + state := GetSequencerState() + for state != SEQUENCER_ACCEPTING { + message := "Sequencer currently not accepting new contributions, waiting..." + status := fmt.Sprintf("[Attempt %d - Last Checked: %s]", attempts, time.Now().String()) + + fmt.Printf("\r%s", removeLine) + fmt.Printf("%s\n", message+spinnerChars[spinnerIndex]) + fmt.Printf(" |- %s", status) + + spinnerIndex = (spinnerIndex + 1) % len(spinnerChars) + attempts += 1 + + time.Sleep(1 * time.Second) + state = GetSequencerState() + } + + fmt.Println("Sequencer is ready for contributions!") +} + func PrintLogo() { fmt.Println(" %#########") fmt.Println(" #############################") @@ -64,4 +82,6 @@ func PrintLogo() { func PrintVersion() { fmt.Println(" ") fmt.Println(" Quilibrium Ceremony Client - CLI - v1.0.1") + fmt.Println() + fmt.Println() } diff --git a/quil_voucher.hex b/quil_voucher.hex deleted file mode 100644 index 0ace8bd..0000000 --- a/quil_voucher.hex +++ /dev/null @@ -1 +0,0 @@ -654990bfacd0d2702f318089f73b838c64f79b0369840bdff6e1f6b8c3aa2698585c61a0e35794afb9365a4f5ed9c841a62eb9f35d29aa50486780552dd2293cb865905d120047905b98f55bb96a8e2b1e960807a3a0f5b236b7819799a64f7c0a52f8c754dc5086373bb0ce2702ebfba900 \ No newline at end of file From c0e9e12a275768e33b8248bd22035bd5f7445873 Mon Sep 17 00:00:00 2001 From: Ryan Sears Date: Mon, 17 Apr 2023 01:32:08 -0400 Subject: [PATCH 2/5] Add docs and expose vouchers from container with `make participate` --- .gitignore | 1 + Makefile | 4 ++-- README.md | 8 +++++++- main.go | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 3520d3e..8e0dfad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea/ +vouchers/ ceremony-client quil_voucher.hex \ No newline at end of file diff --git a/Makefile b/Makefile index 9081699..519f4fa 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,8 @@ build-docker: bash: docker run --rm -it $(IMAGE_TAG) bash -participate: - docker run --rm -it $(IMAGE_TAG) ./ceremony-client "quill-voucher-$(shell date +'%y.%m.%d-%H:%M:%S')" +participate: build-docker + docker run --rm -it -v $(PWD)/vouchers:/vouchers $(IMAGE_TAG) ./ceremony-client "/vouchers/quill-voucher-$(shell date +'%m.%d.%y-%H:%M:%S').hex" dev: docker run --rm -it -v $(PWD):$(PWD) --workdir $(PWD) $(IMAGE_TAG) bash \ No newline at end of file diff --git a/README.md b/README.md index 1c7288b..499eae4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ # ceremonyclient -KZG Ceremony client for Quilibrium. Run with `go run ./... ` or omit the filename to write to quil_voucher.hex. +KZG Ceremony client for Quilibrium. + +# Running + +Run with `go run ./... ` or omit the filename to write to quil_voucher.hex. + +If you have docker installed you can participate in the ceremony by simply running `make participate`. Your voucher will be written to `vouchers/`. \ No newline at end of file diff --git a/main.go b/main.go index ba835cb..ae89517 100644 --- a/main.go +++ b/main.go @@ -41,6 +41,7 @@ func WaitForSequencerToBeReady() { state = GetSequencerState() } + fmt.Println() fmt.Println("Sequencer is ready for contributions!") } From bba9b7f20958e5387bf61e686270788b801995c4 Mon Sep 17 00:00:00 2001 From: Ryan Sears Date: Mon, 17 Apr 2023 21:16:00 -0400 Subject: [PATCH 3/5] Requested changes --- Makefile | 4 ++-- main.go | 5 +++-- quil_voucher.hex.txt | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 quil_voucher.hex.txt diff --git a/Makefile b/Makefile index 519f4fa..036ec36 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -IMAGE_TAG := quillibrium-ceremony-client +IMAGE_TAG := quilibrium-ceremony-client build-docker: docker build -t $(IMAGE_TAG) . @@ -7,7 +7,7 @@ bash: docker run --rm -it $(IMAGE_TAG) bash participate: build-docker - docker run --rm -it -v $(PWD)/vouchers:/vouchers $(IMAGE_TAG) ./ceremony-client "/vouchers/quill-voucher-$(shell date +'%m.%d.%y-%H:%M:%S').hex" + docker run --rm -it -v $(PWD)/vouchers:/vouchers $(IMAGE_TAG) ./ceremony-client "/vouchers/quil-voucher-$(shell date +'%m.%d.%y-%H:%M:%S').hex" dev: docker run --rm -it -v $(PWD):$(PWD) --workdir $(PWD) $(IMAGE_TAG) bash \ No newline at end of file diff --git a/main.go b/main.go index ae89517..2fe6dd8 100644 --- a/main.go +++ b/main.go @@ -21,7 +21,7 @@ func main() { } func WaitForSequencerToBeReady() { - spinnerChars := []string{"🌕", "🌖", "🌗", "🌘", "🌑", "🌒", "🌓", "🌔"} + spinnerChars := []string{"⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"} spinnerIndex := 0 attempts := 0 removeLine := "\u001B[A\u001B[2K" @@ -37,7 +37,7 @@ func WaitForSequencerToBeReady() { spinnerIndex = (spinnerIndex + 1) % len(spinnerChars) attempts += 1 - time.Sleep(1 * time.Second) + time.Sleep(5 * time.Second) state = GetSequencerState() } @@ -46,6 +46,7 @@ func WaitForSequencerToBeReady() { } func PrintLogo() { + fmt.Println() fmt.Println(" %#########") fmt.Println(" #############################") fmt.Println(" ########################################&") diff --git a/quil_voucher.hex.txt b/quil_voucher.hex.txt new file mode 100644 index 0000000..0ace8bd --- /dev/null +++ b/quil_voucher.hex.txt @@ -0,0 +1 @@ +654990bfacd0d2702f318089f73b838c64f79b0369840bdff6e1f6b8c3aa2698585c61a0e35794afb9365a4f5ed9c841a62eb9f35d29aa50486780552dd2293cb865905d120047905b98f55bb96a8e2b1e960807a3a0f5b236b7819799a64f7c0a52f8c754dc5086373bb0ce2702ebfba900 \ No newline at end of file From 5572119ac89e735c0ee61d6d204f2641780d73a3 Mon Sep 17 00:00:00 2001 From: Ryan Sears Date: Mon, 17 Apr 2023 21:16:36 -0400 Subject: [PATCH 4/5] Update .gitignore --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 8e0dfad..27c9a1a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ .idea/ vouchers/ -ceremony-client -quil_voucher.hex \ No newline at end of file +ceremony-client \ No newline at end of file From be5fbd1cf02a9fa7df9c6d2ddedaef0a71c75882 Mon Sep 17 00:00:00 2001 From: Ryan Sears Date: Mon, 17 Apr 2023 21:17:39 -0400 Subject: [PATCH 5/5] Update quil_voucher.hex --- quil_voucher.hex.txt => quil_voucher.hex | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename quil_voucher.hex.txt => quil_voucher.hex (100%) diff --git a/quil_voucher.hex.txt b/quil_voucher.hex similarity index 100% rename from quil_voucher.hex.txt rename to quil_voucher.hex