Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Fix/wasm output format #47

Merged
merged 3 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions cmd/node/appchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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,
Expand All @@ -238,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) {
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/node/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion cmd/node/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading