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

Adjust fee currency blacklisting #345

Open
wants to merge 21 commits into
base: celo-rebase-12
Choose a base branch
from

Conversation

piersy
Copy link

@piersy piersy commented Mar 27, 2025

No description provided.

@ezdac ezdac force-pushed the piersy/adjust-fee-currency-blacklisting branch from 006e714 to 1143d87 Compare March 27, 2025 15:27
@ezdac ezdac force-pushed the piersy/adjust-fee-currency-blacklisting branch from 1b82392 to c20186a Compare March 27, 2025 15:30
@@ -18,21 +19,41 @@ type AddressBlocklist struct {
// will get evicted when evict() is called
headerEvictionTimeoutSeconds uint64
oldestHeader *types.Header

enactFilterEnabled *atomic.Int32
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not use atomic.Bool?

Copy link

Choose a reason for hiding this comment

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

That's a very good question... somehow I thought it doesn't exist

@piersy piersy marked this pull request as ready for review March 27, 2025 16:45
@ezdac ezdac force-pushed the piersy/adjust-fee-currency-blacklisting branch from b7c39f9 to ed193d8 Compare March 27, 2025 16:47
}

// Clean up old transaction hash from map
oldHash := b.ring[b.index]

Choose a reason for hiding this comment

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

wonder what happens when the ring is not yet full... this returns zero and delete(zero) doesn't break?

Copy link
Author

Choose a reason for hiding this comment

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

It will be the empty hash, and delete the empty hash which will be a no-op.

miner/worker.go Outdated
@@ -345,6 +346,7 @@ func (miner *Miner) prepareWork(genParams *generateParams, witness bool) (*envir
common.CurrencyAllowlist(env.feeCurrencyContext.ExchangeRates),
header,
)
env.blockingAllowed = miner.feeCurrencyBlocklist.GetEnableFilterStatus()

Choose a reason for hiding this comment

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

is this done for every block?

Copy link
Author

Choose a reason for hiding this comment

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

Yep, env is constructed per block at line 331

Copy link

Choose a reason for hiding this comment

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

Yes, every time a new payload is requested to be built by the engine-api a new environment is created

@@ -596,6 +599,12 @@ func (miner *Miner) commitTransactions(env *environment, plainTxs, blobTxs *tran
continue
}
}
if miner.blockedTxRingbuffer.Has(ltx.Hash) {
log.Trace("Skipping tx execution, tx in blockedTxRingbuffer", "hash", ltx.Hash)

Choose a reason for hiding this comment

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

trace? maybe some level we had for skipping a tx due to fee currency lock

Copy link

Choose a reason for hiding this comment

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

This would be logged on every block build attempt, so every 1 second

Copy link
Author

Choose a reason for hiding this comment

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

This is the same level we had for skipping a tx due to the fee currency lock, see line 597

miner/worker.go Outdated
// also add the fee-currency to a worker-wide blocklist,
// so that they are not allowlisted in the following blocks
// (only locally in the txpool, not consensus-critical)
miner.feeCurrencyBlocklist.Add(feeCurrency, *env.header)
miner.feeCurrencyBlocklist.Add(*tx.FeeCurrency(), *env.header)

Choose a reason for hiding this comment

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

we're sure that tx.FeeCurrency is never nil here?

Copy link
Author

@piersy piersy Mar 28, 2025

Choose a reason for hiding this comment

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

Previously this function was being called with the de-referenced fee currency here (line 427, github seems to have an issue correctly scrolling to that point) so I'm as sure as we previously were that fee currency is not nil.

eth/api_admin.go Outdated
api.eth.Miner().UnblockTransaction(hash)
}

func (api *AdminAPI) UnblockFeeCurrency(address common.Address) {
Copy link

Choose a reason for hiding this comment

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

Would it be helpful to have getter API for blocked fee currency list or tx list?

Copy link

Choose a reason for hiding this comment

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

Why not. I think the fee-currency is not strictly necessary since we have the "block" and "evict" log messages.
The transactions would be helpful, because this is only logged with trace level.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah I think so. TBH I want to go over this whole blocking feature again and ensure the design is clean. Yesterday we were somewhat in a hurry so didn't have the time to consider all the niceties that you normally would.

Co-authored-by: Seola Oh <[email protected]>
ezdac added 4 commits March 28, 2025 15:44
We want to be able to recognize when the passed in fee-currency does not
have an individual multi-gas-pool set, e.g. when setting the remaining
gas-allowance to 0 due to a fee-currency block.
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