From 93f7bb73138ad8c8af9a9bd312e8bcc4436cb8db Mon Sep 17 00:00:00 2001 From: terence tsao Date: Thu, 5 May 2022 14:45:32 -0700 Subject: [PATCH 1/7] Add timeout values --- beacon-chain/powchain/engine_client.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/beacon-chain/powchain/engine_client.go b/beacon-chain/powchain/engine_client.go index 9a137c10bd88..3601d232def7 100644 --- a/beacon-chain/powchain/engine_client.go +++ b/beacon-chain/powchain/engine_client.go @@ -33,6 +33,10 @@ const ( ExecutionBlockByHashMethod = "eth_getBlockByHash" // ExecutionBlockByNumberMethod request string for JSON-RPC. ExecutionBlockByNumberMethod = "eth_getBlockByNumber" + // Defines the seconds to wait before timing out engine endpoints with block execution semantics. + blockExecutionTimeOut = 8 * time.Second + // Defines the seconds before timing out engine endpoints with non-block execution semantics. + nonBlockExecutionTimeOut = time.Second ) // ForkchoiceUpdatedResponse is the response kind received by the @@ -65,9 +69,11 @@ func (s *Service) NewPayload(ctx context.Context, payload *pb.ExecutionPayload) defer func() { newPayloadLatency.Observe(float64(time.Since(start).Milliseconds())) }() - + d := time.Now().Add(blockExecutionTimeOut) + ctx, cancel := context.WithDeadline(ctx, d) result := &pb.PayloadStatus{} err := s.rpcClient.CallContext(ctx, result, NewPayloadMethod, payload) + cancel() if err != nil { return nil, handleRPCError(err) } @@ -99,8 +105,11 @@ func (s *Service) ForkchoiceUpdated( forkchoiceUpdatedLatency.Observe(float64(time.Since(start).Milliseconds())) }() + d := time.Now().Add(blockExecutionTimeOut) + ctx, cancel := context.WithDeadline(ctx, d) result := &ForkchoiceUpdatedResponse{} err := s.rpcClient.CallContext(ctx, result, ForkchoiceUpdatedMethod, state, attrs) + cancel() if err != nil { return nil, nil, handleRPCError(err) } @@ -132,6 +141,9 @@ func (s *Service) GetPayload(ctx context.Context, payloadId [8]byte) (*pb.Execut getPayloadLatency.Observe(float64(time.Since(start).Milliseconds())) }() + d := time.Now().Add(nonBlockExecutionTimeOut) + ctx, cancel := context.WithDeadline(ctx, d) + defer cancel() result := &pb.ExecutionPayload{} err := s.rpcClient.CallContext(ctx, result, GetPayloadMethod, pb.PayloadIDBytes(payloadId)) return result, handleRPCError(err) @@ -147,10 +159,14 @@ func (s *Service) ExchangeTransitionConfiguration( // We set terminal block number to 0 as the parameter is not set on the consensus layer. zeroBigNum := big.NewInt(0) cfg.TerminalBlockNumber = zeroBigNum.Bytes() + d := time.Now().Add(nonBlockExecutionTimeOut) + ctx, cancel := context.WithDeadline(ctx, d) result := &pb.TransitionConfiguration{} if err := s.rpcClient.CallContext(ctx, result, ExchangeTransitionConfigurationMethod, cfg); err != nil { return handleRPCError(err) } + cancel() + // We surface an error to the user if local configuration settings mismatch // according to the response from the execution node. cfgTerminalHash := params.BeaconConfig().TerminalBlockHash[:] From 55bc2e988c10ee820478788d5546de32ead3af38 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Thu, 5 May 2022 14:53:59 -0700 Subject: [PATCH 2/7] Update engine_client.go --- beacon-chain/powchain/engine_client.go | 1 + 1 file changed, 1 insertion(+) diff --git a/beacon-chain/powchain/engine_client.go b/beacon-chain/powchain/engine_client.go index 3601d232def7..4a419598b64b 100644 --- a/beacon-chain/powchain/engine_client.go +++ b/beacon-chain/powchain/engine_client.go @@ -163,6 +163,7 @@ func (s *Service) ExchangeTransitionConfiguration( ctx, cancel := context.WithDeadline(ctx, d) result := &pb.TransitionConfiguration{} if err := s.rpcClient.CallContext(ctx, result, ExchangeTransitionConfigurationMethod, cfg); err != nil { + cancel() return handleRPCError(err) } cancel() From eb0433b00034db8c5ee375925b58a0ea283470bc Mon Sep 17 00:00:00 2001 From: terence tsao Date: Mon, 9 May 2022 09:30:10 -0700 Subject: [PATCH 3/7] Update engine_client.go --- beacon-chain/powchain/engine_client.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/beacon-chain/powchain/engine_client.go b/beacon-chain/powchain/engine_client.go index 4a419598b64b..e8e34dc51bc5 100644 --- a/beacon-chain/powchain/engine_client.go +++ b/beacon-chain/powchain/engine_client.go @@ -33,10 +33,10 @@ const ( ExecutionBlockByHashMethod = "eth_getBlockByHash" // ExecutionBlockByNumberMethod request string for JSON-RPC. ExecutionBlockByNumberMethod = "eth_getBlockByNumber" - // Defines the seconds to wait before timing out engine endpoints with block execution semantics. - blockExecutionTimeOut = 8 * time.Second + // Defines the seconds to wait before timing out engine endpoints with block execution semantics (newPayload, forkchoiceUpdated). + payloadAndForkchoiceUpdatedTimeout = 8 * time.Second // Defines the seconds before timing out engine endpoints with non-block execution semantics. - nonBlockExecutionTimeOut = time.Second + defaultTimeout = time.Second ) // ForkchoiceUpdatedResponse is the response kind received by the @@ -69,7 +69,7 @@ func (s *Service) NewPayload(ctx context.Context, payload *pb.ExecutionPayload) defer func() { newPayloadLatency.Observe(float64(time.Since(start).Milliseconds())) }() - d := time.Now().Add(blockExecutionTimeOut) + d := time.Now().Add(payloadAndForkchoiceUpdatedTimeout) ctx, cancel := context.WithDeadline(ctx, d) result := &pb.PayloadStatus{} err := s.rpcClient.CallContext(ctx, result, NewPayloadMethod, payload) @@ -105,7 +105,7 @@ func (s *Service) ForkchoiceUpdated( forkchoiceUpdatedLatency.Observe(float64(time.Since(start).Milliseconds())) }() - d := time.Now().Add(blockExecutionTimeOut) + d := time.Now().Add(payloadAndForkchoiceUpdatedTimeout) ctx, cancel := context.WithDeadline(ctx, d) result := &ForkchoiceUpdatedResponse{} err := s.rpcClient.CallContext(ctx, result, ForkchoiceUpdatedMethod, state, attrs) @@ -141,7 +141,7 @@ func (s *Service) GetPayload(ctx context.Context, payloadId [8]byte) (*pb.Execut getPayloadLatency.Observe(float64(time.Since(start).Milliseconds())) }() - d := time.Now().Add(nonBlockExecutionTimeOut) + d := time.Now().Add(defaultTimeout) ctx, cancel := context.WithDeadline(ctx, d) defer cancel() result := &pb.ExecutionPayload{} @@ -159,7 +159,7 @@ func (s *Service) ExchangeTransitionConfiguration( // We set terminal block number to 0 as the parameter is not set on the consensus layer. zeroBigNum := big.NewInt(0) cfg.TerminalBlockNumber = zeroBigNum.Bytes() - d := time.Now().Add(nonBlockExecutionTimeOut) + d := time.Now().Add(defaultTimeout) ctx, cancel := context.WithDeadline(ctx, d) result := &pb.TransitionConfiguration{} if err := s.rpcClient.CallContext(ctx, result, ExchangeTransitionConfigurationMethod, cfg); err != nil { From c479464a3486427b17af3e4e59cf47d0895e037e Mon Sep 17 00:00:00 2001 From: terencechain Date: Mon, 9 May 2022 10:14:18 -0700 Subject: [PATCH 4/7] Update beacon-chain/powchain/engine_client.go Co-authored-by: Preston Van Loon --- beacon-chain/powchain/engine_client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beacon-chain/powchain/engine_client.go b/beacon-chain/powchain/engine_client.go index e8e34dc51bc5..f42ccfd20818 100644 --- a/beacon-chain/powchain/engine_client.go +++ b/beacon-chain/powchain/engine_client.go @@ -71,9 +71,9 @@ func (s *Service) NewPayload(ctx context.Context, payload *pb.ExecutionPayload) }() d := time.Now().Add(payloadAndForkchoiceUpdatedTimeout) ctx, cancel := context.WithDeadline(ctx, d) + defer cancel() result := &pb.PayloadStatus{} err := s.rpcClient.CallContext(ctx, result, NewPayloadMethod, payload) - cancel() if err != nil { return nil, handleRPCError(err) } From a0fe54b18658be991ca018c790b909af59f6df2d Mon Sep 17 00:00:00 2001 From: terencechain Date: Mon, 9 May 2022 10:14:24 -0700 Subject: [PATCH 5/7] Update beacon-chain/powchain/engine_client.go Co-authored-by: Preston Van Loon --- beacon-chain/powchain/engine_client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beacon-chain/powchain/engine_client.go b/beacon-chain/powchain/engine_client.go index f42ccfd20818..3f0bf0e33489 100644 --- a/beacon-chain/powchain/engine_client.go +++ b/beacon-chain/powchain/engine_client.go @@ -107,9 +107,9 @@ func (s *Service) ForkchoiceUpdated( d := time.Now().Add(payloadAndForkchoiceUpdatedTimeout) ctx, cancel := context.WithDeadline(ctx, d) + defer cancel() result := &ForkchoiceUpdatedResponse{} err := s.rpcClient.CallContext(ctx, result, ForkchoiceUpdatedMethod, state, attrs) - cancel() if err != nil { return nil, nil, handleRPCError(err) } From 57272b646c9fbc2fc602fb5e3871fb9660c5dfac Mon Sep 17 00:00:00 2001 From: terencechain Date: Mon, 9 May 2022 10:14:28 -0700 Subject: [PATCH 6/7] Update beacon-chain/powchain/engine_client.go Co-authored-by: Preston Van Loon --- beacon-chain/powchain/engine_client.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/beacon-chain/powchain/engine_client.go b/beacon-chain/powchain/engine_client.go index 3f0bf0e33489..fbf6637fb50b 100644 --- a/beacon-chain/powchain/engine_client.go +++ b/beacon-chain/powchain/engine_client.go @@ -161,12 +161,11 @@ func (s *Service) ExchangeTransitionConfiguration( cfg.TerminalBlockNumber = zeroBigNum.Bytes() d := time.Now().Add(defaultTimeout) ctx, cancel := context.WithDeadline(ctx, d) + defer cancel() result := &pb.TransitionConfiguration{} if err := s.rpcClient.CallContext(ctx, result, ExchangeTransitionConfigurationMethod, cfg); err != nil { - cancel() return handleRPCError(err) } - cancel() // We surface an error to the user if local configuration settings mismatch // according to the response from the execution node. From adc3ec7a868ca391771cf47ac6f5027f6b68a3c7 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Mon, 9 May 2022 11:07:46 -0700 Subject: [PATCH 7/7] Update engine_client.go --- beacon-chain/powchain/engine_client.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/beacon-chain/powchain/engine_client.go b/beacon-chain/powchain/engine_client.go index fbf6637fb50b..08331828c987 100644 --- a/beacon-chain/powchain/engine_client.go +++ b/beacon-chain/powchain/engine_client.go @@ -36,7 +36,7 @@ const ( // Defines the seconds to wait before timing out engine endpoints with block execution semantics (newPayload, forkchoiceUpdated). payloadAndForkchoiceUpdatedTimeout = 8 * time.Second // Defines the seconds before timing out engine endpoints with non-block execution semantics. - defaultTimeout = time.Second + defaultEngineTimeout = time.Second ) // ForkchoiceUpdatedResponse is the response kind received by the @@ -141,7 +141,7 @@ func (s *Service) GetPayload(ctx context.Context, payloadId [8]byte) (*pb.Execut getPayloadLatency.Observe(float64(time.Since(start).Milliseconds())) }() - d := time.Now().Add(defaultTimeout) + d := time.Now().Add(defaultEngineTimeout) ctx, cancel := context.WithDeadline(ctx, d) defer cancel() result := &pb.ExecutionPayload{} @@ -159,7 +159,7 @@ func (s *Service) ExchangeTransitionConfiguration( // We set terminal block number to 0 as the parameter is not set on the consensus layer. zeroBigNum := big.NewInt(0) cfg.TerminalBlockNumber = zeroBigNum.Bytes() - d := time.Now().Add(defaultTimeout) + d := time.Now().Add(defaultEngineTimeout) ctx, cancel := context.WithDeadline(ctx, d) defer cancel() result := &pb.TransitionConfiguration{}