@@ -319,7 +319,11 @@ func startUpdateWorker(wg *sync.WaitGroup, db *database.DatabaseService, client,
319319 // check for transactions to/from proposer feeRecipient
320320 if checkTx {
321321 log .Infof ("checking %d tx..." , len (txs ))
322+
322323 for i , tx := range txs {
324+ if tx .ChainId ().Uint64 () == 0 {
325+ continue
326+ }
323327 txFrom , _ := types .Sender (types .LatestSignerForChainID (tx .ChainId ()), tx )
324328 if txFrom .Hex () == entry .ProposerFeeRecipient {
325329 _log .Infof ("- tx %d from feeRecipient with value %s" , i , tx .Value ().String ())
@@ -369,12 +373,35 @@ func startUpdateWorker(wg *sync.WaitGroup, db *database.DatabaseService, client,
369373 }).Info ("value check done" )
370374
371375 if ! coinbaseIsProposer {
372- // Get builder balance diff
376+ // Get builder profit/subsidy, taking into account possible tx from coinbase to builder-owned address
377+ // First, get the overall balance diff
373378 builderBalanceDiffWei , err := getBalanceDiff (block .Coinbase (), block .Number ())
374379 if err != nil {
375380 _log .WithError (err ).Fatalf ("couldn't get balance diff" )
376381 }
377- // fmt.Println("builder diff", block.Miner, builderBalanceDiffWei)
382+
383+ // Second, adjust for any tx from coinbase to builder-owned address.
384+ builderOwnedAddresses := vars .BuilderAddresses [strings .ToLower (block .Coinbase ().Hex ())]
385+ _log .Infof ("builderOwnedAddresses for %s: %+v (slot %d)" , block .Coinbase ().Hex (), builderOwnedAddresses , entry .Slot )
386+ for _ , tx := range txs {
387+ if tx .ChainId ().Uint64 () == 0 {
388+ continue
389+ }
390+
391+ txFrom , _ := types .Sender (types .LatestSignerForChainID (tx .ChainId ()), tx )
392+ isFromBuilderCoinbase := txFrom .Hex () == block .Coinbase ().Hex ()
393+ isToBuilderOwnedAddress := false
394+ if builderOwnedAddresses != nil && tx .To () != nil && builderOwnedAddresses [strings .ToLower (tx .To ().Hex ())] {
395+ isToBuilderOwnedAddress = true
396+ }
397+
398+ if isFromBuilderCoinbase && isToBuilderOwnedAddress {
399+ _log .Infof ("- Tx from coinbase to builder address found: %s -- adjusting value by +%s ETH" , tx .Hash ().Hex (), common .WeiToEth (tx .Value ()).String ())
400+ builderBalanceDiffWei = new (big.Int ).Add (builderBalanceDiffWei , tx .Value ())
401+ }
402+ }
403+
404+ // save
378405 entry .CoinbaseDiffWei = database .NewNullString (builderBalanceDiffWei .String ())
379406 entry .CoinbaseDiffEth = database .NewNullString (common .WeiToEth (builderBalanceDiffWei ).String ())
380407 }
0 commit comments