@@ -13,6 +13,7 @@ import (
1313 "github.com/ethereum/go-ethereum/core/forkid"
1414 ethtypes "github.com/ethereum/go-ethereum/core/types"
1515 "github.com/ethereum/go-ethereum/crypto"
16+ "github.com/ethereum/go-ethereum/eth/protocols/eth"
1617 "github.com/ethereum/go-ethereum/params"
1718 "github.com/noku-team/assertoor/pkg/coordinator/clients/execution"
1819 "github.com/noku-team/assertoor/pkg/coordinator/helper"
@@ -164,15 +165,34 @@ func (t *Task) Execute(ctx context.Context) error {
164165 gotTx := 0
165166
166167 for gotTx < t .config .QPS {
167- _txs , err := conn .ReadTransactionMessages ()
168- if err != nil {
169- t .logger .Errorf ("Failed to read transaction messages: %v" , err )
168+ // Add a timeout of 10 seconds for reading transaction messages
169+ readChan := make (chan struct {
170+ txs * eth.TransactionsPacket
171+ err error
172+ })
173+
174+ go func () {
175+ txs , err := conn .ReadTransactionMessages ()
176+ readChan <- struct {
177+ txs * eth.TransactionsPacket
178+ err error
179+ }{txs , err }
180+ }()
181+
182+ select {
183+ case result := <- readChan :
184+ if result .err != nil {
185+ t .logger .Errorf ("Failed to read transaction messages: %v" , result .err )
186+ t .ctx .SetResult (types .TaskResultFailure )
187+ return nil
188+ }
189+ gotTx += len (* result .txs )
190+ case <- time .After (10 * time .Second ):
191+ t .logger .Errorf ("Timeout after 10 seconds while reading transaction messages" )
170192 t .ctx .SetResult (types .TaskResultFailure )
171193 return nil
172194 }
173195
174- gotTx += len (* _txs )
175-
176196 if gotTx % t .config .MeasureInterval != 0 {
177197 continue
178198 }
0 commit comments