@@ -31,7 +31,6 @@ import (
31
31
"sync/atomic"
32
32
"time"
33
33
34
- "github.com/holiman/uint256"
35
34
"golang.org/x/sync/errgroup"
36
35
"golang.org/x/sync/semaphore"
37
36
@@ -63,7 +62,6 @@ import (
63
62
"github.com/erigontech/erigon/polygon/heimdall"
64
63
"github.com/erigontech/erigon/turbo/services"
65
64
"github.com/erigontech/erigon/turbo/snapshotsync"
66
- "github.com/erigontech/erigon/txnprovider/txpool"
67
65
)
68
66
69
67
type RoSnapshots struct {
@@ -587,29 +585,35 @@ func DumpTxs(ctx context.Context, db kv.RoDB, chainConfig *chain.Config, blockFr
587
585
warmupCtx , cancel := context .WithCancel (ctx )
588
586
defer cancel ()
589
587
590
- chainID , _ := uint256 .FromBig (chainConfig .ChainID )
591
-
592
588
numBuf := make ([]byte , 8 )
593
589
594
- parse := func (ctx * txpool. TxnParseContext , v , valueBuf []byte , senders []common2.Address , j int ) ([]byte , error ) {
590
+ parse := func (v , valueBuf []byte , senders []common2.Address , j int ) ([]byte , error ) {
595
591
var sender [20 ]byte
596
- slot := txpool.TxnSlot {}
597
-
598
- if _ , err := ctx .ParseTransaction (v , 0 , & slot , sender [:], false /* hasEnvelope */ , false /* wrappedWithBlobs */ , nil ); err != nil {
599
- return valueBuf , err
592
+ txn2 , err := types .DecodeTransaction (v )
593
+ if err != nil {
594
+ return nil , err
600
595
}
596
+ hash := txn2 .Hash ()
597
+ hashFirstByte := hash [:1 ]
601
598
if len (senders ) > 0 {
599
+ txn2 .SetSender (senders [j ])
602
600
sender = senders [j ]
601
+ } else {
602
+ signer := types .LatestSignerForChainID (chainConfig .ChainID )
603
+ sender , err = txn2 .Sender (* signer )
604
+ if err != nil {
605
+ return nil , err
606
+ }
603
607
}
604
608
605
609
valueBuf = valueBuf [:0 ]
606
- valueBuf = append (valueBuf , slot . IDHash [: 1 ] ... )
610
+ valueBuf = append (valueBuf , hashFirstByte ... )
607
611
valueBuf = append (valueBuf , sender [:]... )
608
612
valueBuf = append (valueBuf , v ... )
609
613
return valueBuf , nil
610
614
}
611
615
612
- addSystemTx := func (ctx * txpool. TxnParseContext , tx kv.Tx , txId types.BaseTxnID ) error {
616
+ addSystemTx := func (tx kv.Tx , txId types.BaseTxnID ) error {
613
617
binary .BigEndian .PutUint64 (numBuf , txId .U64 ())
614
618
tv , err := tx .GetOne (kv .EthTx , numBuf )
615
619
if err != nil {
@@ -622,12 +626,10 @@ func DumpTxs(ctx context.Context, db kv.RoDB, chainConfig *chain.Config, blockFr
622
626
return nil
623
627
}
624
628
625
- ctx .WithSender (false )
626
-
627
629
valueBuf := bufPool .Get ().(* [16 * 4096 ]byte )
628
630
defer bufPool .Put (valueBuf )
629
631
630
- parsed , err := parse (ctx , tv , valueBuf [:], nil , 0 )
632
+ parsed , err := parse (tv , valueBuf [:], nil , 0 )
631
633
if err != nil {
632
634
return err
633
635
}
@@ -689,16 +691,14 @@ func DumpTxs(ctx context.Context, db kv.RoDB, chainConfig *chain.Config, blockFr
689
691
parsers .SetLimit (workers )
690
692
691
693
valueBufs := make ([][]byte , workers )
692
- parseCtxs := make ([]* txpool.TxnParseContext , workers )
693
694
694
695
for i := 0 ; i < workers ; i ++ {
695
696
valueBuf := bufPool .Get ().(* [16 * 4096 ]byte )
696
697
defer bufPool .Put (valueBuf )
697
698
valueBufs [i ] = valueBuf [:]
698
- parseCtxs [i ] = txpool .NewTxnParseContext (* chainID )
699
699
}
700
700
701
- if err := addSystemTx (parseCtxs [ 0 ], tx , body .BaseTxnID ); err != nil {
701
+ if err := addSystemTx (tx , body .BaseTxnID ); err != nil {
702
702
return false , err
703
703
}
704
704
@@ -715,14 +715,9 @@ func DumpTxs(ctx context.Context, db kv.RoDB, chainConfig *chain.Config, blockFr
715
715
j ++
716
716
717
717
parsers .Go (func () error {
718
- parseCtx := parseCtxs [tx % workers ]
719
-
720
- parseCtx .WithSender (len (senders ) == 0 )
721
- parseCtx .WithAllowPreEip2s (blockNum <= chainConfig .HomesteadBlock .Uint64 ())
722
-
723
- valueBuf , err := parse (parseCtx , tv , valueBufs [tx % workers ], senders , tx )
724
-
718
+ valueBuf , err := parse (tv , valueBufs [tx % workers ], senders , tx )
725
719
if err != nil {
720
+ log .Warn ("[snapshots] DumpTxs parsing" , "err" , err , "blockNum" , blockNum , "rlp" , hex .EncodeToString (v ))
726
721
return fmt .Errorf ("%w, block: %d" , err , blockNum )
727
722
}
728
723
@@ -753,21 +748,21 @@ func DumpTxs(ctx context.Context, db kv.RoDB, chainConfig *chain.Config, blockFr
753
748
return false , fmt .Errorf ("ForAmount parser: %w" , err )
754
749
}
755
750
756
- if err := addSystemTx (parseCtxs [ 0 ], tx , types .BaseTxnID (body .BaseTxnID .LastSystemTx (body .TxCount ))); err != nil {
751
+ if err := addSystemTx (tx , types .BaseTxnID (body .BaseTxnID .LastSystemTx (body .TxCount ))); err != nil {
757
752
return false , err
758
753
}
759
754
760
755
select {
761
756
case <- ctx .Done ():
762
757
return false , ctx .Err ()
763
758
case <- logEvery .C :
764
- var m runtime.MemStats
765
759
if lvl >= log .LvlInfo {
760
+ var m runtime.MemStats
766
761
dbg .ReadMemStats (& m )
762
+ logger .Log (lvl , "[snapshots] Dumping txs" , "block num" , blockNum , "alloc" , common2 .ByteCount (m .Alloc ), "sys" , common2 .ByteCount (m .Sys ))
763
+ } else {
764
+ logger .Log (lvl , "[snapshots] Dumping txs" , "block num" , blockNum )
767
765
}
768
- logger .Log (lvl , "[snapshots] Dumping txs" , "block num" , blockNum ,
769
- "alloc" , common2 .ByteCount (m .Alloc ), "sys" , common2 .ByteCount (m .Sys ),
770
- )
771
766
default :
772
767
}
773
768
return true , nil
0 commit comments