eth: enforce announcement metadatas and drop peers violating the protocol (#28261)

* eth: enforce announcement metadatas and drop peers violating the protocol

* eth/fetcher: relax eth/68 validation a bit for flakey clients

* tests/fuzzers/txfetcher: pull in suggestion from Marius

* eth/fetcher: add tests for peer dropping

* eth/fetcher: linter linter linter linter linter
This commit is contained in:
Péter Szilágyi
2023-10-10 11:35:51 +03:00
committed by GitHub
parent 6505297456
commit 8afbcf4713
5 changed files with 531 additions and 65 deletions
+6 -1
View File
@@ -83,6 +83,7 @@ func Fuzz(input []byte) int {
return make([]error, len(txs))
},
func(string, []common.Hash) error { return nil },
nil,
clock, rand,
)
f.Start()
@@ -116,6 +117,8 @@ func Fuzz(input []byte) int {
var (
announceIdxs = make([]int, announce)
announces = make([]common.Hash, announce)
types = make([]byte, announce)
sizes = make([]uint32, announce)
)
for i := 0; i < len(announces); i++ {
annBuf := make([]byte, 2)
@@ -124,11 +127,13 @@ func Fuzz(input []byte) int {
}
announceIdxs[i] = (int(annBuf[0])*256 + int(annBuf[1])) % len(txs)
announces[i] = txs[announceIdxs[i]].Hash()
types[i] = txs[announceIdxs[i]].Type()
sizes[i] = uint32(txs[announceIdxs[i]].Size())
}
if verbose {
fmt.Println("Notify", peer, announceIdxs)
}
if err := f.Notify(peer, announces); err != nil {
if err := f.Notify(peer, types, sizes, announces); err != nil {
panic(err)
}