diff --git a/go.mod b/go.mod index 85d16ed6..086411e9 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 ) diff --git a/go.sum b/go.sum index 0120f239..035d76ae 100644 --- a/go.sum +++ b/go.sum @@ -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= @@ -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= diff --git a/host/contracts/contracts_test.go b/host/contracts/contracts_test.go index 7a60a939..b6492345 100644 --- a/host/contracts/contracts_test.go +++ b/host/contracts/contracts_test.go @@ -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, }, diff --git a/host/contracts/manager_test.go b/host/contracts/manager_test.go index 9f91ebc3..51d31b27 100644 --- a/host/contracts/manager_test.go +++ b/host/contracts/manager_test.go @@ -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, }, @@ -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, }, diff --git a/internal/testutil/rhp/v3/rhp.go b/internal/testutil/rhp/v3/rhp.go index 85b05091..829027b3 100644 --- a/internal/testutil/rhp/v3/rhp.go +++ b/internal/testutil/rhp/v3/rhp.go @@ -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}, diff --git a/persist/sqlite/contracts_test.go b/persist/sqlite/contracts_test.go index 24a677c2..46949253 100644 --- a/persist/sqlite/contracts_test.go +++ b/persist/sqlite/contracts_test.go @@ -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, @@ -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, @@ -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, diff --git a/persist/sqlite/volumes_test.go b/persist/sqlite/volumes_test.go index dc308075..68cfd6ce 100644 --- a/persist/sqlite/volumes_test.go +++ b/persist/sqlite/volumes_test.go @@ -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, }, diff --git a/rhp/v2/contracts.go b/rhp/v2/contracts.go index fc7dd025..99be7489 100644 --- a/rhp/v2/contracts.go +++ b/rhp/v2/contracts.go @@ -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 @@ -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") } diff --git a/rhp/v2/contracts_test.go b/rhp/v2/contracts_test.go index fa1d722b..742b570b 100644 --- a/rhp/v2/contracts_test.go +++ b/rhp/v2/contracts_test.go @@ -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}, @@ -68,7 +68,7 @@ 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) @@ -76,14 +76,14 @@ func TestValidateContractRenewal(t *testing.T) { // 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) @@ -91,7 +91,7 @@ func TestValidateContractRenewal(t *testing.T) { // 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) diff --git a/rhp/v3/contracts.go b/rhp/v3/contracts.go index fce1ce67..21d91f64 100644 --- a/rhp/v3/contracts.go +++ b/rhp/v3/contracts.go @@ -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") } diff --git a/rhp/v3/contracts_test.go b/rhp/v3/contracts_test.go index 47e8ae78..c70a55e3 100644 --- a/rhp/v3/contracts_test.go +++ b/rhp/v3/contracts_test.go @@ -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}, @@ -67,7 +67,7 @@ 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) @@ -75,14 +75,14 @@ func TestValidateContractRenewal(t *testing.T) { // 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) @@ -90,7 +90,7 @@ func TestValidateContractRenewal(t *testing.T) { // 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)