@@ -139,10 +139,7 @@ func newL2(cfg *config.L2) (*L2, error) {
139
139
}
140
140
141
141
{ // blocks, blockHeight
142
- ctx , cancel := context .WithTimeout (context .Background (), time .Second )
143
- defer cancel ()
144
-
145
- blockHeight , err := l2 .rpc .BlockNumber (ctx )
142
+ blockHeight , err := l2 .rpc .BlockNumber (context .Background ())
146
143
if err != nil {
147
144
l .Error ("Failed to request block number" ,
148
145
zap .Error (err ),
@@ -190,9 +187,6 @@ func (l2 *L2) stop() {
190
187
func (l2 * L2 ) processNewBlocks (ctx context.Context ) {
191
188
l := logutils .LoggerFromContext (ctx )
192
189
193
- ctx , cancel := context .WithTimeout (ctx , time .Second )
194
- defer cancel ()
195
-
196
190
blockHeight , err := l2 .rpc .BlockNumber (ctx )
197
191
if err != nil {
198
192
l .Warn ("Failed to request block number, skipping this round..." ,
@@ -243,9 +237,6 @@ func (l2 *L2) processNewBlocks(ctx context.Context) {
243
237
func (l2 * L2 ) processBlock (ctx context.Context , blockNumber uint64 ) error {
244
238
l := logutils .LoggerFromContext (ctx )
245
239
246
- ctx , cancel := context .WithTimeout (ctx , time .Second )
247
- defer cancel ()
248
-
249
240
block , err := l2 .rpc .BlockByNumber (ctx , big .NewInt (int64 (blockNumber )))
250
241
if err != nil {
251
242
l .Warn ("Failed to request block by number" ,
@@ -391,9 +382,6 @@ func (l2 *L2) processReorgByHash(ctx context.Context) error {
391
382
)
392
383
}
393
384
394
- ctx , cancel := context .WithTimeout (ctx , time .Second )
395
- defer cancel ()
396
-
397
385
block , err := l2 .rpc .BlockByNumber (ctx , br .number )
398
386
if err != nil {
399
387
l .Warn ("Failed to request block by number, skipping this round of unwind..." ,
@@ -549,9 +537,6 @@ func (l2 *L2) observeWallets(ctx context.Context, o otelapi.Observer) error {
549
537
errs := make ([]error , 0 )
550
538
551
539
for name , addr := range l2 .wallets {
552
- ctx , cancel := context .WithTimeout (ctx , time .Second )
553
- defer cancel ()
554
-
555
540
_balance , err := l2 .rpc .BalanceAt (ctx , addr , nil )
556
541
if err != nil {
557
542
l .Warn ("Failed to request balance" ,
@@ -585,10 +570,7 @@ func (l2 *L2) sendProbeTx(ctx context.Context) {
585
570
)
586
571
587
572
{ // get the gas price
588
- _ctx , cancel := context .WithTimeout (ctx , time .Second )
589
- defer cancel ()
590
-
591
- gasPrice , err = l2 .rpc .SuggestGasPrice (_ctx )
573
+ gasPrice , err = l2 .rpc .SuggestGasPrice (ctx )
592
574
if err == nil {
593
575
metrics .GasPrice_Old .Record (ctx , gasPrice .Int64 ())
594
576
} else {
@@ -610,10 +592,7 @@ func (l2 *L2) sendProbeTx(ctx context.Context) {
610
592
}
611
593
612
594
if l2 .nonce == 0 { // get the nonce
613
- _ctx , cancel := context .WithTimeout (ctx , time .Second )
614
- defer cancel ()
615
-
616
- nonce , err := l2 .rpc .NonceAt (_ctx , l2 .monitorAddr , nil )
595
+ nonce , err := l2 .rpc .NonceAt (ctx , l2 .monitorAddr , nil )
617
596
if err != nil {
618
597
l .Warn ("Failed to request a nonce" ,
619
598
zap .Error (err ),
@@ -655,10 +634,7 @@ tryingNonces:
655
634
return
656
635
}
657
636
658
- _ctx , cancel := context .WithTimeout (ctx , time .Second )
659
- defer cancel ()
660
-
661
- err = l2 .rpc .SendTransaction (_ctx , signedTx )
637
+ err = l2 .rpc .SendTransaction (ctx , signedTx )
662
638
if err == nil {
663
639
metrics .ProbesSentCount .Add (ctx , 1 )
664
640
l2 .nonce ++
@@ -705,10 +681,7 @@ tryingNonces:
705
681
continue tryingNonces
706
682
707
683
case strings .Contains (err .Error (), "nonce too low" ):
708
- _ctx , cancel := context .WithTimeout (ctx , time .Second )
709
- defer cancel ()
710
-
711
- nonce , err := l2 .rpc .NonceAt (_ctx , l2 .monitorAddr , nil )
684
+ nonce , err := l2 .rpc .NonceAt (ctx , l2 .monitorAddr , nil )
712
685
if err != nil {
713
686
l .Warn ("Failed to request a nonce" ,
714
687
zap .Error (err ),
0 commit comments