keep-core - reportRelayEntryTimeout creates an incentive for nodes to race for rewards potentially wasting gas and it creates an opportunity for front-running
The incentive on `reportRelayEntryTimeout` for being rewarded with 5% of the seized amount creates an incentive to call the method but might also kick off a race for front-running this call. This method is being called from the keep node which is unlikely to adjust the gasPrice and might always lose the race against a front-running bot collecting rewards for all timeouts and fraud proofs (issue 5.7)\\n```\\n/\\*\\*\\n \\* @dev Function used to inform about the fact the currently ongoing\\n \\* new relay entry generation operation timed out. As a result, the group\\n \\* which was supposed to produce a new relay entry is immediately\\n \\* terminated and a new group is selected to produce a new relay entry.\\n \\* All members of the group are punished by seizing minimum stake of\\n \\* their tokens. The submitter of the transaction is rewarded with a\\n \\* tattletale reward which is limited to min(1, 20 / group\\_size) of the\\n \\* maximum tattletale reward.\\n \\*/\\nfunction reportRelayEntryTimeout() public {\\n    require(hasEntryTimedOut(), "Entry did not time out");\\n    groups.reportRelayEntryTimeout(signingRequest.groupIndex, groupSize, minimumStake);\\n\\n    // We could terminate the last active group. If that's the case,\\n    // do not try to execute signing again because there is no group\\n    // which can handle it.\\n    if (numberOfGroups() > 0) {\\n        signRelayEntry(\\n            signingRequest.relayRequestId,\\n            signingRequest.previousEntry,\\n            signingRequest.serviceContract,\\n            signingRequest.entryVerificationAndProfitFee,\\n            signingRequest.callbackFee\\n        );\\n    }\\n}\\n```\\n
Make sure that `reportRelayEntryTimeout` throws as early as possible if the group was previously terminated (isGroupTerminated) to avoid that keep-nodes spend gas on a call that will fail. Depending on the reward for calling out the timeout this might create a front-running opportunity that cannot be resolved.
```\\n/\\*\\*\\n \\* @dev Function used to inform about the fact the currently ongoing\\n \\* new relay entry generation operation timed out. As a result, the group\\n \\* which was supposed to produce a new relay entry is immediately\\n \\* terminated and a new group is selected to produce a new relay entry.\\n \\* All members of the group are punished by seizing minimum stake of\\n \\* their tokens. The submitter of the transaction is rewarded with a\\n \\* tattletale reward which is limited to min(1, 20 / group\\_size) of the\\n \\* maximum tattletale reward.\\n \\*/\\nfunction reportRelayEntryTimeout() public {\\n    require(hasEntryTimedOut(), "Entry did not time out");\\n    groups.reportRelayEntryTimeout(signingRequest.groupIndex, groupSize, minimumStake);\\n\\n    // We could terminate the last active group. If that's the case,\\n    // do not try to execute signing again because there is no group\\n    // which can handle it.\\n    if (numberOfGroups() > 0) {\\n        signRelayEntry(\\n            signingRequest.relayRequestId,\\n            signingRequest.previousEntry,\\n            signingRequest.serviceContract,\\n            signingRequest.entryVerificationAndProfitFee,\\n            signingRequest.callbackFee\\n        );\\n    }\\n}\\n```\\n