1
1
package preconfblocks
2
2
3
3
import (
4
+ "context"
4
5
"errors"
5
6
"fmt"
6
7
"math/big"
@@ -67,9 +68,12 @@ func (s *PreconfBlockAPIServer) BuildPreconfBlock(c echo.Context) error {
67
68
s .mutex .Lock ()
68
69
defer s .mutex .Unlock ()
69
70
71
+ // make a new context, we dont want to cancel the request if the caller times out.
72
+ ctx := context .Background ()
73
+
70
74
if s .rpc .PacayaClients .TaikoWrapper != nil {
71
75
// Check if the preconfirmation is enabled.
72
- preconfRouter , err := s .rpc .GetPreconfRouterPacaya (& bind.CallOpts {Context : c . Request (). Context () })
76
+ preconfRouter , err := s .rpc .GetPreconfRouterPacaya (& bind.CallOpts {Context : ctx })
73
77
if err != nil {
74
78
return s .returnError (c , http .StatusInternalServerError , err )
75
79
}
@@ -92,7 +96,7 @@ func (s *PreconfBlockAPIServer) BuildPreconfBlock(c echo.Context) error {
92
96
return s .returnError (c , http .StatusBadRequest , errors .New ("executable data is required" ))
93
97
}
94
98
95
- parent , err := s .rpc .L2 .HeaderByHash (c . Request (). Context () , reqBody .ExecutableData .ParentHash )
99
+ parent , err := s .rpc .L2 .HeaderByHash (ctx , reqBody .ExecutableData .ParentHash )
96
100
if err != nil {
97
101
return s .returnError (c , http .StatusInternalServerError , err )
98
102
}
@@ -163,7 +167,7 @@ func (s *PreconfBlockAPIServer) BuildPreconfBlock(c echo.Context) error {
163
167
}
164
168
165
169
// Check if the L2 execution engine is syncing from L1.
166
- progress , err := s .rpc .L2ExecutionEngineSyncProgress (c . Request (). Context () )
170
+ progress , err := s .rpc .L2ExecutionEngineSyncProgress (ctx )
167
171
if err != nil {
168
172
return s .returnError (c , http .StatusBadRequest , err )
169
173
}
@@ -173,7 +177,7 @@ func (s *PreconfBlockAPIServer) BuildPreconfBlock(c echo.Context) error {
173
177
174
178
// Insert the preconfirmation block.
175
179
headers , err := s .chainSyncer .InsertPreconfBlocksFromExecutionPayloads (
176
- c . Request (). Context () ,
180
+ ctx ,
177
181
[]* eth.ExecutionPayload {executablePayload },
178
182
false ,
179
183
)
@@ -214,7 +218,7 @@ func (s *PreconfBlockAPIServer) BuildPreconfBlock(c echo.Context) error {
214
218
)
215
219
} else {
216
220
if err := s .p2pNode .GossipOut ().PublishL2Payload (
217
- c . Request (). Context () ,
221
+ ctx ,
218
222
& eth.ExecutionPayloadEnvelope {
219
223
ExecutionPayload : & eth.ExecutionPayload {
220
224
BaseFeePerGas : eth .Uint256Quantity (u256 ),
0 commit comments