From 946d3386146b07be6f81e0b4a6463e4f6c616cdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guilherme=20Brand=C3=A3o?= Date: Mon, 5 Feb 2024 12:59:50 +0000 Subject: [PATCH 1/3] Fixed wasm output formatting process --- cmd/node/appchain.go | 9 ++++++--- cmd/node/types.go | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/node/appchain.go b/cmd/node/appchain.go index 289020c..6f92503 100644 --- a/cmd/node/appchain.go +++ b/cmd/node/appchain.go @@ -212,11 +212,14 @@ func (ap *AppChain) SendUpdatedWeights(ctx context.Context, topicId uint64, resu for peer, value := range extractedWeights { ap.Logger.Info().Str("peer", peer) - parsed, err := parseFloatToUint64Weights(strconv.FormatFloat(value, 'f', -1, 64)) + parsed, err := parseFloatToUint64Weights(value) if err != nil { ap.Logger.Error().Err(err).Msg("Error parsing uint") continue } + + fmt.Printf("\n Worker Node: %s Weight: %v \n", peer, cosmossdk_io_math.NewUint(parsed)) + weight := &types.Weight{ TopicId: topicId, Reputer: ap.ReputerAddress, @@ -278,11 +281,11 @@ func extractNumber(stdout string) (string, error) { return response.Value, nil } -func extractWeights(stdout string) (map[string]float64, error) { +func extractWeights(stdout string) (map[string]string, error) { fmt.Println("Extracting weights from stdout: ", stdout) var weights WorkerWeights - err := json.Unmarshal([]byte(stdout), &weights.Weights) + err := json.Unmarshal([]byte(stdout), &weights) if err != nil { return nil, err } diff --git a/cmd/node/types.go b/cmd/node/types.go index 94017df..8a90cb8 100644 --- a/cmd/node/types.go +++ b/cmd/node/types.go @@ -50,7 +50,8 @@ type WeightsResponse struct { } type WorkerWeights struct { - Weights map[string]float64 `json:"-"` // Use a map to dynamically handle worker identifiers + Type string `json:"type"` + Weights map[string]string `json:"weights"` } type WeightsCalcDependencies struct { From 655811f35e24817ad2996ef7ed8d2258494d36c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guilherme=20Brand=C3=A3o?= Date: Mon, 5 Feb 2024 19:10:29 +0000 Subject: [PATCH 2/3] test --- cmd/node/execute.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/node/execute.go b/cmd/node/execute.go index 48ef578..0c585eb 100644 --- a/cmd/node/execute.go +++ b/cmd/node/execute.go @@ -41,7 +41,7 @@ type ExecuteResult struct { func sendResultsToChain(ctx echo.Context, a api.API, appChainClient AppChain, req ExecuteRequest, res ExecuteResponse) { - // Only in weight functions that we will have a "type" in the response + // Only in weight functions that we will have a "type" in the response functionType := "inferences" functionType, err := getResponseInfo(res.Results[0].Result.Stdout) if err != nil { From 49d9e3f4dae4a08fffb47877504746904b20c3cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guilherme=20Brand=C3=A3o?= Date: Wed, 7 Feb 2024 18:54:18 +0000 Subject: [PATCH 3/3] Tx resp log --- cmd/node/appchain.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/node/appchain.go b/cmd/node/appchain.go index 6f92503..4aba70b 100644 --- a/cmd/node/appchain.go +++ b/cmd/node/appchain.go @@ -195,7 +195,7 @@ func (ap *AppChain) SendInferences(ctx context.Context, topicId uint64, results ap.Logger.Info().Err(err).Msg("failed to send inferences to allora blockchain") } - ap.Logger.Info().Str("txhash", txResp.TxHash).Msg("successfully sent inferences to allora blockchain") + ap.Logger.Info().Any("Tx Resp:", txResp).Msg("successfully sent inferences to allora blockchain") return workersInferences } @@ -241,7 +241,7 @@ func (ap *AppChain) SendUpdatedWeights(ctx context.Context, topicId uint64, resu ap.Logger.Info().Err(err).Msg("failed to send weights to allora blockchain") } - ap.Logger.Info().Str("txhash", txResp.TxHash).Msg("successfully sent weights to allora blockchain") + ap.Logger.Info().Any("Tx Resp:", txResp).Msg("successfully sent weights to allora blockchain") } func parseFloatToUint64Weights(input string) (uint64, error) {