Skip to content

Commit

Permalink
Merge pull request ethereum#39 from hkalina/jkalina-discovery-opera
Browse files Browse the repository at this point in the history
Block non-opera nodes from discovery
  • Loading branch information
uprendis authored Nov 15, 2022
2 parents 2b28808 + 66dace0 commit ee56663
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions p2p/enode/idscheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package enode
import (
"crypto/ecdsa"
"fmt"
"github.com/ethereum/go-ethereum/core/forkid"
"io"

"github.com/ethereum/go-ethereum/common/math"
Expand Down Expand Up @@ -62,6 +63,12 @@ func SignV4(r *enr.Record, privkey *ecdsa.PrivateKey) error {
}

func (V4ID) Verify(r *enr.Record, sig []byte) error {
var opera operaNodeEnrEntry
err := r.Load(&opera)
if err != nil {
return fmt.Errorf("invalid opera node; %s", err.Error())
}

var entry s256raw
if err := r.Load(&entry); err != nil {
return err
Expand Down Expand Up @@ -158,3 +165,16 @@ func SignNull(r *enr.Record, id ID) *Node {
}
return &Node{r: *r, id: id}
}

// operaNodeEnrEntry is the ENR entry which advertises `eth` protocol on the discovery.
type operaNodeEnrEntry struct {
ForkID forkid.ID // Fork identifier per EIP-2124

// Ignore additional fields (for forward compatibility).
Rest []rlp.RawValue `rlp:"tail"`
}

// ENRKey implements enr.Entry.
func (e operaNodeEnrEntry) ENRKey() string {
return "opera"
}

0 comments on commit ee56663

Please sign in to comment.