From 939f30ff046f22174e6d4427de7365ce40c34f93 Mon Sep 17 00:00:00 2001 From: Jordan Oroshiba Date: Tue, 30 Jul 2024 16:26:53 -0700 Subject: [PATCH 1/7] fix: faucet not funding full amount --- internal/server/server.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/server/server.go b/internal/server/server.go index 72a7830..0fd0daa 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -63,7 +63,7 @@ func (s *Server) consumeQueue() { defer s.mutex.Unlock() for len(s.queue) != 0 { address := <-s.queue - txHash, err := s.Transfer(context.Background(), address, s.cfg.payout) + txHash, err := s.Transfer(context.Background(), address, s.cfg.payoutNano) if err != nil { log.WithError(err).Error("Failed to handle transaction in the queue") } else { @@ -102,7 +102,7 @@ func (s *Server) handleClaim() http.HandlerFunc { ctx, cancel := context.WithTimeout(r.Context(), 5*time.Second) defer cancel() - txHash, err := s.Transfer(ctx, address, s.cfg.payout) + txHash, err := s.Transfer(ctx, address, s.cfg.payoutNano) s.mutex.Unlock() if err != nil { log.WithError(err).Error("Failed to send transaction") From 4e5317de5f0c847e2e67886d17b22541f7ce9e9c Mon Sep 17 00:00:00 2001 From: Jordan Oroshiba Date: Tue, 30 Jul 2024 16:28:47 -0700 Subject: [PATCH 2/7] enable build on PR --- .github/workflows/docker.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 68d7f34..e301d0e 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -11,6 +11,9 @@ on: - "v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+" - "v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+" - "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+" + pull_request: + branches: + - "main" jobs: build-and-publish-latest: From b8b8814211578efcb65ae307bc00d64c77656255 Mon Sep 17 00:00:00 2001 From: Jordan Oroshiba Date: Tue, 30 Jul 2024 17:03:43 -0700 Subject: [PATCH 3/7] rebuild --- internal/chain/transaction.go | 1 + internal/server/server.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/internal/chain/transaction.go b/internal/chain/transaction.go index 9f66070..10b1b65 100644 --- a/internal/chain/transaction.go +++ b/internal/chain/transaction.go @@ -59,6 +59,7 @@ func (b *TxBuild) Transfer(ctx context.Context, to string, value *big.Int) (byte if err != nil { panic(err) } + log.Infof("DEBUG: value passed into transfer is %s", value) amount, err := convertToUint128(value) if err != nil { diff --git a/internal/server/server.go b/internal/server/server.go index 0fd0daa..e2c91dc 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -63,7 +63,9 @@ func (s *Server) consumeQueue() { defer s.mutex.Unlock() for len(s.queue) != 0 { address := <-s.queue + log.Infof("DEBUG: cfg value before transfer from queue is %s", s.cfg.payoutNano) txHash, err := s.Transfer(context.Background(), address, s.cfg.payoutNano) + log.Infof("DEBUG: cfg value after transfer from queue is %s", s.cfg.payoutNano) if err != nil { log.WithError(err).Error("Failed to handle transaction in the queue") } else { @@ -102,7 +104,9 @@ func (s *Server) handleClaim() http.HandlerFunc { ctx, cancel := context.WithTimeout(r.Context(), 5*time.Second) defer cancel() + log.Infof("DEBUG: cfg value before transfer from handleClaim is %s", s.cfg.payoutNano) txHash, err := s.Transfer(ctx, address, s.cfg.payoutNano) + log.Infof("DEBUG: cfg value after transfer from handleClaim is %s", s.cfg.payoutNano) s.mutex.Unlock() if err != nil { log.WithError(err).Error("Failed to send transaction") From 1f0ded01a78726eacb84b954ba5a328437a6a746 Mon Sep 17 00:00:00 2001 From: Jordan Oroshiba Date: Tue, 30 Jul 2024 17:20:40 -0700 Subject: [PATCH 4/7] should fix --- internal/chain/transaction.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/chain/transaction.go b/internal/chain/transaction.go index 10b1b65..ef901bb 100644 --- a/internal/chain/transaction.go +++ b/internal/chain/transaction.go @@ -60,6 +60,7 @@ func (b *TxBuild) Transfer(ctx context.Context, to string, value *big.Int) (byte panic(err) } log.Infof("DEBUG: value passed into transfer is %s", value) + amount, err := convertToUint128(value) if err != nil { @@ -99,7 +100,8 @@ func (b *TxBuild) Transfer(ctx context.Context, to string, value *big.Int) (byte } // convertToUint128 converts a string to a Uint128 protobuf -func convertToUint128(numStr *big.Int) (*primproto.Uint128, error) { +func convertToUint128(num *big.Int) (*primproto.Uint128, error) { + numStr := new(big.Int).Set(num) // check if the number is negative or overflows Uint128 if numStr.Sign() < 0 { From 4096e1d9bbb669c057a175745f1dc457f2106053 Mon Sep 17 00:00:00 2001 From: Jordan Oroshiba Date: Tue, 30 Jul 2024 17:31:24 -0700 Subject: [PATCH 5/7] im sorry what? --- internal/chain/transaction.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/chain/transaction.go b/internal/chain/transaction.go index ef901bb..06f8454 100644 --- a/internal/chain/transaction.go +++ b/internal/chain/transaction.go @@ -120,5 +120,7 @@ func convertToUint128(num *big.Int) (*primproto.Uint128, error) { Hi: hi, } + log.Infof("DEBUG: value after conversion is %s", num) + return uint128, nil } From bde66d1a25493d8bd32dd929de91cdf33ba36e68 Mon Sep 17 00:00:00 2001 From: Jordan Oroshiba Date: Tue, 30 Jul 2024 17:41:17 -0700 Subject: [PATCH 6/7] cleanup --- internal/chain/transaction.go | 6 +----- internal/server/server.go | 4 ---- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/internal/chain/transaction.go b/internal/chain/transaction.go index 06f8454..1562028 100644 --- a/internal/chain/transaction.go +++ b/internal/chain/transaction.go @@ -58,9 +58,7 @@ func (b *TxBuild) Transfer(ctx context.Context, to string, value *big.Int) (byte nonce, err := b.sequencerClient.GetNonce(ctx, b.fromAddress) if err != nil { panic(err) - } - log.Infof("DEBUG: value passed into transfer is %s", value) - + } amount, err := convertToUint128(value) if err != nil { @@ -120,7 +118,5 @@ func convertToUint128(num *big.Int) (*primproto.Uint128, error) { Hi: hi, } - log.Infof("DEBUG: value after conversion is %s", num) - return uint128, nil } diff --git a/internal/server/server.go b/internal/server/server.go index e2c91dc..0fd0daa 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -63,9 +63,7 @@ func (s *Server) consumeQueue() { defer s.mutex.Unlock() for len(s.queue) != 0 { address := <-s.queue - log.Infof("DEBUG: cfg value before transfer from queue is %s", s.cfg.payoutNano) txHash, err := s.Transfer(context.Background(), address, s.cfg.payoutNano) - log.Infof("DEBUG: cfg value after transfer from queue is %s", s.cfg.payoutNano) if err != nil { log.WithError(err).Error("Failed to handle transaction in the queue") } else { @@ -104,9 +102,7 @@ func (s *Server) handleClaim() http.HandlerFunc { ctx, cancel := context.WithTimeout(r.Context(), 5*time.Second) defer cancel() - log.Infof("DEBUG: cfg value before transfer from handleClaim is %s", s.cfg.payoutNano) txHash, err := s.Transfer(ctx, address, s.cfg.payoutNano) - log.Infof("DEBUG: cfg value after transfer from handleClaim is %s", s.cfg.payoutNano) s.mutex.Unlock() if err != nil { log.WithError(err).Error("Failed to send transaction") From 234b1f965935d98f938c85510b2200e82a5acfd9 Mon Sep 17 00:00:00 2001 From: Jordan Oroshiba Date: Tue, 30 Jul 2024 17:41:52 -0700 Subject: [PATCH 7/7] format --- internal/chain/transaction.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/chain/transaction.go b/internal/chain/transaction.go index 1562028..ea02302 100644 --- a/internal/chain/transaction.go +++ b/internal/chain/transaction.go @@ -58,7 +58,7 @@ func (b *TxBuild) Transfer(ctx context.Context, to string, value *big.Int) (byte nonce, err := b.sequencerClient.GetNonce(ctx, b.fromAddress) if err != nil { panic(err) - } + } amount, err := convertToUint128(value) if err != nil {