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

Commit

Permalink
Merge pull request #90 from JackalLabs/reports
Browse files Browse the repository at this point in the history
Feat: Adding reporting system
  • Loading branch information
TheMarstonConnell authored Jul 28, 2023
2 parents 041b1c7 + bf1779e commit f0af336
Show file tree
Hide file tree
Showing 25 changed files with 613 additions and 28 deletions.
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/cosmos/cosmos-sdk v0.45.17
github.com/cosmos/go-bip39 v1.0.0
github.com/huin/goupnp v1.2.0
github.com/jackalLabs/canine-chain v0.0.0-00010101000000-000000000000
github.com/jackalLabs/canine-chain/v3 v3.0.0-alpha.1
github.com/julienschmidt/httprouter v1.3.0
github.com/rs/cors v1.9.0
github.com/rs/zerolog v1.29.1
Expand Down Expand Up @@ -182,8 +182,6 @@ replace (
// use cosmos-flavored protobufs
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1

github.com/jackalLabs/canine-chain => github.com/JackalLabs/canine-chain v1.2.3-0.20230621063218-8fde7f21c65b

github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.27

github.com/wealdtech/go-merkletree => github.com/TheMarstonConnell/go-merkletree v0.0.0-20230328183338-b5d590ab1aaf
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwS
github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo=
github.com/JackalLabs/blanket v0.0.0 h1:bMuUe12mRO8rekDIo7T37xPLOvLsEOMkzgK5Uqul+FU=
github.com/JackalLabs/blanket v0.0.0/go.mod h1:jl68zTyytfS6oyTbqwcMKyq9Jvvv0IE0eHFMFMcgsD4=
github.com/JackalLabs/canine-chain v1.2.3-0.20230621063218-8fde7f21c65b h1:tWBt15Gnd1WkHgr+k4Skoc06j/O9AYii7qKWHszjoeI=
github.com/JackalLabs/canine-chain v1.2.3-0.20230621063218-8fde7f21c65b/go.mod h1:OVSoZkHP0Z4IoJZmOx06Biqy+45FFLkDkuK4tyuWH1w=
github.com/JackalLabs/cosmos-sdk-new v0.45.17-0.20230525190516-b9142076b70c h1:Ju0uBSyOi03+kCC7gMth8s9m4/QSfd+1IaBe2o6l5ZM=
github.com/JackalLabs/cosmos-sdk-new v0.45.17-0.20230525190516-b9142076b70c/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40=
github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY=
Expand Down Expand Up @@ -686,6 +684,8 @@ github.com/iris-contrib/jade v1.1.4/go.mod h1:EDqR+ur9piDl6DUgs6qRrlfzmlx/D5Uybo
github.com/iris-contrib/pongo2 v0.0.1/go.mod h1:Ssh+00+3GAZqSQb30AvBRNxBx7rf0GqwkjqxNd0u65g=
github.com/iris-contrib/schema v0.0.1/go.mod h1:urYA3uvUNG1TIIjOSCzHr9/LmbQo8LrOcOqfqxa4hXw=
github.com/iris-contrib/schema v0.0.6/go.mod h1:iYszG0IOsuIsfzjymw1kMzTL8YQcCWlm65f3wX8J5iA=
github.com/jackalLabs/canine-chain/v3 v3.0.0-alpha.1 h1:JglWXONdQxQ8kVVWzqj8iioU0Z5pbIeu5BHNDzcfRPs=
github.com/jackalLabs/canine-chain/v3 v3.0.0-alpha.1/go.mod h1:JXs2+971ONESI5L02wB8+wqm0NXEURy23XnvulD1Eh4=
github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1CVv03EnqU1wYL2dFwXxW2An0az9JTl/ZsqXQeBlkU=
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
Expand Down
2 changes: 1 addition & 1 deletion jprov/api/client/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"

sdkclient "github.com/cosmos/cosmos-sdk/client"
storagetypes "github.com/jackalLabs/canine-chain/x/storage/types"
storagetypes "github.com/jackalLabs/canine-chain/v3/x/storage/types"

"github.com/JackalLabs/jackal-provider/jprov/api/types"
"github.com/JackalLabs/jackal-provider/jprov/crypto"
Expand Down
2 changes: 1 addition & 1 deletion jprov/api/network/deals.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
sdkclient "github.com/cosmos/cosmos-sdk/client"

"github.com/JackalLabs/jackal-provider/jprov/api/types"
storagetypes "github.com/jackalLabs/canine-chain/x/storage/types"
storagetypes "github.com/jackalLabs/canine-chain/v3/x/storage/types"
"github.com/julienschmidt/httprouter"
"github.com/spf13/cobra"
"github.com/syndtr/goleveldb/leveldb"
Expand Down
2 changes: 1 addition & 1 deletion jprov/api/network/strays.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
sdkclient "github.com/cosmos/cosmos-sdk/client"

"github.com/JackalLabs/jackal-provider/jprov/api/types"
storagetypes "github.com/jackalLabs/canine-chain/x/storage/types"
storagetypes "github.com/jackalLabs/canine-chain/v3/x/storage/types"
"github.com/julienschmidt/httprouter"
"github.com/spf13/cobra"
"github.com/syndtr/goleveldb/leveldb"
Expand Down
2 changes: 1 addition & 1 deletion jprov/api/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package types

import (
sdk "github.com/cosmos/cosmos-sdk/types"
storagetypes "github.com/jackalLabs/canine-chain/x/storage/types"
storagetypes "github.com/jackalLabs/canine-chain/v3/x/storage/types"
)

type DataBlock struct {
Expand Down
2 changes: 1 addition & 1 deletion jprov/jprovd/client_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/bech32"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/go-bip39"
stortypes "github.com/jackalLabs/canine-chain/x/storage/types"
stortypes "github.com/jackalLabs/canine-chain/v3/x/storage/types"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion jprov/jprovd/init_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/JackalLabs/jackal-provider/jprov/crypto"
"github.com/JackalLabs/jackal-provider/jprov/utils"
"github.com/cosmos/cosmos-sdk/client"
"github.com/jackalLabs/canine-chain/x/storage/types"
"github.com/jackalLabs/canine-chain/v3/x/storage/types"
"github.com/spf13/cobra"
)

Expand Down
1 change: 1 addition & 0 deletions jprov/jprovd/provider_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func StartServerCommand() *cobra.Command {
cmd.Flags().Int64(types.FlagQueueInterval, 4, "The time, in seconds, between running a queue loop.")
cmd.Flags().String(types.FlagProviderName, "A Storage Provider", "The name to identify this provider in block explorers.")
cmd.Flags().Int64(types.FlagSleep, 250, "The time, in milliseconds, before adding another proof msg to the queue.")
cmd.Flags().Bool(types.FlagDoReport, true, "Should this provider report deals (uses gas).")
return cmd
}

Expand Down
2 changes: 1 addition & 1 deletion jprov/jprovd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/jackalLabs/canine-chain/app"
"github.com/jackalLabs/canine-chain/v3/app"

"github.com/spf13/cobra"
)
Expand Down
2 changes: 1 addition & 1 deletion jprov/jprovd/set_provider_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/JackalLabs/jackal-provider/jprov/crypto"
"github.com/JackalLabs/jackal-provider/jprov/utils"
"github.com/cosmos/cosmos-sdk/client"
"github.com/jackalLabs/canine-chain/x/storage/types"
"github.com/jackalLabs/canine-chain/v3/x/storage/types"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion jprov/jprovd/set_provider_keybase.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/JackalLabs/jackal-provider/jprov/crypto"
"github.com/JackalLabs/jackal-provider/jprov/utils"
"github.com/cosmos/cosmos-sdk/client"
"github.com/jackalLabs/canine-chain/x/storage/types"
"github.com/jackalLabs/canine-chain/v3/x/storage/types"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion jprov/jprovd/set_provider_totalspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/JackalLabs/jackal-provider/jprov/crypto"
"github.com/JackalLabs/jackal-provider/jprov/utils"
"github.com/cosmos/cosmos-sdk/client"
"github.com/jackalLabs/canine-chain/x/storage/types"
"github.com/jackalLabs/canine-chain/v3/x/storage/types"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion jprov/queue/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"testing"

storagetypes "github.com/jackalLabs/canine-chain/x/storage/types"
storagetypes "github.com/jackalLabs/canine-chain/v3/x/storage/types"

"github.com/JackalLabs/jackal-provider/jprov/queue"
"github.com/JackalLabs/jackal-provider/jprov/types"
Expand Down
4 changes: 2 additions & 2 deletions jprov/server/attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/JackalLabs/jackal-provider/jprov/queue"
"github.com/JackalLabs/jackal-provider/jprov/types"
"github.com/cosmos/cosmos-sdk/client"
storageKeeper "github.com/jackalLabs/canine-chain/x/storage/keeper"
storageTypes "github.com/jackalLabs/canine-chain/x/storage/types"
storageKeeper "github.com/jackalLabs/canine-chain/v3/x/storage/keeper"
storageTypes "github.com/jackalLabs/canine-chain/v3/x/storage/types"

"github.com/spf13/cobra"
)
Expand Down
30 changes: 29 additions & 1 deletion jprov/server/file_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import (
"errors"
"fmt"
"io"
"math/rand"
"mime/multipart"
"net/http"
"os"
"strings"
"sync"
"time"

"github.com/JackalLabs/jackal-provider/jprov/crypto"
"github.com/JackalLabs/jackal-provider/jprov/queue"
Expand All @@ -22,7 +24,7 @@ import (
"github.com/rs/cors"
"github.com/syndtr/goleveldb/leveldb"

storageTypes "github.com/jackalLabs/canine-chain/x/storage/types"
storageTypes "github.com/jackalLabs/canine-chain/v3/x/storage/types"

"github.com/julienschmidt/httprouter"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -234,6 +236,8 @@ func StartFileServer(cmd *cobra.Command) {
if !strs {
manager.Init(cmd, threads, db)
}
// Start the reporting system
reporter := InitReporter(cmd)

go postProofs(cmd, db, &q, ctx)
go NatCycle(cmd.Context())
Expand All @@ -243,6 +247,30 @@ func StartFileServer(cmd *cobra.Command) {
go manager.Start(cmd)
}

report, err := cmd.Flags().GetBool(types.FlagDoReport)
if err != nil {
fmt.Println(err)
return
}

go func() {
for {
if rand.Int63n(2) == 0 && report {
err := reporter.Report(cmd)
if err != nil {
fmt.Println(err)
}
} else {
err := reporter.AttestReport(&q)
if err != nil {
fmt.Println(err)
}
}

time.Sleep(30 * time.Second)
}
}()

port, err := cmd.Flags().GetInt(types.FlagPort)
if err != nil {
fmt.Println(err)
Expand Down
2 changes: 1 addition & 1 deletion jprov/server/proofs.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

"github.com/cosmos/cosmos-sdk/client"

storageTypes "github.com/jackalLabs/canine-chain/x/storage/types"
storageTypes "github.com/jackalLabs/canine-chain/v3/x/storage/types"

merkletree "github.com/wealdtech/go-merkletree"

Expand Down
Loading

0 comments on commit f0af336

Please sign in to comment.