les, p2p/discv5: implement in-protocol payment#20341
Closed
zsfelfoldi wants to merge 25 commits intoethereum:masterfrom
Closed
les, p2p/discv5: implement in-protocol payment#20341zsfelfoldi wants to merge 25 commits intoethereum:masterfrom
zsfelfoldi wants to merge 25 commits intoethereum:masterfrom
Conversation
Member
There was a problem hiding this comment.
Please add the function description and relative unit tests.
Member
There was a problem hiding this comment.
func (bt *balanceTracker) budget(targetPriority int64, targetCapacity uint64, after time.Duration) uint64 {
current := bt.balanceToPriority(bt.balance)
if targetPriority >= current {
if bt.negTimeFactor == 0 {
return 0
}
diff := time.Duration(float64(targetPriority - current)/bt.negTimeFactor)
if diff >= after {
return 0
}
after -= diff
}
// We have to cover the connection expense by positive balance.
if targetPriority >= 0 {
targetPriority = -1
}
budget := uint64(float64(^targetPriority)*float64(targetCapacity) + float64(after)*bt.timeFactor)
if budget >= maxBalance {
return math.MaxUint64 // target not reachable
}
if budget > bt.balance.pos {
return budget - bt.balance.pos
}
return 0
}
Member
There was a problem hiding this comment.
Just open a question here. So we can only guarantee the idle connection by the budget. However request can also cost a lot. TBH I think request cost should be much higher than connection cost.
So should we consider the estimated request cost when we calculate the budget? Although we can never have a correct number.
Member
There was a problem hiding this comment.
Does it mean servers can only receive the UDP packet and then reply?
So in the following scenarios:
- Client should ask the current token price
- Client should ask the current balance to determine whether they need to buy more tokens for stable connection
Contributor
Author
|
Superseded by #20517 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a WIP PR for the in-protocol payment logic. Currently implemented features:
Coming soon: