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: Initial V2 E2E Prototype #260

Open
wants to merge 16 commits into
base: eigenda_v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "debug",
"env": {
"ENV_PATH": "../../.env",
"EIGENDA_PROXY_EIGENDA_CERT_VERIFICATION_DISABLED": "true",
"EIGENDA_PROXY_EIGENDA_TARGET_KZG_G1_PATH": "../../resources/g1.point",
"EIGENDA_PROXY_EIGENDA_TARGET_KZG_G2_POWER_OF_2_PATH": "../../resources/g2.point.powerOf2"
},
"program": "cmd/server"
}
]
}
11 changes: 5 additions & 6 deletions cmd/server/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
proxy_logging "github.com/Layr-Labs/eigenda-proxy/logging"
"github.com/Layr-Labs/eigensdk-go/logging"

"github.com/Layr-Labs/eigenda-proxy/flags"
"github.com/Layr-Labs/eigenda-proxy/metrics"
"github.com/Layr-Labs/eigenda-proxy/server"
"github.com/urfave/cli/v2"
Expand Down Expand Up @@ -47,7 +46,7 @@ func StartProxySvr(cliCtx *cli.Context) error {
if err != nil {
return fmt.Errorf("failed to create store: %w", err)
}
server := server.NewServer(cliCtx.String(flags.ListenAddrFlagName), cliCtx.Int(flags.PortFlagName), sm, log, m)
server := server.NewServer(&cfg.EigenDAConfig, sm, log, m)

if err := server.Start(); err != nil {
return fmt.Errorf("failed to start the DA server: %w", err)
Expand Down Expand Up @@ -85,11 +84,11 @@ func StartProxySvr(cliCtx *cli.Context) error {
func prettyPrintConfig(cliCtx *cli.Context, log logging.Logger) error {
// we read a new config which we modify to hide private info in order to log the rest
cfg := server.ReadCLIConfig(cliCtx)
if cfg.EigenDAConfig.EdaClientConfig.SignerPrivateKeyHex != "" {
cfg.EigenDAConfig.EdaClientConfig.SignerPrivateKeyHex = "*****" // marshaling defined in client config
if cfg.EigenDAConfig.EdaV1ClientConfig.SignerPrivateKeyHex != "" {
cfg.EigenDAConfig.EdaV1ClientConfig.SignerPrivateKeyHex = "*****" // marshaling defined in client config
}
if cfg.EigenDAConfig.EdaClientConfig.EthRpcUrl != "" {
cfg.EigenDAConfig.EdaClientConfig.EthRpcUrl = "*****" // hiding as RPC providers typically use sensitive API keys within
if cfg.EigenDAConfig.EdaV1ClientConfig.EthRpcUrl != "" {
cfg.EigenDAConfig.EdaV1ClientConfig.EthRpcUrl = "*****" // hiding as RPC providers typically use sensitive API keys within
}

configJSON, err := json.MarshalIndent(cfg, "", " ")
Expand Down
38 changes: 19 additions & 19 deletions commitments/eigenda.go
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
package commitments

type CertEncodingCommitment byte
type EigenDACommit byte

const (
CertV0 CertEncodingCommitment = 0
// EigenDA V1
CertV0 EigenDACommit = iota
CertV1
)

// OPCommitment is the binary representation of a commitment.
// CertCommitment is the binary representation of a commitment.
type CertCommitment interface {
CommitmentType() CertEncodingCommitment
CommitmentType() EigenDACommit
Encode() []byte
Verify(input []byte) error
}

type CertCommitmentV0 []byte

// NewV0CertCommitment creates a new commitment from the given input.
func NewV0CertCommitment(input []byte) CertCommitmentV0 {
return CertCommitmentV0(input)
type EigenDACommitment struct {
prefix EigenDACommit
b []byte
}

// DecodeCertCommitment validates and casts the commitment into a Keccak256Commitment.
func DecodeCertCommitment(commitment []byte) (CertCommitmentV0, error) {
if len(commitment) == 0 {
return nil, ErrInvalidCommitment
// NewV0CertCommitment creates a new commitment from the given input.
func NewCertCommitment(input []byte, v EigenDACommit) EigenDACommitment {
return EigenDACommitment{
prefix: v,
b: input,
}
return commitment, nil
}

// CommitmentType returns the commitment type of Keccak256.
func (c CertCommitmentV0) CommitmentType() CertEncodingCommitment {
return CertV0
// CommitmentType returns the commitment type of EigenDACommitment.
func (c EigenDACommitment) CommitmentType() EigenDACommit {
return c.prefix
}

// Encode adds a commitment type prefix self describing the commitment.
func (c CertCommitmentV0) Encode() []byte {
return append([]byte{byte(CertV0)}, c...)
func (c EigenDACommitment) Encode() []byte {
return append([]byte{byte(c.prefix)}, c.b...)
}
14 changes: 7 additions & 7 deletions commitments/mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

type CommitmentMeta struct {
Mode CommitmentMode
// CertVersion is shared for all modes and denotes version of the EigenDA certificate
CertVersion uint8
// version is shared for all modes and denotes version of the EigenDA certificate
Version EigenDACommit
}

type CommitmentMode string
Expand All @@ -31,19 +31,19 @@ func StringToCommitmentMode(s string) (CommitmentMode, error) {
}
}

func EncodeCommitment(b []byte, c CommitmentMode) ([]byte, error) {
switch c {
func EncodeCommitment(b []byte, cm CommitmentMode, daVersion EigenDACommit) ([]byte, error) {
switch cm {
case OptimismKeccak:
return Keccak256Commitment(b).Encode(), nil

case OptimismGeneric:
certCommit := NewV0CertCommitment(b).Encode()
certCommit := NewCertCommitment(b, daVersion).Encode()
svcCommit := EigenDASvcCommitment(certCommit).Encode()
altDACommit := NewGenericCommitment(svcCommit).Encode()
return altDACommit, nil

case Standard:
return NewV0CertCommitment(b).Encode(), nil
case Standard: // (i.e, Arbitrum)
return NewCertCommitment(b, daVersion).Encode(), nil
}

return nil, fmt.Errorf("unknown commitment mode")
Expand Down
5 changes: 5 additions & 0 deletions common/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type BackendType uint8

const (
EigenDABackendType BackendType = iota
EigenDAV2BackendType
MemoryBackendType
S3BackendType
RedisBackendType
Expand All @@ -26,6 +27,8 @@ func (b BackendType) String() string {
switch b {
case EigenDABackendType:
return "EigenDA"
case EigenDAV2BackendType:
return "EigenDAV2"
case MemoryBackendType:
return "Memory"
case S3BackendType:
Expand All @@ -45,6 +48,8 @@ func StringToBackendType(s string) BackendType {
switch lower {
case "eigenda":
return EigenDABackendType
case "eigenda_v2":
return EigenDAV2BackendType
case "memory":
return MemoryBackendType
case "s3":
Expand Down
4 changes: 2 additions & 2 deletions e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
"github.com/stretchr/testify/require"
)

// Integration tests are run against memstore whereas.
// Testnetintegration tests are run against eigenda backend talking to testnet disperser.
// Integration tests are run against memstore whereas
// testnet integration tests are run against eigenda backend talking to testnet disperser.
// Some of the assertions in the tests are different based on the backend as well.
// e.g, in TestProxyServerCaching we only assert to read metrics with EigenDA
// when referencing memstore since we don't profile the eigenDAClient interactions
Expand Down
22 changes: 11 additions & 11 deletions e2e/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/Layr-Labs/eigenda-proxy/store/generated_key/memstore"
"github.com/Layr-Labs/eigenda-proxy/store/precomputed_key/redis"
"github.com/Layr-Labs/eigenda-proxy/store/precomputed_key/s3"
"github.com/Layr-Labs/eigenda-proxy/verify"
"github.com/Layr-Labs/eigenda-proxy/verify/v1"
"github.com/Layr-Labs/eigenda/api/clients"
"github.com/Layr-Labs/eigenda/encoding/kzg"
"github.com/Layr-Labs/eigensdk-go/logging"
Expand All @@ -29,12 +29,12 @@ import (
)

const (
privateKey = "SIGNER_PRIVATE_KEY"
ethRPC = "ETHEREUM_RPC"
transport = "http"
svcName = "eigenda_proxy"
host = "127.0.0.1"
holeskyDA = "disperser-holesky.eigenda.xyz:443"
privateKey = "SIGNER_PRIVATE_KEY"
ethRPC = "ETHEREUM_RPC"
transport = "http"
svcName = "eigenda_proxy"
host = "127.0.0.1"
v1DisperserHolesky = "disperser-holesky.eigenda.xyz:443"
)

var (
Expand Down Expand Up @@ -183,8 +183,8 @@ func TestSuiteConfig(testCfg *Cfg) server.CLIConfig {

svcManagerAddr := "0xD4A7E1Bd8015057293f0D0A557088c286942e84b" // holesky testnet
eigendaCfg := server.Config{
EdaClientConfig: clients.EigenDAClientConfig{
RPC: holeskyDA,
EdaV1ClientConfig: clients.EigenDAClientConfig{
RPC: v1DisperserHolesky,
StatusQueryTimeout: time.Minute * 45,
StatusQueryRetryInterval: pollInterval,
DisableTLS: false,
Expand Down Expand Up @@ -218,7 +218,7 @@ func TestSuiteConfig(testCfg *Cfg) server.CLIConfig {
}

if testCfg.UseMemory {
eigendaCfg.EdaClientConfig.SignerPrivateKeyHex = "0000000000000000000100000000000000000000000000000000000000000000"
eigendaCfg.EdaV1ClientConfig.SignerPrivateKeyHex = "0000000000000000000100000000000000000000000000000000000000000000"
}

var cfg server.CLIConfig
Expand Down Expand Up @@ -271,7 +271,7 @@ func CreateTestSuite(testSuiteCfg server.CLIConfig) (TestSuite, func()) {
panic(err)
}

proxySvr := server.NewServer(host, 0, sm, log, m)
proxySvr := server.NewServer(&testSuiteCfg.EigenDAConfig, sm, log, m)

log.Info("Starting proxy server...")
err = proxySvr.Start()
Expand Down
Loading
Loading