From 849abf5e53955bb9703cfe55314bb3f9d85da6d9 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 13 Dec 2024 09:42:42 -0800 Subject: [PATCH] chore: update core and coreutils --- cmd/hostd/run.go | 2 +- go.mod | 4 ++-- go.sum | 8 ++++---- host/contracts/lock.go | 12 ++++++++++-- internal/testutil/testutil.go | 12 ++++++------ 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/cmd/hostd/run.go b/cmd/hostd/run.go index 6b1ddb00..41c445dc 100644 --- a/cmd/hostd/run.go +++ b/cmd/hostd/run.go @@ -357,7 +357,7 @@ func runRootCmd(ctx context.Context, cfg config.Config, walletKey types.PrivateK go rhp3.Serve() defer rhp3.Close() - rhp4 := rhp4.NewServer(hostKey, cm, s, contractManager, wm, sm, vm, rhp4.WithPriceTableValidity(30*time.Minute), rhp4.WithContractProofWindowBuffer(72)) + rhp4 := rhp4.NewServer(hostKey, cm, s, contractManager, wm, sm, vm, rhp4.WithPriceTableValidity(30*time.Minute)) var stopListenerFuncs []func() error defer func() { diff --git a/go.mod b/go.mod index d44d7aad..ca7f494a 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.7.1 - go.sia.tech/coreutils v0.7.1-0.20241203172514-7bf95dd18f31 + go.sia.tech/core v0.8.0 + go.sia.tech/coreutils v0.8.0 go.sia.tech/jape v0.12.1 go.sia.tech/mux v1.3.0 go.sia.tech/web/hostd v0.52.0 diff --git a/go.sum b/go.sum index 43da0c93..66a854c6 100644 --- a/go.sum +++ b/go.sum @@ -40,10 +40,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.1 h1:PrKh19Ql5vJbQbB5YGtTHQ8W3fRF8hhYnR4kPOIOIME= -go.sia.tech/core v0.7.1/go.mod h1:gB8iXFJFSV8XIHRaL00CL6Be+hyykB+SYnvRPHCCc/E= -go.sia.tech/coreutils v0.7.1-0.20241203172514-7bf95dd18f31 h1:Qskaf8d6oDKG5emNvGHZsd9iZRqz2GeouVNKY5paXlE= -go.sia.tech/coreutils v0.7.1-0.20241203172514-7bf95dd18f31/go.mod h1:d6jrawloc02MCXi/EVc8FIN5h3C6XDiMs4fuFMcU0PU= +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/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= diff --git a/host/contracts/lock.go b/host/contracts/lock.go index 86f9850b..e8819138 100644 --- a/host/contracts/lock.go +++ b/host/contracts/lock.go @@ -129,9 +129,17 @@ func (cm *Manager) LockV2Contract(id types.FileContractID) (rev rhp4.RevisionSta return rhp4.RevisionState{}, nil, fmt.Errorf("failed to get contract: %w", err) } + renewed := contract.RenewedTo != (types.FileContractID{}) + var maxRevisionHeight uint64 + if contract.ProofHeight > cm.revisionSubmissionBuffer { + maxRevisionHeight = contract.ProofHeight - cm.revisionSubmissionBuffer + } + revisable := !renewed && cm.chain.Tip().Height < maxRevisionHeight return rhp4.RevisionState{ - Revision: contract.V2FileContract, - Roots: cm.getSectorRoots(id), + Revision: contract.V2FileContract, + Renewed: contract.RenewedTo != (types.FileContractID{}), + Revisable: revisable, + Roots: cm.getSectorRoots(id), }, func() { cm.locks.Unlock(id) }, nil diff --git a/internal/testutil/testutil.go b/internal/testutil/testutil.go index 79ce43b1..ff0e25b7 100644 --- a/internal/testutil/testutil.go +++ b/internal/testutil/testutil.go @@ -62,7 +62,7 @@ func V2Network() (*consensus.Network, types.Block) { } // WaitForSync is a helper to wait for the chain and indexer to sync -func WaitForSync(t *testing.T, cm *chain.Manager, idx *index.Manager) { +func WaitForSync(t testing.TB, cm *chain.Manager, idx *index.Manager) { t.Helper() for { @@ -74,7 +74,7 @@ func WaitForSync(t *testing.T, cm *chain.Manager, idx *index.Manager) { } // MineBlocks is a helper to mine blocks and broadcast the headers -func MineBlocks(t *testing.T, cn *ConsensusNode, addr types.Address, n int) { +func MineBlocks(t testing.TB, cn *ConsensusNode, addr types.Address, n int) { t.Helper() for i := 0; i < n; i++ { @@ -95,7 +95,7 @@ func MineBlocks(t *testing.T, cn *ConsensusNode, addr types.Address, n int) { // MineAndSync is a helper to mine blocks and wait for the index to catch up // between each block -func MineAndSync(t *testing.T, hn *HostNode, addr types.Address, n int) { +func MineAndSync(t testing.TB, hn *HostNode, addr types.Address, n int) { t.Helper() for i := 0; i < n; i++ { @@ -106,7 +106,7 @@ func MineAndSync(t *testing.T, hn *HostNode, addr types.Address, n int) { // NewConsensusNode initializes all of the consensus components and returns them. // The function will clean up all resources when the test is done. -func NewConsensusNode(t *testing.T, network *consensus.Network, genesis types.Block, log *zap.Logger) *ConsensusNode { +func NewConsensusNode(t testing.TB, network *consensus.Network, genesis types.Block, log *zap.Logger) *ConsensusNode { t.Helper() dir := t.TempDir() @@ -156,7 +156,7 @@ func NewConsensusNode(t *testing.T, network *consensus.Network, genesis types.Bl // NewHostNode initializes all of the hostd components and returns them. The function // will clean up all resources when the test is done. -func NewHostNode(t *testing.T, pk types.PrivateKey, network *consensus.Network, genesis types.Block, log *zap.Logger) *HostNode { +func NewHostNode(t testing.TB, pk types.PrivateKey, network *consensus.Network, genesis types.Block, log *zap.Logger) *HostNode { t.Helper() cn := NewConsensusNode(t, network, genesis, log) @@ -181,7 +181,7 @@ func NewHostNode(t *testing.T, pk types.PrivateKey, network *consensus.Network, initialSettings := settings.DefaultSettings initialSettings.AcceptingContracts = true - initialSettings.NetAddress = "127.0.0.1:9981" + initialSettings.NetAddress = "127.0.0.1" initialSettings.WindowSize = 10 sm, err := settings.NewConfigManager(pk, cn.Store, cn.Chain, cn.Syncer, vm, wm, settings.WithAnnounceInterval(10), settings.WithValidateNetAddress(false), settings.WithInitialSettings(initialSettings)) if err != nil {