Skip to content

Use registrar client #11

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

Merged
merged 15 commits into from
May 6, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/bin-package-no-tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
jobs:
builder:
name: builder
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Checkout code into the Go module directory
uses: actions/checkout@v1
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:

- name: Build binaries
run: |
go generate ./pkg/capacity/...
cd cmds
make
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ jobs:
name: Running Daemon Tests
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.21
- name: Set up Go 1.23
uses: actions/setup-go@v1
with:
go-version: 1.21
go-version: 1.23
id: go

- name: Prepare dependencies
Expand Down
13 changes: 7 additions & 6 deletions cmds/modules/api_gateway/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,15 @@ func action(cli *cli.Context) error {

sk := ed25519.PrivateKey(idStub.PrivateKey(cli.Context))
pubKey := sk.Public().(ed25519.PublicKey)

log.Info().Str("public key", string(pubKey)).Msg("node public key")
if err != nil {
return err
}

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

router := peer.NewRouter()
gw, err := registrar.NewRegistrarGateway(redis)
gw, err := registrar.NewRegistrarGateway(cli.Context, redis)
if err != nil {
return fmt.Errorf("failed to create api gateway: %w", err)
}
Expand All @@ -92,7 +88,12 @@ func action(cli *cli.Context) error {
}
}()

api, err := zosapi.NewZosAPI(manager, redis, msgBrokerCon)
farm, err := gw.GetFarm(uint64(environment.MustGet().FarmID))
if err != nil {
return fmt.Errorf("failed to get farm: %w", err)
}

api, err := zosapi.NewZosAPIWithFarmerID(redis, uint32(farm.TwinID), msgBrokerCon)
if err != nil {
return fmt.Errorf("failed to create zos api: %w", err)
}
Expand Down
8 changes: 4 additions & 4 deletions cmds/modules/netlightd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (

"github.com/oasisprotocol/curve25519-voi/primitives/x25519"
"github.com/pkg/errors"
"github.com/threefoldtech/zosbase/pkg/netbase/nft"
"github.com/threefoldtech/zosbase/pkg/netlight"
"github.com/threefoldtech/zosbase/pkg/netlight/bridge"
"github.com/threefoldtech/zosbase/pkg/netlight/ifaceutil"
"github.com/threefoldtech/zosbase/pkg/netlight/nft"
"github.com/threefoldtech/zosbase/pkg/netlight/resource"
"github.com/urfave/cli/v2"

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

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

mod, err := netlight.NewNetworker()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmds/modules/noded/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func action(cli *cli.Context) error {
}
go events.Start(ctx)

system, err := monitord.NewSystemMonitor(node, 2*time.Second)
system, err := monitord.NewSystemMonitor(node, 2*time.Second, redis)
if err != nil {
log.Fatal().Err(err).Msg("failed to initialize system monitor")
}
Expand Down
5 changes: 3 additions & 2 deletions cmds/modules/provisiond/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ func action(cli *cli.Context) error {
if err != nil {
return errors.Wrap(err, "failed to get node from twin")
}
nodeID := node.NodeID

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

handler := NewContractEventHandler(node, registrarGateway, engine, consumer)
handler := NewContractEventHandler(nodeID, registrarGateway, engine, consumer)

go func() {
if err := handler.Run(ctx); err != nil && err != context.Canceled {
Expand Down
54 changes: 25 additions & 29 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
module github.com/threefoldtech/zos4

go 1.21

toolchain go1.21.0
go 1.23

require (
github.com/BurntSushi/toml v1.1.0 // indirect
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c // indirect
github.com/ChainSafe/go-schnorrkel v1.1.0 // indirect
github.com/blang/semver v3.5.1+incompatible
github.com/boltdb/bolt v1.3.1 // indirect
Expand All @@ -26,6 +24,7 @@ require (
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gtank/merlin v0.1.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.7
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
github.com/hasura/go-graphql-client v0.10.0 // indirect
github.com/jbenet/go-base58 v0.0.0-20150317085156-6237cf65f3a6 // indirect
Expand All @@ -39,21 +38,17 @@ require (
github.com/threefoldtech/0-fs v1.3.1-0.20240424140157-b488dfedcc56
github.com/threefoldtech/tfchain/clients/tfchain-client-go v0.0.0-20241127100051-77e684bcb1b2
github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go v0.16.1-0.20241229121208-76ac3fea5e67
github.com/threefoldtech/tfgrid4-sdk-go/node-registrar v0.0.0-20250505161246-1567ed2c9e82
github.com/threefoldtech/zbus v1.0.1
github.com/threefoldtech/zosbase v0.1.3-0.20250225140145-b4d6dbd96e56
github.com/threefoldtech/zosbase v0.1.4
github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa
github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/crypto v0.33.0 // indirect
golang.org/x/sys v0.30.0 // indirect
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/hashicorp/go-retryablehttp v0.7.7
github.com/lib/pq v1.10.9
)

require (
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/Microsoft/hcsshim v0.8.25 // indirect
Expand All @@ -75,17 +70,16 @@ require (
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/ethereum/go-ethereum v1.11.6 // indirect
github.com/gin-gonic/gin v1.10.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gofrs/flock v0.12.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/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/gtank/ristretto255 v0.1.2 // indirect
github.com/hanwen/go-fuse/v2 v2.3.0 // indirect
Expand All @@ -96,9 +90,9 @@ require (
github.com/holiman/uint256 v1.2.3 // indirect
github.com/josharian/native v0.0.0-20200817173448-b6b71def0850 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mdlayher/genetlink v1.0.0 // indirect
github.com/mdlayher/netlink v1.4.0 // indirect
github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b // indirect
Expand All @@ -120,37 +114,39 @@ require (
github.com/pkg/xattr v0.4.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
github.com/rs/cors v1.10.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/safchain/ethtool v0.0.0-20201023143004-874930cb3ce0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.0 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/ulikunitz/xz v0.5.8 // indirect
github.com/vedhavyas/go-subkey v1.0.3 // indirect
github.com/vedhavyas/go-subkey/v2 v2.0.0 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/whs/nacl-sealed-box v0.0.0-20180930164530-92b9ba845d8d // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
github.com/xxtea/xxtea-go v0.0.0-20170828040851-35c4b17eecf6 // indirect
github.com/yggdrasil-network/yggdrasil-go v0.4.0 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.opencensus.io v0.23.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/net v0.35.0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/text v0.22.0 // indirect
golang.org/x/tools v0.22.0 // indirect
golang.zx2c4.com/wireguard v0.0.20200320 // indirect
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20200609130330-bd2cb7843e1b // indirect
gonum.org/v1/gonum v0.15.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4 // indirect
google.golang.org/grpc v1.41.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
google.golang.org/grpc v1.70.0 // indirect
google.golang.org/protobuf v1.36.4 // indirect
gopkg.in/djherbis/times.v1 v1.2.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading
Loading