Skip to content

Commit f0ce445

Browse files
Update core dependencies (#1652)
Updating the core dependencies on `master` to make sure we get all the fixes into `v1.1.0`.
2 parents a66aa66 + 9c8b9ff commit f0ce445

File tree

15 files changed

+91
-61
lines changed

15 files changed

+91
-61
lines changed

api/wallet.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ type (
1212
// A SiacoinElement is a SiacoinOutput along with its ID.
1313
SiacoinElement struct {
1414
types.SiacoinOutput
15-
ID types.Hash256 `json:"id"`
16-
MaturityHeight uint64 `json:"maturityHeight"`
15+
ID types.SiacoinOutputID `json:"id"`
16+
MaturityHeight uint64 `json:"maturityHeight"`
1717
}
1818

1919
// A Transaction is an on-chain transaction relevant to a particular wallet,

autopilot/contractor/contractor.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,15 @@ func performContractChecks(ctx *mCtx, alerter alerts.Alerter, bus Bus, w Worker,
963963
continue
964964
}
965965

966+
// NOTE: if we have a contract with a host that is not scanned, we either
967+
// added the host and contract manually or reset the host scans. In that case,
968+
// we ignore the fact that the host is not scanned for now to avoid churn.
969+
if inSet && check.Usability.NotCompletingScan {
970+
keepContract(c.ContractMetadata, host)
971+
logger.Info("ignoring contract with unscanned host")
972+
continue // no more checks until host is scanned
973+
}
974+
966975
// check usability
967976
if !check.Usability.IsUsable() {
968977
reasons := strings.Join(check.Usability.UnusableReasons(), ",")
@@ -1097,9 +1106,10 @@ func performContractFormations(ctx *mCtx, bus Bus, w Worker, cr contractReviser,
10971106
usedHosts[c.HostKey] = struct{}{}
10981107
}
10991108
allHosts, err := bus.SearchHosts(ctx, api.SearchHostOptions{
1109+
AutopilotID: ctx.ApID(),
11001110
Limit: -1,
11011111
FilterMode: api.HostFilterModeAllowed,
1102-
UsabilityMode: api.UsabilityFilterModeAll,
1112+
UsabilityMode: api.UsabilityFilterModeUsable,
11031113
})
11041114
if err != nil {
11051115
return nil, fmt.Errorf("failed to fetch usable hosts: %w", err)

bus/routes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ func (b *Bus) walletOutputsHandler(jc jape.Context) {
376376
elements := make([]api.SiacoinElement, len(utxos))
377377
for i, sce := range utxos {
378378
elements[i] = api.SiacoinElement{
379-
ID: sce.StateElement.ID,
379+
ID: sce.ID,
380380
SiacoinOutput: types.SiacoinOutput{
381381
Value: sce.SiacoinOutput.Value,
382382
Address: sce.SiacoinOutput.Address,

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ require (
1414
github.com/mattn/go-sqlite3 v1.14.24
1515
github.com/montanaflynn/stats v0.7.1
1616
github.com/shopspring/decimal v1.4.0
17-
go.sia.tech/core v0.4.8-0.20240926222149-2c8b541119dc
18-
go.sia.tech/coreutils v0.4.1
17+
go.sia.tech/core v0.6.1
18+
go.sia.tech/coreutils v0.6.0
1919
go.sia.tech/gofakes3 v0.0.5
20-
go.sia.tech/hostd v1.1.3-0.20241022083902-7d61fc09be7c
20+
go.sia.tech/hostd v1.1.3-0.20241101150257-8319b75af8b2
2121
go.sia.tech/jape v0.12.1
2222
go.sia.tech/mux v1.3.0
2323
go.sia.tech/web/renterd v0.61.0

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
5555
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
5656
go.etcd.io/bbolt v1.3.11 h1:yGEzV1wPz2yVCLsD8ZAiGHhHVlczyC9d1rP43/VCRJ0=
5757
go.etcd.io/bbolt v1.3.11/go.mod h1:dksAq7YMXoljX0xu6VF5DMZGbhYYoLUalEiSySYAS4I=
58-
go.sia.tech/core v0.4.8-0.20240926222149-2c8b541119dc h1:+hCcYky+23HtiAnirXsq0U/NaCt1WuIu308lmfTtJNM=
59-
go.sia.tech/core v0.4.8-0.20240926222149-2c8b541119dc/go.mod h1:j2Ke8ihV8or7d2VDrFZWcCkwSVHO0DNMQJAGs9Qop2M=
60-
go.sia.tech/coreutils v0.4.1 h1:ExQ9g6EtnFe70ptNBG+OtZyFU3aBoEzE/06rtbN6f4c=
61-
go.sia.tech/coreutils v0.4.1/go.mod h1:v60kPqZERsb1ZS0PVe4S8hr2ArNEwTdp7XTzErXnV2U=
58+
go.sia.tech/core v0.6.1 h1:eaExM2E2eNr43su2XDkY5J24E3F54YGS7hcC3WtVjVk=
59+
go.sia.tech/core v0.6.1/go.mod h1:P3C1BWa/7J4XgdzWuaYHBvLo2RzZ0UBaJM4TG1GWB2g=
60+
go.sia.tech/coreutils v0.6.0 h1:r0IZt+aVdGG2uIHl7OtaWRYdVx4NQ7ezRoSGa0Ej8GY=
61+
go.sia.tech/coreutils v0.6.0/go.mod h1:XlsnogeYU/Tdjzp/HUNAj5T7tZCdmeBHIBjymbPC+uQ=
6262
go.sia.tech/gofakes3 v0.0.5 h1:vFhVBUFbKE9ZplvLE2w4TQxFMQyF8qvgxV4TaTph+Vw=
6363
go.sia.tech/gofakes3 v0.0.5/go.mod h1:LXEzwGw+OHysWLmagleCttX93cJZlT9rBu/icOZjQ54=
64-
go.sia.tech/hostd v1.1.3-0.20241022083902-7d61fc09be7c h1:oGRzqksT2MFoS4SvkrGbUG1LXNbnmv2KBzzv8uf0R4E=
65-
go.sia.tech/hostd v1.1.3-0.20241022083902-7d61fc09be7c/go.mod h1:EIuirLN/+714h+XaIpnJkU2BFdX/JF6Q1VXhX4N5sbc=
64+
go.sia.tech/hostd v1.1.3-0.20241101150257-8319b75af8b2 h1:6fogOsOr7efjeDHCO0mqIibEa5cOagSSo3JXe1fuifM=
65+
go.sia.tech/hostd v1.1.3-0.20241101150257-8319b75af8b2/go.mod h1:096sIYupHRUGkVyAe6i511la7wQo5LfRHGNUSMIKcT4=
6666
go.sia.tech/jape v0.12.1 h1:xr+o9V8FO8ScRqbSaqYf9bjj1UJ2eipZuNcI1nYousU=
6767
go.sia.tech/jape v0.12.1/go.mod h1:wU+h6Wh5olDjkPXjF0tbZ1GDgoZ6VTi4naFw91yyWC4=
6868
go.sia.tech/mux v1.3.0 h1:hgR34IEkqvfBKUJkAzGi31OADeW2y7D6Bmy/Jcbop9c=

internal/sql/migrations.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,12 @@ var (
288288
return performMigration(ctx, tx, migrationsFs, dbIdentifier, "00018_directory_buckets_2", log)
289289
},
290290
},
291+
{
292+
ID: "00019_scan_reset",
293+
Migrate: func(tx Tx) error {
294+
return performMigration(ctx, tx, migrationsFs, dbIdentifier, "00019_scan_reset", log)
295+
},
296+
},
291297
}
292298
}
293299
MetricsMigrations = func(ctx context.Context, migrationsFs embed.FS, log *zap.SugaredLogger) []Migration {

internal/worker/accounts.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,6 @@ func (a *AccountMgr) refillAccounts() {
351351

352352
if err != nil && shouldLog {
353353
a.logger.Error("failed to refill account for host", zap.Stringer("hostKey", contract.HostKey), zap.Error(err))
354-
} else {
355-
a.logger.Infow("successfully refilled account for host", zap.Stringer("hostKey", contract.HostKey), zap.Error(err))
356354
}
357355
}(c)
358356
}
@@ -409,6 +407,7 @@ func (a *AccountMgr) refillAccount(ctx context.Context, contract api.ContractMet
409407
if err != nil {
410408
return fmt.Errorf("failed to fund account: %w", err)
411409
}
410+
a.logger.Infow("successfully refilled account for host", zap.Stringer("hostKey", contract.HostKey), zap.Error(err))
412411
return nil
413412
}
414413

renterd

-29.3 MB
Binary file not shown.

stores/sql/chain.go

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88

99
"go.sia.tech/core/types"
10+
"go.sia.tech/coreutils/wallet"
1011
"go.sia.tech/renterd/api"
1112
"go.sia.tech/renterd/internal/sql"
1213
"go.uber.org/zap"
@@ -138,12 +139,16 @@ func UpdateFailedContracts(ctx context.Context, tx sql.Tx, blockHeight uint64, l
138139
return nil
139140
}
140141

141-
func UpdateWalletStateElements(ctx context.Context, tx sql.Tx, elements []types.StateElement) error {
142-
if len(elements) == 0 {
143-
return nil
142+
func UpdateWalletSiacoinElementProofs(ctx context.Context, tx sql.Tx, updater wallet.ProofUpdater) error {
143+
elements, err := walletStateElements(ctx, tx)
144+
if err != nil {
145+
return fmt.Errorf("failed to get wallet state elements: %w", err)
146+
}
147+
for i := range elements {
148+
updater.UpdateElementProof(&elements[i].StateElement)
144149
}
145150

146-
updateStmt, err := tx.Prepare(ctx, "UPDATE wallet_outputs SET leaf_index = ?, merkle_proof= ? WHERE output_id = ?")
151+
updateStmt, err := tx.Prepare(ctx, "UPDATE wallet_outputs SET leaf_index = ?, merkle_proof = ? WHERE output_id = ?")
147152
if err != nil {
148153
return fmt.Errorf("failed to prepare statement to update state elements: %w", err)
149154
}
@@ -154,28 +159,9 @@ func UpdateWalletStateElements(ctx context.Context, tx sql.Tx, elements []types.
154159
return fmt.Errorf("failed to update state element '%v': %w", el.ID, err)
155160
}
156161
}
157-
158162
return nil
159163
}
160164

161-
func WalletStateElements(ctx context.Context, tx sql.Tx) ([]types.StateElement, error) {
162-
rows, err := tx.Query(ctx, "SELECT output_id, leaf_index, merkle_proof FROM wallet_outputs")
163-
if err != nil {
164-
return nil, fmt.Errorf("failed to fetch state elements: %w", err)
165-
}
166-
defer rows.Close()
167-
168-
var elements []types.StateElement
169-
for rows.Next() {
170-
if el, err := scanStateElement(rows); err != nil {
171-
return nil, fmt.Errorf("failed to scan state element: %w", err)
172-
} else {
173-
elements = append(elements, el)
174-
}
175-
}
176-
return elements, nil
177-
}
178-
179165
func contractNotFoundErr(fcid types.FileContractID) error {
180166
return fmt.Errorf("%w: %v", api.ErrContractNotFound, fcid)
181167
}
@@ -224,3 +210,26 @@ func updateContractState(ctx context.Context, tx sql.Tx, table string, fcid type
224210
}
225211
return n == 1, nil
226212
}
213+
214+
type stateElement struct {
215+
ID types.Hash256
216+
types.StateElement
217+
}
218+
219+
func walletStateElements(ctx context.Context, tx sql.Tx) ([]stateElement, error) {
220+
rows, err := tx.Query(ctx, "SELECT output_id, leaf_index, merkle_proof FROM wallet_outputs")
221+
if err != nil {
222+
return nil, fmt.Errorf("failed to fetch state elements: %w", err)
223+
}
224+
defer rows.Close()
225+
226+
var elements []stateElement
227+
for rows.Next() {
228+
if el, err := scanStateElement(rows); err != nil {
229+
return nil, fmt.Errorf("failed to scan state element: %w", err)
230+
} else {
231+
elements = append(elements, el)
232+
}
233+
}
234+
return elements, nil
235+
}

stores/sql/main.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2698,8 +2698,8 @@ func scanSiacoinElement(s Scanner) (el types.SiacoinElement, err error) {
26982698
return types.SiacoinElement{}, err
26992699
}
27002700
return types.SiacoinElement{
2701+
ID: types.SiacoinOutputID(id),
27012702
StateElement: types.StateElement{
2702-
ID: types.Hash256(id),
27032703
LeafIndex: leafIndex,
27042704
MerkleProof: merkleProof.Hashes,
27052705
},
@@ -2711,17 +2711,19 @@ func scanSiacoinElement(s Scanner) (el types.SiacoinElement, err error) {
27112711
}, nil
27122712
}
27132713

2714-
func scanStateElement(s Scanner) (types.StateElement, error) {
2714+
func scanStateElement(s Scanner) (stateElement, error) {
27152715
var id Hash256
27162716
var leafIndex uint64
27172717
var merkleProof MerkleProof
27182718
if err := s.Scan(&id, &leafIndex, &merkleProof); err != nil {
2719-
return types.StateElement{}, err
2719+
return stateElement{}, err
27202720
}
2721-
return types.StateElement{
2722-
ID: types.Hash256(id),
2723-
LeafIndex: leafIndex,
2724-
MerkleProof: merkleProof.Hashes,
2721+
return stateElement{
2722+
ID: types.Hash256(id),
2723+
StateElement: types.StateElement{
2724+
LeafIndex: leafIndex,
2725+
MerkleProof: merkleProof.Hashes,
2726+
},
27252727
}, nil
27262728
}
27272729

stores/sql/mysql/chain.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,6 @@ func (c chainUpdateTx) UpdateHost(hk types.PublicKey, ha chain.HostAnnouncement,
330330
return nil
331331
}
332332

333-
func (c chainUpdateTx) UpdateWalletStateElements(elements []types.StateElement) error {
334-
return ssql.UpdateWalletStateElements(c.ctx, c.tx, elements)
335-
}
336-
337-
func (c chainUpdateTx) WalletStateElements() ([]types.StateElement, error) {
338-
return ssql.WalletStateElements(c.ctx, c.tx)
333+
func (c chainUpdateTx) UpdateWalletSiacoinElementProofs(pu wallet.ProofUpdater) error {
334+
return ssql.UpdateWalletSiacoinElementProofs(c.ctx, c.tx, pu)
339335
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
UPDATE hosts SET settings = '{}', price_table = '{}', last_scan = 0, last_scan_success = 0, second_to_last_scan_success = 0, scanned = 0 WHERE 1=1;

stores/sql/sqlite/chain.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,6 @@ func (c chainUpdateTx) UpdateHost(hk types.PublicKey, ha chain.HostAnnouncement,
342342
return nil
343343
}
344344

345-
func (c chainUpdateTx) UpdateWalletStateElements(elements []types.StateElement) error {
346-
return ssql.UpdateWalletStateElements(c.ctx, c.tx, elements)
347-
}
348-
349-
func (c chainUpdateTx) WalletStateElements() ([]types.StateElement, error) {
350-
return ssql.WalletStateElements(c.ctx, c.tx)
345+
func (c chainUpdateTx) UpdateWalletSiacoinElementProofs(pu wallet.ProofUpdater) error {
346+
return ssql.UpdateWalletSiacoinElementProofs(c.ctx, c.tx, pu)
351347
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
UPDATE hosts SET settings = '{}', price_table = '{}', last_scan = 0, last_scan_success = 0, second_to_last_scan_success = 0, scanned = 0 WHERE 1=1;

stores/sql/types.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,13 @@ func (h Hash256) Value() (driver.Value, error) {
195195

196196
// Scan scan value into HostSettings, implements sql.Scanner interface.
197197
func (hs *HostSettings) Scan(value interface{}) error {
198-
bytes, ok := value.([]byte)
199-
if !ok {
198+
var bytes []byte
199+
switch value := value.(type) {
200+
case string:
201+
bytes = []byte(value)
202+
case []byte:
203+
bytes = value
204+
default:
200205
return errors.New(fmt.Sprint("failed to unmarshal Settings value:", value))
201206
}
202207
return json.Unmarshal(bytes, hs)
@@ -212,8 +217,13 @@ func (hs HostSettings) Value() (driver.Value, error) {
212217

213218
// Scan scan value into PriceTable, implements sql.Scanner interface.
214219
func (pt *PriceTable) Scan(value interface{}) error {
215-
bytes, ok := value.([]byte)
216-
if !ok {
220+
var bytes []byte
221+
switch value := value.(type) {
222+
case string:
223+
bytes = []byte(value)
224+
case []byte:
225+
bytes = value
226+
default:
217227
return errors.New(fmt.Sprint("failed to unmarshal PriceTable value:", value))
218228
}
219229
return json.Unmarshal(bytes, pt)

0 commit comments

Comments
 (0)