Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit 7faf54f

Browse files
dvushavalonche
authored andcommitted
better logs (#36)
* miner logs * builder logs
1 parent 031990c commit 7faf54f

File tree

4 files changed

+14
-27
lines changed

4 files changed

+14
-27
lines changed

builder/builder.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ func (b *Builder) Stop() error {
9292
}
9393

9494
func (b *Builder) onSealedBlock(block *types.Block, bundles []types.SimulatedBundle, proposerPubkey boostTypes.PublicKey, proposerFeeRecipient boostTypes.Address, attrs *BuilderPayloadAttributes) error {
95-
start := time.Now()
9695
executableData := beacon.BlockToExecutableData(block)
9796
payload, err := executableDataToExecutionPayload(executableData)
9897
if err != nil {
@@ -137,11 +136,9 @@ func (b *Builder) onSealedBlock(block *types.Block, bundles []types.SimulatedBun
137136
if err != nil {
138137
log.Error("could not submit block", "err", err, "bundles", len(bundles))
139138
return err
140-
} else {
141-
log.Info("could submit block", "bundles", len(bundles))
142139
}
143140

144-
log.Info("submitted block", "header", block.Header(), "bid", blockBidMsg, "time", time.Since(start))
141+
log.Info("submitted block", "slot", blockBidMsg.Slot, "value", blockBidMsg.Value.String(), "parent", blockBidMsg.ParentHash, "hash", block.Hash(), "bundles", len(bundles))
145142

146143
return nil
147144
}
@@ -172,7 +169,7 @@ func (b *Builder) OnPayloadAttribute(attrs *BuilderPayloadAttributes) error {
172169

173170
parentBlock := b.eth.GetBlockByHash(attrs.HeadHash)
174171
if parentBlock == nil {
175-
log.Info("Block hash not found in blocktree", "head block hash", attrs.HeadHash)
172+
log.Warn("Block hash not found in blocktree", "head block hash", attrs.HeadHash)
176173
return errors.New("parent block not found in blocktree")
177174
}
178175

miner/algo_common.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ func (envDiff *environmentDiff) commitTx(tx *types.Transaction, chData chainData
174174
default:
175175
// Strange error, discard the transaction and get the next in line (note, the
176176
// nonce-too-high clause will prevent us from executing in vain).
177-
log.Debug("Transaction failed, account skipped", "hash", tx.Hash(), "err", err)
177+
log.Trace("Transaction failed, account skipped", "hash", tx.Hash(), "err", err)
178178
return nil, shiftTx, err
179179
}
180180
}
@@ -231,12 +231,12 @@ func (envDiff *environmentDiff) commitBundle(bundle *types.SimulatedBundle, chDa
231231
receipt, _, err := tmpEnvDiff.commitTx(tx, chData)
232232

233233
if err != nil {
234-
log.Debug("Bundle tx error", "bundle", bundle.OriginalBundle.Hash, "tx", tx.Hash(), "err", err)
234+
log.Trace("Bundle tx error", "bundle", bundle.OriginalBundle.Hash, "tx", tx.Hash(), "err", err)
235235
return err
236236
}
237237

238238
if receipt.Status != types.ReceiptStatusSuccessful && !bundle.OriginalBundle.RevertingHash(tx.Hash()) {
239-
log.Debug("Bundle tx failed", "bundle", bundle.OriginalBundle.Hash, "tx", tx.Hash(), "err", err)
239+
log.Trace("Bundle tx failed", "bundle", bundle.OriginalBundle.Hash, "tx", tx.Hash(), "err", err)
240240
return errors.New("bundle tx revert")
241241
}
242242

@@ -256,7 +256,7 @@ func (envDiff *environmentDiff) commitBundle(bundle *types.SimulatedBundle, chDa
256256
bundleSimEffGP.Mul(bundleSimEffGP, big.NewInt(99))
257257

258258
if bundleSimEffGP.Cmp(bundleActualEffGP) == 1 {
259-
log.Debug("Bundle underpays after inclusion", "bundle", bundle.OriginalBundle.Hash)
259+
log.Trace("Bundle underpays after inclusion", "bundle", bundle.OriginalBundle.Hash)
260260
return errors.New("bundle underpays")
261261
}
262262

miner/algo_greedy.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (b *greedyBuilder) buildBlock(simBundles []types.SimulatedBundle, transacti
6666
}
6767

6868
if err != nil {
69-
log.Info("could not apply tx", "hash", order.Tx.Hash(), "err", err)
69+
log.Trace("could not apply tx", "hash", order.Tx.Hash(), "err", err)
7070
continue
7171
}
7272
effGapPrice, err := order.Tx.EffectiveGasTip(env.header.BaseFee)
@@ -79,11 +79,11 @@ func (b *greedyBuilder) buildBlock(simBundles []types.SimulatedBundle, transacti
7979
err := envDiff.commitBundle(bundle, b.chainData, b.interrupt)
8080
orders.Pop()
8181
if err != nil {
82-
log.Info("Could not apply bundle", "bundle", bundle.OriginalBundle.Hash, "err", err)
82+
log.Trace("Could not apply bundle", "bundle", bundle.OriginalBundle.Hash, "err", err)
8383
continue
8484
}
8585

86-
log.Info("Included bundle", "bundleEGP", bundle.MevGasPrice.String(), "gasUsed", bundle.TotalGasUsed, "ethToCoinbase", ethIntToFloat(bundle.TotalEth))
86+
log.Trace("Included bundle", "bundleEGP", bundle.MevGasPrice.String(), "gasUsed", bundle.TotalGasUsed, "ethToCoinbase", ethIntToFloat(bundle.TotalEth))
8787
usedBundles = append(usedBundles, *bundle)
8888
}
8989
}

miner/worker.go

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,30 +1367,25 @@ func (w *worker) fillTransactions(interrupt *atomic.Int32, env *environment, val
13671367

13681368
if validatorCoinbase != nil && w.config.BuilderTxSigningKey != nil {
13691369
builderCoinbaseBalanceAfter := env.state.GetBalance(w.coinbase)
1370-
log.Info("Before creating validator profit", "validatorCoinbase", validatorCoinbase.String(), "builderCoinbase", w.coinbase.String(), "builderCoinbaseBalanceBefore", builderCoinbaseBalanceBefore.String(), "builderCoinbaseBalanceAfter", builderCoinbaseBalanceAfter.String())
1370+
log.Trace("Before creating validator profit", "validatorCoinbase", validatorCoinbase.String(), "builderCoinbase", w.coinbase.String(), "builderCoinbaseBalanceBefore", builderCoinbaseBalanceBefore.String(), "builderCoinbaseBalanceAfter", builderCoinbaseBalanceAfter.String())
13711371

13721372
profit := new(big.Int).Sub(builderCoinbaseBalanceAfter, builderCoinbaseBalanceBefore)
13731373
env.gasPool.AddGas(paymentTxGas)
13741374
if profit.Sign() == 1 {
13751375
tx, err := w.createProposerPayoutTx(env, validatorCoinbase, profit)
13761376
if err != nil {
1377-
log.Error("Proposer payout create tx failed", "err", err)
13781377
return fmt.Errorf("proposer payout create tx failed - %v", err), nil
13791378
}
13801379
if tx != nil {
1381-
log.Info("Proposer payout create tx succeeded, proceeding to commit tx")
13821380
_, err = w.commitTransaction(env, tx)
13831381
if err != nil {
1384-
log.Error("Proposer payout commit tx failed", "hash", tx.Hash().String(), "err", err)
13851382
return fmt.Errorf("proposer payout commit tx failed - %v", err), nil
13861383
}
1387-
log.Info("Proposer payout commit tx succeeded", "hash", tx.Hash().String())
13881384
env.tcount++
13891385
} else {
13901386
return errors.New("proposer payout create tx failed due to tx is nil"), nil
13911387
}
13921388
} else {
1393-
log.Warn("Proposer payout create tx failed due to not enough balance", "profit", profit.String())
13941389
return errors.New("proposer payout create tx failed due to not enough balance"), nil
13951390
}
13961391
}
@@ -1437,35 +1432,30 @@ func (w *worker) fillTransactionsAlgoWorker(interrupt *int32, env *environment,
14371432
start := time.Now()
14381433
builder := newGreedyBuilder(w.chain, w.chainConfig, w.blockList, env, interrupt)
14391434
newEnv, blockBundles := builder.buildBlock(bundlesToConsider, pending)
1440-
log.Debug("Build block", "time", time.Since(start), "gas used", newEnv.header.GasUsed)
1435+
log.Debug("Build block", "time", time.Since(start), "gasUsed", newEnv.header.GasUsed)
14411436
*env = *newEnv
14421437

14431438
if validatorCoinbase != nil && w.config.BuilderTxSigningKey != nil {
14441439
builderCoinbaseBalanceAfter := env.state.GetBalance(w.coinbase)
1445-
log.Info("Before creating validator profit", "validatorCoinbase", validatorCoinbase.String(), "builderCoinbase", w.coinbase.String(), "builderCoinbaseBalanceBefore", builderCoinbaseBalanceBefore.String(), "builderCoinbaseBalanceAfter", builderCoinbaseBalanceAfter.String())
1440+
log.Trace("Before creating validator profit", "validatorCoinbase", validatorCoinbase.String(), "builderCoinbase", w.coinbase.String(), "builderCoinbaseBalanceBefore", builderCoinbaseBalanceBefore.String(), "builderCoinbaseBalanceAfter", builderCoinbaseBalanceAfter.String())
14461441

14471442
profit := new(big.Int).Sub(builderCoinbaseBalanceAfter, builderCoinbaseBalanceBefore)
14481443
env.gasPool.AddGas(params.TxGas)
14491444
if profit.Sign() == 1 {
14501445
tx, err := w.createProposerPayoutTx(env, validatorCoinbase, profit)
14511446
if err != nil {
1452-
log.Error("Proposer payout create tx failed", "err", err)
14531447
return fmt.Errorf("proposer payout create tx failed - %v", err), nil
14541448
}
14551449
if tx != nil {
1456-
log.Info("Proposer payout create tx succeeded, proceeding to commit tx")
14571450
_, err = w.commitTransaction(env, tx)
14581451
if err != nil {
1459-
log.Error("Proposer payout commit tx failed", "hash", tx.Hash().String(), "err", err)
14601452
return fmt.Errorf("proposer payout commit tx failed - %v", err), nil
14611453
}
1462-
log.Info("Proposer payout commit tx succeeded", "hash", tx.Hash().String())
14631454
env.tcount++
14641455
} else {
14651456
return errors.New("proposer payout create tx failed due to tx is nil"), nil
14661457
}
14671458
} else {
1468-
log.Warn("Proposer payout create tx failed due to not enough balance", "profit", profit.String())
14691459
return errors.New("proposer payout create tx failed due to not enough balance"), nil
14701460
}
14711461

@@ -1494,7 +1484,7 @@ func (w *worker) generateWork(params *generateParams) (*types.Block, *big.Int, e
14941484
if errors.Is(err, errBlockInterruptedByTimeout) {
14951485
log.Warn("Block building is interrupted", "allowance", common.PrettyDuration(w.newpayloadTimeout))
14961486
}
1497-
log.Info("Filled block with transactions", "time", time.Since(start), "gas used", work.header.GasUsed, "txs", work.txs)
1487+
log.Debug("Filled block with transactions", "time", time.Since(start), "gas used", work.header.GasUsed, "txs", len(work.txs))
14981488
}
14991489
block, err := w.engine.FinalizeAndAssemble(w.chain, work.header, work.state, work.txs, work.unclelist(), work.receipts, params.withdrawals)
15001490
if err != nil {
@@ -1921,7 +1911,7 @@ func (w *worker) createProposerPayoutTx(env *environment, recipient *common.Addr
19211911
}
19221912
gasPrice := new(big.Int).Set(env.header.BaseFee)
19231913
chainId := w.chainConfig.ChainID
1924-
log.Debug("createProposerPayoutTx", "sender", sender, "chainId", chainId.String(), "nonce", nonce, "amount", amount.String(), "baseFee", env.header.BaseFee.String(), "fee", fee)
1914+
log.Trace("createProposerPayoutTx", "sender", sender, "chainId", chainId.String(), "nonce", nonce, "amount", amount.String(), "baseFee", env.header.BaseFee.String(), "fee", fee)
19251915
tx := types.NewTransaction(nonce, *recipient, amount, paymentTxGas, gasPrice, nil)
19261916
return types.SignTx(tx, types.LatestSignerForChainID(chainId), w.config.BuilderTxSigningKey)
19271917
}

0 commit comments

Comments
 (0)