-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
catch additional panics #574
Conversation
CBOR decoding is complex. While we catch panics at the "invoke" level anyways, catching them lower may help us avoid unintended side-effects (e.g., lock poisoning).
These tend to do lots of complex math/parsing. In most cases, a fatal error would be "safe", but: - It's definitely not safe for window post. A panic in window post verification would prevent disputes. - Catching panics and turning them into "illegal argument" errors is relatively safe as these methods are "pure".
}; | ||
use filecoin_proofs_api::update::verify_empty_sector_update_proof; | ||
use filecoin_proofs_api::{self as proofs, post, seal, ProverId, PublicReplicaInfo, SectorId}; | ||
use filecoin_proofs_api::{self as proofs, ProverId, PublicReplicaInfo, SectorId}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started qualifying these calls because distinguishing between "our functions" and "not our functions" was getting difficult.
@@ -990,3 +869,168 @@ fn verify_seal(vi: &SealVerifyInfo) -> Result<bool> { | |||
// Worst case, _some_ node falls out of sync. Better than the network halting. | |||
.context("failed to verify seal proof") | |||
} | |||
|
|||
fn verify_post(verify_info: &WindowPoStVerifyInfo) -> Result<bool> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from above.
.or_illegal_argument() | ||
} | ||
|
||
fn verify_aggregate_seals(aggregate: &AggregateSealVerifyProofAndInfos) -> Result<bool> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from above.
.or_illegal_argument() | ||
} | ||
|
||
fn verify_replica_update(replica: &ReplicaUpdateInfo) -> Result<bool> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from above.
.or_illegal_argument() | ||
} | ||
|
||
fn compute_unsealed_sector_cid( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from above.
Ok(v) => v, | ||
Err(e) => { | ||
log::error!("panic when decoding cbor from actor: {:?}", e); | ||
Err(syscall_error!(IllegalArgument; "panic when decoding cbor from actor").into()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest ErrorNumber::Serialization
here, but read_cbor
is only used for parsing syscall parameters, so ErrorNumber::IllegalArgument
is probably a safe assumption to make.
The only strictly necessary change is the window post one, as a panic there could make a proof indisputable. But there's no real issue with being careful and turning all of these panics into "illegal argument" errors as they're all well isolated.