Skip to content

fix(pseudosettle): bound first-contact allowance to connection time#5531

Open
mfw78 wants to merge 1 commit into
ethersphere:masterfrom
nxm-rs:fix/pseudosettle-first-contact-allowance
Open

fix(pseudosettle): bound first-contact allowance to connection time#5531
mfw78 wants to merge 1 commit into
ethersphere:masterfrom
nxm-rs:fix/pseudosettle-first-contact-allowance

Conversation

@mfw78

@mfw78 mfw78 commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Checklist

  • I have read the coding guide.
  • My change requires a documentation update, and I have done it.
  • I have added tests to cover my changes.
  • I have filled out the description and linked the related issues.

Description

On first contact with a peer, the pseudosettle time-based allowance was anchored to the zero Unix epoch instead of the peer's connection time, so the first refreshment could forgive an effectively unbounded debt. peerAllowance computes the acceptable incoming payment as (now - lastSettlementTime) * refreshRate; with no stored settlement record lastSettlementTime defaulted to 0, making the allowance now * refreshRate.

This records the connection time per peer in init and anchors the first-contact allowance to it, so the initial refreshment only forgives debt accrued over the elapsed connected time. Subsequent settlements are unchanged.

Opened as a draft pending team consensus on #5530, per the contributing guide.

Open API Spec Version Changes (if applicable)

None.

Motivation and Context (Optional)

See #5530.

Related Issue (Optional)

Closes #5530.

Screenshots (if appropriate):

N/A

AI Disclosure

  • This PR contains code that has been generated by an LLM.
  • I have reviewed the AI generated code thoroughly.
  • I possess the technical expertise to responsibly review the code generated in this PR.

The time-based allowance a node grants an incoming refreshment is
computed as (now - lastSettlementTime) * refreshRate. On the first
refreshment from a peer there is no stored settlement time, so the
anchor defaulted to the zero Unix epoch, making the allowance
(now - 0) * refreshRate. This lets the very first refreshment forgive
an effectively unbounded debt, decoupled from how long the peer has
actually been connected.

Anchor the first-contact allowance to the peer's connection time
instead, so the initial refreshment only forgives debt accrued over
the elapsed connected time. Subsequent settlements are unchanged.
@mfw78 mfw78 marked this pull request as draft July 8, 2026 12:29
@mfw78 mfw78 marked this pull request as ready for review July 8, 2026 12:43
@gacevicljubisa

Copy link
Copy Markdown
Member

What about the payer side, should it match the peerAllowance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pseudosettle: first-contact allowance anchored to Unix epoch instead of connection time

2 participants