@@ -37,6 +37,7 @@ import (
37
37
"github.com/ethereum/go-ethereum/eth/tracers/logger"
38
38
"github.com/ethereum/go-ethereum/event"
39
39
"github.com/ethereum/go-ethereum/log"
40
+ "github.com/ethereum/go-ethereum/metrics"
40
41
"github.com/ethereum/go-ethereum/params"
41
42
"github.com/ethereum/go-ethereum/trie"
42
43
)
@@ -1388,7 +1389,11 @@ func (w *worker) fillTransactionsAlgoWorker(interrupt *int32, env *environment)
1388
1389
}
1389
1390
1390
1391
builder := newGreedyBuilder (w .chain , w .chainConfig , w .blockList , env , interrupt )
1392
+ start := time .Now ()
1391
1393
newEnv , blockBundles := builder .buildBlock (bundlesToConsider , pending )
1394
+ if metrics .EnabledBuilder {
1395
+ mergeAlgoTimer .Update (time .Since (start ))
1396
+ }
1392
1397
* env = * newEnv
1393
1398
1394
1399
return nil , blockBundles , bundlesToConsider
@@ -1432,6 +1437,14 @@ func (w *worker) generateWork(params *generateParams) (*types.Block, error) {
1432
1437
}
1433
1438
1434
1439
log .Info ("Block finalized and assembled" , "blockProfit" , ethIntToFloat (block .Profit ), "txs" , len (env .txs ), "bundles" , len (blockBundles ), "gasUsed" , block .GasUsed (), "time" , time .Since (start ))
1440
+ if metrics .EnabledBuilder {
1441
+ buildBlockTimer .Update (time .Since (start ))
1442
+ blockProfitHistogram .Update (block .Profit .Int64 ())
1443
+ blockProfitGauge .Update (block .Profit .Int64 ())
1444
+ culmulativeProfitGauge .Inc (block .Profit .Int64 ())
1445
+ gasUsedGauge .Update (int64 (block .GasUsed ()))
1446
+ transactionNumGauge .Update (int64 (len (env .txs )))
1447
+ }
1435
1448
if params .onBlock != nil {
1436
1449
go params .onBlock (block , orderCloseTime , blockBundles , allBundles )
1437
1450
}
@@ -1722,17 +1735,37 @@ func (w *worker) simulateBundles(env *environment, bundles []types.MevBundle, pe
1722
1735
wg .Add (1 )
1723
1736
go func (idx int , bundle types.MevBundle , state * state.StateDB ) {
1724
1737
defer wg .Done ()
1738
+
1739
+ start := time .Now ()
1740
+ if metrics .EnabledBuilder {
1741
+ bundleTxNumHistogram .Update (int64 (len (bundle .Txs )))
1742
+ }
1743
+
1725
1744
if len (bundle .Txs ) == 0 {
1726
1745
return
1727
1746
}
1728
1747
gasPool := new (core.GasPool ).AddGas (env .header .GasLimit )
1729
1748
simmed , err := w .computeBundleGas (env , bundle , state , gasPool , pendingTxs , 0 )
1730
1749
1750
+ if metrics .EnabledBuilder {
1751
+ simulationMeter .Mark (1 )
1752
+ }
1753
+
1731
1754
if err != nil {
1755
+ if metrics .EnabledBuilder {
1756
+ simulationRevertedMeter .Mark (1 )
1757
+ failedBundleSimulationTimer .UpdateSince (start )
1758
+ }
1759
+
1732
1760
log .Trace ("Error computing gas for a bundle" , "error" , err )
1733
1761
return
1734
1762
}
1735
1763
simResult [idx ] = & simmed
1764
+
1765
+ if metrics .EnabledBuilder {
1766
+ simulationCommittedMeter .Mark (1 )
1767
+ successfulBundleSimulationTimer .UpdateSince (start )
1768
+ }
1736
1769
}(i , bundle , env .state .Copy ())
1737
1770
}
1738
1771
@@ -1748,6 +1781,9 @@ func (w *worker) simulateBundles(env *environment, bundles []types.MevBundle, pe
1748
1781
}
1749
1782
1750
1783
log .Debug ("Simulated bundles" , "block" , env .header .Number , "allBundles" , len (bundles ), "okBundles" , len (simulatedBundles ), "time" , time .Since (start ))
1784
+ if metrics .EnabledBuilder {
1785
+ blockBundleSimulationTimer .Update (time .Since (start ))
1786
+ }
1751
1787
return simulatedBundles , nil
1752
1788
}
1753
1789
0 commit comments