forked from cerc-io/plugeth
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:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user