Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Optional async decoupling for secondary writes and reworked E2E metric assertions #182

Merged
merged 20 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ced2a95
chore: Better abstract secondary storage
epociask Oct 12, 2024
ab6b939
chore: Better abstract secondary storage - add channel stream for sec…
epociask Oct 12, 2024
a598791
chore: Better abstract secondary storage - add channel stream for sec…
epociask Oct 12, 2024
3c3271d
chore: Better abstract secondary storage - observe secondary storage …
epociask Oct 12, 2024
bb9b433
chore: Better abstract secondary storage - observe secondary storage …
epociask Oct 13, 2024
4b9b0e2
chore: Better abstract secondary storage - observe secondary storage …
epociask Oct 13, 2024
13f221b
chore: Better abstract secondary storage - observe secondary storage …
epociask Oct 13, 2024
95790f2
chore: Better abstract secondary storage - observe secondary storage …
epociask Oct 13, 2024
8ef8108
chore: Better abstract secondary storage - observe secondary storage …
epociask Oct 16, 2024
2fce490
chore: Better abstract secondary storage - observe secondary storage …
epociask Oct 17, 2024
89f8272
chore: Better abstract secondary storage - observe secondary storage …
epociask Oct 17, 2024
167df0e
chore: Better abstract secondary storage - observe secondary storage …
epociask Oct 17, 2024
ab57599
chore: Better abstract secondary storage - address PR feedback, add b…
epociask Oct 20, 2024
2bb21b6
chore: Better abstract secondary storage - refactor tests
epociask Oct 20, 2024
0c3a48c
chore: Better abstract secondary storage - more test clean ups
epociask Oct 20, 2024
346e47c
Merge branch 'main' of github.com:Layr-Labs/op-plasma-eigenda into ep…
epociask Oct 20, 2024
1d858c7
Merge branch 'main' of github.com:Layr-Labs/op-plasma-eigenda into ep…
epociask Oct 21, 2024
69187fb
Merge branch 'main' of github.com:Layr-Labs/op-plasma-eigenda into ep…
epociask Oct 21, 2024
9959633
chore: Better abstract secondary storage - update go mock ref
epociask Oct 24, 2024
2d3559f
chore: Better abstract secondary storage - address PR feedback
epociask Oct 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ install-lint:
@echo "Installing golangci-lint..."
@sh -c $(GET_LINT_CMD)

submodules:
git submodule update --init --recursive

op-devnet-allocs:
@echo "Generating devnet allocs..."
@./scripts/op-devnet-allocs.sh

benchmark:
go test -benchmem -run=^$ -bench . ./e2e -test.parallel 4 -deploy-config ../.devnet/devnetL1.json

.PHONY: \
clean \
test
4 changes: 2 additions & 2 deletions cmd/server/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ func StartProxySvr(cliCtx *cli.Context) error {
ctx, ctxCancel := context.WithCancel(cliCtx.Context)
defer ctxCancel()

daRouter, err := server.LoadStoreRouter(ctx, cfg, log, m)
sm, err := server.LoadStoreManager(ctx, cfg, log, m)
if err != nil {
return fmt.Errorf("failed to create store: %w", err)
}
server := server.NewServer(cliCtx.String(flags.ListenAddrFlagName), cliCtx.Int(flags.PortFlagName), daRouter, log, m)
server := server.NewServer(cliCtx.String(flags.ListenAddrFlagName), cliCtx.Int(flags.PortFlagName), sm, log, m)

if err := server.Start(); err != nil {
return fmt.Errorf("failed to start the DA server: %w", err)
Expand Down
40 changes: 40 additions & 0 deletions e2e/benchmark_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package e2e

import (
"context"
"fmt"
"os"
"strconv"
"testing"

"github.com/Layr-Labs/eigenda-proxy/client"
)

// BenchmarkPutsWithSecondary ... Takes in an async worker count and profiles blob insertions using
// constant blob sizes in parallel
func BenchmarkPutsWithSecondary(b *testing.B) {
testCfg := TestConfig(true)
testCfg.UseS3Caching = true
writeThreadCount := os.Getenv("WRITE_THREAD_COUNT")
threadInt, err := strconv.Atoi(writeThreadCount)
if err != nil {
panic(fmt.Errorf("Could not parse WRITE_THREAD_COUNT field %w", err))
}
testCfg.WriteThreadCount = threadInt

tsConfig := TestSuiteConfig(testCfg)
ts, kill := CreateTestSuite(tsConfig)
defer kill()

cfg := &client.Config{
URL: ts.Address(),
}
daClient := client.New(cfg)

for i := 0; i < b.N; i++ {
_, err := daClient.SetData(context.Background(), []byte("I am a blob and I only live for 14 days on EigenDA"))
if err != nil {
panic(err)
}
}
}
70 changes: 68 additions & 2 deletions e2e/main_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
package e2e_test

import (
"net/http"
"os"
"testing"

"github.com/Layr-Labs/eigenda-proxy/client"
"github.com/Layr-Labs/eigenda-proxy/commitments"
"github.com/Layr-Labs/eigenda-proxy/e2e"
"github.com/Layr-Labs/eigenda-proxy/store"
altda "github.com/ethereum-optimism/optimism/op-alt-da"

"github.com/Layr-Labs/eigenda-proxy/metrics"
"github.com/stretchr/testify/require"
)

// Integration tests are run against memstore whereas.
Expand All @@ -11,17 +21,73 @@ import (
// e.g, in TestProxyServerCaching we only assert to read metrics with EigenDA
// when referencing memstore since we don't profile the eigenDAClient interactions
var (
runTestnetIntegrationTests bool
runIntegrationTests bool
runTestnetIntegrationTests bool // holesky tests
runIntegrationTests bool // memstore tests
)

// ParseEnv ... reads testing cfg fields. Go test flags don't work for this library due to the dependency on Optimism's E2E framework
// which initializes test flags per init function which is called before an init in this package.
func ParseEnv() {
runIntegrationTests = os.Getenv("INTEGRATION") == "true" || os.Getenv("INTEGRATION") == "1"
runTestnetIntegrationTests = os.Getenv("TESTNET") == "true" || os.Getenv("TESTNET") == "1"
}

// TestMain ... run main controller
func TestMain(m *testing.M) {
ParseEnv()
code := m.Run()
os.Exit(code)
}

// requireDispersalRetrievalEigenDA ... ensure that blob was successfully dispersed/read to/from EigenDA
func requireDispersalRetrievalEigenDA(t *testing.T, cm *metrics.CountMap, mode commitments.CommitmentMode) {
writeCount, err := cm.Get(string(mode), http.MethodPost)
require.NoError(t, err)
require.True(t, writeCount > 0)

readCount, err := cm.Get(string(mode), http.MethodGet)
require.NoError(t, err)
require.True(t, readCount > 0)
}

// requireWriteReadSecondary ... ensure that secondary backend was successfully written/read to/from
func requireWriteReadSecondary(t *testing.T, cm *metrics.CountMap, bt store.BackendType) {
writeCount, err := cm.Get(http.MethodPut, store.Success, bt.String())
require.NoError(t, err)
require.True(t, writeCount > 0)

readCount, err := cm.Get(http.MethodGet, store.Success, bt.String())
require.NoError(t, err)
require.True(t, readCount > 0)
}

// requireSimpleClientSetGet ... ensures that simple proxy client can disperse and read a blob
func requireSimpleClientSetGet(t *testing.T, ts e2e.TestSuite, blob []byte) {
cfg := &client.Config{
URL: ts.Address(),
}
daClient := client.New(cfg)

t.Log("Setting input data on proxy server...")
blobInfo, err := daClient.SetData(ts.Ctx, blob)
require.NoError(t, err)

t.Log("Getting input data from proxy server...")
preimage, err := daClient.GetData(ts.Ctx, blobInfo)
require.NoError(t, err)
require.Equal(t, blob, preimage)

}

// requireOPClientSetGet ... ensures that alt-da client can disperse and read a blob
func requireOPClientSetGet(t *testing.T, ts e2e.TestSuite, blob []byte, precompute bool) {
daClient := altda.NewDAClient(ts.Address(), false, precompute)

commit, err := daClient.SetInput(ts.Ctx, blob)
require.NoError(t, err)

preimage, err := daClient.GetInput(ts.Ctx, commit)
require.NoError(t, err)
require.Equal(t, blob, preimage)

}
20 changes: 6 additions & 14 deletions e2e/optimism_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package e2e_test

import (
"net/http"
"testing"

"github.com/Layr-Labs/eigenda-proxy/commitments"
Expand Down Expand Up @@ -127,8 +126,8 @@ func TestOptimismKeccak256Commitment(gt *testing.T) {
testCfg := e2e.TestConfig(useMemory())
testCfg.UseKeccak256ModeS3 = true

tsConfig := e2e.TestSuiteConfig(gt, testCfg)
proxyTS, shutDown := e2e.CreateTestSuite(gt, tsConfig)
tsConfig := e2e.TestSuiteConfig(testCfg)
proxyTS, shutDown := e2e.CreateTestSuite(tsConfig)
defer shutDown()

t := actions.NewDefaultTesting(gt)
Expand Down Expand Up @@ -169,20 +168,16 @@ func TestOptimismKeccak256Commitment(gt *testing.T) {
optimism.sequencer.ActL2PipelineFull(t)
optimism.ActL1Finalized(t)

// assert that EigenDA proxy was written and read from using op keccak256 commitment mode
readCount, err := proxyTS.Metrics.HTTPServerRequestsTotal.Find(http.MethodGet, "", string(commitments.OptimismKeccak), "0")
require.NoError(t, err)
require.True(t, readCount > 0)

requireDispersalRetrievalEigenDA(gt, proxyTS.Metrics.HTTPServerRequestsTotal, commitments.OptimismKeccak)
}

func TestOptimismGenericCommitment(gt *testing.T) {
if !runIntegrationTests && !runTestnetIntegrationTests {
gt.Skip("Skipping test as INTEGRATION or TESTNET env var not set")
}

tsConfig := e2e.TestSuiteConfig(gt, e2e.TestConfig(useMemory()))
proxyTS, shutDown := e2e.CreateTestSuite(gt, tsConfig)
tsConfig := e2e.TestSuiteConfig(e2e.TestConfig(useMemory()))
proxyTS, shutDown := e2e.CreateTestSuite(tsConfig)
defer shutDown()

t := actions.NewDefaultTesting(gt)
Expand Down Expand Up @@ -223,8 +218,5 @@ func TestOptimismGenericCommitment(gt *testing.T) {
optimism.sequencer.ActL2PipelineFull(t)
optimism.ActL1Finalized(t)

// assert that EigenDA proxy was written and read from using op generic commitment mode
readCount, err := proxyTS.Metrics.HTTPServerRequestsTotal.Find(http.MethodGet, "", string(commitments.OptimismGeneric), "0")
require.NoError(t, err)
require.True(t, readCount > 0)
requireDispersalRetrievalEigenDA(gt, proxyTS.Metrics.HTTPServerRequestsTotal, commitments.OptimismGeneric)
}
Loading
Loading