node/policy: --min-lease-cost / --max-lease-cost are documented in whole XUSD but compared against micro-XUSD amounts; the floor never fires and any realistic cap rejects every lease (Medium)
Report
Payout address: ead8ad792b4452de17e897155ed6efe9f928d0c8b07bdf6a9cbf4f4d67941dd2
Suggested severity: Medium (validation gap with real effect on provider economics: the documented cost policy is silently off by 10^6; one direction never fires, the other rejects every real lease). Minor if you treat it as a CLI/docs defect only.
Area: node/policy.go (LeaseAcceptPolicy.Allow), cmd/xe/main.go (--min-lease-cost, --max-lease-cost)
Version: master @ 9787859; the code is unchanged at HEAD as far as I can see in node/policy.go
Network: testnet-0005 (unit-test reproduction, no network interaction)
Summary
The provider accept policy takes its cost bounds in whole XUSD:
cmd/xe/main.go:1309-1310:--min-lease-cost/--max-lease-cost— "Reject leases below/above this cost in whole XUSD. 0 = no min/max."- docs (
/docs/compute→ Provider Policy): "--min-lease-cost— minimum cost in whole XUSD (uint64)".
But LeaseAcceptPolicy.Allow compares them directly against b.Amount, which (like every amount on the wire) is in micro-XUSD (1 XUSD = 1,000,000 µXUSD):
// node/policy.go
if p.MinCostXUSD > 0 && b.Amount < p.MinCostXUSD { ... } // whole XUSD vs µXUSD
if p.MaxCostXUSD > 0 && b.Amount > p.MaxCostXUSD { ... }
No conversion happens anywhere between the flag and the comparison (cmd/xe/main.go:1357-1358 copies the flag values straight into MinCostXUSD / MaxCostXUSD). The error message then prints the micro value with an "XUSD" label (cost 31000 XUSD > policy max 100 XUSD), which hides the mismatch from the operator.
Effect
Take a realistic lease, 1 vCPU / 1 GB / 1 GB for one hour at 1.0×: cost = 31,000 µXUSD = 0.031 XUSD.
| Operator sets | Intent | What happens |
|---|---|---|
--min-lease-cost 1 |
reject leases under 1 XUSD | Accepted. 31,000 > 1. The floor can only ever trigger on a lease priced below 1 µXUSD, which core.LeaseCost cannot produce (floor is 1 µXUSD; the cheapest legal lease is 9 µXUSD). The flag is dead. |
--max-lease-cost 100 |
accept leases up to 100 XUSD | Rejected as "cost 31000 XUSD > policy max 100 XUSD". Any cap below 1,000,000 rejects every lease that costs ≥ 1 XUSD-millionth… i.e. in practice everything. |
A provider who sets a sane-looking --max-lease-cost simply stops accepting leases, and the log tells them the lease cost thirty-one thousand XUSD. A provider who sets --min-lease-cost to filter dust gets no filtering at all.
Reproduce (unit test, node package)
=== RUN TestPoC_PolicyCostUnits
poc_policy_units_test.go:17: --min-lease-cost 1 should reject a 0.031 XUSD lease, but it was ACCEPTED (compared 31000 µXUSD against 1)
poc_policy_units_test.go:23: --max-lease-cost 100 should accept a 0.031 XUSD lease, but it was REJECTED: cost 31000 XUSD > policy max 100 XUSD
--- FAIL: TestPoC_PolicyCostUnits (0.00s)
package node
import (
"testing"
"github.com/xeprotocol/xe/core"
)
func TestPoC_PolicyCostUnits(t *testing.T) {
lease := &core.Block{Type: core.BlockLease, Amount: 31_000, Duration: 3600} // 0.031 XUSD
if err := (LeaseAcceptPolicy{MinCostXUSD: 1}).Allow(lease, 0); err == nil {
t.Errorf("--min-lease-cost 1 should reject a 0.031 XUSD lease, but it was ACCEPTED")
}
if err := (LeaseAcceptPolicy{MaxCostXUSD: 100}).Allow(lease, 0); err != nil {
t.Errorf("--max-lease-cost 100 should accept a 0.031 XUSD lease, but it was REJECTED: %v", err)
}
}
Run: GOTOOLCHAIN=go1.25.0 go test ./node/ -run TestPoC_PolicyCostUnits -v
Suggested fix
Pick one unit and make it consistent end to end:
- Convert at the boundary: in
cmd/xe/main.gomultiply the flags by1_000_000(corealready has the per-asset decimals; acore.ToMicro-style helper would avoid magic numbers), or rename the fields/flags toMinCostMicroXUSDand document them as micro-units. - Fix the error strings in
Allowto print the same unit they compare (%d µXUSD, or format viacore.FormatAmount). - Add a test like the one above to the
nodepackage so the units cannot drift again. - The same check should also run on
lease_renew(see #162), with the same units.
Related: #162 (policy not applied to renewals) is a different bug in the same code; this one is about the units of the comparison itself.
Thread
Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the first verifiable submission, so this one closes as a duplicate. If you believe it is a different bug, file a new report that links https://bounty.xe.network/XE-13244 and says what differs; it is read like any other.