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/issue 953 3d pricing metrics #102

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

cloudspores
Copy link

@cloudspores cloudspores commented Oct 17, 2024

Add metrics to cover 3D pricing (#953)

This commit introduces monitoring for 3D pricing, including:

  • Node's perception of extraData (variable cost, fixed cost, eth gas price)
  • Profitability levels of the TxPool's contents (low, high, average)
  • Profitability levels in the context of the last sealed block

Histograms are added to capture profitability metrics, as well as node metrics for evaluating transactions using the TransactionProfitabilityCalculator.

Acceptance Criteria:
Linea-Besu exposes described metrics, and this implementation follows that requirement.

This commit does not include:

  • feature toggling
  • working with Dagger in linea-sequencer

Link to design proposal documentation:

https://www.notion.so/consensys/Design-Proposal-Documentation-120fc61a326e809ab07df86a2a69cd32?pvs=4

Add metrics to monitor 3D pricing (extraData driven):

P1 metrics:
- Node's perception of latest extraData contents
- Profitability levels of TxPool contents
- Profitability metrics for last sealed block (Sequencer only)

Nice to have:
- Profitability levels for TransactionProfitabilityCalcuODlator
- priorityFeePerGas from TransactionProfitabilityCalculator
- compressedTxSize from TransactionProfitabilityCalculator

Implement histograms to capture all described metrics.

Closes #953

Signed-off-by: Ade Lucas <[email protected]>
Add metrics to monitor 3D pricing (extraData driven):

P1 metrics:
- Node's perception of latest extraData contents
- Profitability levels of TxPool contents
- Profitability metrics for last sealed block (Sequencer only)

Nice to have:
- Profitability levels for TransactionProfitabilityCalcuODlator
- priorityFeePerGas from TransactionProfitabilityCalculator
- compressedTxSize from TransactionProfitabilityCalculator

Implement histograms to capture all described metrics.

Closes #953

Signed-off-by: Ade Lucas <[email protected]>
Copy link
Contributor

@fab-10 fab-10 left a comment

Choose a reason for hiding this comment

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

Did a first pass, without going too much in the details, please see my comments, and it will be great, if you can split this in smaller ones, so it is easier to review, for example one PR for each point:

  1. Node's perception of extraData (variable cost, fixed cost, eth gas price)
  2. Profitability levels of the TxPool's contents (low, high, average)
  3. Profitability levels in the context of the last sealed block

where the next is built on top of the previous, I found this way to be easier to digest and not adding too much time

double profitabilityRatio =
payingGasPrice.getAsBigInteger().doubleValue()
/ profitableGasPrice.getAsBigInteger().doubleValue();
profitabilityMetrics.recordEvaluatedTxProfitabilityRatio(profitabilityRatio);
Copy link
Contributor

Choose a reason for hiding this comment

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

since this method also calls profitablePriorityFeePerGas we should be sure that some metrics are not calculated and recorded twice

Comment on lines +161 to +165
log.debug(
"Calculated profitablePriorityFee: {}, profitableGasPrice: {}, payingGasPrice: {}",
profitablePriorityFee.toHumanReadableString(),
profitableGasPrice.toHumanReadableString(),
payingGasPrice.toHumanReadableString());
Copy link
Contributor

Choose a reason for hiding this comment

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

opt: replace with the lambda version to avoid computation when debug is not enabled

Copy link
Author

Choose a reason for hiding this comment

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

Good idea.
Apparently Lombok's @slf4j annotation debug method doesn't directly accept a lambda, so I've got this:

    if (log.isDebugEnabled()) {
      log.debug(
        "Calculated profitablePriorityFee: {}, profitableGasPrice: {}, payingGasPrice: {}",
        profitablePriorityFee.toHumanReadableString(),
        profitableGasPrice.toHumanReadableString(),
        payingGasPrice.toHumanReadableString());
    }

Copy link
Contributor

Choose a reason for hiding this comment

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

it does, look for other usage of log.atDebug()... in the code

Comment on lines +76 to +79
final BlockHeader chainHeadHeader = blockchainService.getChainHeadHeader();
final LineaPricingUtils.PricingData pricingData =
LineaPricingUtils.extractPricingFromExtraData(chainHeadHeader.getExtraData());

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is not necessary, since current value are in LineaProfitabilityConfiguration, that is updated every time a new block arrives

Copy link
Author

Choose a reason for hiding this comment

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

I see what you mean, LineaProfitabilityConfiguration instance has fixedCostWei, variableCostWei. I'll revise the use of PricingData.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also the parsing is already done in https://github.com/Consensys/linea-sequencer/blob/main/sequencer/src/main/java/net/consensys/linea/extradata/LineaExtraDataHandler.java so we need to make sure to avoid duplication and in necessary extend what we have to adapt to the new uses


/** Utility class for handling Linea pricing data extraction from the extraData field. */
@Slf4j
public class LineaPricingUtils {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems a duplicate to me, since we already have the code to parse extraData field

@@ -0,0 +1,83 @@
@startuml
Copy link
Contributor

Choose a reason for hiding this comment

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

what is this file?

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.

2 participants