@@ -44,12 +44,16 @@ func NewDirectTxReaper(
4444 interval time.Duration ,
4545 logger log.EventLogger ,
4646 store ds.Batching ,
47+ daStartHeight uint64 ,
4748) * DirectTxReaper {
49+ if daStartHeight == 0 {
50+ daStartHeight = 1
51+ }
4852 if interval <= 0 {
4953 interval = 100 * time .Millisecond
5054 }
5155 daHeight := new (atomic.Uint64 )
52- daHeight .Store (1 )
56+ daHeight .Store (daStartHeight )
5357 return & DirectTxReaper {
5458 da : da ,
5559 sequencer : sequencer ,
@@ -80,7 +84,7 @@ func (r *DirectTxReaper) Start(ctx context.Context) {
8084 return
8185 case <- ticker .C :
8286 daHeight := r .daHeight .Load ()
83- if err := r .SubmitTxs (daHeight ); err != nil {
87+ if err := r .retrieveDirectTXs (daHeight ); err != nil {
8488 if strings .Contains (err .Error (), coreda .ErrHeightFromFuture .Error ()) {
8589 r .logger .Debug ("IDs not found at height" , "height" , daHeight )
8690 } else {
@@ -94,8 +98,8 @@ func (r *DirectTxReaper) Start(ctx context.Context) {
9498 }
9599}
96100
97- // SubmitTxs retrieves direct transactions from the DA layer and submits them to the sequencer.
98- func (r * DirectTxReaper ) SubmitTxs (daHeight uint64 ) error {
101+ // retrieveDirectTXs retrieves direct transactions from the DA layer and submits them to the sequencer.
102+ func (r * DirectTxReaper ) retrieveDirectTXs (daHeight uint64 ) error {
99103 // Get the latest DA height
100104 // Get all blob IDs at the current DA height
101105 result , err := r .da .GetIDs (r .ctx , daHeight , nil )
@@ -115,7 +119,7 @@ func (r *DirectTxReaper) SubmitTxs(daHeight uint64) error {
115119 }
116120 r .logger .Debug ("Blobs found at height" , "height" , daHeight , "count" , len (blobs ))
117121
118- var newTxs [][] byte
122+ var newTxs []sequencer. DirectTX
119123 for _ , blob := range blobs {
120124 r .logger .Debug ("Processing blob data" )
121125
@@ -134,18 +138,21 @@ func (r *DirectTxReaper) SubmitTxs(daHeight uint64) error {
134138 }
135139
136140 // Process each transaction in the blob
137- for _ , tx := range data .Txs {
141+ for i , tx := range data .Txs {
138142 txHash := hashTx (tx )
139143 has , err := r .seenStore .Has (r .ctx , ds .NewKey (txHash ))
140144 if err != nil {
141145 return fmt .Errorf ("check seenStore: %w" , err )
142146 }
143147 if ! has {
144- newTxs = append (newTxs , tx )
148+ newTxs = append (newTxs , sequencer.DirectTX {
149+ TX : tx ,
150+ ID : result .IDs [i ],
151+ FirstSeenHeight : daHeight ,
152+ FirstSeenTime : result .Timestamp .Unix (),
153+ })
145154 }
146155 }
147- // todo: apply checks"
148- // DA header time: result.Timestamp
149156 }
150157
151158 if len (newTxs ) == 0 {
@@ -154,13 +161,13 @@ func (r *DirectTxReaper) SubmitTxs(daHeight uint64) error {
154161 }
155162
156163 r .logger .Debug ("Submitting direct txs to sequencer" , "txCount" , len (newTxs ))
157- err = r .sequencer .SubmitDirectTxs (r .ctx , newTxs )
164+ err = r .sequencer .SubmitDirectTxs (r .ctx , newTxs ... )
158165 if err != nil {
159166 return fmt .Errorf ("submit direct txs to sequencer: %w" , err )
160167 }
161168 // Mark the transactions as seen
162- for _ , tx := range newTxs {
163- txHash := hashTx (tx )
169+ for _ , v := range newTxs {
170+ txHash := hashTx (v . TX )
164171 if err := r .seenStore .Put (r .ctx , ds .NewKey (txHash ), []byte {1 }); err != nil {
165172 return fmt .Errorf ("persist seen tx: %w" , err )
166173 }
0 commit comments