Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Move validation before
  • Loading branch information
Manav-Aggarwal committed Apr 30, 2025
commit f17189869fe17ae88b01fd7c0ad73a65878a119e
20 changes: 10 additions & 10 deletions block/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,15 +563,6 @@ func (m *Manager) publishBlockInternal(ctx context.Context) error {
}
}

newState, err := m.applyBlock(ctx, header, data)
if err != nil {
if ctx.Err() != nil {
return err
}
// if call to applyBlock fails, we halt the node, see https://github.com/cometbft/cometbft/pull/496
panic(err)
}

signature, err = m.getSignature(header.Header)
if err != nil {
return err
Expand All @@ -581,10 +572,19 @@ func (m *Manager) publishBlockInternal(ctx context.Context) error {
header.Signature = signature

if err := header.ValidateBasic(); err != nil {
// If this ever happens, for reovery, check for a mismatch between the configured signing key and the proposer address in the genesis file
// If this ever happens, for recovery, check for a mismatch between the configured signing key and the proposer address in the genesis file
panic(fmt.Errorf("critical: newly produced header failed validation: %w", err))
}

newState, err := m.applyBlock(ctx, header, data)
if err != nil {
if ctx.Err() != nil {
return err
}
// if call to applyBlock fails, we halt the node, see https://github.com/cometbft/cometbft/pull/496
panic(err)
}

// append metadata to Data before validating and saving
data.Metadata = &types.Metadata{
ChainID: header.ChainID(),
Expand Down