Skip to content

Commit

Permalink
Merge pull request #48 from Layr-Labs/epociask--chore-bump-proxy-v1.6.0
Browse files Browse the repository at this point in the history
chore(eigenda): Bump eigenda-proxy to latest v1.6.0
  • Loading branch information
epociask authored Dec 3, 2024
2 parents 53404c5 + b29bf11 commit 238699d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 24 deletions.
4 changes: 2 additions & 2 deletions arbnode/batch_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1476,13 +1476,13 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error)
}
eigenDaBlobInfo, err = b.eigenDAWriter.Store(ctx, sequencerMsg)

if err != nil && errors.Is(err, eigenda.SvcUnavailableErr) && b.config().EnableEigenDAFailover && b.dapWriter != nil { // Failover to anytrust commitee if enabled
if err != nil && errors.Is(err, eigenda.ErrServiceUnavailable) && b.config().EnableEigenDAFailover && b.dapWriter != nil { // Failover to anytrust commitee if enabled
log.Error("EigenDA service is unavailable, failing over to any trust mode")
b.building.useEigenDA = false
failOver = true
}

if err != nil && errors.Is(err, eigenda.SvcUnavailableErr) && b.config().EnableEigenDAFailover && b.dapWriter == nil { // Failover to ETH DA if enabled
if err != nil && errors.Is(err, eigenda.ErrServiceUnavailable) && b.config().EnableEigenDAFailover && b.dapWriter == nil { // Failover to ETH DA if enabled
// when failing over to ETHDA (i.e 4844, calldata), we may need to re-encode the batch. To do this in compliance with the existing code, it's easiest
// to update an internal field and retrigger the poster's event loop. Since the batch poster can be distributed across mulitple nodes, there could be
// degraded temporary performance as each batch poster will re-encode the batch on another event loop tick using the coordination lock which could worst case
Expand Down
26 changes: 16 additions & 10 deletions eigenda/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

var (
SvcUnavailableErr = fmt.Errorf("eigenda service is unavailable")
ErrServiceUnavailable = fmt.Errorf("eigenda service is unavailable")
)

type EigenDAProxyClient struct {
Expand Down Expand Up @@ -123,21 +123,22 @@ func (c *client) GetData(ctx context.Context, comm []byte) ([]byte, error) {

defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("received unexpected response code: %d", resp.StatusCode)
b, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}

if resp.StatusCode == http.StatusServiceUnavailable {
return nil, SvcUnavailableErr
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("received error response, code=%d, msg = %s", resp.StatusCode, string(b))
}

return io.ReadAll(resp.Body)
return b, nil
}

// SetData writes raw byte data to DA and returns the associated certificate
// which should be verified within the proxy
func (c *client) SetData(ctx context.Context, b []byte) ([]byte, error) {
url := fmt.Sprintf("%s/put/?commitment_mode=simple", c.cfg.URL)
url := fmt.Sprintf("%s/put?commitment_mode=simple", c.cfg.URL)
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, bytes.NewReader(b))
if err != nil {
return nil, fmt.Errorf("failed to create HTTP request: %w", err)
Expand All @@ -148,15 +149,20 @@ func (c *client) SetData(ctx context.Context, b []byte) ([]byte, error) {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("failed to store data: %v", resp.StatusCode)
}

b, err = io.ReadAll(resp.Body)
if err != nil {
return nil, err
}

if resp.StatusCode == http.StatusServiceUnavailable {
return nil, ErrServiceUnavailable
}

if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("failed to store data: %v, err = %s", resp.StatusCode, string(b))
}

if len(b) == 0 {
return nil, fmt.Errorf("read certificate is empty")
}
Expand Down
4 changes: 2 additions & 2 deletions eigenda/proxy_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func NewMockEigenDAProxyClient(shouldFail bool) *MockEigenDAProxyClient {

func (c *MockEigenDAProxyClient) Put(ctx context.Context, data []byte) (*disperser.BlobInfo, error) {
if c.client.(*MockProxyClient).ShouldFail {
return nil, SvcUnavailableErr
return nil, ErrServiceUnavailable
}
return &mockBlobInfo, nil
}
Expand All @@ -103,7 +103,7 @@ func (c *MockEigenDAProxyClient) Get(ctx context.Context, blobInfo *disperser.Bl
}

if c.client.(*MockProxyClient).ShouldReturn503 {
return nil, SvcUnavailableErr
return nil, ErrServiceUnavailable
}

return mockBlobData, nil
Expand Down
30 changes: 20 additions & 10 deletions scripts/start-eigenda-proxy.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
#!/usr/bin/env bash

echo "Pull eigenda-proxy container"
docker pull ghcr.io/layr-labs/eigenda-proxy@sha256:10a4762f5c43e9037835617e6ec0b03da34012df87048a363f43b969ab93679b
echo "==== Pull eigenda-proxy container ===="
docker pull ghcr.io/layr-labs/eigenda-proxy:v1.6.0

echo "Tagging image"
docker tag ghcr.io/layr-labs/eigenda-proxy@sha256:10a4762f5c43e9037835617e6ec0b03da34012df87048a363f43b969ab93679b eigenda-proxy-nitro-test
echo "==== Starting eigenda-proxy container ===="

echo "Start eigenda-proxy container"
# proxy has a bug currently which forces the use of the service manager address
# & eth rpc despite cert verification being disabled.

docker run -d --name eigenda-proxy-nitro-test \
docker run -d --name eigenda-proxy-nitro-test-instance \
-p 4242:6666 \
-e EIGENDA_PROXY_ADDR=0.0.0.0 \
-e EIGENDA_PROXY_PORT=6666 \
-e MEMSTORE_ENABLED=true \
-e MEMSTORE_EXPIRATION=1m \
-e EIGENDA_PROXY_TARGET_URL=http://localhost:3000 \
eigenda-proxy-nitro-test
-e EIGENDA_PROXY_MEMSTORE_ENABLED=true \
-e EIGENDA_PROXY_MEMSTORE_EXPIRATION=1m \
-e EIGENDA_PROXY_EIGENDA_ETH_RPC=http://localhost:6969 \
-e EIGENDA_PROXY_EIGENDA_SERVICE_MANAGER_ADDR="0x0000000000000000000000000000000000000000" \
-e EIGENDA_PROXY_EIGENDA_CERT_VERIFICATION_DISABLED=true \
ghcr.io/layr-labs/eigenda-proxy:v1.6.0

# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
echo "==== Failed to start eigenda-proxy container ===="
exit 1
fi

echo "==== eigenda-proxy container started ===="

## TODO - support teardown or embed a docker client wrapper that spins up and tears down resource
# within system tests. Since this is only used by one system test, it's not a large priority atm.

0 comments on commit 238699d

Please sign in to comment.