diff --git a/.github/workflows/integration-examples.yml b/.github/workflows/integration-examples.yml index 97e745e38..3a7f0d3dc 100644 --- a/.github/workflows/integration-examples.yml +++ b/.github/workflows/integration-examples.yml @@ -23,14 +23,14 @@ jobs: uses: actions/checkout@v2 - name: Run dev environment - run: docker-compose -f ./suave/e2e/docker-compose.yml up -d --build + run: docker compose -f ./suave/e2e/docker-compose.yml up -d --build - name: Check out suapp-examples uses: actions/checkout@v2 with: repository: flashbots/suapp-examples path: suapp-examples - + - name: Build suapp-examples run: | cd suapp-examples diff --git a/Makefile b/Makefile index 7b91be935..5f92c2590 100644 --- a/Makefile +++ b/Makefile @@ -47,10 +47,10 @@ suavedevtools: go run ./suave/gen/main.go -write devnet-up: - docker-compose -f ./suave/devenv/docker-compose.yml up -d --build + docker compose -f ./suave/devenv/docker-compose.yml up -d --build devnet-down: - docker-compose -f ./suave/devenv/docker-compose.yml down + docker compose -f ./suave/devenv/docker-compose.yml down fmt-contracts: cd suave && forge fmt diff --git a/suave/cstore/redis_store_backend.go b/suave/cstore/redis_store_backend.go index 416ae60ef..7ea73e96f 100644 --- a/suave/cstore/redis_store_backend.go +++ b/suave/cstore/redis_store_backend.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/metrics" suave "github.com/ethereum/go-ethereum/suave/core" "github.com/go-redis/redis/v8" ) @@ -86,9 +87,30 @@ func (r *RedisStoreBackend) start() error { return fmt.Errorf("mempool: could not initialize: %w", err) } + go r.trackMetrics() + return nil } +func (r *RedisStoreBackend) count() int64 { + return r.client.DBSize(context.Background()).Val() +} + +var ( + redisStoreItemsGauge = metrics.NewRegisteredGauge("suave/confstore/items", nil) +) + +func (r *RedisStoreBackend) trackMetrics() { + for { + select { + case <-r.ctx.Done(): + return + case <-time.After(10 * time.Second): + redisStoreItemsGauge.Update(r.count()) + } + } +} + func (r *RedisStoreBackend) Stop() error { if r.cancel == nil || r.client == nil { return errors.New("redis store: Stop() called before Start()") diff --git a/suave/cstore/redis_store_backend_test.go b/suave/cstore/redis_store_backend_test.go index e8ffe8418..c597345bb 100644 --- a/suave/cstore/redis_store_backend_test.go +++ b/suave/cstore/redis_store_backend_test.go @@ -82,3 +82,19 @@ func TestRedis_TTL_MultipleEntries_SameIndex(t *testing.T) { require.Len(t, vals, 1) require.Equal(t, record2, vals[0]) } + +func TestRedis_Count(t *testing.T) { + store, err := NewRedisStoreBackend("", 2*time.Second) + require.NoError(t, err) + + for i := 0; i < 10; i++ { + record := suave.DataRecord{ + Id: suave.RandomDataRecordId(), + Version: "a", + DecryptionCondition: 1, + } + require.NoError(t, store.InitRecord(record)) + } + + require.NotZero(t, store.count()) +}