diff --git a/bus/routes.go b/bus/routes.go index a9fe9df99..b207c1bc0 100644 --- a/bus/routes.go +++ b/bus/routes.go @@ -82,19 +82,15 @@ func (b *Bus) accountsFundHandler(jc jape.Context) { return } - // check price table for gouging - gp, err := b.gougingParams(jc.Request.Context()) - if jc.Check("failed to fetch gouging params", err) != nil { - return - } - gc := gouging.NewChecker(gp.GougingSettings, gp.ConsensusState, gp.TransactionFee, nil, nil) - if jc.Check("gouging check failed", gc.CheckUnusedDefaults(pt.HostPriceTable)) != nil { + // check only the FundAccountCost + if types.NewCurrency64(1).Cmp(pt.FundAccountCost) < 0 { + jc.Error(fmt.Errorf("%w: host is gouging on FundAccountCost", gouging.ErrPriceTableGouging), http.StatusServiceUnavailable) return } // cap the deposit by what's left in the contract deposit := req.Amount - cost := types.NewCurrency64(1) + cost := pt.FundAccountCost availableFunds := rev.ValidRenterPayout().Sub(cost) if deposit.Cmp(availableFunds) > 0 { deposit = availableFunds diff --git a/internal/rhp/v3/rhp.go b/internal/rhp/v3/rhp.go index 44d4c91bc..c723d4117 100644 --- a/internal/rhp/v3/rhp.go +++ b/internal/rhp/v3/rhp.go @@ -167,13 +167,13 @@ func (c *Client) Renew(ctx context.Context, gc gouging.Checker, rev types.FileCo return } -func (c *Client) SyncAccount(ctx context.Context, rev *types.FileContractRevision, hk types.PublicKey, siamuxAddr string, accID rhpv3.Account, pt rhpv3.SettingsID, rk types.PrivateKey) (balance types.Currency, _ error) { +func (c *Client) SyncAccount(ctx context.Context, rev *types.FileContractRevision, hk types.PublicKey, siamuxAddr string, accID rhpv3.Account, pt rhpv3.HostPriceTable, rk types.PrivateKey) (balance types.Currency, _ error) { return balance, c.tpool.withTransport(ctx, hk, siamuxAddr, func(ctx context.Context, t *transportV3) error { - payment, err := payByContract(rev, types.NewCurrency64(1), accID, rk) + payment, err := payByContract(rev, pt.AccountBalanceCost, accID, rk) if err != nil { return err } - balance, err = rpcAccountBalance(ctx, t, &payment, accID, pt) + balance, err = rpcAccountBalance(ctx, t, &payment, accID, pt.UID) return err }) } diff --git a/internal/test/e2e/cluster_test.go b/internal/test/e2e/cluster_test.go index 9a801ce43..ec4bfabd4 100644 --- a/internal/test/e2e/cluster_test.go +++ b/internal/test/e2e/cluster_test.go @@ -1384,7 +1384,7 @@ func TestEphemeralAccountSync(t *testing.T) { if len(accounts) != 1 || accounts[0].ID != acc.ID { t.Fatal("account should exist") } else if accounts[0].CleanShutdown || !accounts[0].RequiresSync { - t.Fatalf("account shouldn't be marked as clean shutdown or not require a sync, got %v", accounts[0].CleanShutdown, accounts[0].RequiresSync) + t.Fatal("account shouldn't be marked as clean shutdown or not require a sync, got", accounts[0].CleanShutdown, accounts[0].RequiresSync) } // assert account was funded diff --git a/worker/host.go b/worker/host.go index b5bbb71b7..40695f8b0 100644 --- a/worker/host.go +++ b/worker/host.go @@ -214,16 +214,13 @@ func (h *host) SyncAccount(ctx context.Context, rev *types.FileContractRevision) return err } - // check only the unused defaults - gc, err := GougingCheckerFromContext(ctx, false) - if err != nil { - return err - } else if err := gc.CheckUnusedDefaults(pt.HostPriceTable); err != nil { - return fmt.Errorf("%w: %v", gouging.ErrPriceTableGouging, err) + // check only the AccountBalanceCost + if types.NewCurrency64(1).Cmp(pt.AccountBalanceCost) < 0 { + return fmt.Errorf("%w: host is gouging on AccountBalanceCost", gouging.ErrPriceTableGouging) } return h.acc.WithSync(func() (types.Currency, error) { - return h.client.SyncAccount(ctx, rev, h.hk, h.siamuxAddr, h.acc.ID(), pt.UID, h.renterKey) + return h.client.SyncAccount(ctx, rev, h.hk, h.siamuxAddr, h.acc.ID(), pt.HostPriceTable, h.renterKey) }) }