feat(metering): add base_meteredPriorityFeePerGas RPC endpoint #355
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.
Summary
Add a new RPC endpoint
base_meteredPriorityFeePerGasthat meters a bundle and returns a recommended priority fee based on resource consumption.This PR introduces the core estimation algorithm that answers: "What priority fee would my bundle need to pay to displace enough lower-paying transactions to free up the resources I need?"
Changes
base_meteredPriorityFeePerGasRPC endpoint that meters a bundle and estimates priority feesResourceKind,ResourceLimits,ResourceDemand,ResourceEstimatecompute_estimatealgorithm implementing top-down fee estimationestimate_from_transactionsfor single-block estimation from a list of transactionsAlgorithm
The estimation algorithm walks transactions from highest to lowest priority fee, accumulating resource usage until adding another transaction would leave insufficient capacity for the bundle. The last included transaction's fee becomes the threshold.
Response Format
{ "bundleGasPrice": "0x...", "bundleHash": "0x...", "results": [...], "totalGasUsed": 21000, "totalExecutionTimeUs": 1234, "priorityFee": "0x5f5e100", "blocksSampled": 1, "resourceEstimates": [ { "resource": "gasUsed", "thresholdPriorityFee": "0x...", ... }, { "resource": "executionTime", ... }, { "resource": "dataAvailability", ... } ] }Test Plan
compute_estimatecovering congested, uncongested, and edge casesestimate_from_transactions