Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caplin: added IPV6 support #13214

Merged
merged 1 commit into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions cl/phase1/forkchoice/fork_graph/fork_graph_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ func (f *forkGraphDisk) AnchorSlot() uint64 {
}

func (f *forkGraphDisk) isBlockRootTheCurrentState(blockRoot libcommon.Hash) bool {
if f.currentState == nil {
return false
}
blockRootState, _ := f.currentState.BlockRoot()
return blockRoot == blockRootState
}
Expand Down Expand Up @@ -199,7 +202,7 @@ func (f *forkGraphDisk) AddChainSegment(signedBlock *cltypes.SignedBeaconBlock,
} else {
newState, err = f.getState(block.ParentRoot, false, true)
if err != nil {
return nil, LogisticError, fmt.Errorf("AddChainSegment: %w, parentRoot; %x", err, block.ParentRoot)
return nil, LogisticError, fmt.Errorf("AddChainSegment: %w, parentRoot: %x", err, block.ParentRoot)
}
}

Expand Down Expand Up @@ -262,7 +265,7 @@ func (f *forkGraphDisk) AddChainSegment(signedBlock *cltypes.SignedBeaconBlock,
// Add block to list of invalid blocks
log.Warn("Invalid beacon block", "slot", block.Slot, "blockRoot", blockRoot, "reason", invalidBlockErr)
f.badBlocks.Store(libcommon.Hash(blockRoot), struct{}{})
//f.currentState = nil
f.currentState = nil

return nil, InvalidBlock, invalidBlockErr
}
Expand Down
19 changes: 7 additions & 12 deletions cl/sentinel/sentinel.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,25 +147,20 @@ func (s *Sentinel) createListener() (*discover.UDPv5, error) {
)

ip := net.ParseIP(ipAddr)
if ip.To4() == nil {
return nil, fmt.Errorf("IPV4 address not provided instead %s was provided", ipAddr)
if ip == nil {
return nil, fmt.Errorf("bad ip address provided, %s was provided", ipAddr)
}

var bindIP net.IP
var networkVersion string

// check for our network version
switch {
// if we have 16 byte and 4 byte representation then we are in using udp6
case ip.To16() != nil && ip.To4() == nil:
bindIP = net.IPv6zero
networkVersion = "udp6"
// only 4 bytes then we are using udp4
case ip.To4() != nil:
// If the IP is an IPv4 address, bind to the correct zero address.
if ip.To4() != nil {
bindIP = net.IPv4zero
networkVersion = "udp4"
default:
return nil, fmt.Errorf("bad ip address provided, %s was provided", ipAddr)
} else {
bindIP = net.IPv6zero
networkVersion = "udp6"
}

udpAddr := &net.UDPAddr{
Expand Down
Loading