Skip to content

Commit

Permalink
Merge pull request #501 from SiaFoundation/nate/update-dependencies
Browse files Browse the repository at this point in the history
Update coreutils and FileContract usage
  • Loading branch information
n8maninger authored Nov 18, 2024
2 parents 0b367ae + d6e28ef commit 45fae0a
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 38 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ require (
github.com/hashicorp/golang-lru/v2 v2.0.7
github.com/mattn/go-sqlite3 v1.14.24
github.com/shopspring/decimal v1.4.0
go.sia.tech/core v0.6.1
go.sia.tech/coreutils v0.6.0
go.sia.tech/core v0.6.2
go.sia.tech/coreutils v0.7.0
go.sia.tech/jape v0.12.1
go.sia.tech/web/hostd v0.50.0
go.uber.org/goleak v1.3.0
Expand All @@ -37,9 +37,9 @@ require (
go.sia.tech/mux v1.3.0 // indirect
go.sia.tech/web v0.0.0-20240610131903-5611d44a533e // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/tools v0.22.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
go.etcd.io/bbolt v1.3.11 h1:yGEzV1wPz2yVCLsD8ZAiGHhHVlczyC9d1rP43/VCRJ0=
go.etcd.io/bbolt v1.3.11/go.mod h1:dksAq7YMXoljX0xu6VF5DMZGbhYYoLUalEiSySYAS4I=
go.sia.tech/core v0.6.1 h1:eaExM2E2eNr43su2XDkY5J24E3F54YGS7hcC3WtVjVk=
go.sia.tech/core v0.6.1/go.mod h1:P3C1BWa/7J4XgdzWuaYHBvLo2RzZ0UBaJM4TG1GWB2g=
go.sia.tech/coreutils v0.6.0 h1:r0IZt+aVdGG2uIHl7OtaWRYdVx4NQ7ezRoSGa0Ej8GY=
go.sia.tech/coreutils v0.6.0/go.mod h1:XlsnogeYU/Tdjzp/HUNAj5T7tZCdmeBHIBjymbPC+uQ=
go.sia.tech/core v0.6.2 h1:8NEjxyD93A+EhZopsBy/LvuHH+zUSjRNKnf9rXgtIwU=
go.sia.tech/core v0.6.2/go.mod h1:4v+aT/33857tMfqa5j5OYlAoLsoIrd4d7qMlgeP+VGk=
go.sia.tech/coreutils v0.7.0 h1:YpgOUD4vrpDz0KC7FJz+UCOaKaqV5EkX3gMUUmJoz5s=
go.sia.tech/coreutils v0.7.0/go.mod h1:eMoqzqO4opKQ6n9tTTxHQmccfNlj+8RFOYuDSL/Qd4g=
go.sia.tech/jape v0.12.1 h1:xr+o9V8FO8ScRqbSaqYf9bjj1UJ2eipZuNcI1nYousU=
go.sia.tech/jape v0.12.1/go.mod h1:wU+h6Wh5olDjkPXjF0tbZ1GDgoZ6VTi4naFw91yyWC4=
go.sia.tech/mux v1.3.0 h1:hgR34IEkqvfBKUJkAzGi31OADeW2y7D6Bmy/Jcbop9c=
Expand All @@ -58,20 +58,20 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0=
golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU=
golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg=
golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
Expand Down
2 changes: 1 addition & 1 deletion host/contracts/contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestContractUpdater(t *testing.T) {
rev := contracts.SignedRevision{
Revision: types.FileContractRevision{
FileContract: types.FileContract{
UnlockHash: types.Hash256(contractUnlockConditions.UnlockHash()),
UnlockHash: contractUnlockConditions.UnlockHash(),
WindowStart: 100,
WindowEnd: 200,
},
Expand Down
4 changes: 2 additions & 2 deletions host/contracts/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func TestContractLockUnlock(t *testing.T) {
rev := contracts.SignedRevision{
Revision: types.FileContractRevision{
FileContract: types.FileContract{
UnlockHash: types.Hash256(contractUnlockConditions.UnlockHash()),
UnlockHash: contractUnlockConditions.UnlockHash(),
WindowStart: 100,
WindowEnd: 200,
},
Expand Down Expand Up @@ -1225,7 +1225,7 @@ func TestSectorRoots(t *testing.T) {
rev := contracts.SignedRevision{
Revision: types.FileContractRevision{
FileContract: types.FileContract{
UnlockHash: types.Hash256(contractUnlockConditions.UnlockHash()),
UnlockHash: contractUnlockConditions.UnlockHash(),
WindowStart: 100,
WindowEnd: 200,
},
Expand Down
4 changes: 2 additions & 2 deletions internal/testutil/rhp/v3/rhp.go
Original file line number Diff line number Diff line change
Expand Up @@ -759,13 +759,13 @@ func prepareContractRenewal(currentRevision types.FileContractRevision, renterAd
WindowStart: uint64(endHeight),
WindowEnd: uint64(endHeight + host.WindowSize),
Payout: taxAdjustedPayout(renterPayout.Add(hostValidPayout)),
UnlockHash: types.Hash256(types.UnlockConditions{
UnlockHash: types.UnlockConditions{
PublicKeys: []types.UnlockKey{
renterKey.PublicKey().UnlockKey(),
hostKey.UnlockKey(),
},
SignaturesRequired: 2,
}.UnlockHash()),
}.UnlockHash(),
RevisionNumber: 0,
ValidProofOutputs: []types.SiacoinOutput{
{Value: renterPayout, Address: renterAddress},
Expand Down
6 changes: 3 additions & 3 deletions persist/sqlite/contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func TestReviseContract(t *testing.T) {
ParentID: frand.Entropy256(),
UnlockConditions: contractUnlockConditions,
FileContract: types.FileContract{
UnlockHash: types.Hash256(contractUnlockConditions.UnlockHash()),
UnlockHash: contractUnlockConditions.UnlockHash(),
RevisionNumber: 1,
WindowStart: 100,
WindowEnd: 200,
Expand Down Expand Up @@ -382,7 +382,7 @@ func TestContracts(t *testing.T) {
ParentID: frand.Entropy256(),
UnlockConditions: contractUnlockConditions,
FileContract: types.FileContract{
UnlockHash: types.Hash256(contractUnlockConditions.UnlockHash()),
UnlockHash: contractUnlockConditions.UnlockHash(),
RevisionNumber: 1,
WindowStart: 100,
WindowEnd: 200,
Expand Down Expand Up @@ -450,7 +450,7 @@ func BenchmarkTrimSectors(b *testing.B) {
ParentID: frand.Entropy256(),
UnlockConditions: contractUnlockConditions,
FileContract: types.FileContract{
UnlockHash: types.Hash256(contractUnlockConditions.UnlockHash()),
UnlockHash: contractUnlockConditions.UnlockHash(),
RevisionNumber: 1,
WindowStart: 100,
WindowEnd: 200,
Expand Down
2 changes: 1 addition & 1 deletion persist/sqlite/volumes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ func TestPrune(t *testing.T) {
UnlockConditions: contractUnlockConditions,
ParentID: types.FileContractID(frand.Entropy256()),
FileContract: types.FileContract{
UnlockHash: types.Hash256(contractUnlockConditions.UnlockHash()),
UnlockHash: contractUnlockConditions.UnlockHash(),
WindowStart: 90,
WindowEnd: 100,
},
Expand Down
4 changes: 2 additions & 2 deletions rhp/v2/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func validateContractFormation(fc types.FileContract, hostKey, renterKey types.U
return types.ZeroCurrency, errors.New("host valid and missed outputs must be equal")
case fc.ValidHostPayout().Cmp(settings.MaxCollateral) > 0:
return types.ZeroCurrency, errors.New("excessive initial collateral")
case fc.UnlockHash != types.Hash256(contractUnlockConditions(hostKey, renterKey).UnlockHash()):
case fc.UnlockHash != contractUnlockConditions(hostKey, renterKey).UnlockHash():
return types.ZeroCurrency, errors.New("incorrect unlock hash")
}
return fc.ValidHostPayout().Sub(settings.ContractPrice), nil
Expand Down Expand Up @@ -99,7 +99,7 @@ func validateContractRenewal(existing types.FileContractRevision, renewal types.
return types.ZeroCurrency, types.ZeroCurrency, types.ZeroCurrency, errors.New("wrong address for missed host output")
case renewal.MissedProofOutputs[2].Address != types.VoidAddress:
return types.ZeroCurrency, types.ZeroCurrency, types.ZeroCurrency, errors.New("wrong address for void output")
case renewal.UnlockHash != types.Hash256(contractUnlockConditions(hostKey, renterKey).UnlockHash()):
case renewal.UnlockHash != contractUnlockConditions(hostKey, renterKey).UnlockHash():
return types.ZeroCurrency, types.ZeroCurrency, types.ZeroCurrency, errors.New("incorrect unlock hash")
}

Expand Down
12 changes: 6 additions & 6 deletions rhp/v2/contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ func TestValidateContractRenewal(t *testing.T) {
WindowStart: 100,
WindowEnd: 300,
Payout: types.ZeroCurrency, // not validated here
UnlockHash: types.Hash256(types.UnlockConditions{
UnlockHash: types.UnlockConditions{
PublicKeys: []types.UnlockKey{renterKey.UnlockKey(), hostKey.UnlockKey()},
SignaturesRequired: 2,
}.UnlockHash()),
}.UnlockHash(),
ValidProofOutputs: []types.SiacoinOutput{
{Address: renterAddress, Value: renterAllowance},
{Address: hostAddress, Value: hostCollateral},
Expand Down Expand Up @@ -68,30 +68,30 @@ func TestValidateContractRenewal(t *testing.T) {

// bad renter key
badRenterKey := types.NewPrivateKeyFromSeed(frand.Bytes(32)).PublicKey().UnlockKey()
renewal.UnlockHash = types.Hash256(contractUnlockConditions(hostKey.UnlockKey(), badRenterKey).UnlockHash())
renewal.UnlockHash = contractUnlockConditions(hostKey.UnlockKey(), badRenterKey).UnlockHash()
_, _, _, err := validateContractRenewal(existing, renewal, hostKey.UnlockKey(), renterKey.UnlockKey(), types.ZeroCurrency, types.ZeroCurrency, 0, settings)
if err == nil || err.Error() != "incorrect unlock hash" {
t.Fatalf("expected unlock hash error, got %v", err)
}

// bad host key
badHostKey := types.NewPrivateKeyFromSeed(frand.Bytes(32)).PublicKey().UnlockKey()
renewal.UnlockHash = types.Hash256(contractUnlockConditions(badHostKey, renterKey.UnlockKey()).UnlockHash())
renewal.UnlockHash = contractUnlockConditions(badHostKey, renterKey.UnlockKey()).UnlockHash()
_, _, _, err = validateContractRenewal(existing, renewal, hostKey.UnlockKey(), renterKey.UnlockKey(), types.ZeroCurrency, types.ZeroCurrency, 0, settings)
if err == nil || err.Error() != "incorrect unlock hash" {
t.Fatalf("expected unlock hash error, got %v", err)
}

// original keys
renewal.UnlockHash = types.Hash256(contractUnlockConditions(hostKey.UnlockKey(), renterKey.UnlockKey()).UnlockHash())
renewal.UnlockHash = contractUnlockConditions(hostKey.UnlockKey(), renterKey.UnlockKey()).UnlockHash()
_, _, _, err = validateContractRenewal(existing, renewal, hostKey.UnlockKey(), renterKey.UnlockKey(), types.ZeroCurrency, types.ZeroCurrency, 0, settings)
if err != nil {
t.Fatal(err)
}

// different renter key, same host key
newRenterKey := types.NewPrivateKeyFromSeed(frand.Bytes(32)).PublicKey().UnlockKey()
renewal.UnlockHash = types.Hash256(contractUnlockConditions(hostKey.UnlockKey(), newRenterKey).UnlockHash())
renewal.UnlockHash = contractUnlockConditions(hostKey.UnlockKey(), newRenterKey).UnlockHash()
_, _, _, err = validateContractRenewal(existing, renewal, hostKey.UnlockKey(), newRenterKey, types.ZeroCurrency, types.ZeroCurrency, 0, settings)
if err != nil {
t.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion rhp/v3/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func validateContractRenewal(existing types.FileContractRevision, renewal types.
return types.ZeroCurrency, types.ZeroCurrency, errors.New("wrong address for missed host output")
case renewal.MissedProofOutputs[2].Address != types.VoidAddress:
return types.ZeroCurrency, types.ZeroCurrency, errors.New("wrong address for void output")
case renewal.UnlockHash != types.Hash256(contractUnlockConditions(hostKey, renterKey).UnlockHash()):
case renewal.UnlockHash != contractUnlockConditions(hostKey, renterKey).UnlockHash():
return types.ZeroCurrency, types.ZeroCurrency, errors.New("incorrect unlock hash")
}

Expand Down
12 changes: 6 additions & 6 deletions rhp/v3/contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ func TestValidateContractRenewal(t *testing.T) {
WindowStart: 100,
WindowEnd: 300,
Payout: types.ZeroCurrency, // not validated here
UnlockHash: types.Hash256(types.UnlockConditions{
UnlockHash: types.UnlockConditions{
PublicKeys: []types.UnlockKey{renterKey.UnlockKey(), hostKey.UnlockKey()},
SignaturesRequired: 2,
}.UnlockHash()),
}.UnlockHash(),
ValidProofOutputs: []types.SiacoinOutput{
{Address: renterAddress, Value: renterAllowance},
{Address: hostAddress, Value: hostCollateral},
Expand Down Expand Up @@ -67,30 +67,30 @@ func TestValidateContractRenewal(t *testing.T) {

// bad renter key
badRenterKey := types.NewPrivateKeyFromSeed(frand.Bytes(32)).PublicKey().UnlockKey()
renewal.UnlockHash = types.Hash256(contractUnlockConditions(hostKey.UnlockKey(), badRenterKey).UnlockHash())
renewal.UnlockHash = contractUnlockConditions(hostKey.UnlockKey(), badRenterKey).UnlockHash()
_, _, err := validateContractRenewal(existing, renewal, hostKey.UnlockKey(), renterKey.UnlockKey(), hostAddress, types.ZeroCurrency, types.ZeroCurrency, pt)
if err == nil || err.Error() != "incorrect unlock hash" {
t.Fatalf("expected unlock hash error, got %v", err)
}

// bad host key
badHostKey := types.NewPrivateKeyFromSeed(frand.Bytes(32)).PublicKey().UnlockKey()
renewal.UnlockHash = types.Hash256(contractUnlockConditions(badHostKey, renterKey.UnlockKey()).UnlockHash())
renewal.UnlockHash = contractUnlockConditions(badHostKey, renterKey.UnlockKey()).UnlockHash()
_, _, err = validateContractRenewal(existing, renewal, hostKey.UnlockKey(), renterKey.UnlockKey(), hostAddress, types.ZeroCurrency, types.ZeroCurrency, pt)
if err == nil || err.Error() != "incorrect unlock hash" {
t.Fatalf("expected unlock hash error, got %v", err)
}

// original keys
renewal.UnlockHash = types.Hash256(contractUnlockConditions(hostKey.UnlockKey(), renterKey.UnlockKey()).UnlockHash())
renewal.UnlockHash = contractUnlockConditions(hostKey.UnlockKey(), renterKey.UnlockKey()).UnlockHash()
_, _, err = validateContractRenewal(existing, renewal, hostKey.UnlockKey(), renterKey.UnlockKey(), hostAddress, types.ZeroCurrency, types.ZeroCurrency, pt)
if err != nil {
t.Fatal(err)
}

// different renter key, same host key
newRenterKey := types.NewPrivateKeyFromSeed(frand.Bytes(32)).PublicKey().UnlockKey()
renewal.UnlockHash = types.Hash256(contractUnlockConditions(hostKey.UnlockKey(), newRenterKey).UnlockHash())
renewal.UnlockHash = contractUnlockConditions(hostKey.UnlockKey(), newRenterKey).UnlockHash()
_, _, err = validateContractRenewal(existing, renewal, hostKey.UnlockKey(), newRenterKey, hostAddress, types.ZeroCurrency, types.ZeroCurrency, pt)
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit 45fae0a

Please sign in to comment.