-
Notifications
You must be signed in to change notification settings - Fork 48
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
feat(op-geth): support droppingTxHashes when sendBundle #240
base: develop
Are you sure you want to change the base?
Conversation
} | ||
wg.Wait() | ||
bundleGauge.Update(int64(len(p.bundles))) |
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.
do we need these 2 lines if we early return when len(p.bundles) == 0?
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.
Added.
core/txpool/bundlepool/bundlepool.go
Outdated
defer wg.Done() | ||
if (bundle.MaxTimestamp != 0 && newHead.Time > bundle.MaxTimestamp) || | ||
(bundle.MaxBlockNumber != 0 && newHead.Number.Cmp(new(big.Int).SetUint64(bundle.MaxBlockNumber)) > 0) { | ||
p.slots -= numSlots(p.bundles[hash]) |
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.
Is it thread safe to do p.slots -=
and delete(p.bundles, hash)
?
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.
The reset
function itself is thread safe since we have
p.mu.Lock()
defer p.mu.Unlock()
in the beginning of the function.
However, if you use go func here, it's not.
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.
Removed go func, just use single thread.
core/txpool/bundlepool/bundlepool.go
Outdated
delete(p.bundles, hash) | ||
} else { | ||
for _, tx := range bundle.Txs { | ||
if txSet.Contains(tx.Hash()) && !containsHash(bundle.DroppingTxHashes, tx.Hash()) { |
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 recommend maintain unDroppableTxHashesSet as a cache, we can use it here and in the check of simulation, avoid iterate the slice again and again.
Description
Support droppingTxHashes when sendBundle.
Rationale
The atomicity of bundle transactions can lead to a malicious attack. The attacker can send a failed transaction, such as a transaction that has already been on the chain, which will make the entire bundle invalid. Therefore, the new field can remove such transactions.
Example
N/A
Changes
Notable changes: