Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update rmb with signature #1575

Merged
merged 2 commits into from
Jan 26, 2022
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
10 changes: 9 additions & 1 deletion cmds/modules/noded/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package noded

import (
"context"
"crypto/ed25519"
"fmt"
"os/exec"
"strings"
Expand All @@ -10,6 +11,7 @@ import (
"github.com/pkg/errors"
"github.com/urfave/cli/v2"

"github.com/threefoldtech/substrate-client"
"github.com/threefoldtech/zos/pkg/app"
"github.com/threefoldtech/zos/pkg/capacity"
"github.com/threefoldtech/zos/pkg/environment"
Expand Down Expand Up @@ -201,6 +203,12 @@ func action(cli *cli.Context) error {

log.Info().Uint32("twin", twin).Msg("node has been registered")
log.Debug().Msg("start message bus")
identityd := stubs.NewIdentityManagerStub(redis)
sk := ed25519.PrivateKey(identityd.PrivateKey(ctx))
id, err := substrate.NewIdentityFromEd25519Key(sk)
if err != nil {
return err
}

return runMsgBus(ctx, twin, env.SubstrateURL)
return runMsgBus(ctx, env.SubstrateURL, id)
}
8 changes: 3 additions & 5 deletions cmds/modules/noded/twin.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@ import (
"context"

"github.com/pkg/errors"
"github.com/rs/zerolog/log"
"github.com/threefoldtech/go-rmb"
"github.com/threefoldtech/substrate-client"
)

func runMsgBus(ctx context.Context, twin uint32, substrate string) error {
func runMsgBus(ctx context.Context, substrate string, identity substrate.Identity) error {
// todo: make it argument or parse from broker
const redis = "/var/run/redis.sock"
app, err := rmb.NewServer(substrate, redis, int(twin), 100)
app, err := rmb.NewServer(substrate, redis, 100, identity)
if err != nil {
return err
}

log.Info().Uint32("twin", twin).Msg("starting twin")

if err := app.Serve(ctx); err != nil && !errors.Is(err, context.Canceled) {
return err
}
Expand Down
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412
github.com/alexflint/go-filemutex v1.1.0
github.com/blang/semver v3.5.1+incompatible
github.com/boltdb/bolt v1.3.1 // indirect
github.com/boltdb/bolt v1.3.1
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/cenkalti/backoff/v3 v3.2.2
github.com/centrifuge/go-substrate-rpc-client/v3 v3.0.2
Expand Down Expand Up @@ -61,8 +61,8 @@ require (
github.com/stretchr/objx v0.3.0 // indirect
github.com/stretchr/testify v1.7.0
github.com/threefoldtech/0-fs v1.3.1-0.20201203163303-d963de9adea7
github.com/threefoldtech/go-rmb v0.1.8-0.20220114102147-d3d03a1678f4
github.com/threefoldtech/substrate-client v0.0.0-20220118092946-5c10e5c7e407
github.com/threefoldtech/go-rmb v0.1.9
github.com/threefoldtech/substrate-client v0.0.0-20220118133601-4e68945dc064
github.com/threefoldtech/zbus v0.1.5
github.com/tinylib/msgp v1.1.5 // indirect
github.com/tyler-smith/go-bip39 v1.1.0
Expand All @@ -73,6 +73,7 @@ require (
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/whs/nacl-sealed-box v0.0.0-20180930164530-92b9ba845d8d
github.com/yggdrasil-network/yggdrasil-go v0.4.0
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
golang.org/x/net v0.0.0-20211005001312-d4b1ae081e3b // indirect
Expand Down
28 changes: 8 additions & 20 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbt
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ=
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/StackExchange/wmi v0.0.0-20210224194228-fe8f1750fd46/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
github.com/VictoriaMetrics/fastcache v1.5.7/go.mod h1:ptDBkNMQI4RtmVo8VS/XwRY6RoTu1dAWCbrk+6WsEM8=
github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw=
Expand Down Expand Up @@ -334,7 +332,6 @@ github.com/d2g/dhcp4client v1.0.0/go.mod h1:j0hNfjhrt2SxUOw55nL0ATM/z4Yt3t2Kd1mW
github.com/d2g/dhcp4server v0.0.0-20181031114812-7d4a0a7f59a5/go.mod h1:Eo87+Kg/IX2hfWJfwxMzLyuSZyxSoAug2nGa1G2QAi8=
github.com/d2g/hardwareaddr v0.0.0-20190221164911-e7d9fbe030e4/go.mod h1:bMl4RjIciD2oAxI7DmWRx6gbeqrkoLqv3MV0vzNad+I=
github.com/dave/jennifer v1.2.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg=
github.com/dave/jennifer v1.3.0 h1:p3tl41zjjCZTNBytMwrUuiAnherNUZktlhPTKoF/sEk=
github.com/dave/jennifer v1.3.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg=
github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -949,7 +946,6 @@ github.com/rs/xhandler v0.0.0-20160618193221-ed27b6fd6521/go.mod h1:RvLn4FgxWubr
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.14.3/go.mod h1:3WXPzbXEEliJ+a6UFE4vhIxV8qR1EML6ngzP9ug4eYg=
github.com/rs/zerolog v1.25.0/go.mod h1:7KHcEGe0QZPOm2IE4Kpb5rTh6n1h2hIgS5OOnu1rUaI=
github.com/rs/zerolog v1.26.0 h1:ORM4ibhEZeTeQlCojCK2kPz1ogAY4bGs4tD+SaAdGaE=
github.com/rs/zerolog v1.26.0/go.mod h1:yBiM87lvSqX8h0Ww4sdzNSkVYZ8dL2xjZJG1lAuGZEo=
github.com/rusart/muxprom v0.0.0-20200609120753-9173fa27435a h1:vCw+JDEJSxF1nkTTv3M8lYtUYV0KoGUDwbl7oBtJOd4=
Expand All @@ -967,7 +963,6 @@ github.com/segmentio/kafka-go v0.2.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfP
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sevlyar/go-daemon v0.1.5/go.mod h1:6dJpPatBT9eUwM5VCw9Bt6CdX9Tk6UWvhW3MebLDRKE=
github.com/shirou/gopsutil v2.20.5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU=
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
Expand Down Expand Up @@ -1026,21 +1021,12 @@ github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954/go.mod h1:u2MKk
github.com/tchap/go-patricia v2.2.6+incompatible/go.mod h1:bmLyhP68RS6kStMGxByiQ23RP/odRBOTVjwp2cDyi6I=
github.com/threefoldtech/0-fs v1.3.1-0.20201203163303-d963de9adea7 h1:64QIPSO1Acx7ENdMwQ0Q4tnE94By1BljA/2R2NbY51Y=
github.com/threefoldtech/0-fs v1.3.1-0.20201203163303-d963de9adea7/go.mod h1:OPPZiE/GthPR2IepjKSc8wa+t/7wl3dtHQyEdUcftZI=
github.com/threefoldtech/go-rmb v0.1.7 h1:3xpGgPx/nxDSkEFm1chaXZ4iKkwkYdplgsqQHicg83c=
github.com/threefoldtech/go-rmb v0.1.7/go.mod h1:+9ql1bqMqmBpudtafk5HG4WO0E7Y5AX9Q2njM8SAvnU=
github.com/threefoldtech/go-rmb v0.1.8-0.20220114102147-d3d03a1678f4 h1:C9IzXo3hEcLd8gh0OYMUN+fc2Pxr5pBvqcX2aNCq3fY=
github.com/threefoldtech/go-rmb v0.1.8-0.20220114102147-d3d03a1678f4/go.mod h1:+9ql1bqMqmBpudtafk5HG4WO0E7Y5AX9Q2njM8SAvnU=
github.com/threefoldtech/substrate-client v0.0.0-20210930125201-9bd88e80762d/go.mod h1:t/85gAaltVbJmUnCVwu5lpNKn0HLn9Z9vu/NFJlJcrk=
github.com/threefoldtech/substrate-client v0.0.0-20211231191725-b8f9d49d9a97 h1:3fm4M2cpOMgjirzLLNTxElUI7ksSu+z3z+NtP7zAY+E=
github.com/threefoldtech/substrate-client v0.0.0-20211231191725-b8f9d49d9a97/go.mod h1:kI84UXFN+t0v7I3Qtj+otQwIaGel+AT86L5B0t/zQpI=
github.com/threefoldtech/substrate-client v0.0.0-20220111085721-f87895fa386c h1:v5DLY06zepCo96PrfayXfllpur1BkJY6rO3TlToMurg=
github.com/threefoldtech/substrate-client v0.0.0-20220111085721-f87895fa386c/go.mod h1:kI84UXFN+t0v7I3Qtj+otQwIaGel+AT86L5B0t/zQpI=
github.com/threefoldtech/substrate-client v0.0.0-20220111105032-8bebe8a7d791 h1:V7tInz9sUgcbCZnoVkhUcT34FzGNihU6sQl6Mwzl5r0=
github.com/threefoldtech/substrate-client v0.0.0-20220111105032-8bebe8a7d791/go.mod h1:kI84UXFN+t0v7I3Qtj+otQwIaGel+AT86L5B0t/zQpI=
github.com/threefoldtech/substrate-client v0.0.0-20220118090202-a6eb9f482112 h1:/FTitrM+Ghnf7tlOaplvBCGl6CGMzsu2XXQhBXTpf+Y=
github.com/threefoldtech/substrate-client v0.0.0-20220118090202-a6eb9f482112/go.mod h1:kI84UXFN+t0v7I3Qtj+otQwIaGel+AT86L5B0t/zQpI=
github.com/threefoldtech/substrate-client v0.0.0-20220118092946-5c10e5c7e407 h1:3dbR7Yvgmz/gdLMUajwJc0K0lJopNu7rB1dn+o05MOE=
github.com/threefoldtech/substrate-client v0.0.0-20220118092946-5c10e5c7e407/go.mod h1:kI84UXFN+t0v7I3Qtj+otQwIaGel+AT86L5B0t/zQpI=
github.com/threefoldtech/go-rmb v0.1.8-0.20220126082719-8d5ea5b2d798 h1:H927/dBtFaGf0efixeU3axjxRwb5DdSj6mMcjUJ2Sww=
github.com/threefoldtech/go-rmb v0.1.8-0.20220126082719-8d5ea5b2d798/go.mod h1:kWpSCWxgc7OUGVYmDqioSUkV99xLoZVlBZNbxleex8o=
github.com/threefoldtech/go-rmb v0.1.9 h1:Cz+YH6j4SNtWTje78+Dzp3Omp9mGVdvMANwMf4AwZII=
github.com/threefoldtech/go-rmb v0.1.9/go.mod h1:kWpSCWxgc7OUGVYmDqioSUkV99xLoZVlBZNbxleex8o=
github.com/threefoldtech/substrate-client v0.0.0-20220118133601-4e68945dc064 h1:JgJ2X7EnJuZ311wDF/3zLBttU/so4maOoKQDQQ3U6ZY=
github.com/threefoldtech/substrate-client v0.0.0-20220118133601-4e68945dc064/go.mod h1:kI84UXFN+t0v7I3Qtj+otQwIaGel+AT86L5B0t/zQpI=
github.com/threefoldtech/zbus v0.1.5 h1:S9kXbjejoRRnJw1yKHEXFGF2vqL+Drae2n4vpj0pGHo=
github.com/threefoldtech/zbus v0.1.5/go.mod h1:ZtiRpcqzEBJetVQDsEbw0p48h/AF3O1kf0tvd30I0BU=
github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
Expand Down Expand Up @@ -1107,6 +1093,8 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43/go.mod h1:aX5oPXxHm3bOH+xeAttToC8pqch2ScQN/JoXYupl6xs=
github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50/go.mod h1:NUSPSUX/bi6SeDMUh6brw0nXpxHnc96TguQh0+r/ssA=
github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f/go.mod h1:GlGEuHIJweS1mbCqG+7vt2nvWLzLLnRHbXz5JKd/Qbg=
Expand Down