Skip to content

Commit

Permalink
Update rmb to latest (#2065)
Browse files Browse the repository at this point in the history
* Update rmb to latest

This version supports multiple substrate and relay versions

* add comment about number of possible relays per env
  • Loading branch information
muhamadazmy authored Oct 2, 2023
1 parent 5964239 commit d68470b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 18 deletions.
4 changes: 2 additions & 2 deletions bins/packages/rmb/rmb.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RMB_VERSION="1.0.7"
RMB_CHECKSUM="849f43d0356c1848f63669951d44a64b"
RMB_VERSION="1.1.1"
RMB_CHECKSUM="cccfee332b2795eaccea34a049e7ae0d"
RMB_LINK="https://github.com/threefoldtech/rmb-rs/releases/download/v${RMB_VERSION}/rmb-peer"

download_rmb() {
Expand Down
25 changes: 17 additions & 8 deletions cmds/modules/noded/twin.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,39 @@ func withDefaultPort(substrateUrl string) (string, error) {
return u.String(), nil
}

func runMsgBus(ctx context.Context, sk ed25519.PrivateKey, substrateURLs []string, relayAddr string, redisAddr string) error {
func runMsgBus(ctx context.Context, sk ed25519.PrivateKey, substrateURLs []string, relayAddr []string, redisAddr string) error {
// select the first one as only one URL is set for now
if len(substrateURLs) == 0 {
return errors.New("at least one substrate URL must be provided")
}

if len(relayAddr) == 0 {
return errors.New("at least one relay URL must be provided")
}

seed := sk.Seed()
seedHex := fmt.Sprintf("0x%s", hex.EncodeToString(seed))

log.Info().Msg("starting rmb...")

substrateURL, err := withDefaultPort(substrateURLs[0])
if err != nil {
return err
}

args := []string{
"-s", substrateURL,
"--relay", relayAddr,
"-k", keyType,
"--seed", seedHex,
"--redis", redisAddr,
}

for _, url := range substrateURLs {
url, err := withDefaultPort(url)
if err != nil {
return err
}
args = append(args, "--substrate", url)
}

for _, url := range relayAddr {
args = append(args, "--relay", url)
}

if kernel.GetParams().IsDebug() {
args = append(args, "-d")
}
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v3 v3.0.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
github.com/ethereum/go-ethereum v1.11.6 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
Expand All @@ -85,6 +86,7 @@ require (
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down
27 changes: 19 additions & 8 deletions pkg/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ type Environment struct {
FarmID pkg.FarmID
Orphan bool

FarmSecret string
SubstrateURL []string
RelayURL string
FarmSecret string
SubstrateURL []string
// IMPORTANT NOTICE:
// SINCE RELAYS FOR A NODE IS STORED ON THE CHAIN IN A LIMITED SPACE
// PLEASE MAKE SURE THAT ANY ENV HAS NO MORE THAN FOUR RELAYS CONFIGURED
RelayURL []string
ActivationURL string
GraphQL string

Expand Down Expand Up @@ -81,7 +84,9 @@ var (
SubstrateURL: []string{
"wss://tfchain.dev.grid.tf/",
},
RelayURL: "wss://relay.dev.grid.tf",
RelayURL: []string{
"wss://relay.dev.grid.tf",
},
ActivationURL: "https://activation.dev.grid.tf/activation/activate",
FlistURL: "redis://hub.grid.tf:9900",
BinRepo: "tf-zos-v3-bins.dev",
Expand All @@ -93,7 +98,9 @@ var (
SubstrateURL: []string{
"wss://tfchain.test.grid.tf/",
},
RelayURL: "wss://relay.test.grid.tf",
RelayURL: []string{
"wss://relay.test.grid.tf",
},
ActivationURL: "https://activation.test.grid.tf/activation/activate",
FlistURL: "redis://hub.grid.tf:9900",
BinRepo: "tf-zos-v3-bins.test",
Expand All @@ -105,7 +112,9 @@ var (
SubstrateURL: []string{
"wss://tfchain.qa.grid.tf/",
},
RelayURL: "wss://relay.qa.grid.tf",
RelayURL: []string{
"wss://relay.qa.grid.tf",
},
ActivationURL: "https://activation.qa.grid.tf/activation/activate",
FlistURL: "redis://hub.grid.tf:9900",
BinRepo: "tf-zos-v3-bins.qanet",
Expand All @@ -120,7 +129,9 @@ var (
"wss://03.tfchain.grid.tf/",
"wss://04.tfchain.grid.tf/",
},
RelayURL: "wss://relay.grid.tf",
RelayURL: []string{
"wss://relay.grid.tf",
},
ActivationURL: "https://activation.grid.tf/activation/activate",
FlistURL: "redis://hub.grid.tf:9900",
BinRepo: "tf-zos-v3-bins",
Expand Down Expand Up @@ -200,7 +211,7 @@ func getEnvironmentFromParams(params kernel.Params) (Environment, error) {

if relay, ok := params.Get("relay"); ok {
if len(relay) > 0 {
env.RelayURL = relay[len(relay)-1]
env.RelayURL = relay
}
}

Expand Down

0 comments on commit d68470b

Please sign in to comment.