Skip to content

Commit f1bcc4a

Browse files
authored
fix(taiko-client): dont use c.Request().Context() (#19592)
1 parent 55962b3 commit f1bcc4a

File tree

1 file changed

+9
-5
lines changed
  • packages/taiko-client/driver/preconf_blocks

1 file changed

+9
-5
lines changed

packages/taiko-client/driver/preconf_blocks/api.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package preconfblocks
22

33
import (
4+
"context"
45
"errors"
56
"fmt"
67
"math/big"
@@ -67,9 +68,12 @@ func (s *PreconfBlockAPIServer) BuildPreconfBlock(c echo.Context) error {
6768
s.mutex.Lock()
6869
defer s.mutex.Unlock()
6970

71+
// make a new context, we dont want to cancel the request if the caller times out.
72+
ctx := context.Background()
73+
7074
if s.rpc.PacayaClients.TaikoWrapper != nil {
7175
// 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})
7377
if err != nil {
7478
return s.returnError(c, http.StatusInternalServerError, err)
7579
}
@@ -92,7 +96,7 @@ func (s *PreconfBlockAPIServer) BuildPreconfBlock(c echo.Context) error {
9296
return s.returnError(c, http.StatusBadRequest, errors.New("executable data is required"))
9397
}
9498

95-
parent, err := s.rpc.L2.HeaderByHash(c.Request().Context(), reqBody.ExecutableData.ParentHash)
99+
parent, err := s.rpc.L2.HeaderByHash(ctx, reqBody.ExecutableData.ParentHash)
96100
if err != nil {
97101
return s.returnError(c, http.StatusInternalServerError, err)
98102
}
@@ -163,7 +167,7 @@ func (s *PreconfBlockAPIServer) BuildPreconfBlock(c echo.Context) error {
163167
}
164168

165169
// 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)
167171
if err != nil {
168172
return s.returnError(c, http.StatusBadRequest, err)
169173
}
@@ -173,7 +177,7 @@ func (s *PreconfBlockAPIServer) BuildPreconfBlock(c echo.Context) error {
173177

174178
// Insert the preconfirmation block.
175179
headers, err := s.chainSyncer.InsertPreconfBlocksFromExecutionPayloads(
176-
c.Request().Context(),
180+
ctx,
177181
[]*eth.ExecutionPayload{executablePayload},
178182
false,
179183
)
@@ -214,7 +218,7 @@ func (s *PreconfBlockAPIServer) BuildPreconfBlock(c echo.Context) error {
214218
)
215219
} else {
216220
if err := s.p2pNode.GossipOut().PublishL2Payload(
217-
c.Request().Context(),
221+
ctx,
218222
&eth.ExecutionPayloadEnvelope{
219223
ExecutionPayload: &eth.ExecutionPayload{
220224
BaseFeePerGas: eth.Uint256Quantity(u256),

0 commit comments

Comments
 (0)