Skip to content

Commit fac2e07

Browse files
Simulate ExecuteTxs
1 parent f1f28c4 commit fac2e07

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

execution/evm/execution.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,18 @@ func (c *EngineClient) ExecuteTxs(ctx context.Context, txs [][]byte, blockHeight
211211
ts = prevTimestamp + 1 // Subsequent blocks must have a higher timestamp.
212212
}
213213

214+
// get current finalized block hash
215+
c.mu.Lock()
216+
finalizedBlockHash := c.currentFinalizedBlockHash
217+
c.mu.Unlock()
218+
214219
// update forkchoice to get the next payload id
215220
var forkchoiceResult engine.ForkChoiceResponse
216221
err = c.engineClient.CallContext(ctx, &forkchoiceResult, "engine_forkchoiceUpdatedV3",
217222
engine.ForkchoiceStateV1{
218223
HeadBlockHash: prevBlockHash,
219224
SafeBlockHash: prevBlockHash,
220-
FinalizedBlockHash: prevBlockHash,
225+
FinalizedBlockHash: finalizedBlockHash,
221226
},
222227
&engine.PayloadAttributes{
223228
Timestamp: ts,

execution/evm/execution_test.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package evm
55

66
import (
77
"context"
8+
"log"
89
"math/big"
910
"testing"
1011
"time"
@@ -82,9 +83,10 @@ func TestEngineExecution(t *testing.T) {
8283

8384
prevStateRoot := rollkitGenesisStateRoot
8485
lastHeight, lastHash, lastTxs := checkLatestBlock(tt, ctx)
86+
log.Println("lastTxs", lastTxs)
8587
lastNonce := uint64(0)
8688

87-
for blockHeight := initialHeight; blockHeight <= 10; blockHeight++ {
89+
for blockHeight := initialHeight; blockHeight <= 1; blockHeight++ {
8890
nTxs := int(blockHeight) + 10
8991
// randomly use no transactions
9092
if blockHeight == 4 {
@@ -102,9 +104,18 @@ func TestEngineExecution(t *testing.T) {
102104
payload, err := executionClient.GetTxs(ctx)
103105
require.NoError(tt, err)
104106
require.Lenf(tt, payload, nTxs, "expected %d transactions, got %d", nTxs, len(payload))
107+
log.Println("nTxs", nTxs)
105108

106109
allPayloads = append(allPayloads, payload)
107110

111+
txs = make([]*ethTypes.Transaction, nTxs)
112+
for i := range txs {
113+
txs[i] = GetRandomTransaction(t, TEST_PRIVATE_KEY, TEST_TO_ADDRESS, CHAIN_ID, 22000, &lastNonce)
114+
}
115+
for i := range txs {
116+
SubmitTransaction(t, txs[i])
117+
}
118+
108119
// Check latest block before execution
109120
beforeHeight, beforeHash, beforeTxs := checkLatestBlock(tt, ctx)
110121
require.Equal(tt, lastHeight, beforeHeight, "Latest block height should match")
@@ -124,7 +135,7 @@ func TestEngineExecution(t *testing.T) {
124135
lastHeight, lastHash, lastTxs = checkLatestBlock(tt, ctx)
125136
require.Equal(tt, blockHeight, lastHeight, "Latest block height should match")
126137
require.NotEmpty(tt, lastHash.Hex(), "Latest block hash should not be empty")
127-
require.GreaterOrEqual(tt, lastTxs, 0, "Number of transactions should be non-negative")
138+
require.Equal(tt, lastTxs, nTxs, "Number of transactions should be equal")
128139

129140
if nTxs == 0 {
130141
require.Equal(tt, prevStateRoot, newStateRoot)
@@ -141,6 +152,7 @@ func TestEngineExecution(t *testing.T) {
141152

142153
// start new container and try to sync
143154
t.Run("Sync chain", func(tt *testing.T) {
155+
tt.Skip("Skip sync chain")
144156
jwtSecret := SetupTestRethEngine(t, DOCKER_PATH, JWT_FILENAME)
145157

146158
executionClient, err := NewEngineExecutionClient(

0 commit comments

Comments
 (0)