Merge pull request #783 from filecoin-project/fix/bad-epost-mining

Fix/bad epost mining
This commit is contained in:
Łukasz Magiera 2019-12-09 18:27:24 +01:00 committed by GitHub
commit 44f3a501ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 4 deletions

View File

@ -138,7 +138,7 @@ func (sm *StateManager) computeTipSetState(ctx context.Context, blks []*types.Bl
return cid.Undef, cid.Undef, xerrors.Errorf("failed to get network actor: %w", err) return cid.Undef, cid.Undef, xerrors.Errorf("failed to get network actor: %w", err)
} }
reward := vm.MiningReward(netact.Balance) reward := vm.MiningReward(netact.Balance)
for _, b := range blks { for tsi, b := range blks {
netact, err = vmi.StateTree().GetActor(actors.NetworkAddress) netact, err = vmi.StateTree().GetActor(actors.NetworkAddress)
if err != nil { if err != nil {
return cid.Undef, cid.Undef, xerrors.Errorf("failed to get network actor: %w", err) return cid.Undef, cid.Undef, xerrors.Errorf("failed to get network actor: %w", err)
@ -171,10 +171,10 @@ func (sm *StateManager) computeTipSetState(ctx context.Context, blks []*types.Bl
} }
ret, err := vmi.ApplyMessage(ctx, postSubmitMsg) ret, err := vmi.ApplyMessage(ctx, postSubmitMsg)
if err != nil { if err != nil {
return cid.Undef, cid.Undef, xerrors.Errorf("submit election post message invocation failed: %w", err) return cid.Undef, cid.Undef, xerrors.Errorf("submit election post message for block %s (miner %s) invocation failed: %w", b.Cid(), b.Miner, err)
} }
if ret.ExitCode != 0 { if ret.ExitCode != 0 {
return cid.Undef, cid.Undef, xerrors.Errorf("submit election post invocation returned nonzero exit code: %d", ret.ExitCode) return cid.Undef, cid.Undef, xerrors.Errorf("submit election post invocation returned nonzero exit code: %d (err = %s, block = %s, miner = %s, tsi = %d)", ret.ExitCode, ret.ActorErr, b.Cid(), b.Miner, tsi)
} }
} }

View File

@ -492,6 +492,15 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) err
} }
winnerCheck := async.Err(func() error { winnerCheck := async.Err(func() error {
slashedAt, err := stmgr.GetMinerSlashed(ctx, syncer.sm, baseTs, h.Miner)
if err != nil {
return xerrors.Errorf("failed to check if block miner was slashed: %w", err)
}
if slashedAt != 0 {
return xerrors.Errorf("received block was from miner slashed at height %d", slashedAt)
}
_, tpow, err := stmgr.GetPower(ctx, syncer.sm, baseTs, h.Miner) _, tpow, err := stmgr.GetPower(ctx, syncer.sm, baseTs, h.Miner)
if err != nil { if err != nil {
return xerrors.Errorf("failed getting power: %w", err) return xerrors.Errorf("failed getting power: %w", err)

View File

@ -148,7 +148,7 @@ func (a *StateAPI) stateForTs(ctx context.Context, ts *types.TipSet) (*state.Sta
func (a *StateAPI) StateGetActor(ctx context.Context, actor address.Address, ts *types.TipSet) (*types.Actor, error) { func (a *StateAPI) StateGetActor(ctx context.Context, actor address.Address, ts *types.TipSet) (*types.Actor, error) {
state, err := a.stateForTs(ctx, ts) state, err := a.stateForTs(ctx, ts)
if err != nil { if err != nil {
return nil, err return nil, xerrors.Errorf("computing tipset state failed: %w", err)
} }
return state.GetActor(actor) return state.GetActor(actor)