Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions block/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -800,17 +800,16 @@ func (m *Manager) execValidate(lastState types.State, header *types.SignedHeader
}

// // Verify that the header's timestamp is strictly greater than the last block's time
// headerTime := header.Time()
// if header.Height() > 1 && lastState.LastBlockTime.After(headerTime) {
// return fmt.Errorf("block time must be strictly increasing: got %v, last block time was %v",
// headerTime.UnixNano(), lastState.LastBlockTime)
// }

// // Validate that the header's AppHash matches the lastState's AppHash
// // Note: Assumes deferred execution
// if !bytes.Equal(header.AppHash, lastState.AppHash) {
// return fmt.Errorf("app hash mismatch: expected %x, got %x", lastState.AppHash, header.AppHash)
// }
headerTime := header.Time()
if header.Height() > 1 && lastState.LastBlockTime.After(headerTime) {
return fmt.Errorf("block time must be strictly increasing: got %v, last block time was %v",
headerTime, lastState.LastBlockTime)
}

// AppHash should match the last state's AppHash
if !bytes.Equal(header.AppHash, lastState.AppHash) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this works we should open an issue so we don't forget to dive deeper

return fmt.Errorf("appHash mismatch in delayed execution mode: expected %x, got %x", lastState.AppHash, header.AppHash)
}

return nil
}
Expand Down
42 changes: 20 additions & 22 deletions block/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,28 +575,26 @@ func TestManager_execValidate(t *testing.T) {
require.NoError(err)
})

// TODO: https://github.com/rollkit/rollkit/issues/2250

// t.Run("non-monotonic block time with height > 1", func(t *testing.T) {
// state, header, data, privKey := makeValid()
// state.LastBlockTime = time.Now().Add(time.Minute)
// state.LastBlockHeight = 1
// header.BaseHeader.Height = state.LastBlockHeight + 1
// data.Metadata.Height = state.LastBlockHeight + 1
// signer, err := noopsigner.NewNoopSigner(privKey)
// require.NoError(err)
// header.Signature, err = types.GetSignature(header.Header, signer)
// require.NoError(err)
// err = m.execValidate(state, header, data)
// require.ErrorContains(err, "block time must be strictly increasing")
// })

// t.Run("app hash mismatch", func(t *testing.T) {
// state, header, data, _ := makeValid()
// state.AppHash = []byte("different")
// err := m.execValidate(state, header, data)
// require.ErrorContains(err, "app hash mismatch")
// })
t.Run("non-monotonic block time with height > 1", func(t *testing.T) {
state, header, data, privKey := makeValid()
state.LastBlockTime = time.Now().Add(time.Minute)
state.LastBlockHeight = 1
header.BaseHeader.Height = state.LastBlockHeight + 1
data.Metadata.Height = state.LastBlockHeight + 1
signer, err := noopsigner.NewNoopSigner(privKey)
require.NoError(err)
header.Signature, err = types.GetSignature(header.Header, signer)
require.NoError(err)
err = m.execValidate(state, header, data)
require.ErrorContains(err, "block time must be strictly increasing")
})

t.Run("app hash mismatch", func(t *testing.T) {
state, header, data, _ := makeValid()
state.AppHash = []byte("different")
err := m.execValidate(state, header, data)
require.ErrorContains(err, "appHash mismatch in delayed execution mode")
})
}

// TestGetterMethods tests simple getter methods for the Manager
Expand Down
2 changes: 0 additions & 2 deletions execution/evm/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,11 @@ func (c *EngineClient) ExecuteTxs(ctx context.Context, txs [][]byte, blockHeight
ts = prevTimestamp + 1 // Subsequent blocks must have a higher timestamp.
}

c.mu.Lock()
args := engine.ForkchoiceStateV1{
HeadBlockHash: prevBlockHash,
SafeBlockHash: prevBlockHash,
FinalizedBlockHash: prevBlockHash,
}
c.mu.Unlock()

// update forkchoice to get the next payload id
var forkchoiceResult engine.ForkChoiceResponse
Expand Down
Loading