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

Load generator docker #1260

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2d76c84
Allow some things to be set by env variable.
cody-littley Feb 11, 2025
c10d500
Use new traffic generator in docker file
cody-littley Feb 11, 2025
59c21ef
testing something different
cody-littley Feb 12, 2025
e6e61a5
install make
cody-littley Feb 12, 2025
e2d27cf
tweaks
cody-littley Feb 12, 2025
85c7b6d
tweaks
cody-littley Feb 12, 2025
48f8f3f
tweaks
cody-littley Feb 12, 2025
0101460
the next iteration
cody-littley Feb 12, 2025
65484f7
pwd
cody-littley Feb 12, 2025
6f9463f
debug stuff
cody-littley Feb 12, 2025
b9c1c58
Probe v2 dir
cody-littley Feb 12, 2025
5670b74
tweaks
cody-littley Feb 12, 2025
8f40403
use make build
cody-littley Feb 12, 2025
2c6e1c0
Unify docker build file
cody-littley Feb 12, 2025
43e9f5e
fixes
cody-littley Feb 12, 2025
842d2fc
/
cody-littley Feb 12, 2025
593b45f
debug logging
cody-littley Feb 13, 2025
944eb78
Update URLs for SRS points.
cody-littley Feb 14, 2025
757e279
add long sleep to give time for manual operations
cody-littley Feb 14, 2025
79781f2
add libraries to image for debugging
cody-littley Feb 14, 2025
633033d
remove sleep
cody-littley Feb 14, 2025
89dcae7
Handle GATHERING_SIGNATURES
cody-littley Feb 14, 2025
6501fd8
cleanup
cody-littley Feb 14, 2025
9546cb9
consolodate docker files
cody-littley Feb 14, 2025
3ba64fc
revert whitespace changes
cody-littley Feb 14, 2025
9b6e6ec
Merge branch 'master' into load-generator-docker
cody-littley Feb 14, 2025
0907459
made suggested changes
cody-littley Feb 14, 2025
6a51993
thread safe randomness
cody-littley Feb 14, 2025
d47783e
Merge branch 'master' into load-generator-docker
cody-littley Feb 15, 2025
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
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@ RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go build -o ./bin/relay ./cmd

# Traffic Generator V1 build stage
FROM common-builder AS generator-builder
WORKDIR /app/tools/traffic
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go build -o ./bin/generator ./cmd

# Traffic Generator V2 build stage
FROM common-builder AS generator2-builder
WORKDIR /app/test/v2
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
make build

# Final stages for each component
FROM alpine:3.18 AS churner
COPY --from=churner-builder /app/operators/bin/churner /usr/local/bin
Expand Down Expand Up @@ -129,3 +143,11 @@ ENTRYPOINT ["controller"]
FROM alpine:3.18 AS relay
COPY --from=relay-builder /app/relay/bin/relay /usr/local/bin
ENTRYPOINT ["relay"]

FROM alpine:3.18 AS generator
COPY --from=generator-builder /app/tools/traffic/bin/generator /usr/local/bin
ENTRYPOINT ["generator"]

FROM alpine:3.18 AS generator2
COPY --from=generator2-builder /app/test/v2/bin/load /usr/local/bin
ENTRYPOINT ["load", "-", "-"]
2 changes: 2 additions & 0 deletions api/clients/v2/payload_disperser.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ func (pd *PayloadDisperser) pollBlobStatusUntilCertified(
case dispgrpc.BlobStatus_COMPLETE:
return blobStatusReply, nil
case dispgrpc.BlobStatus_QUEUED, dispgrpc.BlobStatus_ENCODED, dispgrpc.BlobStatus_GATHERING_SIGNATURES:
// TODO (litt): check signing percentage when we are gathering signatures, potentially break
// out of this loop early if we have enough signatures
continue
default:
return nil, fmt.Errorf(
Expand Down
4 changes: 2 additions & 2 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ target "churner-internal" {

target "traffic-generator" {
context = "."
dockerfile = "./trafficgenerator.Dockerfile"
dockerfile = "./Dockerfile"
target = "generator"
tags = ["${REGISTRY}/${REPO}/traffic-generator:${BUILD_TAG}"]
}
Expand All @@ -205,7 +205,7 @@ target "traffic-generator-internal" {

target "traffic-generator-v2" {
context = "."
dockerfile = "./trafficgenerator-v2.Dockerfile"
dockerfile = "./Dockerfile"
target = "generator2"
tags = ["${REGISTRY}/${REPO}/traffic-generator-v2:${BUILD_TAG}"]
}
Expand Down
22 changes: 0 additions & 22 deletions synthetic-test-client.Dockerfile

This file was deleted.

54 changes: 37 additions & 17 deletions test/v2/client/test_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ const (
SRSPathG2 = SRSPath + "/g2.point"
SRSPathG2PowerOf2 = SRSPath + "/g2.point.powerOf2"
SRSPathSRSTables = SRSPath + "/SRSTables"

G1URL = "https://eigenda.s3.amazonaws.com/srs/g1.point"
G2URL = "https://eigenda.s3.amazonaws.com/srs/g2.point"
G2PowerOf2URL = "https://eigenda.s3.amazonaws.com/srs/g2.point.powerOf2"
)

// TestClient encapsulates the various clients necessary for interacting with EigenDA.
Expand Down Expand Up @@ -75,20 +71,12 @@ func NewTestClient(

// Construct the disperser client

privateKeyFile, err := ResolveTildeInPath(config.KeyPath)
if err != nil {
return nil, fmt.Errorf("failed to resolve tilde in path: %w", err)
}
privateKey, err := os.ReadFile(privateKeyFile)
privateKey, err := loadPrivateKey(config.KeyPath, config.KeyVar)
if err != nil {
return nil, fmt.Errorf("failed to read private key file: %w", err)
return nil, fmt.Errorf("failed to load private key: %w", err)
}

privateKeyString := string(privateKey)
privateKeyString = strings.Trim(privateKeyString, "\n \t")
privateKeyString, _ = strings.CutPrefix(privateKeyString, "0x")

signer, err := auth.NewLocalBlobRequestSigner(privateKeyString)
signer, err := auth.NewLocalBlobRequestSigner(privateKey)
if err != nil {
return nil, fmt.Errorf("failed to create signer: %w", err)
}
Expand Down Expand Up @@ -149,7 +137,7 @@ func NewTestClient(

ethClientConfig := geth.EthClientConfig{
RPCURLs: config.EthRPCURLs,
PrivateKeyString: privateKeyString,
PrivateKeyString: privateKey,
NumConfirmations: 0,
NumRetries: 3,
}
Expand Down Expand Up @@ -277,13 +265,45 @@ func NewTestClient(
retrievalClient: retrievalClient,
validatorPayloadRetriever: validatorPayloadRetriever,
certVerifier: certVerifier,
privateKey: privateKeyString,
privateKey: privateKey,
metricsRegistry: metrics.registry,
metrics: metrics,
blobCodec: blobCodec,
}, nil
}

// loadPrivateKey loads the private key from the file/env var specified in the config.
func loadPrivateKey(keyPath string, keyVar string) (string, error) {
if keyPath != "" {
privateKeyFile, err := ResolveTildeInPath(keyPath)
if err != nil {
return "", fmt.Errorf("failed to resolve tilde in path: %w", err)
}
privateKey, err := os.ReadFile(privateKeyFile)
if err != nil {
return "", fmt.Errorf("failed to read private key file: %w", err)
}

return formatPrivateKey(string(privateKey)), nil
}

if keyVar == "" {
return "", fmt.Errorf("either KeyPath or KeyVar must be set")
}
privateKey := os.Getenv(keyVar)
if privateKey == "" {
return "", fmt.Errorf("key not found in environment variable %s", keyVar)
}
return formatPrivateKey(privateKey), nil
}

// formatPrivateKey formats the private key by removing leading/trailing whitespace and "0x" prefix.
func formatPrivateKey(privateKey string) string {
privateKey = strings.Trim(privateKey, "\n \t")
privateKey, _ = strings.CutPrefix(privateKey, "0x")
return privateKey
}

// GetConfig returns the test client's configuration.
func (c *TestClient) GetConfig() *TestClientConfig {
return c.config
Expand Down
10 changes: 8 additions & 2 deletions test/v2/client/test_client_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ import (
type TestClientConfig struct {
// The location where persistent test data is stored (e.g. SRS files). Often private keys are stored here too.
TestDataPath string
// The location where the test client's private key is stored.
// This is the key for the account that is paying for dispersals.
// The location where the test client's private key is stored. This is the key for the account that is
// paying for dispersals.
//
// Either this or KeyVar must be set. If both are set, KeyPath is used.
KeyPath string
// The environment variable that contains the private key for the account that is paying for dispersals.
//
// This is used if KeyPath is not set.
KeyVar string
// The disperser's hostname (url or IP address)
DisperserHostname string
// The disperser's port
Expand Down
25 changes: 10 additions & 15 deletions test/v2/client/test_client_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ package client
import (
"encoding/json"
"fmt"
"github.com/Layr-Labs/eigenda/common"
"github.com/Layr-Labs/eigensdk-go/logging"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Does your IDE use a different import ordering scheme?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's just ordering them alphabetically. Is there a different schema we should be using?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"github.com/stretchr/testify/require"
"os"
"os/exec"
"sync"
"testing"

"github.com/Layr-Labs/eigenda/common"
"github.com/Layr-Labs/eigensdk-go/logging"
"github.com/stretchr/testify/require"
)

var (
Expand All @@ -24,6 +23,13 @@ var (

const (
PreprodEnv = "../config/environment/preprod.json"

//G1URL = "https://eigenda.s3.amazonaws.com/srs/g1.point"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove comments

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted

//G2URL = "https://eigenda.s3.amazonaws.com/srs/g2.point"
//G2PowerOf2URL = "https://eigenda.s3.amazonaws.com/srs/g2.point.powerOf2"
G1URL = "https://srs-mainnet.s3.amazonaws.com/kzg/g1.point"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make https://srs-mainnet.s3.amazonaws.com a configuration value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this makes sense as a config value. The purpose of these is to download the SRS files on a developer laptop the first time they run the test suite. Once those files are present, these constants aren't used for anything. So in kubernetes where we are using a persistent volume, these files are ignored.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I don't think this URL will change anyway.

G2URL = "https://srs-mainnet.s3.amazonaws.com/kzg/g2.point"
G2PowerOf2URL = "https://srs-mainnet.s3.amazonaws.com/kzg/g2.point.powerOf2"
)

// GetConfig returns a TestClientConfig instance parsed from the config file.
Expand Down Expand Up @@ -183,17 +189,6 @@ func setupFilesystem(logger logging.Logger, config *TestClientConfig) error {
return fmt.Errorf("failed to create SRS tables directory: %w", err)
}

// Check to see if the private key file exists. If not, stop the test.
filePath, err := ResolveTildeInPath(config.KeyPath)
if err != nil {
return fmt.Errorf("failed to resolve tilde in path: %w", err)
}
_, err = os.Stat(filePath)
if err != nil {
return fmt.Errorf("private key file %s does not exist. This file should "+
"contain the private key for the account used in the test, in hex: %w", filePath, err)
}

// If any of the srs files do not exist, download them.
err = ensureFileIsPresent(config, SRSPathG1, G1URL)
if err != nil {
Expand Down
17 changes: 16 additions & 1 deletion test/v2/load/main/load_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,27 @@ import (

func main() {
if len(os.Args) != 3 {
panic(fmt.Sprintf("Expected 3 args, got %d. Usage: %s <env_file> <load_file>\n",
panic(fmt.Sprintf("Expected 3 args, got %d. Usage: %s <env_file> <load_file>.\n"+
"If '-' is passed in lieu of a config file, the config file path is read from the environment variable "+
"$GENERATOR_ENV or $GENERATOR_LOAD, respectively.\n",
len(os.Args), os.Args[0]))
}

envFile := os.Args[1]
if envFile == "-" {
envFile = os.Getenv("GENERATOR_ENV")
if envFile == "" {
panic("$GENERATOR_ENV not set")
}
}

loadFile := os.Args[2]
if loadFile == "-" {
loadFile = os.Getenv("GENERATOR_LOAD")
if loadFile == "" {
panic("$GENERATOR_LOAD not set")
}
}

c, err := client.GetClient(envFile)
if err != nil {
Expand Down
20 changes: 0 additions & 20 deletions trafficgenerator-v2.Dockerfile

This file was deleted.

20 changes: 0 additions & 20 deletions trafficgenerator.Dockerfile

This file was deleted.

Loading