Skip to content
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

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from

Conversation

redhdx
Copy link
Contributor

@redhdx redhdx commented Dec 18, 2024

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:

  • Add new field in Bundle struct.

miner/worker_builder.go Outdated Show resolved Hide resolved
miner/worker_builder.go Outdated Show resolved Hide resolved
}
wg.Wait()
bundleGauge.Update(int64(len(p.bundles)))
Copy link
Collaborator

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

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])
Copy link
Collaborator

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)?

Copy link
Collaborator

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.

Copy link
Contributor Author

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.

delete(p.bundles, hash)
} else {
for _, tx := range bundle.Txs {
if txSet.Contains(tx.Hash()) && !containsHash(bundle.DroppingTxHashes, tx.Hash()) {
Copy link
Collaborator

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.

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.

5 participants