diff --git a/go.mod b/go.mod index d439f138a5..a645a12ddf 100644 --- a/go.mod +++ b/go.mod @@ -13,6 +13,7 @@ require ( github.com/celestiaorg/go-fraud v0.2.1 github.com/celestiaorg/go-header v0.6.2 github.com/celestiaorg/go-libp2p-messenger v0.2.0 + github.com/celestiaorg/knuu v0.14.1-0.20240708155453-89195d19ba50 github.com/celestiaorg/nmt v0.21.0 github.com/celestiaorg/rsmt2d v0.13.1 github.com/cosmos/cosmos-sdk v0.46.16 @@ -52,7 +53,9 @@ require ( github.com/multiformats/go-multihash v0.2.3 github.com/open-rpc/meta-schema v0.0.0-20201029221707-1b72ef2ea333 github.com/prometheus/client_golang v1.19.1 + github.com/prometheus/common v0.53.0 github.com/rollkit/go-da v0.4.0 + github.com/rs/zerolog v1.33.0 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.9.0 @@ -101,7 +104,6 @@ require ( github.com/celestiaorg/blobstream-contracts/v3 v3.1.0 // indirect github.com/celestiaorg/go-square v1.1.0 // indirect github.com/celestiaorg/go-square/merkle v0.0.0-20240117232118-fd78256df076 // indirect - github.com/celestiaorg/knuu v0.14.0 // indirect github.com/celestiaorg/merkletree v0.0.0-20230308153949-c33506a7aa26 // indirect github.com/celestiaorg/quantum-gravity-bridge/v2 v2.1.2 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect @@ -139,7 +141,7 @@ require ( github.com/dgraph-io/ristretto v0.1.1 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/distribution/reference v0.5.0 // indirect - github.com/docker/docker v26.1.3+incompatible // indirect + github.com/docker/docker v26.1.4+incompatible // indirect github.com/docker/go-connections v0.4.1-0.20210727194412-58542c764a11 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect @@ -154,6 +156,7 @@ require ( github.com/francoispqt/gojay v1.2.13 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/gammazero/deque v0.2.0 // indirect + github.com/go-ini/ini v1.67.0 // indirect github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect @@ -166,7 +169,7 @@ require ( github.com/go-openapi/swag v0.22.3 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect - github.com/goccy/go-json v0.10.2 // indirect + github.com/goccy/go-json v0.10.3 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/gogo/gateway v1.1.0 // indirect @@ -236,8 +239,8 @@ require ( github.com/joho/godotenv v1.5.1 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/compress v1.17.8 // indirect - github.com/klauspost/cpuid/v2 v2.2.7 // indirect + github.com/klauspost/compress v1.17.9 // indirect + github.com/klauspost/cpuid/v2 v2.2.8 // indirect github.com/klauspost/reedsolomon v1.12.1 // indirect github.com/koron/go-ssdp v0.0.4 // indirect github.com/leodido/go-urn v1.2.1 // indirect @@ -264,7 +267,7 @@ require ( github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect github.com/minio/highwayhash v1.0.2 // indirect github.com/minio/md5-simd v1.1.2 // indirect - github.com/minio/minio-go/v7 v7.0.70 // indirect + github.com/minio/minio-go/v7 v7.0.73 // indirect github.com/minio/sha256-simd v1.0.1 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect @@ -311,7 +314,6 @@ require ( github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/polydawn/refmt v0.89.0 // indirect github.com/prometheus/client_model v0.6.1 // indirect - github.com/prometheus/common v0.53.0 // indirect github.com/prometheus/procfs v0.15.0 // indirect github.com/quic-go/qpack v0.4.0 // indirect github.com/quic-go/quic-go v0.44.0 // indirect @@ -322,7 +324,6 @@ require ( github.com/regen-network/cosmos-proto v0.3.1 // indirect github.com/rs/cors v1.8.3 // indirect github.com/rs/xid v1.5.0 // indirect - github.com/rs/zerolog v1.33.0 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect github.com/shirou/gopsutil v3.21.6+incompatible // indirect github.com/sirupsen/logrus v1.9.3 // indirect @@ -356,7 +357,7 @@ require ( go.uber.org/mock v0.4.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/mod v0.17.0 // indirect - golang.org/x/net v0.25.0 // indirect + golang.org/x/net v0.26.0 // indirect golang.org/x/oauth2 v0.20.0 // indirect golang.org/x/sys v0.21.0 // indirect golang.org/x/term v0.21.0 // indirect @@ -394,3 +395,5 @@ replace ( github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/tendermint/tendermint => github.com/celestiaorg/celestia-core v1.37.0-tm-v0.34.29 ) + +replace github.com/celestiaorg/knuu => /Users/peter/git/celestiaorg/knuu/branches/smuu/otlp-sidecar-volume diff --git a/go.sum b/go.sum index e69ab39cf8..6670a54094 100644 --- a/go.sum +++ b/go.sum @@ -379,8 +379,6 @@ github.com/celestiaorg/go-square v1.1.0 h1:K4tBL5PCJwDtpBfyDxxZ3N962aC9VYb5/bw3L github.com/celestiaorg/go-square v1.1.0/go.mod h1:1EXMErhDrWJM8B8V9hN7dqJ2kUTClfwdqMOmF9yQUa0= github.com/celestiaorg/go-square/merkle v0.0.0-20240117232118-fd78256df076 h1:PYInrsYzrDIsZW9Yb86OTi2aEKuPcpgJt6Mc0Jlc/yg= github.com/celestiaorg/go-square/merkle v0.0.0-20240117232118-fd78256df076/go.mod h1:hlidgivKyvv7m4Yl2Fdf2mSTmazZYxX8+bnr5IQrI98= -github.com/celestiaorg/knuu v0.14.0 h1:96uaDHTzlTfhDLrAiygq9Ewow7UzOzGAbUvMwws1S4A= -github.com/celestiaorg/knuu v0.14.0/go.mod h1:5x/+tlLebBSfLmmSBm2ps6aLjnKLn5bOaZpUfI5FpsA= github.com/celestiaorg/merkletree v0.0.0-20230308153949-c33506a7aa26 h1:P2RI1xJ49EZ8cuHMcH+ZSBonfRDtBS8OS9Jdt1BWX3k= github.com/celestiaorg/merkletree v0.0.0-20230308153949-c33506a7aa26/go.mod h1:2m8ukndOegwB0PU0AfJCwDUQHqd7QQRlSXvQL5VToVY= github.com/celestiaorg/nmt v0.21.0 h1:81MBqxNn3orByoiCtdNVjwi5WsLgMkzHwP02ZMhTBHM= @@ -584,8 +582,8 @@ github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwu github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/docker v26.1.3+incompatible h1:lLCzRbrVZrljpVNobJu1J2FHk8V0s4BawoZippkc+xo= -github.com/docker/docker v26.1.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v26.1.4+incompatible h1:vuTpXDuoga+Z38m1OZHzl7NKisKWaWlhjQk7IDPSLsU= +github.com/docker/docker v26.1.4+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.1-0.20210727194412-58542c764a11 h1:IPrmumsT9t5BS7XcPhgsCTlkWbYg80SEXUzDpReaU6Y= github.com/docker/go-connections v0.4.1-0.20210727194412-58542c764a11/go.mod h1:a6bNUGTbQBsY6VRHTr4h/rkOXjl244DyRD0tx3fgq4Q= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= @@ -701,6 +699,8 @@ github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A= +github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= @@ -774,8 +774,8 @@ github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6Wezm github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/gobwas/ws v1.2.1 h1:F2aeBZrm2NDsc7vbovKrWSogd4wvfAxg0FQ89/iqOTk= github.com/gobwas/ws v1.2.1/go.mod h1:hRKAFb8wOxFROYNsT1bqfWnhX+b5MFeJM9r2ZSwg/KY= -github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= -github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA= +github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -1384,8 +1384,8 @@ github.com/klauspost/compress v1.15.10/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrD github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/klauspost/compress v1.15.12/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/klauspost/compress v1.17.3/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= -github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= -github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= +github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= @@ -1397,8 +1397,8 @@ github.com/klauspost/cpuid/v2 v2.1.1/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8t github.com/klauspost/cpuid/v2 v2.1.2/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/klauspost/cpuid/v2 v2.2.1/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/klauspost/cpuid/v2 v2.2.3/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= -github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= -github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM= +github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6/go.mod h1:+ZoRqAPRLkC4NPOvfYeR5KNOrY6TD+/sAC3HXPZgDYg= github.com/klauspost/pgzip v1.0.2-0.20170402124221-0bf5dcad4ada/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/klauspost/reedsolomon v1.12.1 h1:NhWgum1efX1x58daOBGCFWcxtEhOhXKKl1HAPQUp03Q= @@ -1813,8 +1813,8 @@ github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= -github.com/minio/minio-go/v7 v7.0.70 h1:1u9NtMgfK1U42kUxcsl5v0yj6TEOPR497OAQxpJnn2g= -github.com/minio/minio-go/v7 v7.0.70/go.mod h1:4yBA8v80xGA30cfM3fz0DKYMXunWl/AV/6tWEs9ryzo= +github.com/minio/minio-go/v7 v7.0.73 h1:qr2vi96Qm7kZ4v7LLebjte+MQh621fFWnv93p12htEo= +github.com/minio/minio-go/v7 v7.0.73/go.mod h1:qydcVzV8Hqtj1VtEocfxbmVFa2siu6HGa+LDEPogjD8= github.com/minio/sha256-simd v0.0.0-20190131020904-2d45a736cd16/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U= github.com/minio/sha256-simd v0.0.0-20190328051042-05b4dd3047e5/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U= github.com/minio/sha256-simd v0.1.0/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U= @@ -2786,8 +2786,8 @@ golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= -golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= diff --git a/test/e2e/simple.go b/test/e2e/simple.go index f3cf45229d..6a244b367c 100644 --- a/test/e2e/simple.go +++ b/test/e2e/simple.go @@ -28,6 +28,7 @@ func E2ESimple(logger *log.Logger) error { testNet.SetConsensusParams(app.DefaultInitialConsensusParams()) defer testNet.Cleanup() + defer testNet.NodeCleanup() logger.Println("Creating testnet validators") testnet.NoError("failed to create genesis nodes", testNet.CreateGenesisNodes(4, appVersion, 10000000, 0, testnet.DefaultResources)) @@ -44,14 +45,15 @@ func E2ESimple(logger *log.Logger) error { logger.Println("Starting testnets") testnet.NoError("failed to start testnets", testNet.Start()) - err = testNet.CreateAndStartBridgeNodes(3, "bridge", nodeVersion, nodeTestnet.DefaultBridgeResources) + // FIXME: If you deploy more than one node of the same type, the keys will be the same + err = testNet.CreateAndStartBridgeNodes(1, "bridge", nodeVersion, nodeTestnet.DefaultBridgeResources) testnet.NoError("failed to create and start bridge node", err) - err = testNet.CreateAndStartFullNodes(3, "full", nodeVersion, nodeTestnet.DefaultFullResources) + err = testNet.CreateAndStartFullNodes(1, "full", nodeVersion, nodeTestnet.DefaultFullResources) testnet.NoError("failed to create and start full node", err) - err = testNet.CreateAndStartLightNodes(3, "light", nodeVersion, nodeTestnet.DefaultLightResources) + err = testNet.CreateAndStartLightNodes(1, "light", nodeVersion, nodeTestnet.DefaultLightResources) testnet.NoError("failed to create and start light node", err) - // wait for 30 seconds + logger.Println("Waiting for 30 seconds") time.Sleep(30 * time.Second) logger.Println("Reading blockchain") @@ -65,5 +67,16 @@ func E2ESimple(logger *log.Logger) error { if totalTxs < 10 { return fmt.Errorf("expected at least 10 transactions, got %d", totalTxs) } + + for _, node := range testNet.DaNodes() { + if node.Type == "full" || node.Type == "light" { + head, err := node.GetMetric("das_sampled_chain_head") + testnet.NoError("failed to get metric", err) + if head < 50 { + return fmt.Errorf("expected head to be greater than 50, got %f", head) + } + } + } + return nil } diff --git a/test/e2e/testnet/utils.go b/test/e2e/testnet/node.go similarity index 74% rename from test/e2e/testnet/utils.go rename to test/e2e/testnet/node.go index 3e3061de2f..ab0aad3e29 100644 --- a/test/e2e/testnet/utils.go +++ b/test/e2e/testnet/node.go @@ -4,13 +4,35 @@ import ( "context" "encoding/json" "fmt" + "net/http" "strconv" "time" "github.com/celestiaorg/celestia-app/v2/test/e2e/testnet" "github.com/celestiaorg/knuu/pkg/knuu" + "github.com/prometheus/common/expfmt" ) +const ( + rpcPort = 26658 + p2pPort = 2121 + prometheusPort = 9090 + otlpRemotePort = 4318 + dockerSrcURL = "ghcr.io/celestiaorg/celestia-node" + remoteRootDir = "/home/celestia" + txsimRootDir = "/home/celestia" +) + +type Node struct { + Name string + Type string `json:"type" validate:"oneof=bridge full light"` + Version string + Instance *knuu.Instance + + rpcProxyHost string + prometheusProxyHost string +} + func initInstance(instanceName, version, nodeType, chainId, genesisHash string) (*knuu.Instance, error) { instance, err := knuu.NewInstance(instanceName) if err != nil { @@ -20,15 +42,15 @@ func initInstance(instanceName, version, nodeType, chainId, genesisHash string) if err != nil { return nil, fmt.Errorf("Error setting image: %v", err) } - err = instance.AddPortTCP(2121) + err = instance.AddPortTCP(p2pPort) if err != nil { return nil, fmt.Errorf("Error adding port: %v", err) } - err = instance.AddPortTCP(26658) + err = instance.AddPortTCP(rpcPort) if err != nil { return nil, fmt.Errorf("Error adding port: %v", err) } - _, err = instance.ExecuteCommand("celestia", nodeType, "init", "--node.store", "/home/celestia") + _, err = instance.ExecuteCommand("celestia", nodeType, "init", "--node.store", remoteRootDir) if err != nil { return nil, fmt.Errorf("Error executing command: %v", err) } @@ -40,6 +62,15 @@ func initInstance(instanceName, version, nodeType, chainId, genesisHash string) if err != nil { return nil, fmt.Errorf("Error setting environment variable: %v", err) } + + err = instance.SetOtelEndpoint(otlpRemotePort) + if err != nil { + return nil, fmt.Errorf("Error setting otel endpoint: %v", err) + } + err = instance.SetPrometheusExporter(fmt.Sprintf("0.0.0.0:%d", prometheusPort)) + if err != nil { + return nil, fmt.Errorf("Error setting prometheus exporter: %v", err) + } return instance, nil } @@ -49,7 +80,7 @@ func CreateBridge( version string, consensus *knuu.Instance, resources testnet.Resources, -) (*knuu.Instance, error) { +) (*Node, error) { chainId, err := ChainId(executor, consensus) if err != nil { return nil, fmt.Errorf("error getting chain ID: %w", err) @@ -82,14 +113,25 @@ func CreateBridge( "celestia", "bridge", "start", - "--node.store", "/home/celestia", + "--node.store", remoteRootDir, "--core.ip", consensusIP, + "--rpc.addr", "0.0.0.0", + "--metrics", + "--metrics.endpoint", fmt.Sprintf("localhost:%d", otlpRemotePort), + "--metrics.tls=false", ) if err != nil { return nil, fmt.Errorf("error setting command: %w", err) } - return bridge, nil + testNode := &Node{ + Name: instanceName, + Type: "bridge", + Version: version, + Instance: bridge, + } + + return testNode, nil } func CreateAndStartBridge( @@ -98,16 +140,28 @@ func CreateAndStartBridge( version string, consensus *knuu.Instance, resources testnet.Resources, -) (*knuu.Instance, error) { +) (*Node, error) { bridge, err := CreateBridge(executor, instanceName, version, consensus, resources) if err != nil { return nil, fmt.Errorf("error creating bridge: %w", err) } - if err := bridge.Start(); err != nil { + if err := bridge.Instance.Start(); err != nil { return nil, fmt.Errorf("error starting bridge: %w", err) } + err, rpcProxyHost := bridge.Instance.AddHost(rpcPort) + if err != nil { + return nil, fmt.Errorf("error adding host: %w", err) + } + err, prometheusProxyHost := bridge.Instance.AddHost(prometheusPort) + if err != nil { + return nil, fmt.Errorf("error adding host: %w", err) + } + + bridge.rpcProxyHost = rpcProxyHost + bridge.prometheusProxyHost = prometheusProxyHost + return bridge, nil } @@ -117,9 +171,9 @@ func CreateNode( version string, nodeType string, consensus *knuu.Instance, - trustedNode *knuu.Instance, + trustedNode *Node, resources testnet.Resources, -) (*knuu.Instance, error) { +) (*Node, error) { chainId, err := ChainId(executor, consensus) if err != nil { return nil, fmt.Errorf("error getting chain ID: %w", err) @@ -134,12 +188,12 @@ func CreateNode( return nil, fmt.Errorf("error creating instance: %w", err) } - p2pInfoNode, err := trustedNode.ExecuteCommand("celestia", "p2p", "info", "--node.store", "/home/celestia") + p2pInfoNode, err := trustedNode.Instance.ExecuteCommand("celestia", "p2p", "info", "--node.store", remoteRootDir) if err != nil { return nil, fmt.Errorf("error getting p2p info: %w", err) } - bridgeIP, err := trustedNode.GetIP() + bridgeIP, err := trustedNode.Instance.GetIP() if err != nil { return nil, fmt.Errorf("error getting IP: %w", err) } @@ -162,14 +216,24 @@ func CreateNode( err = node.SetCommand( "celestia", nodeType, "start", - "--node.store", "/home/celestia", + "--node.store", remoteRootDir, "--headers.trusted-peers", trustedPeers, + "--metrics", + "--metrics.endpoint", fmt.Sprintf("localhost:%d", otlpRemotePort), + "--metrics.tls=false", ) if err != nil { return nil, fmt.Errorf("error setting command: %w", err) } - return node, nil + testNode := &Node{ + Name: instanceName, + Type: nodeType, + Version: version, + Instance: node, + } + + return testNode, nil } func CreateAndStartNode( @@ -178,21 +242,81 @@ func CreateAndStartNode( version string, nodeType string, consensus *knuu.Instance, - trustedNode *knuu.Instance, + trustedNode *Node, resources testnet.Resources, -) (*knuu.Instance, error) { +) (*Node, error) { node, err := CreateNode(executor, instanceName, version, nodeType, consensus, trustedNode, resources) if err != nil { return nil, fmt.Errorf("error creating node: %w", err) } - if err := node.Start(); err != nil { + if err := node.Instance.Start(); err != nil { return nil, fmt.Errorf("error starting node: %w", err) } + err, rpcProxyHost := node.Instance.AddHost(rpcPort) + if err != nil { + return nil, fmt.Errorf("error adding host: %w", err) + } + err, prometheusProxyHost := node.Instance.AddHost(prometheusPort) + if err != nil { + return nil, fmt.Errorf("error adding host: %w", err) + } + + node.rpcProxyHost = rpcProxyHost + node.prometheusProxyHost = prometheusProxyHost + return node, nil } +// GetMetric returns a metric from the node +func (n *Node) GetMetric(metricName string) (float64, error) { + host := n.AddressPrometheus() + + resp, err := http.Get(fmt.Sprintf("%s/metrics", host)) + if err != nil { + return 0, fmt.Errorf("failed to fetch Prometheus data: %v", err) + } + defer resp.Body.Close() + + parser := expfmt.TextParser{} + metricFamilies, err := parser.TextToMetricFamilies(resp.Body) + if err != nil { + return 0, fmt.Errorf("failed to parse Prometheus metrics: %v", err) + } + + var metricValue float64 + found := false + + if metricFamily, ok := metricFamilies[metricName]; ok { + for _, metric := range metricFamily.GetMetric() { + switch { + case metric.Counter != nil: + metricValue = metric.Counter.GetValue() + found = true + case metric.Gauge != nil: + metricValue = metric.Gauge.GetValue() + found = true + case metric.Untyped != nil: + metricValue = metric.Untyped.GetValue() + found = true + case metric.Summary != nil: + metricValue = metric.Summary.GetSampleSum() + found = true + case metric.Histogram != nil: + metricValue = metric.Histogram.GetSampleSum() + found = true + } + } + } + + if !found { + return 0, fmt.Errorf("metric not found") + } + + return metricValue, nil +} + type JSONRPCError struct { Code int Message string @@ -452,3 +576,14 @@ func hashFromBlock(block string) (string, error) { } return blockHash, nil } + +// AddressRPC returns an RPC endpoint address for the node. +// This returns the proxy host that can be used to communicate with the node +func (n Node) AddressRPC() string { + return n.rpcProxyHost +} + +// AddressGRPC returns the GRPC endpoint address for the node. +func (n Node) AddressPrometheus() string { + return n.prometheusProxyHost +} diff --git a/test/e2e/testnet/testnet.go b/test/e2e/testnet/testnet.go index f826306083..9db93c4b77 100644 --- a/test/e2e/testnet/testnet.go +++ b/test/e2e/testnet/testnet.go @@ -6,13 +6,14 @@ import ( "github.com/celestiaorg/celestia-app/v2/test/e2e/testnet" "github.com/celestiaorg/celestia-app/v2/test/util/genesis" // Updated this import "github.com/celestiaorg/knuu/pkg/knuu" + "github.com/rs/zerolog/log" ) // LocalTestnet extends the testnet from celestia-app type NodeTestnet struct { testnet.Testnet executor *knuu.Executor - nodes []*knuu.Instance + nodes []*Node } // NewLocalTestnet creates a new instance of LocalTestnet @@ -25,7 +26,26 @@ func NewNodeTestnet(name string, seed int64, grafana *testnet.GrafanaInfo, chain if err != nil { return nil, err } - return &NodeTestnet{*tn, executor, []*knuu.Instance{}}, nil + return &NodeTestnet{*tn, executor, []*Node{}}, nil +} + +// DaNodes returns all DA nodes +func (nt *NodeTestnet) DaNodes() []*Node { + return nt.nodes +} + +// NodeCleanup cleans up the nodes +func (nt *NodeTestnet) NodeCleanup() { + for _, node := range nt.nodes { + err := node.Instance.Destroy() + if err != nil { + log.Error().Err(err).Msg("error destroying node") + } + } + err := nt.executor.Destroy() + if err != nil { + log.Error().Err(err).Msg("error destroying executor") + } } // CreateBridgeNode creates a new bridge node