Skip to content

Commit

Permalink
mod: Update core to v0.6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechampine committed Nov 29, 2024
1 parent 6ac76c1 commit af85bf3
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 139 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain go1.23.2

require (
go.etcd.io/bbolt v1.3.11
go.sia.tech/core v0.6.2
go.sia.tech/core v0.6.3
go.sia.tech/mux v1.3.0
go.uber.org/zap v1.27.0
golang.org/x/crypto v0.29.0
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKs
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
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/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/core v0.6.3 h1:7VdCSF61td1iatjGc5xt8WwCZgyB91mTvKhuL35o234=
go.sia.tech/core v0.6.3/go.mod h1:4v+aT/33857tMfqa5j5OYlAoLsoIrd4d7qMlgeP+VGk=
go.sia.tech/mux v1.3.0 h1:hgR34IEkqvfBKUJkAzGi31OADeW2y7D6Bmy/Jcbop9c=
go.sia.tech/mux v1.3.0/go.mod h1:I46++RD4beqA3cW9Xm9SwXbezwPqLvHhVs9HLpDtt58=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
Expand Down
2 changes: 1 addition & 1 deletion rhp/v4/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func RPCWriteSector(ctx context.Context, t TransportClient, prices rhp4.HostPric

return RPCWriteSectorResult{
Root: resp.Root,
Usage: prices.RPCWriteSectorCost(uint64(length), duration),
Usage: prices.RPCWriteSectorCost(length),
}, nil
}

Expand Down
28 changes: 0 additions & 28 deletions rhp/v4/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ func TestSettings(t *testing.T) {
WalletAddress: w.Address(),
MaxCollateral: types.Siacoins(10000),
MaxContractDuration: 1000,
MaxSectorDuration: 3 * 144,
MaxSectorBatchSize: 100,
RemainingStorage: 100 * proto4.SectorSize,
TotalStorage: 100 * proto4.SectorSize,
Prices: proto4.HostPrices{
Expand Down Expand Up @@ -216,8 +214,6 @@ func TestFormContract(t *testing.T) {
WalletAddress: w.Address(),
MaxCollateral: types.Siacoins(10000),
MaxContractDuration: 1000,
MaxSectorDuration: 3 * 144,
MaxSectorBatchSize: 100,
RemainingStorage: 100 * proto4.SectorSize,
TotalStorage: 100 * proto4.SectorSize,
Prices: proto4.HostPrices{
Expand Down Expand Up @@ -275,8 +271,6 @@ func TestFormContractBasis(t *testing.T) {
WalletAddress: w.Address(),
MaxCollateral: types.Siacoins(10000),
MaxContractDuration: 1000,
MaxSectorDuration: 3 * 144,
MaxSectorBatchSize: 100,
RemainingStorage: 100 * proto4.SectorSize,
TotalStorage: 100 * proto4.SectorSize,
Prices: proto4.HostPrices{
Expand Down Expand Up @@ -333,8 +327,6 @@ func TestRPCRefresh(t *testing.T) {
WalletAddress: w.Address(),
MaxCollateral: types.Siacoins(10000),
MaxContractDuration: 1000,
MaxSectorDuration: 3 * 144,
MaxSectorBatchSize: 100,
RemainingStorage: 100 * proto4.SectorSize,
TotalStorage: 100 * proto4.SectorSize,
Prices: proto4.HostPrices{
Expand Down Expand Up @@ -446,8 +438,6 @@ func TestRPCRenew(t *testing.T) {
WalletAddress: w.Address(),
MaxCollateral: types.Siacoins(10000),
MaxContractDuration: 1000,
MaxSectorDuration: 3 * 144,
MaxSectorBatchSize: 100,
RemainingStorage: 100 * proto4.SectorSize,
TotalStorage: 100 * proto4.SectorSize,
Prices: proto4.HostPrices{
Expand Down Expand Up @@ -607,8 +597,6 @@ func TestAccounts(t *testing.T) {
WalletAddress: w.Address(),
MaxCollateral: types.Siacoins(10000),
MaxContractDuration: 1000,
MaxSectorDuration: 3 * 144,
MaxSectorBatchSize: 100,
RemainingStorage: 100 * proto4.SectorSize,
TotalStorage: 100 * proto4.SectorSize,
Prices: proto4.HostPrices{
Expand Down Expand Up @@ -708,8 +696,6 @@ func TestReadWriteSector(t *testing.T) {
WalletAddress: w.Address(),
MaxCollateral: types.Siacoins(10000),
MaxContractDuration: 1000,
MaxSectorDuration: 3 * 144,
MaxSectorBatchSize: 100,
RemainingStorage: 100 * proto4.SectorSize,
TotalStorage: 100 * proto4.SectorSize,
Prices: proto4.HostPrices{
Expand Down Expand Up @@ -804,8 +790,6 @@ func TestAppendSectors(t *testing.T) {
WalletAddress: w.Address(),
MaxCollateral: types.Siacoins(10000),
MaxContractDuration: 1000,
MaxSectorDuration: 3 * 144,
MaxSectorBatchSize: 100,
RemainingStorage: 100 * proto4.SectorSize,
TotalStorage: 100 * proto4.SectorSize,
Prices: proto4.HostPrices{
Expand Down Expand Up @@ -921,8 +905,6 @@ func TestVerifySector(t *testing.T) {
WalletAddress: w.Address(),
MaxCollateral: types.Siacoins(10000),
MaxContractDuration: 1000,
MaxSectorDuration: 3 * 144,
MaxSectorBatchSize: 100,
RemainingStorage: 100 * proto4.SectorSize,
TotalStorage: 100 * proto4.SectorSize,
Prices: proto4.HostPrices{
Expand Down Expand Up @@ -1014,8 +996,6 @@ func TestRPCFreeSectors(t *testing.T) {
WalletAddress: w.Address(),
MaxCollateral: types.Siacoins(10000),
MaxContractDuration: 1000,
MaxSectorDuration: 3 * 144,
MaxSectorBatchSize: 100,
RemainingStorage: 100 * proto4.SectorSize,
TotalStorage: 100 * proto4.SectorSize,
Prices: proto4.HostPrices{
Expand Down Expand Up @@ -1137,8 +1117,6 @@ func TestRPCSectorRoots(t *testing.T) {
WalletAddress: w.Address(),
MaxCollateral: types.Siacoins(10000),
MaxContractDuration: 1000,
MaxSectorDuration: 3 * 144,
MaxSectorBatchSize: 100,
RemainingStorage: 100 * proto4.SectorSize,
TotalStorage: 100 * proto4.SectorSize,
Prices: proto4.HostPrices{
Expand Down Expand Up @@ -1247,8 +1225,6 @@ func BenchmarkWrite(b *testing.B) {
WalletAddress: w.Address(),
MaxCollateral: types.Siacoins(10000),
MaxContractDuration: 1000,
MaxSectorDuration: 3 * 144,
MaxSectorBatchSize: 100,
RemainingStorage: 100 * proto4.SectorSize,
TotalStorage: 100 * proto4.SectorSize,
Prices: proto4.HostPrices{
Expand Down Expand Up @@ -1337,8 +1313,6 @@ func BenchmarkRead(b *testing.B) {
WalletAddress: w.Address(),
MaxCollateral: types.Siacoins(10000),
MaxContractDuration: 1000,
MaxSectorDuration: 3 * 144,
MaxSectorBatchSize: 100,
RemainingStorage: 100 * proto4.SectorSize,
TotalStorage: 100 * proto4.SectorSize,
Prices: proto4.HostPrices{
Expand Down Expand Up @@ -1439,8 +1413,6 @@ func BenchmarkContractUpload(b *testing.B) {
WalletAddress: w.Address(),
MaxCollateral: types.Siacoins(10000),
MaxContractDuration: 1000,
MaxSectorDuration: 3 * 144,
MaxSectorBatchSize: 100,
RemainingStorage: 100 * proto4.SectorSize,
TotalStorage: 100 * proto4.SectorSize,
Prices: proto4.HostPrices{
Expand Down
25 changes: 5 additions & 20 deletions rhp/v4/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,6 @@ import (
"lukechampine.com/frand"
)

const (
sectorsPerTiB = (1 << 40) / (1 << 22)
memoryPer1TiB = sectorsPerTiB * 32

sectorsPer10TiB = 10 * sectorsPerTiB
memoryPer10TiB = sectorsPer10TiB * 32

sectorsPer100TiB = 100 * sectorsPerTiB
memoryPer100TiB = sectorsPer100TiB * 32
)

var protocolVersion = [3]byte{4, 0, 0}

type (
Expand Down Expand Up @@ -233,8 +222,7 @@ func (s *Server) handleRPCWriteSector(stream net.Conn) error {
if err := rhp4.ReadRequest(stream, &req); err != nil {
return errorDecodingError("failed to read request: %v", err)
}
settings := s.settings.RHP4Settings()
if err := req.Validate(s.hostKey.PublicKey(), settings.MaxSectorDuration); err != nil {
if err := req.Validate(s.hostKey.PublicKey(), rhp4.TempSectorDuration); err != nil {
return errorBadRequest("request invalid: %v", err)
}
prices := req.Prices
Expand All @@ -253,7 +241,7 @@ func (s *Server) handleRPCWriteSector(stream net.Conn) error {
return errorDecodingError("failed to read sector data: %v", err)
}

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

fc := state.Revision

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

settings := s.settings.RHP4Settings()
if err := req.Validate(s.hostKey.PublicKey(), settings.MaxSectorBatchSize); err != nil {
if err := req.Validate(s.hostKey.PublicKey(), rhp4.MaxSectorBatchSize); err != nil {
return errorBadRequest("request invalid: %v", err)
}

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

// validate the request fields
settings := s.settings.RHP4Settings()
if err := req.Validate(s.hostKey.PublicKey(), state.Revision, settings.MaxSectorBatchSize); err != nil {
if err := req.Validate(s.hostKey.PublicKey(), state.Revision, rhp4.MaxSectorBatchSize); err != nil {
return rhp4.NewRPCError(rhp4.ErrorCodeBadRequest, err.Error())
}
prices := req.Prices
Expand Down
85 changes: 0 additions & 85 deletions wallet/wallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1792,91 +1792,6 @@ func TestSingleAddressWalletEventTypes(t *testing.T) {
mineAndSync(t, cm, ws, wm, types.VoidAddress, 1)
assertEvent(t, wm, types.Hash256(types.FileContractID(fce.ID).V2RenterOutputID()), wallet.EventTypeV2ContractResolution, renterPayout, types.ZeroCurrency, cm.Tip().Height+network.MaturityDelay)
})

t.Run("v2 contract resolution - finalization", func(t *testing.T) {
// create a storage contract
renterPayout := types.Siacoins(10000)
fc := types.V2FileContract{
RenterOutput: types.SiacoinOutput{
Address: addr,
Value: renterPayout,
},
HostOutput: types.SiacoinOutput{
Address: types.VoidAddress,
Value: types.ZeroCurrency,
},
ProofHeight: cm.TipState().Index.Height + 10,
ExpirationHeight: cm.TipState().Index.Height + 20,

RenterPublicKey: pk.PublicKey(),
HostPublicKey: pk.PublicKey(),
}
contractValue := renterPayout.Add(cm.TipState().V2FileContractTax(fc))
sigHash := cm.TipState().ContractSigHash(fc)
sig := pk.SignHash(sigHash)
fc.RenterSignature = sig
fc.HostSignature = sig

// create a transaction with the contract
txn := types.V2Transaction{
FileContracts: []types.V2FileContract{fc},
}
basis, toSign, err := wm.FundV2Transaction(&txn, contractValue, false)
if err != nil {
t.Fatal(err)
}
wm.SignV2Inputs(&txn, toSign)

// broadcast the transaction
if _, err := cm.AddV2PoolTransactions(basis, []types.V2Transaction{txn}); err != nil {
t.Fatal(err)
}
// current tip
tip := cm.Tip()
// mine a block to confirm the contract formation
mineAndSync(t, cm, ws, wm, types.VoidAddress, 1)

// this is annoying because we have to keep the file contract
// proof
_, applied, err := cm.UpdatesSince(tip, 1000)
if err != nil {
t.Fatal(err)
}

// get the confirmed file contract element
var fce types.V2FileContractElement
applied[0].ForEachV2FileContractElement(func(ele types.V2FileContractElement, _ bool, _ *types.V2FileContractElement, _ types.V2FileContractResolutionType) {
fce = ele
})
for _, cau := range applied {
cau.UpdateElementProof(&fce.StateElement)
}

// finalize the contract
finalRevision := fce.V2FileContract
finalRevision.RevisionNumber = math.MaxUint64
finalRevisionSigHash := cm.TipState().ContractSigHash(finalRevision)
// create a renewal
finalization := types.V2FileContractFinalization(pk.SignHash(finalRevisionSigHash))

// create the renewal transaction
resolutionTxn := types.V2Transaction{
FileContractResolutions: []types.V2FileContractResolution{
{
Parent: fce,
Resolution: &finalization,
},
},
}

// broadcast the renewal
if _, err := cm.AddV2PoolTransactions(cm.Tip(), []types.V2Transaction{resolutionTxn}); err != nil {
t.Fatal(err)
}
// mine a block to confirm the renewal
mineAndSync(t, cm, ws, wm, types.VoidAddress, 1)
assertEvent(t, wm, types.Hash256(types.FileContractID(fce.ID).V2RenterOutputID()), wallet.EventTypeV2ContractResolution, renterPayout, types.ZeroCurrency, cm.Tip().Height+network.MaturityDelay)
})
}

func TestV2TPoolRace(t *testing.T) {
Expand Down

0 comments on commit af85bf3

Please sign in to comment.