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

Fix ReportConsensusFault Gas Mismatch #1043

Merged
merged 1 commit into from
Mar 9, 2021
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions vm/actor/src/builtin/miner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2696,7 +2696,7 @@ impl Actor {

let mut pledge_delta = TokenAmount::from(0);

let (burn_amount, reward_amount, state) = rt.transaction(|st: &mut State, rt| {
let (burn_amount, reward_amount) = rt.transaction(|st: &mut State, rt| {
let mut info = get_miner_info(rt.store(), &st)?;

// Verify miner hasn't already been faulted
Expand Down Expand Up @@ -2735,7 +2735,7 @@ impl Actor {
e.downcast_default(ExitCode::ErrSerialization, "failed to save miner info")
})?;

Ok((burn_amount, reward_amount, st.clone()))
Ok((burn_amount, reward_amount))
})?;

if let Err(e) = rt.send(reporter, METHOD_SEND, Serialized::default(), reward_amount) {
Expand All @@ -2745,6 +2745,7 @@ impl Actor {
burn_funds(rt, burn_amount)?;
notify_pledge_changed(rt, &pledge_delta)?;

let state: State = rt.state()?;
state
.check_balance_invariants(&rt.current_balance()?)
.map_err(|e| {
Expand All @@ -2753,7 +2754,6 @@ impl Actor {
format!("balance invariants broken: {}", e),
)
})?;

Ok(())
}

Expand Down
6 changes: 2 additions & 4 deletions vm/interpreter/src/default_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ where
let prev_val = self.caller_validated;
let prev_depth = self.depth;
let prev_msg = self.vm_msg.clone();

let res = self.execute_send(msg, gas_cost);

// Reset values back to their values before the call
Expand Down Expand Up @@ -520,9 +519,9 @@ where
.get_actor(self.vm_msg.receiver())?
.ok_or_else(|| format!("actor not found {:?}", self.vm_msg.receiver()))?;

let ms = actor::miner::State::load(self.store(), &actor)?;
let ms = actor::miner::State::load(&self.store, &actor)?;

let worker = ms.info(self.store())?.worker;
let worker = ms.info(&self.store)?.worker;

resolve_to_key_addr(&self.state, &self.store, &worker)
}
Expand Down Expand Up @@ -884,7 +883,6 @@ where
self.gas_tracker
.borrow_mut()
.charge_gas(self.price_list.on_verify_consensus_fault())?;

// Note that block syntax is not validated. Any validly signed block will be accepted pursuant to the below conditions.
// Whether or not it could ever have been accepted in a chain is not checked/does not matter here.
// for that reason when checking block parent relationships, rather than instantiating a Tipset to do so
Expand Down
1 change: 1 addition & 0 deletions vm/interpreter/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ where
return Ok(());
}
let ret = self.apply_message(msg)?;

if let Some(cb) = &mut callback {
cb(&cid, msg, &ret)?;
}
Expand Down