-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1822 - Per-Peer Transaction Rules #1891
Conversation
…eer-transaction-rules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to have both per-block and per-peer-per-block limits
Hey @kushti , I reverted the interblock cost changes. It now considers both Interblock and Per-Peer costs. Not sure what to set the per-peer block limit to though. |
…eer-transaction-rules
|
||
//TODO peer should always be set? Throw exception? | ||
val peer = processingResult.transaction.source.get | ||
val peerTxInfo = txInfo(peer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exception can be thrown here if txInfo has no a record for peer
@@ -179,17 +189,35 @@ class ErgoNodeViewSynchronizer(networkControllerRef: ActorRef, | |||
// should not be here, and so ReserveCostValue should not be used | |||
log.warn("Cost is empty in processMempoolResult") | |||
} | |||
|
|||
//TODO peer should always be set? Throw exception? | |||
val peer = processingResult.transaction.source.get |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
source can be empty if transaction is submitted via local API. In this case we need to skip txInfo update.
case _: DeclinedTransaction => interblockCost.copy(declinedCost = interblockCost.declinedCost + cost) | ||
case _: FailedTransaction => { | ||
interblockCost.copy(invalidatedCost = interblockCost.invalidatedCost + cost) | ||
peerTxInfo.copy(invalidatedCost = peerTxInfo.invalidatedCost + cost) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ng would be peer-related in this branch, and others also
case _: DeclinedTransaction => { | ||
interblockCost.copy(declinedCost = interblockCost.declinedCost + cost) | ||
peerTxInfo.copy(declinedCost = peerTxInfo.declinedCost + cost) | ||
} | ||
} | ||
|
||
log.debug(s"Old global cost info: $interblockCost, new $ng, tx processing cache size: ${txProcessingCache.size}") | ||
interblockCost = ng |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but then you put ng into interblock (all peers) data
…ergoplatform/ergo into 1822-per-peer-transaction-rules
/** | ||
* Max cost of per-peer transactions we are going to process between blocks | ||
*/ | ||
private val MempoolPeerCostPerBlock = 12000000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be lowered (or configurable?) I assume.
if (interblockCost.totalCost < MempoolCostPerBlock) { | ||
if ((peerOpt.isDefined && | ||
perPeerCost.getOrElse(peerOpt.get, IncomingTxInfo.empty()).totalCost < MempoolPeerCostPerBlock) || | ||
interblockCost.totalCost < MempoolCostPerBlock) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perPeerCost.getOrElse
may be a bit overkill here as the perPeerCost(peer) should always be set at this point when the peer is defined. But I figured it's better to continue gracefully in case of any edge cases.
val peerCost = perPeerCost.getOrElse(remote, IncomingTxInfo.empty()).totalCost | ||
|
||
val (toProcess, toPutIntoCache) = | ||
if (peerCost < MempoolPeerCostPerBlock || interblockCost.totalCost < MempoolCostPerBlock) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be && instead of ||...updating.
…eer-transaction-rules
#1822