Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit b22933b

Browse files
add more logging
1 parent 1cfa88f commit b22933b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

chain/block.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,20 +158,18 @@ func (b *StatelessBlock) verify() (*StatelessBlock, *versiondb.Database, error)
158158
}
159159

160160
// Process new transactions
161-
log.Debug("build context", "next difficulty", context.NextDifficulty, "next cost", context.NextCost)
161+
log.Debug("build context", "height", b.Hght, "difficulty", b.Difficulty, "cost", b.Cost)
162162
surplusWork := uint64(0)
163163
for _, tx := range b.Txs {
164164
if err := tx.Execute(onAcceptDB, b.Tmstmp, context); err != nil {
165-
log.Debug("failed tx verification", "err", err)
166165
return nil, nil, err
167166
}
168-
surplusWork += (tx.Difficulty() - context.NextDifficulty) * tx.Units()
167+
surplusWork += (tx.Difficulty() - b.Difficulty) * tx.Units()
169168
}
170169
// Ensure enough work is performed to compensate for block production speed
171170
requiredSurplus := b.Difficulty * b.Cost
172171
if surplusWork < requiredSurplus {
173-
log.Debug("insufficient block surplus", "found", surplusWork, "required", requiredSurplus)
174-
return nil, nil, ErrInsufficientSurplus
172+
return nil, nil, fmt.Errorf("%w: required=%d found=%d", ErrInsufficientSurplus, requiredSurplus, surplusWork)
175173
}
176174
return parent, onAcceptDB, nil
177175
}

client/helper.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ func MineSignIssueTx(
5555
return ids.Empty, err
5656
}
5757

58-
color.Yellow("issuing tx (units: %d) %s with block ID %s", tx.Units(), tx.ID(), utx.GetBlockID())
58+
surplusContribution := (tx.Difficulty() - diff) * tx.Units()
59+
color.Yellow(
60+
"issuing tx %s (units=%d, difficulty=%d, surplus=%d, blkID=%s)",
61+
tx.ID(), tx.Units(), tx.Difficulty(), surplusContribution, tx.GetBlockID(),
62+
)
5963
txID, err = cli.IssueTx(tx.Bytes())
6064
if err != nil {
6165
return ids.Empty, err

0 commit comments

Comments
 (0)