diff --git a/.github/workflows/bin-package-no-tag.yaml b/.github/workflows/bin-package-no-tag.yaml index e90ebecf..f0813536 100644 --- a/.github/workflows/bin-package-no-tag.yaml +++ b/.github/workflows/bin-package-no-tag.yaml @@ -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 diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 63143f54..7e7ed948 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -26,7 +26,6 @@ jobs: - name: Build binaries run: | - go generate ./pkg/capacity/... cd cmds make env: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index b1ee560d..a95376ca 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -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 diff --git a/cmds/modules/api_gateway/main.go b/cmds/modules/api_gateway/main.go index d06ffcb6..d85c8e14 100644 --- a/cmds/modules/api_gateway/main.go +++ b/cmds/modules/api_gateway/main.go @@ -57,11 +57,7 @@ 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 { @@ -69,7 +65,7 @@ func action(cli *cli.Context) error { } 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) } @@ -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) } diff --git a/cmds/modules/netlightd/main.go b/cmds/modules/netlightd/main.go index dac41d46..9f03f52f 100644 --- a/cmds/modules/netlightd/main.go +++ b/cmds/modules/netlightd/main.go @@ -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" @@ -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 { diff --git a/cmds/modules/noded/main.go b/cmds/modules/noded/main.go index cee6d0dd..fe237c47 100644 --- a/cmds/modules/noded/main.go +++ b/cmds/modules/noded/main.go @@ -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") } diff --git a/cmds/modules/provisiond/main.go b/cmds/modules/provisiond/main.go index 278d0623..f44d264c 100644 --- a/cmds/modules/provisiond/main.go +++ b/cmds/modules/provisiond/main.go @@ -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 { @@ -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. @@ -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 { diff --git a/go.mod b/go.mod index 946a9187..4efdda26 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/go.sum b/go.sum index 14ef960b..a259d0c7 100644 --- a/go.sum +++ b/go.sum @@ -5,8 +5,8 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT github.com/Arceliar/ironwood v0.0.0-20210619124114-6ad55cae5031/go.mod h1:RP72rucOFm5udrnEzTmIWLRVGQiV/fSUAQXJ0RST/nk= github.com/Arceliar/phony v0.0.0-20210209235338-dde1a8dca979/go.mod h1:6Lkn+/zJilRMsKmbmG1RPoamiArC6HS73xbwRyp3UyI= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I= -github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs= +github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/ChainSafe/go-schnorrkel v1.1.0 h1:rZ6EU+CZFCjB4sHUE1jIu8VDoB/wRKZxoe1tkcO71Wk= github.com/ChainSafe/go-schnorrkel v1.1.0/go.mod h1:ABkENxiP+cvjFiByMIZ9LYbRoNNLeBLiakC1XeTFxfE= github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= @@ -40,10 +40,10 @@ github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFA github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce h1:YtWJF7RHm2pYCvA5t0RPmAaLUhREsKuKd+SLhxFbFeQ= github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o= github.com/buger/jsonparser v0.0.0-20180808090653-f4dd9f5a6b44/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= -github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0= -github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= -github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM= -github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= +github.com/bytedance/sonic v1.12.6 h1:/isNmCUF2x3Sh8RAp/4mh4ZGkcFAX/hLrzrK3AvpRzk= +github.com/bytedance/sonic v1.12.6/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= +github.com/bytedance/sonic/loader v0.2.1 h1:1GgorWTqf12TA8mma4DDSbaQigE2wOgQo7iCjjJv3+E= +github.com/bytedance/sonic/loader v0.2.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/cenkalti/backoff/v3 v3.2.2 h1:cfUAAO3yvKMYKPrvhDuHSwQnhZNk/RMHKdZqKTxfm6M= @@ -53,7 +53,6 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA github.com/centrifuge/go-substrate-rpc-client/v4 v4.0.12 h1:DCYWIBOalB0mKKfUg2HhtGgIkBbMA1fnlnkZp7fHB18= github.com/centrifuge/go-substrate-rpc-client/v4 v4.0.12/go.mod h1:5g1oM4Zu3BOaLpsKQ+O8PAv2kNuq+kPcA1VzFbsSqxE= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E= github.com/cheggaaa/pb/v3 v3.0.8/go.mod h1:UICbiLec/XO6Hw6k+BHEtHeQFzzBH4i2/qk/ow1EJTA= github.com/cilium/ebpf v0.4.0/go.mod h1:4tRaxcgiL706VnOzHOdBlY8IEAIdxINsQBcU4xJJXRs= @@ -66,7 +65,6 @@ github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/containerd/cgroups v1.0.1/go.mod h1:0SJrPIenamHDcZhEcJMNBB85rHcUsw4f25ZfBiPYRkU= github.com/containerd/cgroups v1.0.3 h1:ADZftAkglvCiD44c77s5YmMqaP2pzVCFZvBmAlBdAP4= github.com/containerd/cgroups v1.0.3/go.mod h1:/ofk34relqNjSGyqPrmEULrO4Sc8LJhvJmWbUCUKqj8= @@ -145,7 +143,6 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/ethereum/go-ethereum v1.11.6 h1:2VF8Mf7XiSUfmoNOy3D+ocfl9Qu8baQBrCNbo2CXQ8E= github.com/ethereum/go-ethereum v1.11.6/go.mod h1:+a8pUj1tOyJ2RinsNQD4326YS+leSoKGiG/uVVb0x6Y= @@ -168,8 +165,8 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= -github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= -github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= +github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= +github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= github.com/gizak/termui/v3 v3.1.0 h1:ZZmVDgwHl7gR7elfKf1xc4IudXZ5qqfDh4wExk4Iajc= github.com/gizak/termui/v3 v3.1.0/go.mod h1:bXQEBkJpzxUAKf0+xq9MSWAvWZlE7c+aidmyFlkYTrY= github.com/go-co-op/gocron v1.33.1 h1:wjX+Dg6Ae29a/f9BSQjY1Rl+jflTpW9aDyMqseCj78c= @@ -177,6 +174,10 @@ github.com/go-co-op/gocron v1.33.1/go.mod h1:NLi+bkm4rRSy1F8U7iacZOz0xPseMoIOnva github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= @@ -187,8 +188,8 @@ github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= -github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8= -github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= +github.com/go-playground/validator/v10 v10.17.0 h1:SmVVlfAOtlZncTxRuinDPomC2DkXJ4E5T9gDA0AIH74= +github.com/go-playground/validator/v10 v10.17.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-redis/redis v6.15.9+incompatible h1:K0pv1D7EQUjfyoMql+r/jZqCLizCGKFlFgcHWWmHQjg= github.com/go-redis/redis v6.15.9+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= @@ -200,15 +201,15 @@ github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8= github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= -github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= -github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/goccy/go-json v0.10.4 h1:JSwxQzIqKfmFX1swYPpUThQZp/Ka4wzJdK0LWVytLPM= +github.com/goccy/go-json v0.10.4/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= github.com/godbus/dbus v0.0.0-20180201030542-885f9cc04c9c/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw= github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/flock v0.7.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= -github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= -github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= +github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E= +github.com/gofrs/flock v0.12.1/go.mod h1:9zxTsyu5xtJ9DK+1tFZyibEV7y3uwDxPPfbxeeHCoD0= github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0= github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -240,8 +241,9 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/gologme/log v1.2.0/go.mod h1:gq31gQ8wEHkR+WekdWsqDuf8pXTUZA9BnnzTuPz1Y9U= @@ -258,8 +260,8 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa h1:Q75Upo5UN4JbPFURXZ8nLKYUvF85dyFRop/vQ0Rv+64= github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -346,8 +348,8 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= -github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= -github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/klauspost/cpuid/v2 v2.2.9 h1:66ze0taIn2H33fBvCkXuv9BmCwDfafmiIVpKV9kKGuY= +github.com/klauspost/cpuid/v2 v2.2.9/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK4QwQ3WMXF8= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -364,14 +366,13 @@ github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LE github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= -github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= -github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lxn/walk v0.0.0-20210112085537-c389da54e794/go.mod h1:E23UucZGqpuUANJooIbHWCufXvOcT6E7Stq81gU+CSQ= github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= @@ -381,8 +382,9 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= -github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o= github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= @@ -463,8 +465,8 @@ github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaR github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.8.1 h1:1Nf83orprkJyknT6h7zbuEGUEjcyVlCxSUGTENmNCRM= -github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= -github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= +github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M= +github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc= github.com/philhofer/fwd v1.1.1 h1:GdGcTjf5RNAxwS4QLsiMzJYj5KEvPJD3Abr261yRQXQ= github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/pierrec/lz4 v2.3.0+incompatible h1:CZzRn4Ut9GbUkHlQ7jqBXeZQV41ZSKWFc302ZU6lUTk= @@ -497,8 +499,9 @@ github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40T github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= +github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= @@ -506,8 +509,8 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= -github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= -github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= +github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= +github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/rs/cors v1.10.1 h1:L0uuZVXIKlI1SShY2nhFfo44TYvDPQ1w4oFkUJNfhyo= github.com/rs/cors v1.10.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= @@ -528,8 +531,9 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= @@ -552,6 +556,7 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= @@ -563,16 +568,18 @@ github.com/threefoldtech/tfchain/clients/tfchain-client-go v0.0.0-20241127100051 github.com/threefoldtech/tfchain/clients/tfchain-client-go v0.0.0-20241127100051-77e684bcb1b2/go.mod h1:cOL5YgHUmDG5SAXrsZxFjUECRQQuAqOoqvXhZG5sEUw= github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go v0.16.1-0.20241229121208-76ac3fea5e67 h1:Ii9TmXPBC1GYxRirReSygRZvEGXfAsQRaIipMEzGik0= github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go v0.16.1-0.20241229121208-76ac3fea5e67/go.mod h1:93SROfr+QjgaJ5/jIWtIpLkhaD8Pv8WbdfwvwMNG2p4= +github.com/threefoldtech/tfgrid4-sdk-go/node-registrar v0.0.0-20250505161246-1567ed2c9e82 h1:McGjlE+QTqruyo9OEe9ZoUH8FEndniEd/YU/kWHeCJ8= +github.com/threefoldtech/tfgrid4-sdk-go/node-registrar v0.0.0-20250505161246-1567ed2c9e82/go.mod h1:5p+3dprweeEymBRNCB8b8cdGmP36g9LGtf2wwqyqvFk= github.com/threefoldtech/zbus v1.0.1 h1:3KaEpyOiDYAw+lrAyoQUGIvY9BcjVRXlQ1beBRqhRNk= github.com/threefoldtech/zbus v1.0.1/go.mod h1:E/v/xEvG/l6z/Oj0aDkuSUXFm/1RVJkhKBwDTAIdsHo= -github.com/threefoldtech/zosbase v0.1.3-0.20250225140145-b4d6dbd96e56 h1:/2WsNT5UFiKzDxzd/9gxVX/sf6LC2Nna5F7YyZs/ovY= -github.com/threefoldtech/zosbase v0.1.3-0.20250225140145-b4d6dbd96e56/go.mod h1:rxc49wA04S4IsBOYe0omVO7nu7GXridueh2PJh34gSo= +github.com/threefoldtech/zosbase v0.1.4 h1:ZLm06TujSSIU8rX28X5Dx7utWQhiDqKBoTqGKBKOwDI= +github.com/threefoldtech/zosbase v0.1.4/go.mod h1:rxc49wA04S4IsBOYe0omVO7nu7GXridueh2PJh34gSo= github.com/tinylib/msgp v1.1.5 h1:2gXmtWueD2HefZHQe1QOy9HVzmFrLOVvsXwXBQ0ayy0= github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg= -github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM= -github.com/tklauser/go-sysconf v0.3.11/go.mod h1:GqXfhXY3kiPa0nAXPDIQIWzJbMCB7AmcWpGR8lSZfqI= -github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYms= -github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4= +github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tsenart/deadcode v0.0.0-20160724212837-210d2dc333e9/go.mod h1:q+QjxYvZ+fpjMXqs+XEriussHjSYqeXVnAdSV1tkMYk= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= @@ -594,6 +601,8 @@ github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa h1:5SqCsI/2Qya2bC github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI= github.com/vedhavyas/go-subkey v1.0.3 h1:iKR33BB/akKmcR2PMlXPBeeODjWLM90EL98OrOGs8CA= github.com/vedhavyas/go-subkey v1.0.3/go.mod h1:CloUaFQSSTdWnINfBRFjVMkWXZANW+nd8+TI5jYcl6Y= +github.com/vedhavyas/go-subkey/v2 v2.0.0 h1:LemDIsrVtRSOkp0FA8HxP6ynfKjeOj3BY2U9UNfeDMA= +github.com/vedhavyas/go-subkey/v2 v2.0.0/go.mod h1:95aZ+XDCWAUUynjlmi7BtPExjXgXxByE0WfBwbmIRH4= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852 h1:cPXZWzzG0NllBLdjWoD1nDfaqu98YMv+OneaKc8sPOA= github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho= @@ -617,13 +626,23 @@ github.com/yggdrasil-network/yggdrasil-go v0.4.0/go.mod h1:/iMJjOrXRsjlFgqhWOPhe github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 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/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= -github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= +github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= +github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= -go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= +go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= +go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= +go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U= +go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg= +go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M= +go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8= +go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5lEG4= +go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= +go.opentelemetry.io/otel/sdk/metric v1.32.0 h1:rZvFnvmvawYb0alrYkjraqJq0Z4ZUJAiyYCU9snn1CU= +go.opentelemetry.io/otel/sdk/metric v1.32.0/go.mod h1:PWeZlq0zt9YkYAp3gjKZ0eicRYvOh1Gd+X99x6GHpCQ= +go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= +go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= @@ -631,8 +650,8 @@ go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc= -golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= +golang.org/x/arch v0.12.0 h1:UsYJhbzPYGsT0HbEdmYcqtCv8UNGvnaL561NnIUvaKg= +golang.org/x/arch v0.12.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -645,8 +664,8 @@ golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWP golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= -golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= -golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= +golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= @@ -692,8 +711,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8= +golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -705,8 +724,8 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= -golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= +golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -760,13 +779,15 @@ golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211116061358-0a5406a5449c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -775,8 +796,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7-0.20210503195748-5c7c50ebbd4f/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= -golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= +golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -834,8 +855,8 @@ google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTp google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.41.0 h1:f+PlOh7QV4iIJkPrx5NQ7qaNGFQ3OTse67yaDHfju4E= -google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k= +google.golang.org/grpc v1.70.0 h1:pWFv03aZoHzlRKHWicjsZytKAiYCtNS0dHbXnIdq7jQ= +google.golang.org/grpc v1.70.0/go.mod h1:ofIJqVKDXx/JiXrwr2IG4/zwdH9txy3IlF40RmcJSQw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -848,8 +869,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM= +google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/pkg/Makefile b/pkg/Makefile new file mode 100644 index 00000000..0c366cbe --- /dev/null +++ b/pkg/Makefile @@ -0,0 +1,29 @@ +PWD := $(shell pwd) +GOPATH := $(shell go env GOPATH) + +all: build + +all: getdeps test + +getdeps: + @echo "Installing golangci-lint" && go get github.com/golangci/golangci-lint/cmd/golangci-lint && go install github.com/golangci/golangci-lint/cmd/golangci-lint + @echo "Installing zbusc" && go install github.com/threefoldtech/zbus/zbusc + go mod tidy + +lint: + @echo "Running $@" + @${GOPATH}/bin/golangci-lint run -c ../.golangci.yml + +check: test +test: lint build + go test -vet=off -v $(shell go list ./... | grep -Ev "stubs|network" ) + +testrace: lint build + go test -vet=off -v $(shell go list ./... | grep -Ev "stubs|network" ) + +generate: + @echo "Generating modules client stubs" + go generate github.com/threefoldtech/zos4/pkg + +build: + @CGO_ENABLED=0 go build -v ./... diff --git a/pkg/identity/identityd.go b/pkg/identity/identityd.go index 53e82347..b643bd09 100644 --- a/pkg/identity/identityd.go +++ b/pkg/identity/identityd.go @@ -1,13 +1,11 @@ package identity import ( - "encoding/json" - "fmt" - "net/http" + "net/url" "github.com/rs/zerolog/log" - "github.com/threefoldtech/zos4/pkg/types" + "github.com/threefoldtech/tfgrid4-sdk-go/node-registrar/client" "github.com/threefoldtech/zosbase/pkg/crypto" "github.com/threefoldtech/zosbase/pkg/identity/store" @@ -87,24 +85,17 @@ func (d *identityManager) Farm() (name string, err error) { } env := environment.MustGet() - - url := fmt.Sprintf("%s/v1/farms/%d", env.RegistrarURL, env.FarmID) - resp, err := http.DefaultClient.Get(url) + url, err := url.JoinPath(env.RegistrarURL, "api", "v1") if err != nil { return "", err } - if resp.StatusCode != http.StatusOK { - return "", fmt.Errorf("failed to get farm with status code %s", resp.Status) - } - defer resp.Body.Close() - - var farm types.Farm - err = json.NewDecoder(resp.Body).Decode(&farm) + client, err := client.NewRegistrarClient(url) if err != nil { return "", err } + farm, err := client.GetFarm(uint64(env.FarmID)) d.farm = farm.FarmName return farm.FarmName, err } diff --git a/pkg/power/power.go b/pkg/power/power.go index c76859be..32a67e13 100644 --- a/pkg/power/power.go +++ b/pkg/power/power.go @@ -9,8 +9,8 @@ import ( "github.com/pkg/errors" "github.com/rs/zerolog/log" + "github.com/threefoldtech/tfgrid4-sdk-go/node-registrar/client" "github.com/threefoldtech/zos4/pkg/stubs" - "github.com/threefoldtech/zos4/pkg/types" "github.com/threefoldtech/zosbase/pkg" "github.com/threefoldtech/zosbase/pkg/events" "github.com/threefoldtech/zosbase/pkg/network/bridge" @@ -132,7 +132,7 @@ func (p *PowerServer) syncSelf() error { return nil } -func (p *PowerServer) powerUp(node *types.Node, reason string) error { +func (p *PowerServer) powerUp(node *client.Node, reason string) error { log.Info().Uint64("node", node.NodeID).Str("reason", reason).Msg("powering on node") mac := "" diff --git a/pkg/power/uptime.go b/pkg/power/uptime.go index e94e80b0..c103cb76 100644 --- a/pkg/power/uptime.go +++ b/pkg/power/uptime.go @@ -55,7 +55,7 @@ func (u *Uptime) SendNow() error { return errors.Wrap(err, "failed to get uptime") } - return u.registrarGateway.UpdateNodeUptimeV2(context.Background(), uptime, uint64(time.Now().Unix())) + return u.registrarGateway.UpdateNodeUptimeV2(context.Background(), uptime, time.Now().Unix()) } func (u *Uptime) uptime(ctx context.Context) error { diff --git a/pkg/registrar_gateway.go b/pkg/registrar_gateway.go index 5811f2d8..a22c9e1b 100644 --- a/pkg/registrar_gateway.go +++ b/pkg/registrar_gateway.go @@ -5,32 +5,36 @@ import ( substrateTypes "github.com/centrifuge/go-substrate-rpc-client/v4/types" substrate "github.com/threefoldtech/tfchain/clients/tfchain-client-go" - "github.com/threefoldtech/zos4/pkg/types" + "github.com/threefoldtech/tfgrid4-sdk-go/node-registrar/client" "github.com/threefoldtech/zosbase/pkg" ) //go:generate zbusc -module api-gateway -version 0.0.1 -name api-gateway -package stubs github.com/threefoldtech/zos4/pkg+RegistrarGateway stubs/registrar-gateway.go type RegistrarGateway interface { - CreateNode(node types.UpdateNodeRequest) (uint64, error) - CreateTwin(relay string, pk []byte) (types.Account, error) - EnsureAccount(pk []byte) (twin types.Account, err error) + CreateTwin(relay []string, rmbEncKey string) (client.Account, error) + EnsureAccount(relay []string, rmbEncKey string) (twin client.Account, err error) + GetTwin(id uint64) (client.Account, error) + GetTwinByPubKey(pk []byte) (uint64, error) + + CreateNode(node client.Node) (uint64, error) + GetNode(id uint64) (client.Node, error) + GetNodes(farmID uint64) ([]uint64, error) + GetNodeByTwinID(twin uint64) (client.Node, error) + UpdateNode(node client.Node) error + UpdateNodeUptimeV2(uptime uint64, timestamp int64) (err error) + + GetFarm(id uint64) (client.Farm, error) + + GetTime() (time.Time, error) + GetZosVersion() (client.ZosVersion, error) + + GetNodeContracts(node uint32) ([]substrateTypes.U64, error) GetContract(id uint64) (substrate.Contract, pkg.SubstrateError) GetContractIDByNameRegistration(name string) (uint64, pkg.SubstrateError) GetNodeRentContract(node uint32) (uint64, pkg.SubstrateError) - GetFarm(id uint64) (types.Farm, error) - GetNode(id uint64) (types.Node, error) - GetNodeByTwinID(twin uint64) (uint64, error) - GetNodeContracts(node uint32) ([]substrateTypes.U64, error) - GetNodes(farmID uint32) ([]uint32, error) GetPowerTarget() (power substrate.NodePower, err error) - GetTwin(id uint64) (types.Account, error) - GetTwinByPubKey(pk []byte) (uint64, error) Report(consumptions []substrate.NruConsumption) (substrateTypes.Hash, error) SetContractConsumption(resources ...substrate.ContractResources) error SetNodePowerState(up bool) (hash substrateTypes.Hash, err error) - UpdateNode(node types.UpdateNodeRequest) (uint64, error) - UpdateNodeUptimeV2(uptime uint64, timestampHint uint64) (err error) - GetTime() (time.Time, error) - GetZosVersion() (string, error) } diff --git a/pkg/registrar_gateway/registrar_gateway.go b/pkg/registrar_gateway/registrar_gateway.go index 2d1f6387..08adbbda 100644 --- a/pkg/registrar_gateway/registrar_gateway.go +++ b/pkg/registrar_gateway/registrar_gateway.go @@ -1,16 +1,10 @@ package registrargw import ( - "bytes" "context" "crypto/ed25519" - "encoding/base64" "encoding/hex" - "encoding/json" - "fmt" - "io" - "net/http" - "strings" + "net/url" "sync" "time" @@ -18,10 +12,10 @@ import ( "github.com/pkg/errors" "github.com/rs/zerolog/log" substrate "github.com/threefoldtech/tfchain/clients/tfchain-client-go" + "github.com/threefoldtech/tfgrid4-sdk-go/node-registrar/client" "github.com/threefoldtech/zbus" zos4Pkg "github.com/threefoldtech/zos4/pkg" "github.com/threefoldtech/zos4/pkg/stubs" - "github.com/threefoldtech/zos4/pkg/types" "github.com/threefoldtech/zosbase/pkg" "github.com/threefoldtech/zosbase/pkg/environment" ) @@ -29,89 +23,183 @@ import ( const AuthHeader = "X-Auth" type registrarGateway struct { - mu sync.Mutex - baseURL string - httpClient *http.Client - privKey ed25519.PrivateKey - nodeID uint64 - twinID uint64 + mu sync.Mutex + registrarClient client.RegistrarClient } -var ErrorRecordNotFound = errors.New("could not find the reqested record") +func NewRegistrarGateway(ctx context.Context, cl zbus.Client) (zos4Pkg.RegistrarGateway, error) { + identity := stubs.NewIdentityManagerStub(cl) + sk := ed25519.PrivateKey(identity.PrivateKey(ctx)) + hexSeed := hex.EncodeToString(sk.Seed()) -func NewRegistrarGateway(cl zbus.Client) (zos4Pkg.RegistrarGateway, error) { - client := http.DefaultClient env := environment.MustGet() + url, err := url.JoinPath(env.RegistrarURL, "api", "v1") + if err != nil { + return ®istrarGateway{}, err + } - identity := stubs.NewIdentityManagerStub(cl) - sk := ed25519.PrivateKey(identity.PrivateKey(context.TODO())) + cli, err := client.NewRegistrarClient(url, hexSeed) + if err != nil { + return ®istrarGateway{}, errors.Wrap(err, "failed to create new registrar client") + } gw := ®istrarGateway{ - httpClient: client, - baseURL: env.RegistrarURL, - mu: sync.Mutex{}, - privKey: sk, + mu: sync.Mutex{}, + registrarClient: cli, } - pk := sk.Public().(ed25519.PublicKey) - twin, err := gw.GetTwinByPubKey(pk) - if err == nil { - gw.twinID = twin + return gw, nil +} - node, err := gw.GetNodeByTwinID(twin) - if err == nil { - gw.nodeID = node - } - } +func (r *registrarGateway) GetZosVersion() (client.ZosVersion, error) { + log.Debug().Str("method", "GetZosVersion").Msg("method called") - return gw, nil + return r.registrarClient.GetZosVersion() } -func (r *registrarGateway) GetZosVersion() (string, error) { - url := fmt.Sprintf("%s/v1/zos/version", r.baseURL) - log.Debug().Str("url", url).Msg("requesting zos version") +func (r *registrarGateway) CreateNode(node client.Node) (uint64, error) { + log.Debug(). + Str("method", "CreateNode"). + Uint32("farm_id", uint32(node.FarmID)). + Uint32("twin_id", uint32(node.TwinID)). + Msg("method called") - return r.getZosVersion(url) + r.mu.Lock() + defer r.mu.Unlock() + + return r.registrarClient.RegisterNode(node) } -func (r *registrarGateway) CreateNode(node types.UpdateNodeRequest) (uint64, error) { - url := fmt.Sprintf("%s/v1/nodes", r.baseURL) +func (r *registrarGateway) CreateTwin(relays []string, rmbEncKey string) (client.Account, error) { log.Debug(). - Str("url", url). - Uint32("farm id", uint32(node.FarmID)). - Msg("creating node") + Str("method", "CreateTwin"). + Strs("relay", relays). + Str("rmbEncKey", rmbEncKey). + Msg("method called") r.mu.Lock() defer r.mu.Unlock() - return r.createNode(url, node) + account, _, err := r.registrarClient.CreateAccount(relays, rmbEncKey) + return account, err } -func (r *registrarGateway) CreateTwin(relay string, pk []byte) (types.Account, error) { - url := fmt.Sprintf("%s/v1/accounts", r.baseURL) - log.Debug().Str("url", url).Str("relay", relay).Str("pk", hex.EncodeToString(pk)).Msg("creating account") +func (r *registrarGateway) EnsureAccount(relays []string, rmbEncKey string) (client.Account, error) { + log.Debug(). + Str("method", "EnsureAccount"). + Strs("relay", relays). + Str("rmbEncKey", rmbEncKey). + Msg("method called") r.mu.Lock() defer r.mu.Unlock() - twin, err := r.createTwin(url, []string{relay}, pk) - if err != nil { - return types.Account{}, err + return r.registrarClient.EnsureAccount(relays, rmbEncKey) +} + +func (r *registrarGateway) GetFarm(id uint64) (client.Farm, error) { + log.Debug(). + Str("method", "GetFarm"). + Uint64("farm_id", id). + Msg("method called") + + return r.registrarClient.GetFarm(id) +} + +func (r *registrarGateway) GetNode(id uint64) (client.Node, error) { + log.Debug(). + Str("method", "GetNode"). + Uint64("node_id", id). + Msg("method called") + + return r.registrarClient.GetNode(id) +} + +func (r *registrarGateway) GetNodeByTwinID(twinID uint64) (client.Node, error) { + log.Debug(). + Str("method", "GetNodeByTwinID"). + Uint64("twin_id", twinID). + Msg("method called") + + return r.registrarClient.GetNodeByTwinID(twinID) +} + +func (r *registrarGateway) GetNodes(farmID uint64) (nodeIDs []uint64, err error) { + log.Debug(). + Str("method", "GetNodes"). + Uint64("farm_id", farmID). + Msg("method called") + + nodes, err := r.registrarClient.ListNodes(client.ListNodesWithFarmID(farmID)) + for _, node := range nodes { + nodeIDs = append(nodeIDs, node.NodeID) } - return twin, nil + return +} + +func (r *registrarGateway) GetTwin(id uint64) (result client.Account, err error) { + log.Debug(). + Str("method", "GetTwin"). + Uint64("twin_id", id). + Msg("method called") + + return r.registrarClient.GetAccount(id) } -func (r *registrarGateway) EnsureAccount(pk []byte) (twin types.Account, err error) { - url := fmt.Sprintf("%s/v1/accounts", r.baseURL) +func (r *registrarGateway) GetTwinByPubKey(pk []byte) (result uint64, err error) { + log.Debug(). + Str("method", "GetTwinByPubKey"). + Str("pk", hex.EncodeToString(pk)). + Msg("method called") + + account, err := r.registrarClient.GetAccountByPK(pk) + return account.TwinID, err +} - publicKeyBase64 := base64.StdEncoding.EncodeToString(pk) - log.Debug().Str("url", url).Bytes("public_key", []byte(publicKeyBase64)).Msg("ensure account") +func (r *registrarGateway) UpdateNode(node client.Node) error { + log.Debug(). + Str("method", "UpdateNode"). + Uint64("twin_id", node.TwinID). + Msg("method called") r.mu.Lock() defer r.mu.Unlock() + opts := []client.UpdateNodeOpts{ + client.UpdateNodesWithFarmID(node.FarmID), + client.UpdateNodesWithLocation(node.Location), + client.UpdateNodesWithResources(node.Resources), + client.UpdateNodesWithInterfaces(node.Interfaces), + client.UpdateNodesWithSerialNumber(node.SerialNumber), + } + + if node.SecureBoot { + opts = append(opts, client.UpdateNodesWithSecureBoot()) + } + if node.Virtualized { + opts = append(opts, client.UpdateNodesWithVirtualized()) + } + + return r.registrarClient.UpdateNode(opts...) +} + +func (r *registrarGateway) UpdateNodeUptimeV2(uptime uint64, timestamp int64) (err error) { + log.Debug(). + Str("method", "UpdateNodeUptimeV2"). + Uint64("uptime", uptime). + Msg("method called") + + r.mu.Lock() + defer r.mu.Unlock() + + return r.registrarClient.ReportUptime(client.UptimeReport{Uptime: uptime, Timestamp: timestamp}) +} - return r.ensureAccount(url, pk) +func (r *registrarGateway) GetTime() (time.Time, error) { + // log.Trace().Str("method", "Time").Msg("method called") + // + // return g.sub.Time() + return time.Now(), nil } func (r *registrarGateway) GetContract(id uint64) (result substrate.Contract, serr pkg.SubstrateError) { @@ -133,27 +221,6 @@ func (r *registrarGateway) GetContractIDByNameRegistration(name string) (result return } -func (r *registrarGateway) GetFarm(id uint64) (farm types.Farm, err error) { - url := fmt.Sprintf("%s/v1/farms/%d", r.baseURL, id) - log.Debug().Str("url", url).Uint64("id", id).Msg("get farm") - - return r.getFarm(url) -} - -func (r *registrarGateway) GetNode(id uint64) (node types.Node, err error) { - url := fmt.Sprintf("%s/v1/nodes/%d", r.baseURL, id) - log.Trace().Str("url", url).Uint64("id", id).Msg("get node") - - return r.getNode(url) -} - -func (r *registrarGateway) GetNodeByTwinID(twin uint64) (result uint64, err error) { - url := fmt.Sprintf("%s/v1/nodes", r.baseURL) - log.Trace().Str("url", url).Uint64("twin", twin).Msg("get node by twin_id") - - return r.getNodeByTwinID(url, twin) -} - func (r *registrarGateway) GetNodeContracts(node uint32) ([]subTypes.U64, error) { // log.Trace().Str("method", "GetNodeContracts").Uint32("node", node).Msg("method called") // return g.sub.GetNodeContracts(node) @@ -168,13 +235,6 @@ func (r *registrarGateway) GetNodeRentContract(node uint32) (result uint64, serr return } -func (r *registrarGateway) GetNodes(farmID uint32) (nodeIDs []uint32, err error) { - log.Trace().Str("method", "GetNodes").Uint32("farm id", farmID).Msg("method called") - - url := fmt.Sprintf("%s/v1/nodes", r.baseURL) - return r.getNodesInFarm(url, farmID) -} - func (r *registrarGateway) GetPowerTarget() (power substrate.NodePower, err error) { // log.Trace().Str("method", "GetPowerTarget").Uint32("node id", uint32(g.nodeID)).Msg("method called") // return g.sub.GetPowerTarget(uint32(g.nodeID)) @@ -186,20 +246,6 @@ func (r *registrarGateway) GetPowerTarget() (power substrate.NodePower, err erro return } -func (r *registrarGateway) GetTwin(id uint64) (result types.Account, err error) { - url := fmt.Sprintf("%s/v1/accounts/", r.baseURL) - log.Trace().Str("url", "url").Uint64("id", id).Msg("get account") - - return r.getTwin(url, id) -} - -func (r *registrarGateway) GetTwinByPubKey(pk []byte) (result uint64, err error) { - url := fmt.Sprintf("%s/v1/accounts/", r.baseURL) - log.Trace().Str("method", "GetTwinByPubKey").Str("pk", hex.EncodeToString(pk)).Msg("method called") - - return r.getTwinByPubKey(url, pk) -} - func (r *registrarGateway) Report(consumptions []substrate.NruConsumption) (subTypes.Hash, error) { // contractIDs := make([]uint64, 0, len(consumptions)) // for _, v := range consumptions { @@ -242,490 +288,3 @@ func (r *registrarGateway) SetNodePowerState(up bool) (hash subTypes.Hash, err e // return g.sub.SetNodePowerState(g.identity, up) return subTypes.Hash{}, nil } - -func (r *registrarGateway) UpdateNode(node types.UpdateNodeRequest) (uint64, error) { - url := fmt.Sprintf("%s/v1/nodes/%d", r.baseURL, r.nodeID) - log.Debug().Str("url", url).Msg("upate node") - r.mu.Lock() - defer r.mu.Unlock() - - return r.updateNode(url, node) -} - -func (r *registrarGateway) UpdateNodeUptimeV2(uptime uint64, timestampHint uint64) (err error) { - url := fmt.Sprintf("%s/v1/nodes/%d/uptime", r.baseURL, r.nodeID) - log.Debug(). - Str("url", url). - Uint64("uptime", uptime). - Uint64("timestamp hint", timestampHint). - Msg("sending uptime report") - r.mu.Lock() - defer r.mu.Unlock() - - return r.updateNodeUptimeV2(r.twinID, url, uptime) -} - -func (r *registrarGateway) GetTime() (time.Time, error) { - // log.Trace().Str("method", "Time").Msg("method called") - // - // return g.sub.Time() - return time.Now(), nil -} - -func buildSubstrateError(err error) (serr pkg.SubstrateError) { - if err == nil { - return - } - - serr.Err = err - serr.Code = pkg.CodeGenericError - - if errors.Is(err, substrate.ErrNotFound) { - serr.Code = pkg.CodeNotFound - } else if errors.Is(err, substrate.ErrBurnTransactionNotFound) { - serr.Code = pkg.CodeBurnTransactionNotFound - } else if errors.Is(err, substrate.ErrRefundTransactionNotFound) { - serr.Code = pkg.CodeRefundTransactionNotFound - } else if errors.Is(err, substrate.ErrFailedToDecode) { - serr.Code = pkg.CodeFailedToDecode - } else if errors.Is(err, substrate.ErrInvalidVersion) { - serr.Code = pkg.CodeInvalidVersion - } else if errors.Is(err, substrate.ErrUnknownVersion) { - serr.Code = pkg.CodeUnknownVersion - } else if errors.Is(err, substrate.ErrIsUsurped) { - serr.Code = pkg.CodeIsUsurped - } else if errors.Is(err, substrate.ErrAccountNotFound) { - serr.Code = pkg.CodeAccountNotFound - } else if errors.Is(err, substrate.ErrDepositFeeNotFound) { - serr.Code = pkg.CodeDepositFeeNotFound - } else if errors.Is(err, substrate.ErrMintTransactionNotFound) { - serr.Code = pkg.CodeMintTransactionNotFound - } - return -} - -func (r *registrarGateway) createTwin(url string, relayURL []string, pk []byte) (twin types.Account, err error) { - publicKeyBase64 := base64.StdEncoding.EncodeToString(pk) - timestamp := time.Now().Unix() - signature := getNodeSignature(publicKeyBase64, r.privKey, timestamp) - - account := types.AccountCreationRequest{ - PublicKey: publicKeyBase64, - Signature: signature, - Timestamp: timestamp, - - RMBEncKey: "", - Relays: relayURL, - } - - var body bytes.Buffer - err = json.NewEncoder(&body).Encode(account) - if err != nil { - return - } - - resp, err := r.httpClient.Post(url, "application/json", &body) - if err != nil { - return - } - - if resp.StatusCode != http.StatusCreated { - err = parseRespError(resp.Body) - return twin, errors.Wrapf(err, "failed to create twin with status %s", resp.Status) - } - defer resp.Body.Close() - - err = json.NewDecoder(resp.Body).Decode(&twin) - - r.twinID = twin.TwinID - return twin, err -} - -func (r *registrarGateway) ensureAccount(relay string, pk []byte) (twin types.Account, err error) { - url := fmt.Sprintf("%s/v1/accounts/", r.baseURL) - twinID, err := r.getTwinByPubKey(url, pk) - if err != nil { - if !errors.Is(err, ErrorRecordNotFound) { - return types.Account{}, errors.Wrap(err, "failed to get twin by public key") - } - - twin, err := r.createTwin(url, []string{relay}, pk) - if err != nil { - return types.Account{}, errors.Wrap(err, "failed to create twin") - } - return twin, nil - } - - return r.getTwin(url, twinID) -} - -func (r *registrarGateway) getTwin(url string, twinID uint64) (result types.Account, err error) { - req, err := http.NewRequest("GET", url, nil) - if err != nil { - return - } - - q := req.URL.Query() - q.Add("twin_id", fmt.Sprint(twinID)) - req.URL.RawQuery = q.Encode() - - resp, err := r.httpClient.Do(req) - if err != nil { - return - } - - if resp == nil { - return result, errors.New("no response received") - } - - if resp.StatusCode == http.StatusNotFound { - return result, ErrorRecordNotFound - } - - if resp.StatusCode != http.StatusOK { - err = parseRespError(resp.Body) - return result, errors.Wrapf(err, "failed to get account by twin id with status code %s", resp.Status) - } - - defer resp.Body.Close() - - err = json.NewDecoder(resp.Body).Decode(&result) - - return result, err -} - -func (r *registrarGateway) getTwinByPubKey(url string, pk []byte) (result uint64, err error) { - publicKeyBase64 := base64.StdEncoding.EncodeToString(pk) - - req, err := http.NewRequest("GET", url, nil) - if err != nil { - return result, err - } - - q := req.URL.Query() - q.Add("public_key", publicKeyBase64) - req.URL.RawQuery = q.Encode() - - resp, err := r.httpClient.Do(req) - if err != nil { - return result, err - } - - if resp == nil { - return result, errors.New("no response received") - } - defer resp.Body.Close() - - if resp.StatusCode == http.StatusNotFound { - return result, ErrorRecordNotFound - } - - if resp.StatusCode != http.StatusOK { - err = parseRespError(resp.Body) - return result, errors.Wrapf(err, "failed to get account by public_key with status code %s", resp.Status) - } - - var account types.Account - err = json.NewDecoder(resp.Body).Decode(&account) - - if r.twinID == 0 { - r.twinID = account.TwinID - } - return account.TwinID, err -} - -func (r *registrarGateway) getZosVersion(url string) (string, error) { - resp, err := r.httpClient.Get(url) - if err != nil { - return "", err - } - - if resp.StatusCode != http.StatusOK { - err = parseRespError(resp.Body) - return "", errors.Wrapf(err, "failed to get zos version with status code %s", resp.Status) - } - - defer resp.Body.Close() - - var versionString string - err = json.NewDecoder(resp.Body).Decode(&versionString) - if err != nil { - return "", err - } - - versionBytes, err := base64.StdEncoding.DecodeString(versionString) - if err != nil { - return "", err - } - - correctedJSON := strings.ReplaceAll(string(versionBytes), "'", "\"") - - var version types.ZosVersion - err = json.NewDecoder(strings.NewReader(correctedJSON)).Decode(&version) - if err != nil { - return "", err - } - - return version.Version, err -} - -func (r *registrarGateway) createNode(url string, node types.UpdateNodeRequest) (nodeID uint64, err error) { - var body bytes.Buffer - err = json.NewEncoder(&body).Encode(node) - if err != nil { - return - } - - req, err := http.NewRequest("POST", url, &body) - if err != nil { - return - } - - r.authRequest(req, r.twinID) - - resp, err := r.httpClient.Do(req) - if err != nil { - return 0, err - } - - if resp == nil || resp.StatusCode != http.StatusCreated { - err = parseRespError(resp.Body) - return 0, errors.Wrapf(err, "failed to update node on the registrar with status code %s", resp.Status) - } - - defer resp.Body.Close() - - result := struct { - NodeID uint64 `json:"node_id"` - }{} - err = json.NewDecoder(resp.Body).Decode(&result) - - r.nodeID = result.NodeID - return result.NodeID, err -} - -func (r *registrarGateway) getFarm(url string) (farm types.Farm, err error) { - resp, err := r.httpClient.Get(url) - if err != nil { - return farm, err - } - - if resp.StatusCode == http.StatusNotFound { - return farm, ErrorRecordNotFound - } - - if resp.StatusCode != http.StatusOK { - err = parseRespError(resp.Body) - return farm, errors.Wrapf(err, "failed to get farm with status code %s", resp.Status) - } - defer resp.Body.Close() - - err = json.NewDecoder(resp.Body).Decode(&farm) - if err != nil { - return farm, err - } - - return farm, err -} - -func (r *registrarGateway) getNode(url string) (node types.Node, err error) { - resp, err := r.httpClient.Get(url) - if err != nil { - return - } - - if resp.StatusCode == http.StatusNotFound { - return node, ErrorRecordNotFound - } - - if resp.StatusCode != http.StatusOK { - err = parseRespError(resp.Body) - return node, errors.Wrapf(err, "failed to get node with status code %s", resp.Status) - } - - defer resp.Body.Close() - - err = json.NewDecoder(resp.Body).Decode(&node) - if err != nil { - return - } - - if r.nodeID == 0 { - r.nodeID = node.NodeID - } - return node, err -} - -func (r *registrarGateway) getNodeByTwinID(url string, twin uint64) (result uint64, err error) { - req, err := http.NewRequest("GET", url, nil) - if err != nil { - return - } - - q := req.URL.Query() - q.Add("twin_id", fmt.Sprint(twin)) - req.URL.RawQuery = q.Encode() - - resp, err := r.httpClient.Do(req) - if err != nil { - return - } - - if resp == nil { - return result, errors.New("no response received") - } - - if resp.StatusCode == http.StatusNotFound { - return result, ErrorRecordNotFound - } - - if resp.StatusCode != http.StatusOK { - err = parseRespError(resp.Body) - return result, errors.Wrapf(err, "failed to get node by twin id with status code %s", resp.Status) - } - - defer resp.Body.Close() - - var nodes []types.Node - err = json.NewDecoder(resp.Body).Decode(&nodes) - if err != nil { - return - } - if len(nodes) == 0 { - return result, ErrorRecordNotFound - } - - if r.nodeID == 0 { - r.nodeID = nodes[0].NodeID - } - return nodes[0].NodeID, nil -} - -func (r *registrarGateway) getNodesInFarm(url string, farmID uint32) (nodeIDs []uint32, err error) { - req, err := http.NewRequest("GET", url, nil) - if err != nil { - return - } - - q := req.URL.Query() - q.Add("farm_id", fmt.Sprint(farmID)) - req.URL.RawQuery = q.Encode() - - resp, err := r.httpClient.Do(req) - if err != nil { - return - } - - if resp == nil || resp.StatusCode != http.StatusOK { - err = parseRespError(resp.Body) - return nodeIDs, errors.Wrapf(err, "failed to get nodes in farm %d with status code %s", farmID, resp.Status) - } - - defer resp.Body.Close() - - var nodes []types.Node - err = json.NewDecoder(resp.Body).Decode(&nodes) - if err != nil { - return - } - - for _, node := range nodes { - nodeIDs = append(nodeIDs, uint32(node.NodeID)) - } - - return nodeIDs, nil -} - -func (r *registrarGateway) updateNode(url string, node types.UpdateNodeRequest) (uint64, error) { - var body bytes.Buffer - err := json.NewEncoder(&body).Encode(node) - if err != nil { - return 0, err - } - - req, err := http.NewRequest("PATCH", url, &body) - if err != nil { - return 0, err - } - - r.authRequest(req, r.twinID) - log.Info().Any("request", req.Body).Msg("request body is ") - - resp, err := r.httpClient.Do(req) - if err != nil { - return 0, err - } - - if resp == nil || resp.StatusCode != http.StatusOK { - err = parseRespError(resp.Body) - return 0, errors.Wrapf(err, "failed to update node with twin id %d with status code %s", r.twinID, resp.Status) - } - defer resp.Body.Close() - - res, err := r.getNode(url) - return res.NodeID, err -} - -func (r *registrarGateway) updateNodeUptimeV2(twinID uint64, url string, uptime uint64) (err error) { - report := types.UptimeReportRequest{Uptime: time.Duration(uptime), Timestamp: time.Now()} - - var body bytes.Buffer - err = json.NewEncoder(&body).Encode(report) - if err != nil { - return err - } - - req, err := http.NewRequest("POST", url, &body) - if err != nil { - return err - } - - r.authRequest(req, twinID) - - resp, err := r.httpClient.Do(req) - if err != nil { - return err - } - - if resp == nil || resp.StatusCode != http.StatusCreated { - err = parseRespError(resp.Body) - return errors.Wrap(err, "failed to send node up time report") - } - - return -} - -func getNodeSignature(pubKey string, privKey []byte, timestamp int64) (signatureBase64 string) { - // Create challenge - challenge := []byte(fmt.Sprintf("%d:%s", timestamp, pubKey)) - - signature := ed25519.Sign(privKey, challenge) - signatureBase64 = base64.StdEncoding.EncodeToString(signature) - return -} - -func (r *registrarGateway) authRequest(req *http.Request, twinID uint64) { - // Create authentication challenge - timestamp := time.Now().Unix() - challenge := []byte(fmt.Sprintf("%d:%v", timestamp, twinID)) - signature := ed25519.Sign(r.privKey, challenge) - authHeader := fmt.Sprintf( - "%s:%s", - base64.StdEncoding.EncodeToString(challenge), - base64.StdEncoding.EncodeToString(signature), - ) - - req.Header.Set("X-Auth", authHeader) - req.Header.Set("Content-Type", "application/json") -} - -func parseRespError(body io.ReadCloser) error { - errResp := struct { - Error string - }{} - err := json.NewDecoder(body).Decode(&errResp) - if err != nil { - return err - } - return errors.New(errResp.Error) -} diff --git a/pkg/registrar_light/register.go b/pkg/registrar_light/register.go index ebb3ae64..64aad110 100644 --- a/pkg/registrar_light/register.go +++ b/pkg/registrar_light/register.go @@ -2,7 +2,6 @@ package registrar import ( "context" - "crypto/ed25519" "fmt" "reflect" "strings" @@ -10,10 +9,9 @@ import ( "github.com/pkg/errors" "github.com/rs/zerolog/log" + "github.com/threefoldtech/tfgrid4-sdk-go/node-registrar/client" "github.com/threefoldtech/zbus" - registrargw "github.com/threefoldtech/zos4/pkg/registrar_gateway" zos4Stubs "github.com/threefoldtech/zos4/pkg/stubs" - "github.com/threefoldtech/zos4/pkg/types" "github.com/threefoldtech/zosbase/pkg/environment" "github.com/threefoldtech/zosbase/pkg/geoip" gridtypes "github.com/threefoldtech/zosbase/pkg/gridtypes" @@ -111,26 +109,26 @@ func registerNode( return 0, 0, errors.Wrap(err, "failed to get zos bridge information") } - interfaces := types.Interface{ + interfaces := []client.Interface{{ Name: infs.Interfaces["zos"].Name, Mac: infs.Interfaces["zos"].Mac, - IPs: func() string { + IPs: func() []string { ips := make([]string, 0) for _, ip := range infs.Interfaces["zos"].IPs { ips = append(ips, ip.IP.String()) } - return strings.Join(ips, "/") + return ips }(), - } + }} - resources := types.Resources{ + resources := client.Resources{ HRU: uint64(info.Capacity.HRU), SRU: uint64(info.Capacity.SRU), CRU: info.Capacity.CRU, MRU: uint64(info.Capacity.MRU), } - location := types.Location{ + location := client.Location{ Longitude: fmt.Sprint(info.Location.Longitude), Latitude: fmt.Sprint(info.Location.Latitude), Country: info.Location.Country, @@ -139,10 +137,7 @@ func registerNode( log.Info().Str("id", mgr.NodeID(ctx).Identity()).Msg("start registration of the node on zos4 registrar") - sk := ed25519.PrivateKey(mgr.PrivateKey(ctx)) - pubKey := sk.Public().(ed25519.PublicKey) - - account, err := registrarGateway.EnsureAccount(ctx, pubKey) + account, err := registrarGateway.EnsureAccount(ctx, env.RelayURL, "") if err != nil { log.Info().Msg("failed to EnsureAccount") return 0, 0, errors.Wrap(err, "failed to ensure account") @@ -151,34 +146,24 @@ func registerNode( serial := info.SerialNumber - real := types.Node{ + real := client.Node{ FarmID: uint64(env.FarmID), TwinID: twinID, Resources: resources, Location: location, - Interfaces: []types.Interface{interfaces}, + Interfaces: interfaces, SecureBoot: info.SecureBoot, Virtualized: info.Virtualized, SerialNumber: serial, } - req := types.UpdateNodeRequest{ - TwinID: real.TwinID, - FarmID: real.FarmID, - Resources: real.Resources, - Location: real.Location, - Interfaces: real.Interfaces, - SecureBoot: real.SecureBoot, - Virtualized: real.Virtualized, - SerialNumber: real.SerialNumber, - } - - nodeID, regErr := registrarGateway.GetNodeByTwinID(ctx, twinID) + node, regErr := registrarGateway.GetNodeByTwinID(ctx, twinID) + nodeID = node.NodeID if regErr != nil { - if strings.Contains(regErr.Error(), registrargw.ErrorRecordNotFound.Error()) { - nodeID, err = registrarGateway.CreateNode(ctx, req) + if strings.Contains(regErr.Error(), client.ErrorNodeNotFound.Error()) { + nodeID, err = registrarGateway.CreateNode(ctx, real) if err != nil { - return 0, 0, errors.Wrap(err, "failed to create node on chain") + return 0, 0, errors.Wrap(err, "failed to create node on registrar") } } else { return 0, 0, errors.Wrapf(regErr, "failed to get node information for twin id: %d", twinID) @@ -186,14 +171,14 @@ func registerNode( } // node exists - var onChain types.Node - onChain, err = registrarGateway.GetNode(ctx, nodeID) + var onRegistrar client.Node + onRegistrar, err = registrarGateway.GetNode(ctx, nodeID) if err != nil { return 0, 0, errors.Wrapf(err, "failed to get node with id: %d", nodeID) } - // ignore virt-what value if the node is marked as real on the chain - if !onChain.Virtualized { + // ignore virt-what value if the node is marked as real on the registrar + if !onRegistrar.Virtualized { real.Virtualized = false } @@ -203,9 +188,9 @@ func registerNode( // otherwise we update the node log.Debug().Uint64("node", nodeID).Msg("node already found on registrar") - if !reflect.DeepEqual(real, onChain) { - log.Debug().Msgf("node data have changed, issuing an update node real: %+v\nonchain: %+v", real, onChain) - _, err := registrarGateway.UpdateNode(ctx, req) + if !reflect.DeepEqual(real, onRegistrar) { + log.Debug().Msgf("node data have changed, issuing an update node real: %+v\nonRegistrar: %+v", real, onRegistrar) + err := registrarGateway.UpdateNode(ctx, real) if err != nil { return 0, 0, errors.Wrapf(err, "failed to update node data with id: %d", nodeID) } diff --git a/pkg/registrar_light/registrar.go b/pkg/registrar_light/registrar.go index e2d095c5..7545c4cd 100644 --- a/pkg/registrar_light/registrar.go +++ b/pkg/registrar_light/registrar.go @@ -2,7 +2,6 @@ package registrar import ( "context" - "crypto/ed25519" "os" "sync" "time" @@ -160,13 +159,9 @@ func (r *Registrar) register(ctx context.Context, cl zbus.Client, env environmen } func (r *Registrar) reActivate(ctx context.Context, cl zbus.Client) error { + env := environment.MustGet() registrarGateway := zos4stubs.NewRegistrarGatewayStub(cl) - identityManager := zos4stubs.NewIdentityManagerStub(cl) - - sk := ed25519.PrivateKey(identityManager.PrivateKey(ctx)) - pubKey := sk.Public().(ed25519.PublicKey) - - _, err := registrarGateway.EnsureAccount(ctx, pubKey) + _, err := registrarGateway.EnsureAccount(ctx, env.RelayURL, "") return err } diff --git a/pkg/stubs/registrar-gateway.go b/pkg/stubs/registrar-gateway.go index ce924e65..b9a9d48e 100644 --- a/pkg/stubs/registrar-gateway.go +++ b/pkg/stubs/registrar-gateway.go @@ -6,13 +6,12 @@ package stubs import ( "context" - "time" - - types1 "github.com/centrifuge/go-substrate-rpc-client/v4/types" + types "github.com/centrifuge/go-substrate-rpc-client/v4/types" tfchainclientgo "github.com/threefoldtech/tfchain/clients/tfchain-client-go" + client "github.com/threefoldtech/tfgrid4-sdk-go/node-registrar/client" zbus "github.com/threefoldtech/zbus" - types "github.com/threefoldtech/zos4/pkg/types" pkg "github.com/threefoldtech/zosbase/pkg" + "time" ) type RegistrarGatewayStub struct { @@ -32,7 +31,7 @@ func NewRegistrarGatewayStub(client zbus.Client) *RegistrarGatewayStub { } } -func (s *RegistrarGatewayStub) CreateNode(ctx context.Context, arg0 types.UpdateNodeRequest) (ret0 uint64, ret1 error) { +func (s *RegistrarGatewayStub) CreateNode(ctx context.Context, arg0 client.Node) (ret0 uint64, ret1 error) { args := []interface{}{arg0} result, err := s.client.RequestContext(ctx, s.module, s.object, "CreateNode", args...) if err != nil { @@ -49,7 +48,7 @@ func (s *RegistrarGatewayStub) CreateNode(ctx context.Context, arg0 types.Update return } -func (s *RegistrarGatewayStub) CreateTwin(ctx context.Context, arg0 string, arg1 []uint8) (ret0 types.Account, ret1 error) { +func (s *RegistrarGatewayStub) CreateTwin(ctx context.Context, arg0 []string, arg1 string) (ret0 client.Account, ret1 error) { args := []interface{}{arg0, arg1} result, err := s.client.RequestContext(ctx, s.module, s.object, "CreateTwin", args...) if err != nil { @@ -66,8 +65,8 @@ func (s *RegistrarGatewayStub) CreateTwin(ctx context.Context, arg0 string, arg1 return } -func (s *RegistrarGatewayStub) EnsureAccount(ctx context.Context, arg0 []uint8) (ret0 types.Account, ret1 error) { - args := []interface{}{arg0} +func (s *RegistrarGatewayStub) EnsureAccount(ctx context.Context, arg0 []string, arg1 string) (ret0 client.Account, ret1 error) { + args := []interface{}{arg0, arg1} result, err := s.client.RequestContext(ctx, s.module, s.object, "EnsureAccount", args...) if err != nil { panic(err) @@ -117,7 +116,7 @@ func (s *RegistrarGatewayStub) GetContractIDByNameRegistration(ctx context.Conte return } -func (s *RegistrarGatewayStub) GetFarm(ctx context.Context, arg0 uint64) (ret0 types.Farm, ret1 error) { +func (s *RegistrarGatewayStub) GetFarm(ctx context.Context, arg0 uint64) (ret0 client.Farm, ret1 error) { args := []interface{}{arg0} result, err := s.client.RequestContext(ctx, s.module, s.object, "GetFarm", args...) if err != nil { @@ -134,7 +133,7 @@ func (s *RegistrarGatewayStub) GetFarm(ctx context.Context, arg0 uint64) (ret0 t return } -func (s *RegistrarGatewayStub) GetNode(ctx context.Context, arg0 uint64) (ret0 types.Node, ret1 error) { +func (s *RegistrarGatewayStub) GetNode(ctx context.Context, arg0 uint64) (ret0 client.Node, ret1 error) { args := []interface{}{arg0} result, err := s.client.RequestContext(ctx, s.module, s.object, "GetNode", args...) if err != nil { @@ -151,7 +150,7 @@ func (s *RegistrarGatewayStub) GetNode(ctx context.Context, arg0 uint64) (ret0 t return } -func (s *RegistrarGatewayStub) GetNodeByTwinID(ctx context.Context, arg0 uint64) (ret0 uint64, ret1 error) { +func (s *RegistrarGatewayStub) GetNodeByTwinID(ctx context.Context, arg0 uint64) (ret0 client.Node, ret1 error) { args := []interface{}{arg0} result, err := s.client.RequestContext(ctx, s.module, s.object, "GetNodeByTwinID", args...) if err != nil { @@ -168,7 +167,7 @@ func (s *RegistrarGatewayStub) GetNodeByTwinID(ctx context.Context, arg0 uint64) return } -func (s *RegistrarGatewayStub) GetNodeContracts(ctx context.Context, arg0 uint32) (ret0 []types1.U64, ret1 error) { +func (s *RegistrarGatewayStub) GetNodeContracts(ctx context.Context, arg0 uint32) (ret0 []types.U64, ret1 error) { args := []interface{}{arg0} result, err := s.client.RequestContext(ctx, s.module, s.object, "GetNodeContracts", args...) if err != nil { @@ -202,7 +201,7 @@ func (s *RegistrarGatewayStub) GetNodeRentContract(ctx context.Context, arg0 uin return } -func (s *RegistrarGatewayStub) GetNodes(ctx context.Context, arg0 uint32) (ret0 []uint32, ret1 error) { +func (s *RegistrarGatewayStub) GetNodes(ctx context.Context, arg0 uint64) (ret0 []uint64, ret1 error) { args := []interface{}{arg0} result, err := s.client.RequestContext(ctx, s.module, s.object, "GetNodes", args...) if err != nil { @@ -253,7 +252,7 @@ func (s *RegistrarGatewayStub) GetTime(ctx context.Context) (ret0 time.Time, ret return } -func (s *RegistrarGatewayStub) GetTwin(ctx context.Context, arg0 uint64) (ret0 types.Account, ret1 error) { +func (s *RegistrarGatewayStub) GetTwin(ctx context.Context, arg0 uint64) (ret0 client.Account, ret1 error) { args := []interface{}{arg0} result, err := s.client.RequestContext(ctx, s.module, s.object, "GetTwin", args...) if err != nil { @@ -287,7 +286,7 @@ func (s *RegistrarGatewayStub) GetTwinByPubKey(ctx context.Context, arg0 []uint8 return } -func (s *RegistrarGatewayStub) GetZosVersion(ctx context.Context) (ret0 string, ret1 error) { +func (s *RegistrarGatewayStub) GetZosVersion(ctx context.Context) (ret0 client.ZosVersion, ret1 error) { args := []interface{}{} result, err := s.client.RequestContext(ctx, s.module, s.object, "GetZosVersion", args...) if err != nil { @@ -304,7 +303,7 @@ func (s *RegistrarGatewayStub) GetZosVersion(ctx context.Context) (ret0 string, return } -func (s *RegistrarGatewayStub) Report(ctx context.Context, arg0 []tfchainclientgo.NruConsumption) (ret0 types1.Hash, ret1 error) { +func (s *RegistrarGatewayStub) Report(ctx context.Context, arg0 []tfchainclientgo.NruConsumption) (ret0 types.Hash, ret1 error) { args := []interface{}{arg0} result, err := s.client.RequestContext(ctx, s.module, s.object, "Report", args...) if err != nil { @@ -339,7 +338,7 @@ func (s *RegistrarGatewayStub) SetContractConsumption(ctx context.Context, arg0 return } -func (s *RegistrarGatewayStub) SetNodePowerState(ctx context.Context, arg0 bool) (ret0 types1.Hash, ret1 error) { +func (s *RegistrarGatewayStub) SetNodePowerState(ctx context.Context, arg0 bool) (ret0 types.Hash, ret1 error) { args := []interface{}{arg0} result, err := s.client.RequestContext(ctx, s.module, s.object, "SetNodePowerState", args...) if err != nil { @@ -356,24 +355,22 @@ func (s *RegistrarGatewayStub) SetNodePowerState(ctx context.Context, arg0 bool) return } -func (s *RegistrarGatewayStub) UpdateNode(ctx context.Context, arg0 types.UpdateNodeRequest) (ret0 uint64, ret1 error) { +func (s *RegistrarGatewayStub) UpdateNode(ctx context.Context, arg0 client.Node) (ret0 error) { args := []interface{}{arg0} result, err := s.client.RequestContext(ctx, s.module, s.object, "UpdateNode", args...) if err != nil { panic(err) } result.PanicOnError() - ret1 = result.CallError() - loader := zbus.Loader{ - &ret0, - } + ret0 = result.CallError() + loader := zbus.Loader{} if err := result.Unmarshal(&loader); err != nil { panic(err) } return } -func (s *RegistrarGatewayStub) UpdateNodeUptimeV2(ctx context.Context, arg0 uint64, arg1 uint64) (ret0 error) { +func (s *RegistrarGatewayStub) UpdateNodeUptimeV2(ctx context.Context, arg0 uint64, arg1 int64) (ret0 error) { args := []interface{}{arg0, arg1} result, err := s.client.RequestContext(ctx, s.module, s.object, "UpdateNodeUptimeV2", args...) if err != nil { diff --git a/pkg/types/types.go b/pkg/types/types.go deleted file mode 100644 index 33c6d9d6..00000000 --- a/pkg/types/types.go +++ /dev/null @@ -1,104 +0,0 @@ -package types - -import ( - "time" - - "github.com/lib/pq" -) - -type UpdateNodeRequest struct { - TwinID uint64 `json:"twin_id" binding:"required,min=1"` - FarmID uint64 `json:"farm_id" binding:"required,min=1"` - Resources Resources `json:"resources" binding:"required"` - Location Location `json:"location" binding:"required"` - Interfaces []Interface `json:"interfaces" binding:"required"` - SecureBoot bool `json:"secure_boot"` - Virtualized bool `json:"virtualized"` - SerialNumber string `json:"serial_number" binding:"required"` -} - -type UpdateAccountRequest struct { - Relays pq.StringArray `json:"relays"` - RMBEncKey string `json:"rmb_enc_key"` -} - -type AccountCreationRequest struct { - Timestamp int64 `json:"timestamp"` - PublicKey string `json:"public_key"` - // the registrar expect a signature of a message with format `timestampStr:publicKeyBase64` - // - signature format: base64(ed25519_or_sr22519_signature) - Signature string `json:"signature"` - Relays []string `json:"relays"` - RMBEncKey string `json:"rmb_enc_key"` -} - -type UptimeReportRequest struct { - Uptime time.Duration `json:"uptime"` - Timestamp time.Time `json:"timestamp"` -} - -type Account struct { - TwinID uint64 `json:"twin_id"` - Relays []string `json:"relays"` // Optional list of relay domains - RMBEncKey string `json:"rmb_enc_key"` // Optional base64 encoded public key for rmb communication - // The public key (ED25519 for nodes, ED25519 or SR25519 for farmers) in the more standard base64 since we are moving from substrate echo system? - // (still SS58 can be used or plain base58 ,TBD) - PublicKey string `json:"public_key"` -} - -type Farm struct { - FarmID uint64 `json:"farm_id"` - FarmName string `json:"farm_name"` - TwinID uint64 `json:"twin_id"` // Farmer account reference - Dedicated bool `json:"dedicated"` -} - -type Node struct { - NodeID uint64 `json:"node_id"` - FarmID uint64 `json:"farm_id"` - TwinID uint64 `json:"twin_id"` // Node account reference - - Location Location `json:"location"` - - Resources Resources `json:"resources"` - Interfaces []Interface `json:"interface"` - SecureBoot bool `json:"secure_boot"` - Virtualized bool `json:"virtualized"` - SerialNumber string `json:"serial_number"` - UptimeReports []UptimeReport `json:"uptime"` - - Approved bool -} - -type UptimeReport struct { - ID uint64 - NodeID uint64 `json:"node_id"` - Duration time.Duration `json:"duration"` - Timestamp time.Time `json:"timestamp"` - WasRestart bool `json:"was_restart"` // True if this report followed a restart -} - -type ZosVersion struct { - Version string `json:"version"` - SafeToUpgrade bool `json:"safe_to_upgrade"` -} - -type Interface struct { - Name string `json:"name"` - Mac string `json:"mac"` - IPs string `json:"ips"` -} - -type Resources struct { - HRU uint64 `json:"hru"` - SRU uint64 `json:"sru"` - CRU uint64 `json:"cru"` - MRU uint64 `json:"mru"` -} - -type Location struct { - Country string `json:"country"` - City string `json:"city"` - Longitude string `json:"longitude"` - Latitude string `json:"latitude"` -} diff --git a/pkg/upgrade/upgrade.go b/pkg/upgrade/upgrade.go index d61870e0..08224d58 100644 --- a/pkg/upgrade/upgrade.go +++ b/pkg/upgrade/upgrade.go @@ -2,7 +2,6 @@ package upgrade import ( "context" - "encoding/json" "fmt" "io" "math/rand" @@ -20,6 +19,7 @@ import ( "github.com/threefoldtech/0-fs/meta" "github.com/threefoldtech/0-fs/rofs" "github.com/threefoldtech/0-fs/storage" + "github.com/threefoldtech/tfgrid4-sdk-go/node-registrar/client" "github.com/threefoldtech/zbus" "github.com/threefoldtech/zos4/pkg/stubs" "github.com/threefoldtech/zosbase/pkg/app" @@ -55,37 +55,23 @@ const ( ZosPackage = "zos.flist" ) -type RegistrarVersion struct { - SafeToUpgrade bool `json:"safe_to_upgrade"` - Version string `json:"version"` -} - -func getRolloutConfig(ctx context.Context, gw *stubs.RegistrarGatewayStub) (RegistrarVersion, []uint32, error) { +func getRolloutConfig(ctx context.Context, gw *stubs.RegistrarGatewayStub) (client.ZosVersion, []uint32, error) { env := environment.MustGet() config, err := environment.GetConfig() if err != nil { - return RegistrarVersion{}, nil, errors.Wrap(err, "failed to get network config") + return client.ZosVersion{}, nil, errors.Wrap(err, "failed to get network config") } - // if we are on devnet just update we don't need to update the version throught out the registrar - v := "v0.0.0" + // if we are on devnet just update we don't need to update the version through out the registrar + v := client.ZosVersion{Version: "v0.0.0", SafeToUpgrade: true} if env.RunningMode != environment.RunningDev { v, err = gw.GetZosVersion(ctx) if err != nil { - return RegistrarVersion{}, nil, errors.Wrap(err, "failed to get zos version from registrar") - } - } - var registrarVersion RegistrarVersion - err = json.Unmarshal([]byte(v), ®istrarVersion) - if err != nil { - log.Debug().Err(err).Msg("failed to unmarshal chain version and safe to upgrade flag") - registrarVersion = RegistrarVersion{ - SafeToUpgrade: true, - Version: v, + return client.ZosVersion{}, nil, errors.Wrap(err, "failed to get zos version from registrar") } } - return registrarVersion, config.RolloutUpgrade.TestFarms, nil + return v, config.RolloutUpgrade.TestFarms, nil } // Upgrader is the component that is responsible