Skip to content

Commit

Permalink
Merge branch 'chris/refactor-contract-updates' into chris/transition-…
Browse files Browse the repository at this point in the history
…test
  • Loading branch information
ChrisSchinnerl authored Dec 16, 2024
2 parents 8d8fe9c + 43ad7d8 commit 1618443
Show file tree
Hide file tree
Showing 8 changed files with 1,679 additions and 116 deletions.
12 changes: 12 additions & 0 deletions .changeset/extend_openapi_spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
default: major
---

# Extend OpenAPI spec

The following routes were added:
- consensus
- contracts
- syncer
- txpool
- wallet
4 changes: 2 additions & 2 deletions bus/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func (b *Bus) consensusStateHandler(jc jape.Context) {
}

func (b *Bus) consensusNetworkHandler(jc jape.Context) {
jc.Encode(*b.cm.TipState().Network)
jc.Encode(b.cm.TipState().Network)
}

func (b *Bus) postSystemSQLite3BackupHandler(jc jape.Context) {
Expand Down Expand Up @@ -787,7 +787,7 @@ func (b *Bus) contractsHandlerGET(jc jape.Context) {
case api.ContractFilterModeArchived:
case api.ContractFilterModeGood:
default:
jc.Error(fmt.Errorf("invalid filter mode: '%v'", filterMode), http.StatusBadRequest)
jc.Error(fmt.Errorf("invalid filter mode '%v', must be one of [active, archived, all, good]", filterMode), http.StatusBadRequest)
return
}

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ require (
github.com/mattn/go-sqlite3 v1.14.24
github.com/montanaflynn/stats v0.7.1
github.com/shopspring/decimal v1.4.0
go.sia.tech/core v0.7.2-0.20241210224920-0534a5928ddb
go.sia.tech/coreutils v0.7.1-0.20241211045514-6881993d8806
go.sia.tech/core v0.8.0
go.sia.tech/coreutils v0.8.0
go.sia.tech/gofakes3 v0.0.5
go.sia.tech/hostd v1.1.3-0.20241212215223-9e3440475bed
go.sia.tech/jape v0.12.1
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
github.com/stretchr/testify v1.10.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.7.2-0.20241210224920-0534a5928ddb h1:JHX+qWKS9sAXmEroICAu2jPQkr3CYUF7iWd/zlATsBM=
go.sia.tech/core v0.7.2-0.20241210224920-0534a5928ddb/go.mod h1:tM9tPD+1jp8d+dqVpX6idTyv5RpI0GEh5L5SyuOpqlc=
go.sia.tech/coreutils v0.7.1-0.20241211045514-6881993d8806 h1:zmLtpmFQPKMukYMiQByZzOODvMshriyLhK12BnIsmU8=
go.sia.tech/coreutils v0.7.1-0.20241211045514-6881993d8806/go.mod h1:6z3oHrQqcLoFEAT/l6XnvOivEGXgIfWBKcq0OqsouWA=
go.sia.tech/core v0.8.0 h1:J6vZQlVhpj4bTVeuC2GKkfkGEs8jf0j651Kl1wwOxjg=
go.sia.tech/core v0.8.0/go.mod h1:Wj1qzvpMM2rqEQjwWJEbCBbe9VWX/mSJUu2Y2ABl1QA=
go.sia.tech/coreutils v0.8.0 h1:1dcl0vxY+MBgAdJ7PdewAr8RkZJn4/6wAKEZfi4iYn0=
go.sia.tech/coreutils v0.8.0/go.mod h1:ml5MefDMWCvPKNeRVIGHmyF5tv27C9h1PiI/iOiTGLg=
go.sia.tech/gofakes3 v0.0.5 h1:vFhVBUFbKE9ZplvLE2w4TQxFMQyF8qvgxV4TaTph+Vw=
go.sia.tech/gofakes3 v0.0.5/go.mod h1:LXEzwGw+OHysWLmagleCttX93cJZlT9rBu/icOZjQ54=
go.sia.tech/hostd v1.1.3-0.20241212215223-9e3440475bed h1:C42AxWwwoP13EhZsdWwR17Rc9S7gXI4JnRN0AyZRxc8=
Expand Down
5 changes: 3 additions & 2 deletions internal/rhp/v4/rhp.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ func (c *Client) FundAccounts(ctx context.Context, hk types.PublicKey, hostIP st

// LatestRevision returns the latest revision of a contract.
func (c *Client) LatestRevision(ctx context.Context, hk types.PublicKey, addr string, contractID types.FileContractID) (revision types.V2FileContract, _ error) {
err := c.tpool.withTransport(ctx, hk, addr, func(c rhp.TransportClient) (err error) {
revision, err = rhp.RPCLatestRevision(ctx, c, contractID)
err := c.tpool.withTransport(ctx, hk, addr, func(c rhp.TransportClient) error {
res, err := rhp.RPCLatestRevision(ctx, c, contractID)
revision = res.Contract
return err
})
return revision, err
Expand Down
8 changes: 7 additions & 1 deletion internal/test/e2e/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,13 @@ func (tc *TestCluster) ContractRoots(ctx context.Context, fcid types.FileContrac
if h == nil {
return nil, fmt.Errorf("no host found for contract %v", c)
}
return h.contracts.SectorRoots(fcid), nil
var roots []types.Hash256
state, unlock, err := h.contractsV2.LockV2Contract(fcid)
if err == nil {
roots = append(roots, state.Roots...)
defer unlock()
}
return append(roots, h.contracts.SectorRoots(fcid)...), nil
}

func (tc *TestCluster) IsPassedV2AllowHeight() bool {
Expand Down
38 changes: 21 additions & 17 deletions internal/test/e2e/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"go.sia.tech/coreutils/chain"
rhp4 "go.sia.tech/coreutils/rhp/v4"
"go.sia.tech/coreutils/syncer"
"go.sia.tech/coreutils/testutil"
"go.sia.tech/coreutils/wallet"
"go.sia.tech/hostd/host/accounts"
"go.sia.tech/hostd/host/contracts"
Expand Down Expand Up @@ -111,14 +112,15 @@ type Host struct {
s *syncer.Syncer
syncerCancel context.CancelFunc

store *sqlite.Store
wallet *wallet.SingleAddressWallet
settings *settings.ConfigManager
storage *storage.VolumeManager
index *index.Manager
registry *registry.Manager
accounts *accounts.AccountManager
contracts *contracts.Manager
store *sqlite.Store
wallet *wallet.SingleAddressWallet
settings *settings.ConfigManager
storage *storage.VolumeManager
index *index.Manager
registry *registry.Manager
accounts *accounts.AccountManager
contracts *contracts.Manager
contractsV2 *testutil.EphemeralContractor

rhpv2 *rhpv2.SessionHandler
rhpv3 *rhpv3.SessionHandler
Expand Down Expand Up @@ -307,7 +309,8 @@ func NewHost(privKey types.PrivateKey, cm *chain.Manager, dir string, network *c
rhpv3 := rhpv3.NewSessionHandler(rhp3Listener, privKey, cm, s, wallet, accounts, contracts, registry, storage, settings, log.Named("rhpv3"))
go rhpv3.Serve()

rhpv4 := rhp4.NewServer(privKey, cm, s, contracts, wallet, settings, storage, rhp4.WithPriceTableValidity(30*time.Minute), rhp4.WithContractProofWindowBuffer(1))
contractsV2 := testutil.NewEphemeralContractor(cm)
rhpv4 := rhp4.NewServer(privKey, cm, s, contractsV2, wallet, settings, storage, rhp4.WithPriceTableValidity(30*time.Minute))
go rhp.ServeRHP4SiaMux(rhp4Listener, rhpv4, log.Named("rhp4"))

return &Host{
Expand All @@ -317,14 +320,15 @@ func NewHost(privKey types.PrivateKey, cm *chain.Manager, dir string, network *c
s: s,
syncerCancel: syncerCancel,

store: db,
wallet: wallet,
settings: settings,
index: idx,
storage: storage,
registry: registry,
accounts: accounts,
contracts: contracts,
store: db,
wallet: wallet,
settings: settings,
index: idx,
storage: storage,
registry: registry,
accounts: accounts,
contracts: contracts,
contractsV2: contractsV2,

rhpv2: rhpv2,
rhpv3: rhpv3,
Expand Down
Loading

0 comments on commit 1618443

Please sign in to comment.