Skip to content

Commit

Permalink
fix(sequencer): limit sequencer metadata lists length (#1149)
Browse files Browse the repository at this point in the history
  • Loading branch information
zale144 authored Aug 27, 2024
1 parent 3d67c2d commit 255f4ee
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions x/sequencer/types/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const (
MaxDetailsLength = 280
MaxExtraDataLength = 280
maxURLLength = 256
maxListLength = 5
)

func (d SequencerMetadata) Validate() error {
Expand Down Expand Up @@ -117,5 +118,25 @@ func (d SequencerMetadata) EnsureLength() (SequencerMetadata, error) {
}
}

if len(d.P2PSeeds) > maxListLength {
return d, errors.Newf("invalid p2p seeds length; got: %d, max: %d", len(d.P2PSeeds), maxListLength)
}

if len(d.Rpcs) > maxListLength {
return d, errors.Newf("invalid rpcs length; got: %d, max: %d", len(d.Rpcs), maxListLength)
}

if len(d.EvmRpcs) > maxListLength {
return d, errors.Newf("invalid evm rpcs length; got: %d, max: %d", len(d.EvmRpcs), maxListLength)
}

if len(d.RestApiUrls) > maxListLength {
return d, errors.Newf("invalid rest api urls length; got: %d, max: %d", len(d.RestApiUrls), maxListLength)
}

if len(d.GenesisUrls) > maxListLength {
return d, errors.Newf("invalid genesis urls length; got: %d, max: %d", len(d.GenesisUrls), maxListLength)
}

return d, nil
}

0 comments on commit 255f4ee

Please sign in to comment.