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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion fvm/src/kernel/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ use fvm_ipld_blockstore::Blockstore;
use fvm_ipld_encoding::{bytes_32, IPLD_RAW};
use fvm_shared::address::Payload;
use fvm_shared::bigint::Zero;
use fvm_shared::chainid::ChainID;
use fvm_shared::consensus::ConsensusFault;
use fvm_shared::crypto::signature;
use fvm_shared::econ::TokenAmount;
use fvm_shared::error::ErrorNumber;
use fvm_shared::event::ActorEvent;
use fvm_shared::piece::{zero_piece_commitment, PaddedPieceSize};
use fvm_shared::sector::RegisteredPoStProof::{StackedDRGWindow32GiBV1, StackedDRGWindow32GiBV1P1};
use fvm_shared::sector::{RegisteredPoStProof, SectorInfo};
use fvm_shared::sys::out::vm::ContextFlags;
use fvm_shared::{commcid, ActorID};
Expand Down Expand Up @@ -539,9 +541,26 @@ where
.call_manager
.charge_gas(self.call_manager.price_list().on_verify_post(verify_info))?;

// Due to a bug on calibrationnet, we have some _valid_ StackedDRGWindow32GiBV1P1
// proofs that were deemed invalid on chain. This was fixed WITHOUT a network version check.
// As a result, we need to explicitly consider all such proofs invalid, ONLY on calibrationnet,
// and ONLY before epoch 498691,
let calibnet_chain_id = ChainID::from(314159);
let mut verify_info = verify_info.clone();

#[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.

if self.call_manager.context().epoch <= 498691
&& !verify_info.proofs.is_empty()
&& 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?

{
verify_info.proofs[0].post_proof = StackedDRGWindow32GiBV1;
}
}

// This is especially important to catch as, otherwise, a bad "post" could be undisputable.
t.record(catch_and_log_panic("verifying post", || {
verify_post(verify_info)
verify_post(&verify_info)
}))
}

Expand Down