Skip to content

Commit

Permalink
Merge branch 'master' into sukun/address-service-1
Browse files Browse the repository at this point in the history
  • Loading branch information
sukunrt committed Feb 20, 2025
2 parents fdde271 + f88beca commit a5c5d2a
Show file tree
Hide file tree
Showing 139 changed files with 3,371 additions and 1,347 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ jobs:
go-check:
uses: ipdxco/unified-github-workflows/.github/workflows/go-check.yml@v1.0
with:
go-version: "1.22.x"
go-version: "1.24.x"
go-generate-ignore-protoc-version-comments: true
4 changes: 2 additions & 2 deletions .github/workflows/go-test-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
run: test_analysis ${{ env.GOTESTFLAGS }}
- name: Upload test results
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}_${{ matrix.go }}_test_results.db
path: ./test_results.db
Expand All @@ -131,7 +131,7 @@ jobs:
run: test_analysis -race ${{ env.GORACEFLAGS }} ./...
- name: Upload test results (Race)
if: (steps.race.conclusion == 'success' || steps.race.conclusion == 'failure')
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}_${{ matrix.go }}_test_results_race.db
path: ./test_results.db
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:
go-test:
uses: ./.github/workflows/go-test-template.yml
with:
go-versions: '["1.22.x", "1.23.x"]'
go-versions: '["1.23.x", "1.24.x"]'
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
7 changes: 7 additions & 0 deletions .github/workflows/interop-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Interoperability Testing

on:
workflow_dispatch:
pull_request:
Expand All @@ -8,6 +9,7 @@ on:
- 'internal/**'
- 'p2p/**'
- 'test-plans/**'
- '.github/workflows/interop-test.yml'
push:
branches:
- "master"
Expand All @@ -23,6 +25,11 @@ jobs:
name: Run transport interoperability tests
runs-on: ${{ fromJSON(vars['INTEROP_TEST_RUNNER_UBUNTU'] || '"ubuntu-22.04"') }}
steps:
- name: Free Disk Space (Ubuntu)
if: vars['INTEROP_TEST_RUNNER_UBUNTU'] == ''
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
with:
tool-cache: true
- uses: actions/checkout@v4
- name: Build image
run: docker build -t go-libp2p-head -f test-plans/PingDockerfile .
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ concurrency:

jobs:
release-check:
uses: marcopolo/unified-github-workflows/.github/workflows/release-check.yml@e66cb9667a2e1148efda4591e29c56258eaf385b
uses: ipdxco/unified-github-workflows/.github/workflows/release-check.yml@v1.0
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,25 @@ Guidelines:
- ask questions or talk about things in our [discussion forums](https://discuss.libp2p.io), or open an [issue](https://github.com/libp2p/go-libp2p/issues) for bug reports, or #libp2p-implementers on [Filecoin slack](https://filecoin.io/slack).
- ensure you are able to contribute (no legal issues please -- we use the DCO)
- get in touch with @libp2p/go-libp2p-maintainers about how best to contribute
- No drive-by contributions seeking to collect airdrops.
- Many projects aim to reward contributors to common goods. Great. However,
this creates an unfortunate incentive for low-effort PRs, submitted solely to
claim rewards. These PRs consume maintainers’ time and energy to triage, with
little to no impact on end users. If we suspect this is the intent of a PR,
we may close it without comment. If you believe this was done in error,
contact us via email. Reference this README section and explain why your PR
is not a “drive-by contribution.”
- have fun!

There's a few things you can do right now to help out:
- Go through the modules below and **check out existing issues**. This would be especially useful for modules in active development. Some knowledge of IPFS/libp2p may be required, as well as the infrastructure behind it - for instance, you may need to read up on p2p and more complex operations like muxing to be able to help technically.
- **Perform code reviews**.
- **Add tests**. There can never be enough tests.
- Go through the modules below and **check out existing issues**. This would
be especially useful for modules in active development. Some knowledge of
IPFS/libp2p may be required, as well as the infrastructure behind it - for
instance, you may need to read up on p2p and more complex operations like
muxing to be able to help technically.


## Supported Go Versions

Expand Down
36 changes: 30 additions & 6 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,12 +448,9 @@ func (cfg *Config) newBasicHost(swrm *swarm.Swarm, eventBus event.Bus) (*bhost.B
return h, nil
}

// NewNode constructs a new libp2p Host from the Config.
//
// This function consumes the config. Do not reuse it (really!).
func (cfg *Config) NewNode() (host.Host, error) {
func (cfg *Config) validate() error {
if cfg.EnableAutoRelay && !cfg.Relay {
return nil, fmt.Errorf("cannot enable autorelay; relay is not enabled")
return fmt.Errorf("cannot enable autorelay; relay is not enabled")
}
// If possible check that the resource manager conn limit is higher than the
// limit set in the conn manager.
Expand All @@ -464,6 +461,33 @@ func (cfg *Config) NewNode() (host.Host, error) {
}
}

if len(cfg.PSK) > 0 && cfg.ShareTCPListener {
return errors.New("cannot use shared TCP listener with PSK")
}

return nil
}

// NewNode constructs a new libp2p Host from the Config.
//
// This function consumes the config. Do not reuse it (really!).
func (cfg *Config) NewNode() (host.Host, error) {

validateErr := cfg.validate()
if validateErr != nil {
if cfg.ResourceManager != nil {
cfg.ResourceManager.Close()
}
if cfg.ConnManager != nil {
cfg.ConnManager.Close()
}
if cfg.Peerstore != nil {
cfg.Peerstore.Close()
}

return nil, validateErr
}

if !cfg.DisableMetrics {
rcmgr.MustRegisterWith(cfg.PrometheusRegisterer)
}
Expand Down Expand Up @@ -510,7 +534,7 @@ func (cfg *Config) NewNode() (host.Host, error) {
}
fxopts = append(fxopts, transportOpts...)

// Configure routing and autorelay
// Configure routing
if cfg.Routing != nil {
fxopts = append(fxopts,
fx.Provide(cfg.Routing),
Expand Down
2 changes: 1 addition & 1 deletion core/connmgr/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type ConnManager interface {
// TagPeer tags a peer with a string, associating a weight with the tag.
TagPeer(peer.ID, string, int)

// Untag removes the tagged value from the peer.
// UntagPeer removes the tagged value from the peer.
UntagPeer(p peer.ID, tag string)

// UpsertTag updates an existing tag or inserts a new one.
Expand Down
34 changes: 16 additions & 18 deletions core/crypto/pb/crypto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/event/addrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ type EvtLocalAddressesUpdated struct {
}

// EvtAutoRelayAddrsUpdated is sent by the autorelay when the node's relay addresses are updated
type EvtAutoRelayAddrs struct {
type EvtAutoRelayAddrsUpdated struct {
RelayAddrs []ma.Multiaddr
}
4 changes: 2 additions & 2 deletions core/host/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ type Host interface {
// Peerstore returns the Host's repository of Peer Addresses and Keys.
Peerstore() peerstore.Peerstore

// Returns the listen addresses of the Host
// Addrs returns the listen addresses of the Host
Addrs() []ma.Multiaddr

// Networks returns the Network interface of the Host
// Network returns the Network interface of the Host
Network() network.Network

// Mux returns the Mux multiplexing incoming streams to protocol handlers
Expand Down
50 changes: 50 additions & 0 deletions core/network/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,60 @@ package network

import (
"context"
"fmt"
"io"

ic "github.com/libp2p/go-libp2p/core/crypto"

"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/core/protocol"

ma "github.com/multiformats/go-multiaddr"
)

type ConnErrorCode uint32

type ConnError struct {
Remote bool
ErrorCode ConnErrorCode
TransportError error
}

func (c *ConnError) Error() string {
side := "local"
if c.Remote {
side = "remote"
}
if c.TransportError != nil {
return fmt.Sprintf("connection closed (%s): code: 0x%x: transport error: %s", side, c.ErrorCode, c.TransportError)
}
return fmt.Sprintf("connection closed (%s): code: 0x%x", side, c.ErrorCode)
}

func (c *ConnError) Is(target error) bool {
if tce, ok := target.(*ConnError); ok {
return tce.ErrorCode == c.ErrorCode && tce.Remote == c.Remote
}
return false
}

func (c *ConnError) Unwrap() []error {
return []error{ErrReset, c.TransportError}
}

const (
ConnNoError ConnErrorCode = 0
ConnProtocolNegotiationFailed ConnErrorCode = 0x1000
ConnResourceLimitExceeded ConnErrorCode = 0x1001
ConnRateLimited ConnErrorCode = 0x1002
ConnProtocolViolation ConnErrorCode = 0x1003
ConnSupplanted ConnErrorCode = 0x1004
ConnGarbageCollected ConnErrorCode = 0x1005
ConnShutdown ConnErrorCode = 0x1006
ConnGated ConnErrorCode = 0x1007
ConnCodeOutOfRange ConnErrorCode = 0x1008
)

// Conn is a connection to a remote peer. It multiplexes streams.
// Usually there is no need to use a Conn directly, but it may
// be useful to get information about the peer on the other side:
Expand All @@ -24,6 +69,11 @@ type Conn interface {
ConnStat
ConnScoper

// CloseWithError closes the connection with errCode. The errCode is sent to the
// peer on a best effort basis. For transports that do not support sending error
// codes on connection close, the behavior is identical to calling Close.
CloseWithError(errCode ConnErrorCode) error

// ID returns an identifier that uniquely identifies this Conn within this
// host, during this run. Connection IDs may repeat across restarts.
ID() string
Expand Down
Loading

0 comments on commit a5c5d2a

Please sign in to comment.