@@ -532,7 +532,7 @@ func (ct *catchpointTracker) commitRound(ctx context.Context, tx *sql.Tx, dcc *d
532532 dcc .stats .MerkleTrieUpdateDuration = time .Duration (time .Now ().UnixNano ())
533533 }
534534
535- err = ct .accountsUpdateBalances (dcc .compactAccountDeltas , dcc .compactResourcesDeltas , dcc .compactKvDeltas )
535+ err = ct .accountsUpdateBalances (dcc .compactAccountDeltas , dcc .compactResourcesDeltas , dcc .compactKvDeltas , dcc . oldBase , dcc . newBase )
536536 if err != nil {
537537 return err
538538 }
@@ -928,7 +928,7 @@ func (ct *catchpointTracker) close() {
928928}
929929
930930// accountsUpdateBalances applies the given compactAccountDeltas to the merkle trie
931- func (ct * catchpointTracker ) accountsUpdateBalances (accountsDeltas compactAccountDeltas , resourcesDeltas compactResourcesDeltas , kvDeltas map [string ]modifiedKvValue ) (err error ) {
931+ func (ct * catchpointTracker ) accountsUpdateBalances (accountsDeltas compactAccountDeltas , resourcesDeltas compactResourcesDeltas , kvDeltas map [string ]modifiedKvValue , oldBase basics. Round , newBase basics. Round ) (err error ) {
932932 if ! ct .catchpointEnabled () {
933933 return nil
934934 }
@@ -1045,10 +1045,32 @@ func (ct *catchpointTracker) accountsUpdateBalances(accountsDeltas compactAccoun
10451045 }
10461046
10471047 // write it all to disk.
1048+ var cstats merkletrie.CommitStats
10481049 if accumulatedChanges > 0 {
1049- _ , err = ct .balancesTrie .Commit ()
1050+ cstats , err = ct .balancesTrie .Commit ()
10501051 }
10511052
1053+ if ct .log .GetTelemetryEnabled () {
1054+ root , rootErr := ct .balancesTrie .RootHash ()
1055+ if rootErr != nil {
1056+ ct .log .Infof ("accountsUpdateBalances: error retrieving balances trie root: %v" , rootErr )
1057+ return
1058+ }
1059+ ct .log .EventWithDetails (telemetryspec .Accounts , telemetryspec .CatchpointRootUpdateEvent , telemetryspec.CatchpointRootUpdateEventDetails {
1060+ Root : root .String (),
1061+ OldBase : uint64 (oldBase ),
1062+ NewBase : uint64 (newBase ),
1063+ NewPageCount : cstats .NewPageCount ,
1064+ NewNodeCount : cstats .NewNodeCount ,
1065+ UpdatedPageCount : cstats .UpdatedPageCount ,
1066+ UpdatedNodeCount : cstats .UpdatedNodeCount ,
1067+ DeletedPageCount : cstats .DeletedPageCount ,
1068+ FanoutReallocatedNodeCount : cstats .FanoutReallocatedNodeCount ,
1069+ PackingReallocatedNodeCount : cstats .PackingReallocatedNodeCount ,
1070+ LoadedPages : cstats .LoadedPages ,
1071+ })
1072+
1073+ }
10521074 return
10531075}
10541076
0 commit comments