-
Notifications
You must be signed in to change notification settings - Fork 140
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
Conversation
actors/runtime/src/runtime/fvm.rs
Outdated
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); |
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.
We should be charging this gas inside the FVM Kernel, not inside the actor runtime.
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.
Makes sense
shared/src/consensus/mod.rs
Outdated
/// Consensus fault types in VM. | ||
#[derive(FromPrimitive, Clone, Copy, Debug)] | ||
#[repr(u8)] | ||
pub enum ConsensusFaultType { | ||
NoFault = 0, |
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'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.
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.
synced on this: decision is to move the "no fault" (Go) -> Option (Rust) step into the FFI
(basically, this change shouldn't have to touch the actors or actor runtime) |
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.
One nit, but LGTM.
shared/src/consensus/mod.rs
Outdated
/// 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, | ||
} |
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.
- There's no real need for a named type here. We can just use
(Option<ConsensusFault>, i64)
. - This doesn't really belong in "shared" (shared is for types shared between actors and the FVM, not the FVM and lotus).
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.
lgtm
Addresses #319