diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 18a2954..56d7457 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -33,10 +33,10 @@ jobs: cd ../.. - name: Verify paths - run: make -C waku print-paths + run: make -C pkg/kernel print-paths - name: Verify libwaku artifacts - run: make -C waku check-folders + run: make -C pkg/kernel check-folders - name: Install Go dependencies run: | @@ -49,7 +49,7 @@ jobs: export LOGOS_DELIVERY_DIR=$(pwd)/vendor/logos-delivery export CGO_CFLAGS="-I${LOGOS_DELIVERY_DIR}/library/" export CGO_LDFLAGS="-L${LOGOS_DELIVERY_DIR}/build/ -lwaku -Wl,-rpath,${LOGOS_DELIVERY_DIR}/build/" - make -C waku build + make -C pkg/kernel build - name: Increase ulimit run: sudo sh -c "ulimit -n 8192" @@ -57,8 +57,7 @@ jobs: - name: Run daily test run: | set -euo pipefail - cd waku - export LOGOS_DELIVERY_DIR=$(pwd)/vendor/logos-delivery + cd pkg/kernel export LOGOS_DELIVERY_DIR=$(pwd)/vendor/logos-delivery export CGO_CFLAGS="-I${LOGOS_DELIVERY_DIR}/library/" export CGO_LDFLAGS="-L${LOGOS_DELIVERY_DIR}/build/ -lwaku -Wl,-rpath,${LOGOS_DELIVERY_DIR}/build/" go test -count=10 -p=1 -v -timeout=360m . | tee ../testlogs.log diff --git a/.github/workflows/CI_endurance.yml b/.github/workflows/CI_endurance.yml index 66ae899..7b7538d 100644 --- a/.github/workflows/CI_endurance.yml +++ b/.github/workflows/CI_endurance.yml @@ -39,7 +39,7 @@ jobs: make libwaku - name: Build waku bindings - run: make -C waku build + run: make -C pkg/kernel build - name: Increase ulimit run: sudo sh -c "ulimit -n 8192" @@ -49,7 +49,7 @@ jobs: run: | set -euo pipefail go test -tags stress \ - -p=1 -v ./waku -count=1 -timeout=360m -run '^(TestStressMemoryUsageForThreeNodes|TestStressStoreQuery5kMessagesWithPagination|TestStressHighThroughput10kPublish|TestStressLargePayloadEphemeralMessagesEndurance|TestStressConnectDisconnect1kIteration)$' | tee testlogs1.log + -p=1 -v ./pkg/kernel -count=1 -timeout=360m -run '^(TestStressMemoryUsageForThreeNodes|TestStressStoreQuery5kMessagesWithPagination|TestStressHighThroughput10kPublish|TestStressLargePayloadEphemeralMessagesEndurance|TestStressConnectDisconnect1kIteration)$' | tee testlogs1.log - name: Upload Test Logs (Group 1) uses: actions/upload-artifact@v4 @@ -98,7 +98,7 @@ jobs: make libwaku - name: Build waku bindings - run: make -C waku build + run: make -C pkg/kernel build - name: Increase ulimit run: sudo sh -c "ulimit -n 8192" @@ -109,7 +109,7 @@ jobs: run: | set -euo pipefail go test -tags stress \ - -p=1 -v ./waku -count=1 -timeout=360m -run '^(TestStressRandomNodesInMesh|TestStress2Nodes2kIterationTearDown|TestPeerExchangePXLoad)$' | tee testlogs2.log + -p=1 -v ./pkg/kernel -count=1 -timeout=360m -run '^(TestStressRandomNodesInMesh|TestStress2Nodes2kIterationTearDown|TestPeerExchangePXLoad)$' | tee testlogs2.log - name: Upload Test Logs (Group 2) uses: actions/upload-artifact@v4 diff --git a/.github/workflows/Repeated_tests_endurancce.yml b/.github/workflows/Repeated_tests_endurancce.yml index 449d9da..ff41f6a 100644 --- a/.github/workflows/Repeated_tests_endurancce.yml +++ b/.github/workflows/Repeated_tests_endurancce.yml @@ -39,7 +39,7 @@ jobs: make libwaku - name: Build waku bindings - run: make -C waku build + run: make -C pkg/kernel build - name: Clean environment run: go clean -cache diff --git a/.gitignore b/.gitignore index b714513..ca4f3b6 100644 --- a/.gitignore +++ b/.gitignore @@ -23,15 +23,18 @@ go.work # Generated dependencies and cache nimcache -waku/store.sqlite3 +pkg/kernel/store.sqlite3 -waku/store.sqlite3-shm +pkg/kernel/store.sqlite3-shm -waku/store.sqlite3-wal +pkg/kernel/store.sqlite3-wal -waku/test_repeated_start_stop.log +pkg/kernel/test_repeated_start_stop.log third_party/ # JetBrains IDEs -.idea/ \ No newline at end of file +.idea/ +# Kernel bindings build output +/pkg/kernel/kernel-bindings +/pkg/kernel/waku-bindings diff --git a/README.md b/README.md index f86363e..e461e77 100644 --- a/README.md +++ b/README.md @@ -23,13 +23,13 @@ export CGO_CFLAGS="-I${LOGOS_DELIVERY_DIR}/library" export CGO_LDFLAGS="-L${LOGOS_DELIVERY_DIR}/build -lwaku -Wl,-rpath,${LOGOS_DELIVERY_DIR}/build" # compile all packages -make -C waku build +make -C pkg/kernel build # run all tests -make -C waku test +make -C pkg/kernel test # run a specific test -make -C waku test TEST=TestConnectedPeersInfo +make -C pkg/kernel test TEST=TestConnectedPeersInfo ``` ## Development @@ -39,9 +39,9 @@ When working on this repository itself, `logos-delivery` is included as a git su - Initialize and update the submodule, then build `libwaku` ```sh git submodule update --init --recursive - make -C waku build-libwaku + make -C pkg/kernel build-libwaku ``` - Build the project. Submodule paths are used by default to find `libwaku`. ```shell - make -C waku build + make -C pkg/kernel build ``` diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..ca9dd5b --- /dev/null +++ b/examples/README.md @@ -0,0 +1,6 @@ +# Examples + +Runnable examples for the Go bindings. + +A `messaging/` example (create a node, subscribe, send, print received events) +will be added alongside the Messaging API implementation. diff --git a/internal/ffi/doc.go b/internal/ffi/doc.go new file mode 100644 index 0000000..a9586c2 --- /dev/null +++ b/internal/ffi/doc.go @@ -0,0 +1,8 @@ +// Package ffi holds the cgo bridge over the logos-delivery C libraries: the +// synchronous request/callback plumbing, the global event callback, and the +// handle registry. It exposes Go-typed primitives so the public packages +// (e.g. messaging) stay pure Go. +// +// Scaffolding only for now; the Messaging API bindings land here (over +// liblogosdelivery) in a follow-up. +package ffi diff --git a/waku/Makefile b/pkg/kernel/Makefile similarity index 94% rename from waku/Makefile rename to pkg/kernel/Makefile index 4a6523a..68b9104 100644 --- a/waku/Makefile +++ b/pkg/kernel/Makefile @@ -1,7 +1,7 @@ # Makefile for Waku Go Bindings # Path to logos-delivery submodule -export LOGOS_DELIVERY_DIR ?= $(shell pwd)/../vendor/logos-delivery +export LOGOS_DELIVERY_DIR ?= $(shell pwd)/../../vendor/logos-delivery # Debugging output print-paths: @@ -52,7 +52,7 @@ check-folders: build: @echo "Building Logos Messaging Go Bindings (manual)..." - CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" go build -o waku-bindings . + CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" go build -o kernel-bindings . test: build @echo "Running tests (manual)..." @@ -65,4 +65,4 @@ test: build # Clean up generated files clean: @echo "Cleaning up..." - @rm -f waku-bindings + @rm -f kernel-bindings diff --git a/waku/common/config.go b/pkg/kernel/common/config.go similarity index 100% rename from waku/common/config.go rename to pkg/kernel/common/config.go diff --git a/waku/common/envelope.go b/pkg/kernel/common/envelope.go similarity index 96% rename from waku/common/envelope.go rename to pkg/kernel/common/envelope.go index a16537a..805c315 100644 --- a/waku/common/envelope.go +++ b/pkg/kernel/common/envelope.go @@ -3,7 +3,7 @@ package common import ( "encoding/json" - "github.com/logos-messaging/logos-delivery-go-bindings/waku/pb" + "github.com/logos-messaging/logos-delivery-go-bindings/pkg/kernel/pb" ) // Envelope contains information about the pubsub topic of a WakuMessage diff --git a/waku/common/message_hash.go b/pkg/kernel/common/message_hash.go similarity index 100% rename from waku/common/message_hash.go rename to pkg/kernel/common/message_hash.go diff --git a/waku/common/peers.go b/pkg/kernel/common/peers.go similarity index 100% rename from waku/common/peers.go rename to pkg/kernel/common/peers.go diff --git a/waku/common/rate_limit.go b/pkg/kernel/common/rate_limit.go similarity index 100% rename from waku/common/rate_limit.go rename to pkg/kernel/common/rate_limit.go diff --git a/waku/common/store.go b/pkg/kernel/common/store.go similarity index 100% rename from waku/common/store.go rename to pkg/kernel/common/store.go diff --git a/pkg/kernel/doc.go b/pkg/kernel/doc.go new file mode 100644 index 0000000..9505cbb --- /dev/null +++ b/pkg/kernel/doc.go @@ -0,0 +1,9 @@ +// Package kernel is the low-level Go wrapper over the logos-delivery Kernel API +// (libwaku): relay, store, lightpush, filter, peer management, discovery. +// +// It mirrors go-waku's shape and predates the Messaging API. It is considered +// legacy: once logos-delivery#3851 consolidates libwaku and liblogosdelivery +// into a single tiered library, the kernel surface will be re-pointed at that +// library and exposed as accessors on the messaging Node rather than as a +// standalone package. New consumers should prefer the messaging package. +package kernel diff --git a/waku/logging.go b/pkg/kernel/logging.go similarity index 97% rename from waku/logging.go rename to pkg/kernel/logging.go index 8be327c..994fa40 100644 --- a/waku/logging.go +++ b/pkg/kernel/logging.go @@ -1,4 +1,4 @@ -package waku +package kernel import ( "sync" diff --git a/waku/nodes_basic_test.go b/pkg/kernel/nodes_basic_test.go similarity index 97% rename from waku/nodes_basic_test.go rename to pkg/kernel/nodes_basic_test.go index 8d8619f..9a1e848 100644 --- a/waku/nodes_basic_test.go +++ b/pkg/kernel/nodes_basic_test.go @@ -1,10 +1,10 @@ -package waku +package kernel import ( "testing" "time" - "github.com/logos-messaging/logos-delivery-go-bindings/waku/common" + "github.com/logos-messaging/logos-delivery-go-bindings/pkg/kernel/common" "github.com/stretchr/testify/require" ) diff --git a/waku/nwaku.go b/pkg/kernel/nwaku.go similarity index 99% rename from waku/nwaku.go rename to pkg/kernel/nwaku.go index 3037093..cc81114 100644 --- a/waku/nwaku.go +++ b/pkg/kernel/nwaku.go @@ -1,4 +1,4 @@ -package waku +package kernel /* #include @@ -352,17 +352,17 @@ import ( "time" "unsafe" - "github.com/logos-messaging/logos-delivery-go-bindings/waku/timesource" + "github.com/logos-messaging/logos-delivery-go-bindings/pkg/kernel/timesource" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/p2p/enode" "github.com/libp2p/go-libp2p/core/peer" libp2pproto "github.com/libp2p/go-libp2p/core/protocol" - "github.com/logos-messaging/logos-delivery-go-bindings/waku/pb" - "github.com/logos-messaging/logos-delivery-go-bindings/waku/utils" + "github.com/logos-messaging/logos-delivery-go-bindings/pkg/kernel/pb" + "github.com/logos-messaging/logos-delivery-go-bindings/pkg/kernel/utils" "github.com/multiformats/go-multiaddr" - "github.com/logos-messaging/logos-delivery-go-bindings/waku/common" + "github.com/logos-messaging/logos-delivery-go-bindings/pkg/kernel/common" ) const requestTimeout = 30 * time.Second diff --git a/waku/nwaku_test.go b/pkg/kernel/nwaku_test.go similarity index 99% rename from waku/nwaku_test.go rename to pkg/kernel/nwaku_test.go index d624aae..4a73ed3 100644 --- a/waku/nwaku_test.go +++ b/pkg/kernel/nwaku_test.go @@ -1,4 +1,4 @@ -package waku +package kernel import ( "context" @@ -13,9 +13,9 @@ import ( "github.com/cenkalti/backoff/v3" "github.com/libp2p/go-libp2p/core/peer" - "github.com/logos-messaging/logos-delivery-go-bindings/waku/common" - "github.com/logos-messaging/logos-delivery-go-bindings/waku/pb" - "github.com/logos-messaging/logos-delivery-go-bindings/waku/store" + "github.com/logos-messaging/logos-delivery-go-bindings/pkg/kernel/common" + "github.com/logos-messaging/logos-delivery-go-bindings/pkg/kernel/pb" + "github.com/logos-messaging/logos-delivery-go-bindings/pkg/kernel/store" ma "github.com/multiformats/go-multiaddr" "github.com/stretchr/testify/require" ) diff --git a/waku/nwaku_test_utils.go b/pkg/kernel/nwaku_test_utils.go similarity index 98% rename from waku/nwaku_test_utils.go rename to pkg/kernel/nwaku_test_utils.go index 4a845da..e69b499 100644 --- a/waku/nwaku_test_utils.go +++ b/pkg/kernel/nwaku_test_utils.go @@ -1,4 +1,4 @@ -package waku +package kernel import ( "context" @@ -16,9 +16,9 @@ import ( "github.com/cenkalti/backoff/v3" "github.com/libp2p/go-libp2p/core/peer" + "github.com/logos-messaging/logos-delivery-go-bindings/pkg/kernel/common" + "github.com/logos-messaging/logos-delivery-go-bindings/pkg/kernel/pb" "github.com/logos-messaging/logos-delivery-go-bindings/utils" - "github.com/logos-messaging/logos-delivery-go-bindings/waku/common" - "github.com/logos-messaging/logos-delivery-go-bindings/waku/pb" "google.golang.org/protobuf/proto" ) diff --git a/waku/pb/message.pb.go b/pkg/kernel/pb/message.pb.go similarity index 100% rename from waku/pb/message.pb.go rename to pkg/kernel/pb/message.pb.go diff --git a/waku/peer_connections_test.go b/pkg/kernel/peer_connections_test.go similarity index 99% rename from waku/peer_connections_test.go rename to pkg/kernel/peer_connections_test.go index 317f072..d33c54a 100644 --- a/waku/peer_connections_test.go +++ b/pkg/kernel/peer_connections_test.go @@ -1,11 +1,11 @@ -package waku +package kernel import ( "slices" "testing" "time" - "github.com/logos-messaging/logos-delivery-go-bindings/waku/common" + "github.com/logos-messaging/logos-delivery-go-bindings/pkg/kernel/common" "github.com/stretchr/testify/require" ) diff --git a/waku/relay_test.go b/pkg/kernel/relay_test.go similarity index 99% rename from waku/relay_test.go rename to pkg/kernel/relay_test.go index 5b17253..2bd7036 100644 --- a/waku/relay_test.go +++ b/pkg/kernel/relay_test.go @@ -1,4 +1,4 @@ -package waku +package kernel import ( "fmt" @@ -7,8 +7,8 @@ import ( "time" "github.com/cenkalti/backoff/v3" - "github.com/logos-messaging/logos-delivery-go-bindings/waku/common" - "github.com/logos-messaging/logos-delivery-go-bindings/waku/pb" + "github.com/logos-messaging/logos-delivery-go-bindings/pkg/kernel/common" + "github.com/logos-messaging/logos-delivery-go-bindings/pkg/kernel/pb" "github.com/stretchr/testify/require" "google.golang.org/protobuf/proto" ) diff --git a/waku/store/store.go b/pkg/kernel/store/store.go similarity index 100% rename from waku/store/store.go rename to pkg/kernel/store/store.go diff --git a/waku/store_test.go b/pkg/kernel/store_test.go similarity index 99% rename from waku/store_test.go rename to pkg/kernel/store_test.go index bb1448c..5b01f72 100644 --- a/waku/store_test.go +++ b/pkg/kernel/store_test.go @@ -1,4 +1,4 @@ -package waku +package kernel import ( "fmt" @@ -6,10 +6,10 @@ import ( "time" "github.com/cenkalti/backoff/v3" - "github.com/logos-messaging/logos-delivery-go-bindings/waku/pb" + "github.com/logos-messaging/logos-delivery-go-bindings/pkg/kernel/pb" "github.com/stretchr/testify/require" - "github.com/logos-messaging/logos-delivery-go-bindings/waku/common" + "github.com/logos-messaging/logos-delivery-go-bindings/pkg/kernel/common" "google.golang.org/protobuf/proto" ) diff --git a/waku/stress_test.go b/pkg/kernel/stress_test.go similarity index 99% rename from waku/stress_test.go rename to pkg/kernel/stress_test.go index 37fd42b..cbdef17 100644 --- a/waku/stress_test.go +++ b/pkg/kernel/stress_test.go @@ -1,7 +1,7 @@ //go:build stress // +build stress -package waku +package kernel import ( "fmt" @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/logos-messaging/logos-delivery-go-bindings/waku/common" + "github.com/logos-messaging/logos-delivery-go-bindings/pkg/kernel/common" "github.com/stretchr/testify/require" // "go.uber.org/zap/zapcore" diff --git a/waku/test_data.go b/pkg/kernel/test_data.go similarity index 97% rename from waku/test_data.go rename to pkg/kernel/test_data.go index 00f9fc0..99b9613 100644 --- a/waku/test_data.go +++ b/pkg/kernel/test_data.go @@ -1,10 +1,10 @@ -package waku +package kernel import ( "fmt" "time" - "github.com/logos-messaging/logos-delivery-go-bindings/waku/common" + "github.com/logos-messaging/logos-delivery-go-bindings/pkg/kernel/common" "google.golang.org/protobuf/proto" ) diff --git a/waku/timesource/timesource.go b/pkg/kernel/timesource/timesource.go similarity index 100% rename from waku/timesource/timesource.go rename to pkg/kernel/timesource/timesource.go diff --git a/waku/utils/utils.go b/pkg/kernel/utils/utils.go similarity index 100% rename from waku/utils/utils.go rename to pkg/kernel/utils/utils.go diff --git a/pkg/messaging/doc.go b/pkg/messaging/doc.go new file mode 100644 index 0000000..88dff8d --- /dev/null +++ b/pkg/messaging/doc.go @@ -0,0 +1,10 @@ +// Package messaging is the high-level, idiomatic Go binding for the +// logos-delivery Messaging API (an opinionated layer over the kernel protocols +// that owns reliability, re-subscriptions, store-based catch-up and the +// Messaging event surface). +// +// It will expose a Node type (create/start/stop, send/subscribe/unsubscribe) +// and a unified Events channel, backed by cgo calls into liblogosdelivery via +// the internal/ffi package. Scaffolding only for now; the implementation lands +// in a follow-up. +package messaging diff --git a/waku/waku-bindings b/waku/waku-bindings deleted file mode 100644 index ae10486..0000000 Binary files a/waku/waku-bindings and /dev/null differ