Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

add cost tracking for each bank during replay #30035

Merged
merged 2 commits into from
Feb 13, 2023

Conversation

tao-stones
Copy link
Contributor

@tao-stones tao-stones commented Jan 31, 2023

Problem

Leaders use cost_tracker to ensure each block produced are with block limits. Same cost tracking and checking against limits should be symmetrically performed during replay, blocks exceed limits should fail replay.

Summary of Changes

  • calling bank.cost_tracker.try_add(tx) during replaying, return error if block exceeds limits
  • add feature gate since this change breaks consensus

Feature Gate Issue: #29595

NOTE: Until this point, cost_model and cost_tracker are exclusively used by leaders during block packing, so we enjoyed the freedom to change how it works without worrying much about breaking consensus. With this PR, future changes to cost_model.rs, cost_tracker.rs, block_cost_limits.rs and maybe other models that would change how transaction cost measures against block limits could break consensus, therefore need to be feature gated.

@tao-stones tao-stones force-pushed the replay_cost_tracking branch from 14b9aa7 to 3a702c7 Compare January 31, 2023 23:51
@tao-stones tao-stones marked this pull request as ready for review January 31, 2023 23:51
@tao-stones tao-stones requested review from steviez and pgarg66 January 31, 2023 23:51
@tao-stones tao-stones added the feature-gate Pull Request adds or modifies a runtime feature gate label Feb 2, 2023
@tao-stones tao-stones force-pushed the replay_cost_tracking branch from 658eddd to 0b286e2 Compare February 3, 2023 20:16
@tao-stones tao-stones force-pushed the replay_cost_tracking branch from 343ed24 to c99fb81 Compare February 8, 2023 16:35
@steviez
Copy link
Contributor

steviez commented Feb 10, 2023

NOTE: Until this point, cost_model and cost_tracker are exclusively used by leaders during block packing, so we enjoyed the freedom to change how it works without worrying much about breaking consensus. With this PR, future changes to cost_model.rs, cost_tracker.rs, block_cost_limits.rs and maybe other models that would change how transaction cost measures against block limits could break consensus, therefore need to be feature gated.

To confirm,

  • Prior to this change, the limits imposed by this files were only checked by leaders
  • But, the above wouldn't hypothetically prevent someone with mods from creating blocks that broke some rules
  • After this change, non-leaders will begin checking these rules in replay
  • Checking of these rules in replay could result in rejecting a block that previously would have been allowed through

And the last bullet is why this could affect consensus, and why we need a feature gate for this change and any subsequent modifications to these file. Is that all correct?

@tao-stones
Copy link
Contributor Author

NOTE: Until this point, cost_model and cost_tracker are exclusively used by leaders during block packing, so we enjoyed the freedom to change how it works without worrying much about breaking consensus. With this PR, future changes to cost_model.rs, cost_tracker.rs, block_cost_limits.rs and maybe other models that would change how transaction cost measures against block limits could break consensus, therefore need to be feature gated.

To confirm,

  • Prior to this change, the limits imposed by this files were only checked by leaders
  • But, the above wouldn't hypothetically prevent someone with mods from creating blocks that broke some rules
  • After this change, non-leaders will begin checking these rules in replay
  • Checking of these rules in replay could result in rejecting a block that previously would have been allowed through

And the last bullet is why this could affect consensus, and why we need a feature gate for this change and any subsequent modifications to these file. Is that all correct?

Exactly, all points correct. Checking during replay prevents large-than-limits blocks from being replayed, potentially causing validators skipping slots.

Copy link
Contributor

@steviez steviez left a comment

Choose a reason for hiding this comment

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

Things look good to me, but looks like there is a merge issue that will require resolution and thus me looking again since a ship it would get dismissed.

Copy link
Contributor

@steviez steviez left a comment

Choose a reason for hiding this comment

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

Nice, got the PR down to the bare minimum to introduce the feature gate!

@tao-stones
Copy link
Contributor Author

Nice, got the PR down to the bare minimum to introduce the feature gate!

Thank you ❤️

@tao-stones tao-stones merged commit 51bace2 into solana-labs:master Feb 13, 2023
@tao-stones tao-stones deleted the replay_cost_tracking branch February 13, 2023 19:10
tao-stones added a commit to tao-stones/solana that referenced this pull request Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-gate Pull Request adds or modifies a runtime feature gate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants