Skip to content

Commit 333f689

Browse files
committed
mod: Update core to v0.6.3
1 parent 96d0b27 commit 333f689

File tree

6 files changed

+9
-139
lines changed

6 files changed

+9
-139
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ toolchain go1.23.2
66

77
require (
88
go.etcd.io/bbolt v1.3.11
9-
go.sia.tech/core v0.6.2
9+
go.sia.tech/core v0.6.3
1010
go.sia.tech/mux v1.3.0
1111
go.uber.org/zap v1.27.0
1212
golang.org/x/crypto v0.29.0

go.sum

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKs
66
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
77
go.etcd.io/bbolt v1.3.11 h1:yGEzV1wPz2yVCLsD8ZAiGHhHVlczyC9d1rP43/VCRJ0=
88
go.etcd.io/bbolt v1.3.11/go.mod h1:dksAq7YMXoljX0xu6VF5DMZGbhYYoLUalEiSySYAS4I=
9-
go.sia.tech/core v0.6.1 h1:eaExM2E2eNr43su2XDkY5J24E3F54YGS7hcC3WtVjVk=
10-
go.sia.tech/core v0.6.1/go.mod h1:P3C1BWa/7J4XgdzWuaYHBvLo2RzZ0UBaJM4TG1GWB2g=
11-
go.sia.tech/core v0.6.2 h1:8NEjxyD93A+EhZopsBy/LvuHH+zUSjRNKnf9rXgtIwU=
12-
go.sia.tech/core v0.6.2/go.mod h1:4v+aT/33857tMfqa5j5OYlAoLsoIrd4d7qMlgeP+VGk=
9+
go.sia.tech/core v0.6.3 h1:7VdCSF61td1iatjGc5xt8WwCZgyB91mTvKhuL35o234=
10+
go.sia.tech/core v0.6.3/go.mod h1:4v+aT/33857tMfqa5j5OYlAoLsoIrd4d7qMlgeP+VGk=
1311
go.sia.tech/mux v1.3.0 h1:hgR34IEkqvfBKUJkAzGi31OADeW2y7D6Bmy/Jcbop9c=
1412
go.sia.tech/mux v1.3.0/go.mod h1:I46++RD4beqA3cW9Xm9SwXbezwPqLvHhVs9HLpDtt58=
1513
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=

rhp/v4/rpc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ func RPCWriteSector(ctx context.Context, t TransportClient, prices rhp4.HostPric
287287

288288
return RPCWriteSectorResult{
289289
Root: resp.Root,
290-
Usage: prices.RPCWriteSectorCost(uint64(length), duration),
290+
Usage: prices.RPCWriteSectorCost(length),
291291
}, nil
292292
}
293293

rhp/v4/rpc_test.go

-28
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,6 @@ func TestSettings(t *testing.T) {
156156
WalletAddress: w.Address(),
157157
MaxCollateral: types.Siacoins(10000),
158158
MaxContractDuration: 1000,
159-
MaxSectorDuration: 3 * 144,
160-
MaxSectorBatchSize: 100,
161159
RemainingStorage: 100 * proto4.SectorSize,
162160
TotalStorage: 100 * proto4.SectorSize,
163161
Prices: proto4.HostPrices{
@@ -216,8 +214,6 @@ func TestFormContract(t *testing.T) {
216214
WalletAddress: w.Address(),
217215
MaxCollateral: types.Siacoins(10000),
218216
MaxContractDuration: 1000,
219-
MaxSectorDuration: 3 * 144,
220-
MaxSectorBatchSize: 100,
221217
RemainingStorage: 100 * proto4.SectorSize,
222218
TotalStorage: 100 * proto4.SectorSize,
223219
Prices: proto4.HostPrices{
@@ -275,8 +271,6 @@ func TestFormContractBasis(t *testing.T) {
275271
WalletAddress: w.Address(),
276272
MaxCollateral: types.Siacoins(10000),
277273
MaxContractDuration: 1000,
278-
MaxSectorDuration: 3 * 144,
279-
MaxSectorBatchSize: 100,
280274
RemainingStorage: 100 * proto4.SectorSize,
281275
TotalStorage: 100 * proto4.SectorSize,
282276
Prices: proto4.HostPrices{
@@ -333,8 +327,6 @@ func TestRPCRefresh(t *testing.T) {
333327
WalletAddress: w.Address(),
334328
MaxCollateral: types.Siacoins(10000),
335329
MaxContractDuration: 1000,
336-
MaxSectorDuration: 3 * 144,
337-
MaxSectorBatchSize: 100,
338330
RemainingStorage: 100 * proto4.SectorSize,
339331
TotalStorage: 100 * proto4.SectorSize,
340332
Prices: proto4.HostPrices{
@@ -446,8 +438,6 @@ func TestRPCRenew(t *testing.T) {
446438
WalletAddress: w.Address(),
447439
MaxCollateral: types.Siacoins(10000),
448440
MaxContractDuration: 1000,
449-
MaxSectorDuration: 3 * 144,
450-
MaxSectorBatchSize: 100,
451441
RemainingStorage: 100 * proto4.SectorSize,
452442
TotalStorage: 100 * proto4.SectorSize,
453443
Prices: proto4.HostPrices{
@@ -607,8 +597,6 @@ func TestAccounts(t *testing.T) {
607597
WalletAddress: w.Address(),
608598
MaxCollateral: types.Siacoins(10000),
609599
MaxContractDuration: 1000,
610-
MaxSectorDuration: 3 * 144,
611-
MaxSectorBatchSize: 100,
612600
RemainingStorage: 100 * proto4.SectorSize,
613601
TotalStorage: 100 * proto4.SectorSize,
614602
Prices: proto4.HostPrices{
@@ -708,8 +696,6 @@ func TestReadWriteSector(t *testing.T) {
708696
WalletAddress: w.Address(),
709697
MaxCollateral: types.Siacoins(10000),
710698
MaxContractDuration: 1000,
711-
MaxSectorDuration: 3 * 144,
712-
MaxSectorBatchSize: 100,
713699
RemainingStorage: 100 * proto4.SectorSize,
714700
TotalStorage: 100 * proto4.SectorSize,
715701
Prices: proto4.HostPrices{
@@ -804,8 +790,6 @@ func TestAppendSectors(t *testing.T) {
804790
WalletAddress: w.Address(),
805791
MaxCollateral: types.Siacoins(10000),
806792
MaxContractDuration: 1000,
807-
MaxSectorDuration: 3 * 144,
808-
MaxSectorBatchSize: 100,
809793
RemainingStorage: 100 * proto4.SectorSize,
810794
TotalStorage: 100 * proto4.SectorSize,
811795
Prices: proto4.HostPrices{
@@ -921,8 +905,6 @@ func TestVerifySector(t *testing.T) {
921905
WalletAddress: w.Address(),
922906
MaxCollateral: types.Siacoins(10000),
923907
MaxContractDuration: 1000,
924-
MaxSectorDuration: 3 * 144,
925-
MaxSectorBatchSize: 100,
926908
RemainingStorage: 100 * proto4.SectorSize,
927909
TotalStorage: 100 * proto4.SectorSize,
928910
Prices: proto4.HostPrices{
@@ -1014,8 +996,6 @@ func TestRPCFreeSectors(t *testing.T) {
1014996
WalletAddress: w.Address(),
1015997
MaxCollateral: types.Siacoins(10000),
1016998
MaxContractDuration: 1000,
1017-
MaxSectorDuration: 3 * 144,
1018-
MaxSectorBatchSize: 100,
1019999
RemainingStorage: 100 * proto4.SectorSize,
10201000
TotalStorage: 100 * proto4.SectorSize,
10211001
Prices: proto4.HostPrices{
@@ -1137,8 +1117,6 @@ func TestRPCSectorRoots(t *testing.T) {
11371117
WalletAddress: w.Address(),
11381118
MaxCollateral: types.Siacoins(10000),
11391119
MaxContractDuration: 1000,
1140-
MaxSectorDuration: 3 * 144,
1141-
MaxSectorBatchSize: 100,
11421120
RemainingStorage: 100 * proto4.SectorSize,
11431121
TotalStorage: 100 * proto4.SectorSize,
11441122
Prices: proto4.HostPrices{
@@ -1247,8 +1225,6 @@ func BenchmarkWrite(b *testing.B) {
12471225
WalletAddress: w.Address(),
12481226
MaxCollateral: types.Siacoins(10000),
12491227
MaxContractDuration: 1000,
1250-
MaxSectorDuration: 3 * 144,
1251-
MaxSectorBatchSize: 100,
12521228
RemainingStorage: 100 * proto4.SectorSize,
12531229
TotalStorage: 100 * proto4.SectorSize,
12541230
Prices: proto4.HostPrices{
@@ -1337,8 +1313,6 @@ func BenchmarkRead(b *testing.B) {
13371313
WalletAddress: w.Address(),
13381314
MaxCollateral: types.Siacoins(10000),
13391315
MaxContractDuration: 1000,
1340-
MaxSectorDuration: 3 * 144,
1341-
MaxSectorBatchSize: 100,
13421316
RemainingStorage: 100 * proto4.SectorSize,
13431317
TotalStorage: 100 * proto4.SectorSize,
13441318
Prices: proto4.HostPrices{
@@ -1439,8 +1413,6 @@ func BenchmarkContractUpload(b *testing.B) {
14391413
WalletAddress: w.Address(),
14401414
MaxCollateral: types.Siacoins(10000),
14411415
MaxContractDuration: 1000,
1442-
MaxSectorDuration: 3 * 144,
1443-
MaxSectorBatchSize: 100,
14441416
RemainingStorage: 100 * proto4.SectorSize,
14451417
TotalStorage: 100 * proto4.SectorSize,
14461418
Prices: proto4.HostPrices{

rhp/v4/server.go

+5-20
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,6 @@ import (
1717
"lukechampine.com/frand"
1818
)
1919

20-
const (
21-
sectorsPerTiB = (1 << 40) / (1 << 22)
22-
memoryPer1TiB = sectorsPerTiB * 32
23-
24-
sectorsPer10TiB = 10 * sectorsPerTiB
25-
memoryPer10TiB = sectorsPer10TiB * 32
26-
27-
sectorsPer100TiB = 100 * sectorsPerTiB
28-
memoryPer100TiB = sectorsPer100TiB * 32
29-
)
30-
3120
var protocolVersion = [3]byte{4, 0, 0}
3221

3322
type (
@@ -233,8 +222,7 @@ func (s *Server) handleRPCWriteSector(stream net.Conn) error {
233222
if err := rhp4.ReadRequest(stream, &req); err != nil {
234223
return errorDecodingError("failed to read request: %v", err)
235224
}
236-
settings := s.settings.RHP4Settings()
237-
if err := req.Validate(s.hostKey.PublicKey(), settings.MaxSectorDuration); err != nil {
225+
if err := req.Validate(s.hostKey.PublicKey(), rhp4.TempSectorDuration); err != nil {
238226
return errorBadRequest("request invalid: %v", err)
239227
}
240228
prices := req.Prices
@@ -253,7 +241,7 @@ func (s *Server) handleRPCWriteSector(stream net.Conn) error {
253241
return errorDecodingError("failed to read sector data: %v", err)
254242
}
255243

256-
usage := prices.RPCWriteSectorCost(req.DataLength, req.Duration)
244+
usage := prices.RPCWriteSectorCost(req.DataLength)
257245
if err = s.contractor.DebitAccount(req.Token.Account, usage); err != nil {
258246
return fmt.Errorf("failed to debit account: %w", err)
259247
}
@@ -284,8 +272,7 @@ func (s *Server) handleRPCFreeSectors(stream net.Conn) error {
284272

285273
fc := state.Revision
286274

287-
settings := s.settings.RHP4Settings()
288-
if err := req.Validate(s.hostKey.PublicKey(), fc, settings.MaxSectorBatchSize); err != nil {
275+
if err := req.Validate(s.hostKey.PublicKey(), fc, rhp4.MaxSectorBatchSize); err != nil {
289276
return errorBadRequest("request invalid: %v", err)
290277
}
291278
prices := req.Prices
@@ -347,8 +334,7 @@ func (s *Server) handleRPCAppendSectors(stream net.Conn) error {
347334
return errorDecodingError("failed to read request: %v", err)
348335
}
349336

350-
settings := s.settings.RHP4Settings()
351-
if err := req.Validate(s.hostKey.PublicKey(), settings.MaxSectorBatchSize); err != nil {
337+
if err := req.Validate(s.hostKey.PublicKey(), rhp4.MaxSectorBatchSize); err != nil {
352338
return errorBadRequest("request invalid: %v", err)
353339
}
354340

@@ -483,8 +469,7 @@ func (s *Server) handleRPCSectorRoots(stream net.Conn) error {
483469
defer unlock()
484470

485471
// validate the request fields
486-
settings := s.settings.RHP4Settings()
487-
if err := req.Validate(s.hostKey.PublicKey(), state.Revision, settings.MaxSectorBatchSize); err != nil {
472+
if err := req.Validate(s.hostKey.PublicKey(), state.Revision, rhp4.MaxSectorBatchSize); err != nil {
488473
return rhp4.NewRPCError(rhp4.ErrorCodeBadRequest, err.Error())
489474
}
490475
prices := req.Prices

wallet/wallet_test.go

-85
Original file line numberDiff line numberDiff line change
@@ -1792,91 +1792,6 @@ func TestSingleAddressWalletEventTypes(t *testing.T) {
17921792
mineAndSync(t, cm, ws, wm, types.VoidAddress, 1)
17931793
assertEvent(t, wm, types.Hash256(types.FileContractID(fce.ID).V2RenterOutputID()), wallet.EventTypeV2ContractResolution, renterPayout, types.ZeroCurrency, cm.Tip().Height+network.MaturityDelay)
17941794
})
1795-
1796-
t.Run("v2 contract resolution - finalization", func(t *testing.T) {
1797-
// create a storage contract
1798-
renterPayout := types.Siacoins(10000)
1799-
fc := types.V2FileContract{
1800-
RenterOutput: types.SiacoinOutput{
1801-
Address: addr,
1802-
Value: renterPayout,
1803-
},
1804-
HostOutput: types.SiacoinOutput{
1805-
Address: types.VoidAddress,
1806-
Value: types.ZeroCurrency,
1807-
},
1808-
ProofHeight: cm.TipState().Index.Height + 10,
1809-
ExpirationHeight: cm.TipState().Index.Height + 20,
1810-
1811-
RenterPublicKey: pk.PublicKey(),
1812-
HostPublicKey: pk.PublicKey(),
1813-
}
1814-
contractValue := renterPayout.Add(cm.TipState().V2FileContractTax(fc))
1815-
sigHash := cm.TipState().ContractSigHash(fc)
1816-
sig := pk.SignHash(sigHash)
1817-
fc.RenterSignature = sig
1818-
fc.HostSignature = sig
1819-
1820-
// create a transaction with the contract
1821-
txn := types.V2Transaction{
1822-
FileContracts: []types.V2FileContract{fc},
1823-
}
1824-
basis, toSign, err := wm.FundV2Transaction(&txn, contractValue, false)
1825-
if err != nil {
1826-
t.Fatal(err)
1827-
}
1828-
wm.SignV2Inputs(&txn, toSign)
1829-
1830-
// broadcast the transaction
1831-
if _, err := cm.AddV2PoolTransactions(basis, []types.V2Transaction{txn}); err != nil {
1832-
t.Fatal(err)
1833-
}
1834-
// current tip
1835-
tip := cm.Tip()
1836-
// mine a block to confirm the contract formation
1837-
mineAndSync(t, cm, ws, wm, types.VoidAddress, 1)
1838-
1839-
// this is annoying because we have to keep the file contract
1840-
// proof
1841-
_, applied, err := cm.UpdatesSince(tip, 1000)
1842-
if err != nil {
1843-
t.Fatal(err)
1844-
}
1845-
1846-
// get the confirmed file contract element
1847-
var fce types.V2FileContractElement
1848-
applied[0].ForEachV2FileContractElement(func(ele types.V2FileContractElement, _ bool, _ *types.V2FileContractElement, _ types.V2FileContractResolutionType) {
1849-
fce = ele
1850-
})
1851-
for _, cau := range applied {
1852-
cau.UpdateElementProof(&fce.StateElement)
1853-
}
1854-
1855-
// finalize the contract
1856-
finalRevision := fce.V2FileContract
1857-
finalRevision.RevisionNumber = math.MaxUint64
1858-
finalRevisionSigHash := cm.TipState().ContractSigHash(finalRevision)
1859-
// create a renewal
1860-
finalization := types.V2FileContractFinalization(pk.SignHash(finalRevisionSigHash))
1861-
1862-
// create the renewal transaction
1863-
resolutionTxn := types.V2Transaction{
1864-
FileContractResolutions: []types.V2FileContractResolution{
1865-
{
1866-
Parent: fce,
1867-
Resolution: &finalization,
1868-
},
1869-
},
1870-
}
1871-
1872-
// broadcast the renewal
1873-
if _, err := cm.AddV2PoolTransactions(cm.Tip(), []types.V2Transaction{resolutionTxn}); err != nil {
1874-
t.Fatal(err)
1875-
}
1876-
// mine a block to confirm the renewal
1877-
mineAndSync(t, cm, ws, wm, types.VoidAddress, 1)
1878-
assertEvent(t, wm, types.Hash256(types.FileContractID(fce.ID).V2RenterOutputID()), wallet.EventTypeV2ContractResolution, renterPayout, types.ZeroCurrency, cm.Tip().Height+network.MaturityDelay)
1879-
})
18801795
}
18811796

18821797
func TestV2TPoolRace(t *testing.T) {

0 commit comments

Comments
 (0)