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

allow the verify consensus fault extern to return gasused #330

Merged
merged 2 commits into from
Feb 18, 2022
Merged

Conversation

arajasek
Copy link
Contributor

Addresses #319

fvm::crypto::verify_consensus_fault(h1, h2, extra).map_err(|_| Error::msg("no fault"))
let ret = fvm::crypto::verify_consensus_fault(h1, h2, extra)
.map_err(|_| Error::msg("failed to verify fault"))?;
self.charge_gas("verify_consensus_fault_accesses", ret.gas_used);
Copy link
Member

Choose a reason for hiding this comment

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

We should be charging this gas inside the FVM Kernel, not inside the actor runtime.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense

/// Consensus fault types in VM.
#[derive(FromPrimitive, Clone, Copy, Debug)]
#[repr(u8)]
pub enum ConsensusFaultType {
NoFault = 0,
Copy link
Member

Choose a reason for hiding this comment

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

I'm pretty strongly against a "no fault" variant as it means all the other fields in the ConsensusFault object will be garbage. We only do this kind of thing in go because go doesn't have enums/options.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

synced on this: decision is to move the "no fault" (Go) -> Option (Rust) step into the FFI

@Stebalien
Copy link
Member

(basically, this change shouldn't have to touch the actors or actor runtime)

@jennijuju jennijuju added this to the M0 milestone Feb 16, 2022
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, but LGTM.

Comment on lines 16 to 24
/// Result of checking two headers for a consensus fault, with the gas used
/// Only for v14 and earlier
#[derive(Clone, Debug)]
pub struct ConsensusFaultWithGas {
/// The fault.
pub fault: Option<ConsensusFault>,
/// Gas used in checking the fault
pub gas_used: i64,
}
Copy link
Member

Choose a reason for hiding this comment

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

  1. There's no real need for a named type here. We can just use (Option<ConsensusFault>, i64).
  2. This doesn't really belong in "shared" (shared is for types shared between actors and the FVM, not the FVM and lotus).

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

@arajasek arajasek enabled auto-merge February 18, 2022 17:40
@arajasek arajasek merged commit 794f310 into master Feb 18, 2022
@arajasek arajasek deleted the asr/fault branch February 18, 2022 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

3 participants