Skip to content

Commit 6b65331

Browse files
Merge pull request #18 from valory-xyz/feat/modern-go-bump
chore: Bump to Go 1.24 and libp2p v0.33
2 parents 0248dd9 + 657adbb commit 6b65331

17 files changed

Lines changed: 1569 additions & 1096 deletions

File tree

.github/workflows/workflow.yml

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,20 @@ jobs:
1616
runs-on: ubuntu-latest
1717
timeout-minutes: 10
1818
steps:
19-
- uses: actions/checkout@master
20-
- uses: actions/setup-go@v3
19+
- uses: actions/checkout@v4
20+
- uses: actions/setup-go@v5
2121
with:
22-
go-version: "1.17.7"
22+
go-version: "1.24.0"
2323
- name: Install dependencies (ubuntu-latest)
2424
run: |
2525
sudo apt-get update --fix-missing
2626
sudo apt-get autoremove
2727
sudo apt-get autoclean
2828
- name: Golang code style check (libp2p_node)
29-
uses: golangci/golangci-lint-action@v3.1.0
30-
env:
31-
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
29+
uses: golangci/golangci-lint-action@v6
3230
with:
33-
version: v1.45.2
31+
version: v1.64.5
32+
args: --timeout=5m
3433
working-directory: ./
3534

3635
golang_checks:
@@ -41,37 +40,27 @@ jobs:
4140
strategy:
4241
matrix:
4342
os: [ubuntu-latest, macos-latest, windows-latest]
44-
python-version: [3.6]
4543
timeout-minutes: 45
4644
steps:
47-
- uses: actions/checkout@master
48-
- uses: actions/setup-go@v3
45+
- uses: actions/checkout@v4
46+
- uses: actions/setup-go@v5
4947
with:
50-
go-version: "1.17.7"
51-
- if: matrix.os == 'macos-latest'
52-
working-directory: .
53-
run: |
54-
export LINKPATH=`go env GOTOOLDIR`/link
55-
echo $LINKPATH
56-
sudo cp $LINKPATH ${LINKPATH}_orig
57-
sudo cp link $LINKPATH
58-
sudo chmod a+x $LINKPATH
59-
- if: matrix.python-version == '3.6'
60-
name: Golang unit tests (libp2p_node)
48+
go-version: "1.24.0"
49+
- name: Golang unit tests (libp2p_node)
6150
working-directory: ./
6251
run: make test
6352

6453
libp2p_coverage:
6554
name: libp2p_coverage
6655
runs-on: ubuntu-latest
6756
steps:
68-
- name: Set up Go 1.17.7
69-
uses: actions/setup-go@v1
57+
- name: Set up Go 1.24.0
58+
uses: actions/setup-go@v5
7059
with:
71-
go-version: "1.17.7"
60+
go-version: "1.24.0"
7261
id: go
7362
- name: Check out code into the Go module directory
74-
uses: actions/checkout@v1
63+
uses: actions/checkout@v4
7564
- name: Install dependencies (ubuntu-latest)
7665
run: |
7766
sudo apt-get update --fix-missing

CLAUDE.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Overview
6+
7+
This repo is `libp2p_node`, the Go implementation of a node for the Agent Communication Network (ACN). ACN lets agents (see `open-aea`) discover each other and exchange messages addressed solely by wallet address. The binary is a single entry point (`libp2p_node.go`, `package main`, module `libp2p_node`) that wires together the AEA-side pipe and the libp2p-based DHT.
8+
9+
## Common commands
10+
11+
```bash
12+
make build # go build
13+
make test # full test suite with coverage (serial: -p 1, no inlining, no test cache)
14+
make race_test # same, with -race
15+
make lint # golines . -w && golangci-lint run
16+
make install # go get -v -t -d ./...
17+
make clean # remove binary + coverage.txt
18+
```
19+
20+
Run a single test:
21+
```bash
22+
go test -gcflags=-l -count=1 -v ./dht/dhtpeer -run TestRoutingAllToAllConnectClientsSamePeer
23+
```
24+
`-gcflags=-l` disables inlining (required by `bou.ke/monkey`), and `-p 1` in `make test` forces serial package execution because tests bind fixed ports — keep those flags when running tests that touch networking.
25+
26+
`run_acn_node_standalone.py` launches the built binary standalone (outside an AEA), reading env-file config; `--config-from-env` on the binary reads config from environment variables instead of an AEA pipe. See README for bootstrap/entry node env-file examples.
27+
28+
## Architecture
29+
30+
The node can run in one of two modes, selected in `libp2p_node.go:main` by whether a public URI is set:
31+
32+
- **Peer mode** (`dht/dhtpeer`) — full libp2p host. Runs the DHT, optionally a relay service, a delegate service (TCP endpoint for `p2p_libp2p_client` connections), an optional mailbox service, and optional Prometheus monitoring. Constructed via functional options (`dht/dhtpeer/options.go`).
33+
- **Client mode** (`dht/dhtclient`) — lightweight, bootstraps from entry peers, no public address. Used when `AEA_P2P_URI_PUBLIC` is unset.
34+
35+
Both modes implement the `dhtnode.DHTNode` interface (`dht/dhtnode/dhtnode.go`): `RouteEnvelope`, `ProcessEnvelope`, `MultiAddr`, `PeerID`, `Close`. `main` connects the AEA pipe to the node by (a) forwarding envelopes from `agent.Queue()` into `node.RouteEnvelope`, and (b) registering `agent.Put` as the node's inbound envelope handler.
36+
37+
Key packages:
38+
39+
- `aea/` — the AEA-facing API. `api.go` handles config (env or pipe-based), `envelope.proto`/`envelope.pb.go` is the wire format, `pipe.go` is the Unix-pipe transport to a co-located Python AEA.
40+
- `dht/dhtnode/` — shared stream protocol handlers and the `DHTNode` interface. The ACN libp2p protocol IDs (`/aea/0.1.0`, `/aea-address/0.1.0`, `/aea-register/0.1.0`) are defined here.
41+
- `dht/dhtpeer/` — peer implementation; `mailbox.go` is the store-and-forward mailbox service, `notifee.go` hooks libp2p connection events, `benchmarks_test.go` contains throughput benchmarks.
42+
- `dht/dhtclient/` — client implementation.
43+
- `dht/dhttests/` — shared test fixtures/harness (imported by other `dht/*` tests).
44+
- `dht/common/`, `dht/monitoring/` — shared helpers and the Prometheus monitoring abstraction.
45+
- `acn/`, `protocols/`, `utils/`, `common/` — ACN-level helpers, generated protocol messages, logging and crypto utilities.
46+
- `mocks/` — gomock-generated mocks (see https://github.com/golang/mock for regeneration).
47+
48+
### Messaging patterns
49+
50+
ACN supports several delivery paths between an AEA `Connection` and a `Peer`, via optional `Delegate Client` and `Relay Peer` hops — see README.md "Messaging patterns" for the full matrix. ACN must guarantee total ordering of messages between any pair of agents regardless of which path is used.
51+
52+
## Go / tooling notes
53+
54+
- Go module: `libp2p_node` (go 1.17). Internal imports use the module path, e.g. `libp2p_node/dht/dhtpeer`.
55+
- Dependencies are pinned to older libp2p (`go-libp2p v0.8.3`, `go-libp2p-core v0.5.3`, `go-libp2p-kad-dht v0.7.11`) — do not casually bump these; the DHT protocol and stream APIs differ substantially in newer versions.
56+
- `golines` reformats long lines as part of `make lint`; run it before committing Go changes.

aea/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func (aea AeaApi) RecordStoragePath() string {
136136
func (aea AeaApi) Put(envelope *Envelope) error {
137137
if aea.standalone {
138138
errorMsg := "node running in standalone mode"
139-
logger.Warn().Msgf(errorMsg)
139+
logger.Warn().Msg(errorMsg)
140140
return errors.New(errorMsg)
141141
}
142142
aea.send_queue <- envelope
@@ -146,7 +146,7 @@ func (aea AeaApi) Put(envelope *Envelope) error {
146146
func (aea *AeaApi) Get() *Envelope {
147147
if aea.standalone {
148148
errorMsg := "node running in standalone mode"
149-
logger.Warn().Msgf(errorMsg)
149+
logger.Warn().Msg(errorMsg)
150150
return nil
151151
}
152152
return <-aea.out_queue

dht/common/handlers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828

2929
"log"
3030

31-
"github.com/libp2p/go-libp2p-core/network"
31+
"github.com/libp2p/go-libp2p/core/network"
3232
"github.com/pkg/errors"
3333
"github.com/rs/zerolog"
3434
"google.golang.org/protobuf/proto"

0 commit comments

Comments
 (0)