Skip to content
This repository was archived by the owner on May 30, 2025. It is now read-only.

Commit a356102

Browse files
committed
add payload tx to mempool if not exists before engine api call
1 parent 1e6bd7b commit a356102

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

execution.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,15 @@ func (c *EngineClient) ExecuteTxs(ctx context.Context, txs [][]byte, blockHeight
161161
if err != nil {
162162
return nil, 0, fmt.Errorf("failed to unmarshal transaction: %w", err)
163163
}
164+
txHash := ethTxs[i].Hash()
165+
_, isPending, err := c.ethClient.TransactionByHash(context.Background(), txHash)
166+
if err == nil && isPending {
167+
continue // skip SendTransaction
168+
}
169+
err = c.ethClient.SendTransaction(context.Background(), ethTxs[i])
170+
if err != nil {
171+
return nil, 0, fmt.Errorf("failed to send transaction: %w", err)
172+
}
164173
}
165174

166175
// encode

execution_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func TestEngineExecution(t *testing.T) {
105105

106106
payload, err := executionClient.GetTxs(ctx)
107107
require.NoError(tt, err)
108-
require.Lenf(tt, payload, nTxs+1, "expected %d transactions, got %d", nTxs+1, len(payload))
108+
require.Lenf(tt, payload, nTxs, "expected %d transactions, got %d", nTxs, len(payload))
109109

110110
allPayloads = append(allPayloads, payload)
111111

@@ -180,7 +180,11 @@ func TestEngineExecution(t *testing.T) {
180180
if len(payload) > 0 {
181181
require.NotZero(tt, maxBytes)
182182
}
183-
require.NotEqual(tt, prevStateRoot, newStateRoot)
183+
if len(payload) == 0 {
184+
require.Equal(tt, prevStateRoot, newStateRoot)
185+
} else {
186+
require.NotEqual(tt, prevStateRoot, newStateRoot)
187+
}
184188

185189
err = executionClient.SetFinal(ctx, blockHeight)
186190
require.NoError(tt, err)

0 commit comments

Comments
 (0)