Repository navigation
Conversation
When peer.chaincodeAddress is not set, the peer builds the chaincode endpoint, and the chaincode listen address if that is not set either, from the host of peer.address and a port with "%s:%s". For an IPv6 host such as 2001:db8::1 this gives 2001:db8::1:7052, which is not a valid address. createChaincodeServer then panics with "too many colons in address" and the peer does not start. Use net.JoinHostPort, which adds the brackets for IPv6 hosts. Signed-off-by: Hamed Yousefi <hdyousefi@gmail.com>
Signed-off-by: Hamed Yousefi <hdyousefi@gmail.com>
Signed-off-by: Hamed Yousefi <hdyousefi@gmail.com>
Signed-off-by: Hamed Yousefi <hdyousefi@gmail.com>
|
Tick the box to add this pull request to the merge queue (same as
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of change
Description
When
peer.chaincodeAddressis not set,computeChaincodeEndpointininternal/peer/node/start.gobuilds the endpoint that chaincode connects to from the host ofpeer.address. It does the same whenpeer.chaincodeListenAddresshas the host0.0.0.0or::. Whenpeer.chaincodeListenAddressis not set,createChaincodeServeralso builds the listen address from that host. All three join host and port withfmt.Sprintf.The host comes from
net.SplitHostPort(peer.address), so forpeer.address: "[2001:db8::1]:7051"it is2001:db8::1, without brackets. The joined address is2001:db8::1:7052, which is not a valid address, and the peer panics at startup:computeChaincodeEndpointalready treats::like0.0.0.0, so IPv6 is meant to work here. Settingpeer.chaincodeAddressexplicitly avoids the problem.This change uses
net.JoinHostPortin those three places. It adds the brackets for IPv6 hosts and gives the same result as before for IPv4 addresses and host names.Additional details
Tests:
TestComputeChaincodeEndpointcases for an IPv6 peer address, withpeer.chaincodeListenAddressunset, set to[::]:8052, and set to another IPv6 address. Without the fix, the first two fail withexpected: "[2001:db8::1]:7052",actual: "2001:db8::1:7052"(and the same for port 8052).TestCreateChaincodeServerIPv6PeerAddresscallscreateChaincodeServerwith the peer host::1and no chaincode addresses set, and checks the endpoint and the listen address. Without the fix, it panics with the error above. With only thecomputeChaincodeEndpointpart of the fix, it fails withlisten tcp: address ::1:7052: too many colons in address. It is skipped when the IPv6 loopback address can't be used.Ran:
go test -race ./internal/peer/node/...passes.Related issues
Fixes #5633.