@@ -1495,6 +1495,49 @@ func (s *StateDB) handleDestruction(nodes *trienode.MergedNodeSet) (map[common.A
14951495 return incomplete , nil
14961496}
14971497
1498+ func (s * StateDB ) DebugPrint (block uint64 , deleteEmptyObjects bool ) {
1499+ log .Info ("================== block start ===============" , "number" , block )
1500+ hash := s .IntermediateRoot (deleteEmptyObjects )
1501+ log .Info ("mpt root" , "hash" , hash )
1502+
1503+ addrs := make ([]common.Address , 0 )
1504+ for addr := range s .stateObjectsDirty {
1505+ if obj := s .stateObjects [addr ]; ! obj .deleted {
1506+ addrs = append (addrs , addr )
1507+ }
1508+ }
1509+ sort .SliceStable (addrs , func (i , j int ) bool {
1510+ return addrs [i ].Cmp (addrs [j ]) < 0
1511+ })
1512+
1513+ for _ , addr := range addrs {
1514+ if obj := s .stateObjects [addr ]; ! obj .deleted {
1515+ log .Info ("state object" , "address" , obj .address )
1516+ log .Info ("state object" , "addrHash" , obj .addrHash )
1517+ log .Info ("state object" , "dirtyCode" , obj .dirtyCode )
1518+ log .Info ("state object" , "selfDestructed" , obj .selfDestructed )
1519+ log .Info ("state object" , "deleted" , obj .deleted )
1520+ log .Info ("state object" , "created" , obj .created )
1521+ if obj .origin != nil {
1522+ log .Info ("state object origin" , "Nonce" , obj .origin .Nonce )
1523+ log .Info ("state object origin" , "Balance" , obj .origin .Balance )
1524+ log .Info ("state object origin" , "Root" , obj .origin .Root )
1525+ log .Info ("state object origin" , "CodeHash" , common .Bytes2Hex (obj .origin .CodeHash ))
1526+ } else {
1527+ log .Info ("state object origin is nil" )
1528+ }
1529+ log .Info ("state object new" , "Nonce" , obj .data .Nonce )
1530+ log .Info ("state object new" , "Balance" , obj .data .Balance )
1531+ log .Info ("state object new" , "Root" , obj .data .Root )
1532+ log .Info ("state object new" , "CodeHash" , common .Bytes2Hex (obj .data .CodeHash ))
1533+ }
1534+ }
1535+ log .Info ("================== block end ================" , "number" , block )
1536+ if block == 1 {
1537+ log .Crit ("exit...." )
1538+ }
1539+ }
1540+
14981541// Once the state is committed, tries cached in stateDB (including account
14991542// trie, storage tries) will no longer be functional. A new state instance
15001543// must be created with new root and updated database for accessing post-
0 commit comments