Skip to content

Commit

Permalink
Sprint june 5 (#471)
Browse files Browse the repository at this point in the history
* Move min lock demand (#458)

* min_lock_demand

* min_lock_demand

* remove dead code

* go mod

* go mod

* updated gosdk (#466)

* Rename to not_available (#457)

* remove unstake

* not_available

* go mod

* go mod

* repoint to not_available gosdk

---------

Co-authored-by: Kishan-Dhakan <[email protected]>
Co-authored-by: Kishan Dhakan <[email protected]>

* point gosdk to staging

---------

Co-authored-by: Piers Shepperson <[email protected]>
Co-authored-by: Yury <[email protected]>
  • Loading branch information
3 people authored Jul 3, 2023
1 parent 73fc922 commit 0c2ceaa
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 59 deletions.
4 changes: 2 additions & 2 deletions cmd/getallocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var getallocationCmd = &cobra.Command{
fmt.Printf(" file_options: %08b\n", alloc.FileOptions)
fmt.Println(" write pool ", alloc.WritePool)
fmt.Println(" blobbers:")

fmt.Println(" min_lock_demand:", alloc.MinLockDemand*100, "%")
for _, d := range alloc.BlobberDetails {
fmt.Println(" - blobber_id: ", d.BlobberID)
fmt.Println(" base URL: ", getBaseURL(d.BlobberID, alloc.Blobbers))
Expand All @@ -86,7 +86,7 @@ var getallocationCmd = &cobra.Command{
fmt.Println(" terms: (allocation related terms)")
fmt.Println(" read_price: ", d.Terms.ReadPrice, "/ GB (by 64KB chunks)")
fmt.Println(" write_price: ", d.Terms.WritePrice, "/ GB")
fmt.Println(" min_lock_demand: ", d.Terms.MinLockDemand*100, "%")
fmt.Println(" min_lock_demand: ", d.MinLockDemand*100, "%")
fmt.Println(" max_offer_duration: ", d.Terms.MaxOfferDuration)
}

Expand Down
59 changes: 5 additions & 54 deletions cmd/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,6 @@ import (
"github.com/spf13/cobra"
)

// TODO: @Piers: update print logic sc-config; using datastructure might make sense instead of
// InputMap because some fields have specific type (like Balance) which includes formatting logic

// func printStorageSCConfig(conf *sdk.StorageSCConfig) {
// fmt.Println("min_alloc_size: ", conf.MinAllocSize)
// fmt.Println("min_alloc_duration: ", conf.MinAllocDuration)
// fmt.Println("max_challenge_completion_time:", conf.MaxChallengeCompletionTime)
// fmt.Println("min_offer_duration: ", conf.MinOfferDuration)
// fmt.Println("min_blobber_capacity: ", conf.MinBlobberCapacity)
// fmt.Println("max_delegates: ", conf.MaxDelegates)
// fmt.Println("max_charge: ", conf.MaxCharge*100, "%")
// fmt.Println("readpool:")
// fmt.Println(" min_lock:", conf.ReadPool.MinLock)
// fmt.Println(" min_lock_period:", conf.ReadPool.MinLockPeriod)
// fmt.Println(" max_lock_period:", conf.ReadPool.MaxLockPeriod)
// fmt.Println("writepool:")
// fmt.Println(" min_lock:", conf.WritePool.MinLock)
// fmt.Println(" min_lock_period:", conf.WritePool.MinLockPeriod)
// fmt.Println(" max_lock_period:", conf.WritePool.MaxLockPeriod)
// fmt.Println("stakepool:")
// fmt.Println(" min_lock:", conf.StakePool.MinLock)
// fmt.Println(" interest_rate:", conf.StakePool.InterestRate)
// fmt.Println(" interest_interval:", conf.StakePool.InterestInterval)
// fmt.Println("validator_reward: ", conf.ValidatorReward)
// fmt.Println("blobber_slash: ", conf.BlobberSlash)
// fmt.Println("max_read_price: ", conf.MaxReadPrice, "/ GB")
// fmt.Println("max_write_price: ", conf.MaxWritePrice, "/ GB / time_unit")
// fmt.Println("time_unit: ", conf.TimeUnit)
// fmt.Println("failed_challenges_to_cancel: ", conf.FailedChallengesToCancel)
// fmt.Println("failed_challenges_to_revoke_min_lock:", conf.FailedChallengesToRevokeMinLock)
// fmt.Println("challenge_enabled: ", conf.ChallengeEnabled)
// fmt.Println("max_challenges_per_generation: ", conf.MaxChallengesPerGeneration)
// fmt.Println("challenge_rate_per_mb_min: ", conf.ChallengeGenerationRate)
// }

// scConfig shows SC configurations
var scConfig = &cobra.Command{
Use: "sc-config",
Expand Down Expand Up @@ -86,7 +51,6 @@ func printBlobbers(nodes []*sdk.Blobber, isActive bool) {
fmt.Println(" terms:")
fmt.Println(" read_price: ", val.Terms.ReadPrice.String(), "/ GB")
fmt.Println(" write_price: ", val.Terms.WritePrice.String(), "/ GB / time_unit")
fmt.Println(" min_lock_demand: ", val.Terms.MinLockDemand)
fmt.Println(" max_offer_duration: ", val.Terms.MaxOfferDuration.String())
}
}
Expand Down Expand Up @@ -166,11 +130,10 @@ var blobberInfoCmd = &cobra.Command{
fmt.Println("last_health_check:", blob.LastHealthCheck.ToTime())
fmt.Println("capacity_used: ", blob.Allocated)
fmt.Println("total_stake: ", blob.TotalStake)
fmt.Println("is_available: ", blob.IsAvailable)
fmt.Println("not_available: ", blob.NotAvailable)
fmt.Println("terms:")
fmt.Println(" read_price: ", blob.Terms.ReadPrice, "/ GB")
fmt.Println(" write_price: ", blob.Terms.WritePrice, "/ GB")
fmt.Println(" min_lock_demand: ", blob.Terms.MinLockDemand*100.0, "%")
fmt.Println(" max_offer_duration:", blob.Terms.MaxOfferDuration)
fmt.Println("settings:")
fmt.Println(" delegate_wallet:", blob.StakePoolSettings.DelegateWallet)
Expand Down Expand Up @@ -239,17 +202,6 @@ var blobberUpdateCmd = &cobra.Command{
blob.Terms.WritePrice = writePriceBalance
}

if flags.Changed("min_lock_demand") {
var mld float64
if mld, err = flags.GetFloat64("min_lock_demand"); err != nil {
log.Fatal(err)
}
if mld < 0 || mld > 1 {
log.Fatal("invalid min_lock_demand: out of [0; 1) range")
}
blob.Terms.MinLockDemand = mld
}

if flags.Changed("max_offer_duration") {
var mod time.Duration
if mod, err = flags.GetDuration("max_offer_duration"); err != nil {
Expand Down Expand Up @@ -306,12 +258,12 @@ var blobberUpdateCmd = &cobra.Command{
blob.BaseURL = url
}

if flags.Changed("is_available") {
if flags.Changed("not_available") {
var ia bool
if ia, err = flags.GetBool("is_available"); err != nil {
if ia, err = flags.GetBool("not_available"); err != nil {
log.Fatal(err)
}
blob.IsAvailable = ia
blob.NotAvailable = ia
}

if _, _, err = sdk.UpdateBlobberSettings(blob); err != nil {
Expand Down Expand Up @@ -342,12 +294,11 @@ func init() {
buf.Int64("capacity", 0, "update blobber capacity bid, optional")
buf.Float64("read_price", 0.0, "update read_price, optional")
buf.Float64("write_price", 0.0, "update write_price, optional")
buf.Float64("min_lock_demand", 0.0, "update min_lock_demand, optional")
buf.Duration("max_offer_duration", 0*time.Second, "update max_offer_duration, optional")
buf.Float64("min_stake", 0.0, "update min_stake, optional")
buf.Float64("max_stake", 0.0, "update max_stake, optional")
buf.Int("num_delegates", 0, "update num_delegates, optional")
buf.Float64("service_charge", 0.0, "update service_charge, optional")
buf.Bool("is_available", true, "(default false) set blobber's availability for new allocations")
buf.Bool("not_available", true, "(default false) set blobber's availability for new allocations")
blobberUpdateCmd.MarkFlagRequired("blobber_id")
}
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/0chain/errors v1.0.3
github.com/0chain/gosdk v1.8.17-0.20230623160341-6d98b815ed3e
github.com/0chain/gosdk v1.8.17-0.20230630164210-0c14d02962ab
github.com/icza/bitio v1.1.0
github.com/olekukonko/tablewriter v0.0.5
github.com/spf13/cobra v1.6.0
Expand All @@ -28,6 +28,7 @@ require (
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/h2non/filetype v1.1.3 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/herumi/bls-go-binary v1.31.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
Expand Down Expand Up @@ -65,6 +66,7 @@ require (
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Expand Down
7 changes: 5 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565 h1:z+DtCR8mBsjPnEs
github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565/go.mod h1:UyDC8Qyl5z9lGkCnf9RHJPMektnFX8XtCJZHXCCVj8E=
github.com/0chain/errors v1.0.3 h1:QQZPFxTfnMcRdt32DXbzRQIfGWmBsKoEdszKQDb0rRM=
github.com/0chain/errors v1.0.3/go.mod h1:xymD6nVgrbgttWwkpSCfLLEJbFO6iHGQwk/yeSuYkIc=
github.com/0chain/gosdk v1.8.17-0.20230623160341-6d98b815ed3e h1:DFoj1CqpwT/7t+KwzHca+TEk0cwY7FOl/b1T0xkQZBQ=
github.com/0chain/gosdk v1.8.17-0.20230623160341-6d98b815ed3e/go.mod h1:GgqNjoHBO0JN9TcpDAC28/VE2VsZi4MDr4qGdzfWV+I=
github.com/0chain/gosdk v1.8.17-0.20230630164210-0c14d02962ab h1:EtfLUOe4ow1hAgHsUmngDr8XuizO1riMDM7Iwq2wGOw=
github.com/0chain/gosdk v1.8.17-0.20230630164210-0c14d02962ab/go.mod h1:GgqNjoHBO0JN9TcpDAC28/VE2VsZi4MDr4qGdzfWV+I=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Luzifer/go-openssl/v3 v3.1.0 h1:QqKqo6kYXGGUsvtUoCpRZm8lHw+jDfhbzr36gVj+/gw=
Expand Down Expand Up @@ -194,6 +194,7 @@ github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpx
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs=
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/herumi/bls-go-binary v1.31.0 h1:L1goQ2tMtGgpXCg5AwHAdJQpLs/pfnWWEc3Wog6OhmI=
Expand Down Expand Up @@ -665,6 +666,8 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU=
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
Expand Down

0 comments on commit 0c2ceaa

Please sign in to comment.