Skip to content

Commit 2fd25b9

Browse files
committed
Merge pull request #11 from threefoldtech/use-registrar-client
Use registrar client
2 parents d8cb40c + d813867 commit 2fd25b9

File tree

20 files changed

+377
-914
lines changed

20 files changed

+377
-914
lines changed

.github/workflows/bin-package-no-tag.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ on:
1717
jobs:
1818
builder:
1919
name: builder
20-
runs-on: ubuntu-20.04
20+
runs-on: ubuntu-22.04
2121
steps:
2222
- name: Checkout code into the Go module directory
2323
uses: actions/checkout@v1

.github/workflows/publish.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ jobs:
2626

2727
- name: Build binaries
2828
run: |
29-
go generate ./pkg/capacity/...
3029
cd cmds
3130
make
3231
env:

.github/workflows/test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ jobs:
66
name: Running Daemon Tests
77
runs-on: ubuntu-latest
88
steps:
9-
- name: Set up Go 1.21
9+
- name: Set up Go 1.23
1010
uses: actions/setup-go@v1
1111
with:
12-
go-version: 1.21
12+
go-version: 1.23
1313
id: go
1414

1515
- name: Prepare dependencies

cmds/modules/api_gateway/main.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,15 @@ func action(cli *cli.Context) error {
5757

5858
sk := ed25519.PrivateKey(idStub.PrivateKey(cli.Context))
5959
pubKey := sk.Public().(ed25519.PublicKey)
60-
6160
log.Info().Str("public key", string(pubKey)).Msg("node public key")
62-
if err != nil {
63-
return err
64-
}
6561

6662
manager, err := environment.GetSubstrate()
6763
if err != nil {
6864
return fmt.Errorf("failed to create substrate manager: %w", err)
6965
}
7066

7167
router := peer.NewRouter()
72-
gw, err := registrar.NewRegistrarGateway(redis)
68+
gw, err := registrar.NewRegistrarGateway(cli.Context, redis)
7369
if err != nil {
7470
return fmt.Errorf("failed to create api gateway: %w", err)
7571
}
@@ -92,7 +88,12 @@ func action(cli *cli.Context) error {
9288
}
9389
}()
9490

95-
api, err := zosapi.NewZosAPI(manager, redis, msgBrokerCon)
91+
farm, err := gw.GetFarm(uint64(environment.MustGet().FarmID))
92+
if err != nil {
93+
return fmt.Errorf("failed to get farm: %w", err)
94+
}
95+
96+
api, err := zosapi.NewZosAPIWithFarmerID(redis, uint32(farm.TwinID), msgBrokerCon)
9697
if err != nil {
9798
return fmt.Errorf("failed to create zos api: %w", err)
9899
}

cmds/modules/netlightd/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import (
1010

1111
"github.com/oasisprotocol/curve25519-voi/primitives/x25519"
1212
"github.com/pkg/errors"
13+
"github.com/threefoldtech/zosbase/pkg/netbase/nft"
1314
"github.com/threefoldtech/zosbase/pkg/netlight"
1415
"github.com/threefoldtech/zosbase/pkg/netlight/bridge"
1516
"github.com/threefoldtech/zosbase/pkg/netlight/ifaceutil"
16-
"github.com/threefoldtech/zosbase/pkg/netlight/nft"
1717
"github.com/threefoldtech/zosbase/pkg/netlight/resource"
1818
"github.com/urfave/cli/v2"
1919

@@ -131,9 +131,9 @@ func action(cli *cli.Context) error {
131131
return fmt.Errorf("failed to setup mycelium on host: %w", err)
132132
}
133133

134-
if err := nft.DropTrafficToLAN(); err != nil {
135-
return fmt.Errorf("failed to drop traffic to lan: %w", err)
136-
}
134+
// if err := nft.DropTrafficToLAN(""); err != nil {
135+
// return fmt.Errorf("failed to drop traffic to lan: %w", err)
136+
// }
137137

138138
mod, err := netlight.NewNetworker()
139139
if err != nil {

cmds/modules/noded/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ func action(cli *cli.Context) error {
220220
}
221221
go events.Start(ctx)
222222

223-
system, err := monitord.NewSystemMonitor(node, 2*time.Second)
223+
system, err := monitord.NewSystemMonitor(node, 2*time.Second, redis)
224224
if err != nil {
225225
log.Fatal().Err(err).Msg("failed to initialize system monitor")
226226
}

cmds/modules/provisiond/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ func action(cli *cli.Context) error {
273273
if err != nil {
274274
return errors.Wrap(err, "failed to get node from twin")
275275
}
276+
nodeID := node.NodeID
276277

277278
queues := filepath.Join(rootDir, "queues")
278279
if err := os.MkdirAll(queues, 0755); err != nil {
@@ -300,7 +301,7 @@ func action(cli *cli.Context) error {
300301
queues,
301302
provision.WithTwins(users),
302303
provision.WithAdmins(admins),
303-
provision.WithAPIGateway(node, registrarGateway),
304+
provision.WithAPIGateway(nodeID, registrarGateway),
304305
// set priority to some reservation types on boot
305306
// so we always need to make sure all volumes and networks
306307
// comes first.
@@ -361,7 +362,7 @@ func action(cli *cli.Context) error {
361362
return errors.Wrap(err, "failed to create event consumer")
362363
}
363364

364-
handler := NewContractEventHandler(node, registrarGateway, engine, consumer)
365+
handler := NewContractEventHandler(nodeID, registrarGateway, engine, consumer)
365366

366367
go func() {
367368
if err := handler.Run(ctx); err != nil && err != context.Canceled {

go.mod

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module github.com/threefoldtech/zos4
22

3-
go 1.21
3+
go 1.23.0
44

5-
toolchain go1.21.0
5+
toolchain go1.24.2
66

77
require (
8-
github.com/BurntSushi/toml v1.1.0 // indirect
8+
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c // indirect
99
github.com/ChainSafe/go-schnorrkel v1.1.0 // indirect
1010
github.com/blang/semver v3.5.1+incompatible
1111
github.com/boltdb/bolt v1.3.1 // indirect
@@ -26,6 +26,7 @@ require (
2626
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
2727
github.com/google/uuid v1.6.0 // indirect
2828
github.com/gtank/merlin v0.1.1 // indirect
29+
github.com/hashicorp/go-retryablehttp v0.7.7
2930
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
3031
github.com/hasura/go-graphql-client v0.10.0 // indirect
3132
github.com/jbenet/go-base58 v0.0.0-20150317085156-6237cf65f3a6 // indirect
@@ -39,21 +40,17 @@ require (
3940
github.com/threefoldtech/0-fs v1.3.1-0.20240424140157-b488dfedcc56
4041
github.com/threefoldtech/tfchain/clients/tfchain-client-go v0.0.0-20241127100051-77e684bcb1b2
4142
github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go v0.16.1-0.20241229121208-76ac3fea5e67
43+
github.com/threefoldtech/tfgrid4-sdk-go/node-registrar v0.0.0-20250506110945-e1591751c92f
4244
github.com/threefoldtech/zbus v1.0.1
43-
github.com/threefoldtech/zosbase v0.1.3-0.20250225140145-b4d6dbd96e56
45+
github.com/threefoldtech/zosbase v0.1.4
4446
github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa
4547
github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852
4648
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f // indirect
47-
golang.org/x/crypto v0.31.0 // indirect
48-
golang.org/x/sys v0.28.0 // indirect
49+
golang.org/x/crypto v0.33.0 // indirect
50+
golang.org/x/sys v0.30.0 // indirect
4951
gopkg.in/yaml.v2 v2.4.0
5052
)
5153

52-
require (
53-
github.com/hashicorp/go-retryablehttp v0.7.7
54-
github.com/lib/pq v1.10.9
55-
)
56-
5754
require (
5855
github.com/Microsoft/go-winio v0.5.2 // indirect
5956
github.com/Microsoft/hcsshim v0.8.25 // indirect
@@ -75,17 +72,16 @@ require (
7572
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
7673
github.com/dustin/go-humanize v1.0.1 // indirect
7774
github.com/ethereum/go-ethereum v1.11.6 // indirect
78-
github.com/gin-gonic/gin v1.10.0 // indirect
7975
github.com/go-ole/go-ole v1.2.6 // indirect
8076
github.com/go-stack/stack v1.8.1 // indirect
81-
github.com/gofrs/flock v0.8.1 // indirect
77+
github.com/gofrs/flock v0.12.1 // indirect
8278
github.com/gogo/googleapis v1.4.1 // indirect
8379
github.com/gogo/protobuf v1.3.2 // indirect
8480
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
8581
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
86-
github.com/golang/protobuf v1.5.2 // indirect
82+
github.com/golang/protobuf v1.5.4 // indirect
8783
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
88-
github.com/google/go-cmp v0.6.0 // indirect
84+
github.com/google/go-cmp v0.7.0 // indirect
8985
github.com/gorilla/websocket v1.5.3 // indirect
9086
github.com/gtank/ristretto255 v0.1.2 // indirect
9187
github.com/hanwen/go-fuse/v2 v2.3.0 // indirect
@@ -96,9 +92,9 @@ require (
9692
github.com/holiman/uint256 v1.2.3 // indirect
9793
github.com/josharian/native v0.0.0-20200817173448-b6b71def0850 // indirect
9894
github.com/klauspost/compress v1.16.7 // indirect
99-
github.com/mattn/go-colorable v0.1.13 // indirect
95+
github.com/mattn/go-colorable v0.1.14 // indirect
10096
github.com/mattn/go-isatty v0.0.20 // indirect
101-
github.com/mattn/go-runewidth v0.0.13 // indirect
97+
github.com/mattn/go-runewidth v0.0.16 // indirect
10298
github.com/mdlayher/genetlink v1.0.0 // indirect
10399
github.com/mdlayher/netlink v1.4.0 // indirect
104100
github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b // indirect
@@ -120,37 +116,40 @@ require (
120116
github.com/pkg/xattr v0.4.1 // indirect
121117
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
122118
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
123-
github.com/rivo/uniseg v0.2.0 // indirect
119+
github.com/rivo/uniseg v0.4.7 // indirect
124120
github.com/robfig/cron/v3 v3.0.1 // indirect
121+
github.com/rogpeppe/go-internal v1.13.1 // indirect
125122
github.com/rs/cors v1.10.1 // indirect
126123
github.com/russross/blackfriday/v2 v2.1.0 // indirect
127124
github.com/safchain/ethtool v0.0.0-20201023143004-874930cb3ce0 // indirect
128-
github.com/sirupsen/logrus v1.8.1 // indirect
125+
github.com/sirupsen/logrus v1.9.3 // indirect
129126
github.com/stretchr/objx v0.5.2 // indirect
130-
github.com/tklauser/go-sysconf v0.3.11 // indirect
131-
github.com/tklauser/numcpus v0.6.0 // indirect
127+
github.com/tklauser/go-sysconf v0.3.12 // indirect
128+
github.com/tklauser/numcpus v0.6.1 // indirect
132129
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
133130
github.com/ulikunitz/xz v0.5.8 // indirect
134131
github.com/vedhavyas/go-subkey v1.0.3 // indirect
132+
github.com/vedhavyas/go-subkey/v2 v2.0.0 // indirect
135133
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
136134
github.com/whs/nacl-sealed-box v0.0.0-20180930164530-92b9ba845d8d // indirect
137135
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
138136
github.com/xxtea/xxtea-go v0.0.0-20170828040851-35c4b17eecf6 // indirect
139137
github.com/yggdrasil-network/yggdrasil-go v0.4.0 // indirect
140-
github.com/yusufpapurcu/wmi v1.2.2 // indirect
141-
go.opencensus.io v0.23.0 // indirect
138+
github.com/yusufpapurcu/wmi v1.2.4 // indirect
139+
go.opencensus.io v0.24.0 // indirect
142140
go.uber.org/atomic v1.9.0 // indirect
143-
golang.org/x/net v0.26.0 // indirect
144-
golang.org/x/sync v0.10.0 // indirect
145-
golang.org/x/text v0.21.0 // indirect
141+
golang.org/x/mod v0.23.0 // indirect
142+
golang.org/x/net v0.35.0 // indirect
143+
golang.org/x/sync v0.11.0 // indirect
144+
golang.org/x/text v0.22.0 // indirect
146145
golang.org/x/tools v0.22.0 // indirect
147146
golang.zx2c4.com/wireguard v0.0.20200320 // indirect
148147
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20200609130330-bd2cb7843e1b // indirect
149148
gonum.org/v1/gonum v0.15.0 // indirect
150149
google.golang.org/appengine v1.6.7 // indirect
151150
google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4 // indirect
152-
google.golang.org/grpc v1.41.0 // indirect
153-
google.golang.org/protobuf v1.34.2 // indirect
151+
google.golang.org/grpc v1.70.0 // indirect
152+
google.golang.org/protobuf v1.36.4 // indirect
154153
gopkg.in/djherbis/times.v1 v1.2.0 // indirect
155154
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
156155
gopkg.in/yaml.v3 v3.0.1 // indirect

0 commit comments

Comments
 (0)