internal/era: error if accumulator has more records than max allowed

This commit is contained in:
lightclient@protonmail.com 2023-05-23 14:04:18 +02:00 committed by lightclient
parent ca3d8bf717
commit cccf47b4f4
No known key found for this signature in database
GPG key ID: 75C916AFEE20183E

View file

@ -30,6 +30,9 @@ func ComputeAccumulator(hashes []common.Hash, tds []*big.Int) (common.Hash, erro
if len(hashes) != len(tds) {
return common.Hash{}, fmt.Errorf("must have equal number hashes as td values")
}
if len(hashes) > MaxEra1Size {
return common.Hash{}, fmt.Errorf("too many records: have %d, max %d", len(hashes), MaxEra1Size)
}
hh := ssz.NewHasher()
for i := range hashes {
rec := headerRecord{hashes[i], tds[i]}