@@ -32,6 +32,7 @@ import (
32
32
"github.com/ethereum/go-ethereum/common"
33
33
"github.com/ethereum/go-ethereum/common/gopool"
34
34
"github.com/ethereum/go-ethereum/common/hexutil"
35
+ "github.com/ethereum/go-ethereum/common/systemcontract"
35
36
"github.com/ethereum/go-ethereum/consensus"
36
37
"github.com/ethereum/go-ethereum/core"
37
38
"github.com/ethereum/go-ethereum/core/rawdb"
@@ -281,6 +282,7 @@ func (api *API) traceChain(ctx context.Context, start, end *types.Block, config
281
282
BlockHash : task .block .Hash (),
282
283
TxIndex : i ,
283
284
TxHash : tx .Hash (),
285
+ TxCount : len (task .block .Transactions ()),
284
286
}
285
287
res , err := api .traceTx (localctx , msg , txctx , blockCtx , task .statedb , config )
286
288
if err != nil {
@@ -540,7 +542,15 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config
540
542
statedb .SetBalance (consensus .SystemAddress , big .NewInt (0 ))
541
543
statedb .AddBalance (vmctx .Coinbase , balance )
542
544
}
545
+ if i == len (block .Transactions ())- 1 && tx .To ().Hex () == systemcontract .ValidatorContract {
546
+ blockRewards := posa .BlockRewards (block .Header ().Number )
547
+ if blockRewards != nil {
548
+ statedb .AddBalance (vmctx .Coinbase , blockRewards )
549
+ }
550
+ }
551
+
543
552
}
553
+
544
554
}
545
555
546
556
statedb .Prepare (tx .Hash (), block .Hash (), i )
@@ -621,6 +631,7 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
621
631
BlockHash : blockHash ,
622
632
TxIndex : task .index ,
623
633
TxHash : txs [task .index ].Hash (),
634
+ TxCount : len (txs ),
624
635
}
625
636
res , err := api .traceTx (ctx , msg , txctx , blockCtx , task .statedb , config )
626
637
if err != nil {
@@ -640,14 +651,19 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
640
651
641
652
// Generate the next state snapshot fast without tracing
642
653
msg , _ := tx .AsMessage (signer )
643
-
644
654
if posa , ok := api .backend .Engine ().(consensus.PoSA ); ok {
645
655
if isSystem , _ := posa .IsSystemTransaction (tx , block .Header ()); isSystem {
646
656
balance := statedb .GetBalance (consensus .SystemAddress )
647
657
if balance .Cmp (common .Big0 ) > 0 {
648
658
statedb .SetBalance (consensus .SystemAddress , big .NewInt (0 ))
649
659
statedb .AddBalance (block .Header ().Coinbase , balance )
650
660
}
661
+ if i == len (txs )- 1 && tx .To ().Hex () == systemcontract .ValidatorContract {
662
+ blockRewards := posa .BlockRewards (block .Header ().Number )
663
+ if blockRewards != nil {
664
+ statedb .AddBalance (block .Header ().Coinbase , blockRewards )
665
+ }
666
+ }
651
667
}
652
668
}
653
669
@@ -772,6 +788,12 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block
772
788
statedb .SetBalance (consensus .SystemAddress , big .NewInt (0 ))
773
789
statedb .AddBalance (vmctx .Coinbase , balance )
774
790
}
791
+ if i == len (block .Transactions ())- 1 && tx .To ().Hex () == systemcontract .ValidatorContract {
792
+ blockRewards := posa .BlockRewards (block .Header ().Number )
793
+ if blockRewards != nil {
794
+ statedb .AddBalance (vmctx .Coinbase , blockRewards )
795
+ }
796
+ }
775
797
}
776
798
}
777
799
statedb .Prepare (tx .Hash (), block .Hash (), i )
@@ -836,6 +858,7 @@ func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *
836
858
BlockHash : blockHash ,
837
859
TxIndex : int (index ),
838
860
TxHash : hash ,
861
+ TxCount : len (block .Transactions ()),
839
862
}
840
863
return api .traceTx (ctx , msg , txctx , vmctx , statedb , config )
841
864
}
@@ -938,6 +961,13 @@ func (api *API) traceTx(ctx context.Context, message core.Message, txctx *Contex
938
961
statedb .SetBalance (consensus .SystemAddress , big .NewInt (0 ))
939
962
statedb .AddBalance (vmctx .Coinbase , balance )
940
963
}
964
+ if txctx .TxIndex == txctx .TxCount - 1 && message .To ().Hex () == systemcontract .ValidatorContract {
965
+ blockRewards := posa .BlockRewards (vmctx .BlockNumber )
966
+ if blockRewards != nil {
967
+ statedb .AddBalance (vmctx .Coinbase , blockRewards )
968
+ }
969
+ }
970
+
941
971
}
942
972
943
973
// Call Prepare to clear out the statedb access list
0 commit comments