Skip to content

Commit

Permalink
all: upgrade coreutils
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjan committed Feb 14, 2024
1 parent 3f4b6fa commit ddc1131
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 70 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ require (
github.com/montanaflynn/stats v0.7.1
gitlab.com/NebulousLabs/encoding v0.0.0-20200604091946-456c3dc907fe
go.sia.tech/core v0.2.1
go.sia.tech/coreutils v0.0.1
go.sia.tech/coreutils v0.0.2-0.20240210055213-149e3e4b222e
go.sia.tech/gofakes3 v0.0.0-20231109151325-e0d47c10dce2
go.sia.tech/hostd v1.0.2-beta.2.0.20240131203318-9d84aad6ef13
go.sia.tech/jape v0.11.2-0.20240124024603-93559895d640
go.sia.tech/mux v1.2.0
go.sia.tech/siad v1.5.10-0.20230228235644-3059c0b930ca
go.sia.tech/web/renterd v0.43.0
go.uber.org/zap v1.26.0
golang.org/x/crypto v0.18.0
golang.org/x/term v0.16.0
golang.org/x/crypto v0.19.0
golang.org/x/term v0.17.0
gopkg.in/yaml.v3 v3.0.1
gorm.io/driver/mysql v1.5.2
gorm.io/driver/sqlite v1.5.4
Expand Down Expand Up @@ -78,7 +78,7 @@ require (
go.sia.tech/web v0.0.0-20231213145933-3f175a86abff // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.16.1 // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
go.sia.tech/core v0.2.1 h1:CqmMd+T5rAhC+Py3NxfvGtvsj/GgwIqQHHVrdts/LqY=
go.sia.tech/core v0.2.1/go.mod h1:3EoY+rR78w1/uGoXXVqcYdwSjSJKuEMI5bL7WROA27Q=
go.sia.tech/coreutils v0.0.1 h1:Th8iiF9fjkBaxlKRgPJfRtsD3Pb8U4d2m/OahB6wffg=
go.sia.tech/coreutils v0.0.1/go.mod h1:3Mb206QDd3NtRiaHZ2kN87/HKXhcBF6lHVatS7PkViY=
go.sia.tech/coreutils v0.0.2-0.20240210055213-149e3e4b222e h1:KuRaxuGAMvicVG3mioGJY1oe17Pj9thyrcsvGEcSCfo=
go.sia.tech/coreutils v0.0.2-0.20240210055213-149e3e4b222e/go.mod h1:3Mb206QDd3NtRiaHZ2kN87/HKXhcBF6lHVatS7PkViY=
go.sia.tech/gofakes3 v0.0.0-20231109151325-e0d47c10dce2 h1:ulzfJNjxN5DjXHClkW2pTiDk+eJ+0NQhX87lFDZ03t0=
go.sia.tech/gofakes3 v0.0.0-20231109151325-e0d47c10dce2/go.mod h1:PlsiVCn6+wssrR7bsOIlZm0DahsVrDydrlbjY4F14sg=
go.sia.tech/hostd v1.0.2-beta.2.0.20240131203318-9d84aad6ef13 h1:JcyVUtJfzeMh+zJAW20BMVhBYekg+h0T8dMeF7GzAFs=
Expand Down Expand Up @@ -277,8 +277,8 @@ golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220507011949-2cf3adece122/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
Expand Down Expand Up @@ -332,16 +332,16 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210421210424-b80969c67360/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE=
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
Expand Down
22 changes: 12 additions & 10 deletions stores/hostdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ type (

// announcement describes an announcement for a single host.
announcement struct {
chain.Announcement
chain.HostAnnouncement
blockHeight uint64
blockID types.BlockID
hk types.PublicKey
timestamp time.Time
}
)
Expand Down Expand Up @@ -918,17 +919,18 @@ func (ss *SQLStore) processConsensusChangeHostDB(cc modules.ConsensusChange) {

// Process announcements, but only if they are not too old.
if b.Timestamp.After(time.Now().Add(-ss.announcementMaxAge)) {
chain.ForEachAnnouncement(types.Block(b), func(a chain.Announcement) {
if a.NetAddress == "" {
chain.ForEachHostAnnouncement(types.Block(b), func(hk types.PublicKey, ha chain.HostAnnouncement) {
if ha.NetAddress == "" {
return
}
newAnnouncements = append(newAnnouncements, announcement{
Announcement: a,
blockHeight: height,
blockID: b.ID(),
timestamp: b.Timestamp,
blockHeight: height,
blockID: b.ID(),
hk: hk,
timestamp: b.Timestamp,
HostAnnouncement: ha,
})
ss.unappliedHostKeys[a.PublicKey] = struct{}{}
ss.unappliedHostKeys[hk] = struct{}{}
})
}
height++
Expand Down Expand Up @@ -1013,12 +1015,12 @@ func insertAnnouncements(tx *gorm.DB, as []announcement) error {
var announcements []dbAnnouncement
for _, a := range as {
hosts = append(hosts, dbHost{
PublicKey: publicKey(a.PublicKey),
PublicKey: publicKey(a.hk),
LastAnnouncement: a.timestamp.UTC(),
NetAddress: a.NetAddress,
})
announcements = append(announcements, dbAnnouncement{
HostKey: publicKey(a.PublicKey),
HostKey: publicKey(a.hk),
BlockHeight: a.blockHeight,
BlockID: a.blockID.String(),
NetAddress: a.NetAddress,
Expand Down
52 changes: 18 additions & 34 deletions stores/hostdb_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package stores

import (
"bytes"
"context"
"errors"
"fmt"
Expand Down Expand Up @@ -61,9 +60,9 @@ func TestSQLHostDB(t *testing.T) {
blockHeight: 42,
blockID: types.BlockID{1, 2, 3},
timestamp: time.Now().UTC().Round(time.Second),
Announcement: chain.Announcement{
hk: hk,
HostAnnouncement: chain.HostAnnouncement{
NetAddress: "address",
PublicKey: hk,
},
}
err = ss.insertTestAnnouncement(a)
Expand Down Expand Up @@ -111,12 +110,12 @@ func TestSQLHostDB(t *testing.T) {

// Insert another announcement for an unknown host.
unknownKeyAnn := a
unknownKeyAnn.PublicKey = types.PublicKey{1, 4, 7}
unknownKeyAnn.hk = types.PublicKey{1, 4, 7}
err = ss.insertTestAnnouncement(unknownKeyAnn)
if err != nil {
t.Fatal(err)
}
h3, err := ss.Host(ctx, unknownKeyAnn.PublicKey)
h3, err := ss.Host(ctx, unknownKeyAnn.hk)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -511,20 +510,18 @@ func TestInsertAnnouncements(t *testing.T) {
timestamp: time.Now(),
blockHeight: 1,
blockID: types.BlockID{1},
Announcement: chain.Announcement{
hk: types.GeneratePrivateKey().PublicKey(),
HostAnnouncement: chain.HostAnnouncement{
NetAddress: "foo.bar:1000",
PublicKey: types.GeneratePrivateKey().PublicKey(),
},
}
ann2 := announcement{
Announcement: chain.Announcement{
PublicKey: types.GeneratePrivateKey().PublicKey(),
},
hk: types.GeneratePrivateKey().PublicKey(),
HostAnnouncement: chain.HostAnnouncement{},
}
ann3 := announcement{
Announcement: chain.Announcement{
PublicKey: types.GeneratePrivateKey().PublicKey(),
},
hk: types.GeneratePrivateKey().PublicKey(),
HostAnnouncement: chain.HostAnnouncement{},
}

// Insert the first one and check that all fields are set.
Expand All @@ -537,7 +534,7 @@ func TestInsertAnnouncements(t *testing.T) {
}
ann.Model = Model{} // ignore
expectedAnn := dbAnnouncement{
HostKey: publicKey(ann1.PublicKey),
HostKey: publicKey(ann1.hk),
BlockHeight: 1,
BlockID: types.BlockID{1}.String(),
NetAddress: "foo.bar:1000",
Expand Down Expand Up @@ -1099,10 +1096,8 @@ func (s *SQLStore) addTestHost(hk types.PublicKey) error {
func (s *SQLStore) addCustomTestHost(hk types.PublicKey, na string) error {
s.unappliedHostKeys[hk] = struct{}{}
s.unappliedAnnouncements = append(s.unappliedAnnouncements, []announcement{{
Announcement: chain.Announcement{
NetAddress: na,
PublicKey: hk,
},
hk: hk,
HostAnnouncement: chain.HostAnnouncement{NetAddress: na},
}}...)
s.lastSave = time.Now().Add(s.persistInterval * -2)
return s.applyUpdates(false)
Expand Down Expand Up @@ -1142,25 +1137,14 @@ func newTestPK() (types.PublicKey, types.PrivateKey) {
return pk, sk
}

func newTestHostAnnouncement(na string) (chain.Announcement, types.PrivateKey) {
uk, sk := newTestPK()
a := chain.Announcement{
func newTestHostAnnouncement(na string) (chain.HostAnnouncement, types.PrivateKey) {
_, sk := newTestPK()
a := chain.HostAnnouncement{
NetAddress: na,
PublicKey: uk,
}
return a, sk
}

func newTestTransaction(ha chain.Announcement, sk types.PrivateKey) stypes.Transaction {
buf := new(bytes.Buffer)
enc := types.NewEncoder(buf)
v1Ann := chain.V1Announcement{
Specifier: types.NewSpecifier(chain.AnnouncementSpecifier),
NetAddress: ha.NetAddress,
PublicKey: sk.PublicKey().UnlockKey(),
}
v1Ann.Sign(sk)
v1Ann.EncodeTo(enc)
enc.Flush()
return stypes.Transaction{ArbitraryData: [][]byte{buf.Bytes()}}
func newTestTransaction(ha chain.HostAnnouncement, sk types.PrivateKey) stypes.Transaction {
return stypes.Transaction{ArbitraryData: [][]byte{ha.ToArbitraryData(sk)}}
}
16 changes: 8 additions & 8 deletions stores/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ func TestSQLContractStore(t *testing.T) {

// Add an announcement.
err = ss.insertTestAnnouncement(announcement{
Announcement: chain.Announcement{
hk: hk,
HostAnnouncement: chain.HostAnnouncement{
NetAddress: "address",
PublicKey: hk,
},
})
if err != nil {
Expand Down Expand Up @@ -515,18 +515,18 @@ func TestRenewedContract(t *testing.T) {

// Add announcements.
err = ss.insertTestAnnouncement(announcement{
Announcement: chain.Announcement{
hk: hk,
HostAnnouncement: chain.HostAnnouncement{
NetAddress: "address",
PublicKey: hk,
},
})
if err != nil {
t.Fatal(err)
}
err = ss.insertTestAnnouncement(announcement{
Announcement: chain.Announcement{
hk: hk2,
HostAnnouncement: chain.HostAnnouncement{
NetAddress: "address2",
PublicKey: hk2,
},
})
if err != nil {
Expand Down Expand Up @@ -2279,9 +2279,9 @@ func TestRecordContractSpending(t *testing.T) {

// Add an announcement.
err = ss.insertTestAnnouncement(announcement{
Announcement: chain.Announcement{
hk: hk,
HostAnnouncement: chain.HostAnnouncement{
NetAddress: "address",
PublicKey: hk,
},
})
if err != nil {
Expand Down
13 changes: 7 additions & 6 deletions stores/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,17 +248,18 @@ func (cs *chainSubscriber) processChainApplyUpdateHostDB(cau *chain.ApplyUpdate)
if time.Since(b.Timestamp) > cs.announcementMaxAge {
return // ignore old announcements
}
chain.ForEachAnnouncement(b, func(ha chain.Announcement) {
chain.ForEachHostAnnouncement(b, func(hk types.PublicKey, ha chain.HostAnnouncement) {
if ha.NetAddress == "" {
return // ignore
}
cs.announcements = append(cs.announcements, announcement{
Announcement: ha,
blockHeight: cau.State.Index.Height,
blockID: b.ID(),
timestamp: b.Timestamp,
blockHeight: cau.State.Index.Height,
blockID: b.ID(),
hk: hk,
timestamp: b.Timestamp,
HostAnnouncement: ha,
})
cs.hosts[types.PublicKey(ha.PublicKey)] = struct{}{}
cs.hosts[hk] = struct{}{}
})
}

Expand Down

0 comments on commit ddc1131

Please sign in to comment.