Skip to content
Closed
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
4 changes: 2 additions & 2 deletions block/internal/syncing/da_retriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func (r *daRetriever) tryDecodeHeader(bz []byte, daHeight uint64) *types.SignedH
}
}
if r.strictMode && !isValidEnvelope {
r.logger.Warn().Msg("strict mode: rejecting block that is not a fully valid envelope")
r.logger.Warn().Uint64("da_height", daHeight).Msg("strict mode: rejecting block that is not a fully valid envelope")
return nil
}

Expand All @@ -304,7 +304,7 @@ func (r *daRetriever) tryDecodeHeader(bz []byte, daHeight uint64) *types.SignedH
}

if isValidEnvelope && !r.strictMode {
r.logger.Info().Uint64("height", header.Height()).Msg("valid DA envelope detected, switching to STRICT MODE")
r.logger.Info().Uint64("height", header.Height()).Uint64("da_height", daHeight).Msg("valid DA envelope detected, switching to STRICT MODE")
r.strictMode = true
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/da/jsonrpc/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ type Header struct {
// RawHeader contains the raw tendermint header fields.
type RawHeader struct {
ChainID string `json:"chain_id"`
Height string `json:"height"`
Height uint64 `json:"height"`
Time time.Time `json:"time"`
}

// Commit contains commit information.
type Commit struct {
Height string `json:"height"`
Height uint64 `json:"height"`
}

// DAHeader contains the Data Availability header.
Expand Down
11 changes: 0 additions & 11 deletions types/serialization.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,11 +522,6 @@ const (
legacyLastResultsHashField = 9
)

// Maximum size of unknown fields to prevent DoS attacks via malicious headers
// with excessive unknown field data. 1MB should be more than sufficient for
// legitimate legacy headers (typical header is ~500 bytes).
const maxUnknownFieldSize = 1024 * 1024 // 1MB

// Maximum size for individual legacy hash fields. Standard hashes are 32 bytes,
// but we allow up to 1KB for flexibility with different hash algorithms.
const maxLegacyHashSize = 1024 // 1KB
Expand All @@ -537,13 +532,7 @@ func decodeLegacyHeaderFields(pHeader *pb.Header) (*LegacyHeaderFields, error) {
return nil, nil
}

// Protect against DoS attacks via headers with massive unknown field data
if len(unknown) > maxUnknownFieldSize {
return nil, fmt.Errorf("unknown fields too large: %d bytes (max %d)", len(unknown), maxUnknownFieldSize)
}

var legacy LegacyHeaderFields

for len(unknown) > 0 {
fieldNum, typ, n := protowire.ConsumeTag(unknown)
if n < 0 {
Expand Down
Loading