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: reject V1P1 proofs on calibrationnet before cutoff #1755

Merged
merged 1 commit into from
Apr 26, 2023

Conversation

arajasek
Copy link
Contributor

This resolves the inconsistent state on calibrationnet that resulted from the bug fixed in #1750. It's unfortunate to have to have a patch like this, but we can drop it when we graduate to FVM4.

@arajasek arajasek force-pushed the asr/calibnet-hack branch from 125fd61 to 083f082 Compare April 26, 2023 19:01
if self.call_manager.context().epoch <= 498691
&& verify_info.proofs[0].post_proof == StackedDRGWindow32GiBV1P1
{
let mut verify_info_copy = verify_info.clone();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Other efforts to fail early, such as returning Err here, or panicking without calling verify_post lead to slightly different gas usage. This surprises me, since these operations seem to be uncharged, but 🤷

Copy link
Member

Choose a reason for hiding this comment

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

Ah. Well, I think this returns Ok(false) on failure?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked at the code and thoroughly convinced myself it did not, but...you're right. That's much nicer.

@codecov-commenter
Copy link

codecov-commenter commented Apr 26, 2023

Codecov Report

Merging #1755 (083f082) into release/v3.3 (5fcae00) will decrease coverage by 1.43%.
The diff coverage is 0.00%.

Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff                @@
##           release/v3.3    #1755      +/-   ##
================================================
- Coverage         75.29%   73.87%   -1.43%     
================================================
  Files               146      146              
  Lines             14124    14258     +134     
================================================
- Hits              10635    10533     -102     
- Misses             3489     3725     +236     
Impacted Files Coverage Δ
fvm/src/kernel/default.rs 42.93% <0.00%> (-10.86%) ⬇️

... and 5 files with indirect coverage changes

if self.call_manager.context().epoch <= 498691
&& verify_info.proofs[0].post_proof == StackedDRGWindow32GiBV1P1
{
let mut verify_info_copy = verify_info.clone();
Copy link
Member

Choose a reason for hiding this comment

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

Ah. Well, I think this returns Ok(false) on failure?

let mut verify_info_copy = verify_info.clone();
verify_info_copy.proofs[0].post_proof = StackedDRGWindow32GiBV1;
return t.record(catch_and_log_panic("verifying post", || {
verify_post(&verify_info_copy)
Copy link
Member

Choose a reason for hiding this comment

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

can we just replace verify_info and continue on to the verify_post call below? IMO, always cloning is fine. Otherwise, you should be able to write write something like:

let mut verify_info_tmp: WindowPoStVerifyInfo;
if ... {
    verify_info_tmp = verify_info.clone();
    verify_info = &verify_info_tmp;
}

#[allow(clippy::collapsible_if)]
if self.call_manager.context().network.chain_id == ChainID::from(314159) {
if self.call_manager.context().epoch <= 498691
&& verify_info.proofs[0].post_proof == StackedDRGWindow32GiBV1P1
Copy link
Member

Choose a reason for hiding this comment

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

Can we double-check the index? Just in case?

@@ -539,6 +541,19 @@ where
.call_manager
.charge_gas(self.call_manager.price_list().on_verify_post(verify_info))?;

#[allow(clippy::collapsible_if)]
if self.call_manager.context().network.chain_id == ChainID::from(314159) {
Copy link
Member

Choose a reason for hiding this comment

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

Let's define a constant for the chain ID to make it clear where this applies.

@arajasek arajasek force-pushed the asr/calibnet-hack branch from 083f082 to 4e42e32 Compare April 26, 2023 20:47
Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

One nit, lgtm.

let calibnet_chain_id = ChainID::from(314159);

#[allow(clippy::collapsible_if)]
if self.call_manager.context().network.chain_id == calibnet_chain_id {
Copy link
Member

Choose a reason for hiding this comment

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

Any reason not to collapse these checks? rustfmt should align everything nicely. Also, we can get a reference to the context first:

let ctx = self.call_manager.context();
if ctx.network.chain_id == calibnet_chain_id
    && ctx.epoch <= 498691
    && ... {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Stebalien I wanted to explicitly have it wrapped in a "ARE YOU CALIBNET" top-level block. But we are biking all over this shed.

Agreed with getting context first.

Copy link
Member

Choose a reason for hiding this comment

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

I don't really care. I just mildly prefer appeasing the linter rather than fighting it.

Copy link
Member

Choose a reason for hiding this comment

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

But you're right, it makes sense to have a top-level check.

@arajasek
Copy link
Contributor Author

Unfortunately, switching to just returning Ok(false) doesn't work because there are 3 V1P1 PoSts that succeeded on-chain, despite being verified as V1 proofs.

I don't fully understand this, asking the Proofs folks for insight. Regardless, we can just go back to cloning and mutating the infos.

@arajasek arajasek force-pushed the asr/calibnet-hack branch from 4e42e32 to 0f6f8af Compare April 26, 2023 21:22
Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

Wait, no, still need to check the index in proofs.

@arajasek
Copy link
Contributor Author

What do you want to check? I thought you just meant that the index 0 exists (which I have done)

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

nvm. Steven isn't looking

@arajasek arajasek merged commit 4258dfc into release/v3.3 Apr 26, 2023
@arajasek arajasek deleted the asr/calibnet-hack branch April 26, 2023 21:42
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.

3 participants