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

Fix the epoch used for gas in the message pool & validation #8163

Merged
merged 2 commits into from
Feb 24, 2022

Conversation

Stebalien
Copy link
Member

@Stebalien Stebalien commented Feb 21, 2022

Related Issues

Partially fixes #6652.

Proposed Changes

Bring the gas epoch used in chain validation in-line with the gas epoch used in message execution.

Additional Info

This change should only affect the one gas repricing we had (Calico). It should only affect consensus if the blocks at the upgrade height included a message without enough gas to cover the message's execution. In the old code:

  • The message pool and chain sync logic would have allowed this message.
  • The VM itself would have penalized the miner.

Looking at the relevant blocks around 265200 (the Calico upgrade height), I'm not seeing any miner penalties so I have to assume that this didn't happen.

Checklist

Before you mark the PR ready for review, please make sure that:

  • All commits have a clear commit message.
  • The PR title is in the form of of <PR type>: <area>: <change being made>
    • example: fix: mempool: Introduce a cache for valid signatures
    • PR type: fix, feat, INTERFACE BREAKING CHANGE, CONSENSUS BREAKING, build, chore, ci, docs,perf, refactor, revert, style, test
    • area: api, chain, state, vm, data transfer, market, mempool, message, block production, multisig, networking, paychan, proving, sealing, wallet, deps
  • This PR has tests for new functionality or change in behaviour
  • If new user-facing features are introduced, clear usage guidelines and / or documentation updates should be included in https://lotus.filecoin.io or Discussion Tutorials.
  • CI is green

We need to use the height at which the messages will be executed, not
the height of the previous tipset. This brings the gas checking for
validation with the gas we actually _charge_ during message execution.

This only matters for the Calico upgrade (the only upgrade where we
changed the gas prices).

This change could potentially cause a block at that height to be
rejected if it includes a message with insufficient gas for inclusion.
However, that _should_ have shown up as a miner penalty when we executed
the blocks in the following tipset. Given that there were no miner
penalties at 265199-265201, this change should be "safe".
Previously, we checked message gas/validity with the previous block's
height. This doesn't affect consensus, but will help us avoid adding
messages to the message pool that shouldn't be there.
@Stebalien Stebalien requested a review from a team as a code owner February 21, 2022 18:19
@codecov
Copy link

codecov bot commented Feb 21, 2022

Codecov Report

Merging #8163 (1234fcf) into master (9429229) will decrease coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8163      +/-   ##
==========================================
- Coverage   39.48%   39.45%   -0.04%     
==========================================
  Files         666      666              
  Lines       72498    72498              
==========================================
- Hits        28627    28603      -24     
- Misses      38915    38933      +18     
- Partials     4956     4962       +6     
Impacted Files Coverage Δ
chain/consensus/filcns/filecoin.go 52.17% <100.00%> (-0.44%) ⬇️
chain/messagepool/check.go 77.25% <100.00%> (ø)
chain/messagepool/messagepool.go 63.76% <100.00%> (ø)
cli/util.go 41.66% <0.00%> (-8.34%) ⬇️
markets/retrievaladapter/client_blockstore.go 62.50% <0.00%> (-6.25%) ⬇️
chain/stmgr/call.go 67.87% <0.00%> (-3.64%) ⬇️
chain/types/tipset_key.go 85.96% <0.00%> (-3.51%) ⬇️
chain/stmgr/searchwait.go 67.30% <0.00%> (-2.57%) ⬇️
miner/miner.go 56.39% <0.00%> (-1.64%) ⬇️
extern/storage-sealing/fsm.go 56.44% <0.00%> (-1.05%) ⬇️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9429229...1234fcf. Read the comment docs.

@Stebalien
Copy link
Member Author

The right way to test this is to:

  1. Create a gas price change that would increase the inclusion price of a message.
  2. Create a message with enough gas to cover the inclusion cost before the upgrade, but not after:
    1. The mpool should reject it at the upgrade epoch.
    2. The miner shouldn't include it at the upgrade epoch.
    3. The syncer should not validate the message.

But doing that sounds... painful. Thoughts?

Copy link
Contributor

@arajasek arajasek left a comment

Choose a reason for hiding this comment

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

@Stebalien I'm comfortable landing this as-is, I think it's a strict improvement (and also can't find any messages that would break consensus around the Calico upgrade).

The test you're describing wouldn't be that hard to write. I can do it, but it's probably not the highest priority, so it's up to you whether you wanna block landing this on such a test.

Also, just to confirm our understandings align, the reason this was affecting the recent caterpillarnet setups was because the pricelist was changing at the first epoch (even though the Calico upgrade was disabled) because Lotus always starts with the v0 pricelist (for epoch 0) before then switching if appropriate. Is that your take?

If so, an easy improvement might be to change that -- the first pricelist should be dictated by a network's Genesis network version. That wouldn't affect mainnet, and would mean any new networks start from the v1 pricelist. I think it would affect calibnet, though...

@Stebalien
Copy link
Member Author

Also, just to confirm our understandings align, the reason this was affecting the recent caterpillarnet setups was because the pricelist was changing at the first epoch (even though the Calico upgrade was disabled) because Lotus always starts with the v0 pricelist (for epoch 0) before then switching if appropriate. Is that your take?

Unfortunately, this change isn't actually relevant to that issue. I'm just fixing what I can without breaking anything.

I'll let you merge when/if ready. As you say, writing a test for this isn't high priority.

@arajasek arajasek merged commit 64b13af into master Feb 24, 2022
@arajasek arajasek deleted the steb/fix-inclusion-price-at-upgrade branch February 24, 2022 23:06
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.

PricelistByEpoch Technical Debt
2 participants