From 34c6ea8f96c011b67a189d430536ed162dd3c8da Mon Sep 17 00:00:00 2001 From: Ethen Pociask Date: Mon, 20 May 2024 16:42:19 -0700 Subject: [PATCH] chore(op-plasma-eigenda): Remove dead and unecessary code - update docs --- README.md | 31 ++++++++++++++++--------------- cmd/daserver/flags.go | 15 +++++++++++---- server.go | 27 +++++---------------------- store/eigenda.go | 10 ++-------- verify/verifier.go | 4 ++-- 5 files changed, 36 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index b5cdf6b..a9cd5fd 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # EigenDA Plasma DA Server ## Introduction - This simple DA server implementation supports ephemeral storage via EigenDA. ## EigenDA Configuration @@ -11,22 +10,12 @@ Additional cli args are provided for targeting an EigenDA network backend: - `--eigenda-status-query-retry-interval`: (default: 5s) How often a client will attempt a retry when awaiting network blob finalization. - `--eigenda-use-tls`: (default: true) Whether or not to use TLS for grpc communication with disperser. - `eigenda-g1-path`: Directory path to g1.point file -- `eigenda-g2-path`: Directory path to g2.point file - `eigenda-g2-power-of-tau`: Directory path to g2.point.powerOf2 file - `eigenda-cache-path`: Directory path to dump cached SRS tables ## Running Locally 1. Compile binary: `make da-server` -2. Run binary; e.g: `./bin/da-server --addr 127.0.0.1 --port 5050 --eigenda-rpc 127.0.0.1:443 --eigenda-status-query-timeout 45m --eigenda-g1-path test/resources/g1.point --eigenda-g2-path test/resources/g2.point --eigenda-g2-tau-path test/resources/g2.point.powerOf2 --eigenda-use-tls true` - -## Breaking changes from existing OP-Stack - -### Server / Client -Unlike the keccak256 DA server implementation where commitments can be generated by the batcher via hashing, EigenDA commitments are represented as a constituent tuple `(blob_certificate, commitment)`. Certificates only derivable from the network **once** a blob has been successfully finalized (i.e, dispersed, confirmed, and submitted within a batch to Ethereum). The existing `op-plasma` schema in the monorepo of having a precomputed key was broken in the following ways: -* POST `/put` endpoint was modified to remove the `commitment` query param and return the generated `commitment` value in the response body -* Modified `DaClient` to use an alternative request/response flows with server for inserting and fetching preimages - -**NOTE:** Optimism has planned support for the aforementioned client-->server interaction scheme within plasma. These changes will eventually be rebased accordingly. +2. Run binary; e.g: `./bin/da-server --addr 127.0.0.1 --port 5050 --eigenda-rpc 127.0.0.1:443 --eigenda-status-query-timeout 45m --eigenda-g1-path test/resources/g1.point --eigenda-g2-tau-path test/resources/g2.point.powerOf2 --eigenda-use-tls true` ### Commitment Schemas An `EigenDACommitment` layer type has been added that supports verification against its respective pre-images. Otherwise this logic is pseudo-identical to the existing `Keccak256` commitment type. The commitment is encoded via the following byte array: @@ -38,7 +27,7 @@ An `EigenDACommitment` layer type has been added that supports verification agai ``` -The raw commitment for EigenDA is encoding the following certificate and kzg fields: +The `raw commitment` for EigenDA is encoding the following certificate and kzg fields: ```go type Cert struct { BatchHeaderHash []byte @@ -49,17 +38,29 @@ type Cert struct { } ``` +**NOTE:** Commitments are cryptographically verified against the data fetched from EigenDA for all `/get` calls. + ## Testing Some unit tests have been introduced to assert correctness of encoding/decoding logic and mocked server interactions. These can be ran via `make test`. Otherwise E2E tests (`test/e2e_test.go`) exists which asserts that a commitment can be generated when inserting some arbitrary data to the server and can be read using the commitment for a key lookup via the client. These can be ran via `make e2e-test`. Please **note** that this test uses the EigenDA Holesky network which is subject to rate-limiting and slow confirmation times *(i.e, >10 minutes per blob confirmation)*. Please advise EigenDA's [inabox](https://github.com/Layr-Labs/eigenda/tree/master/inabox#readme) if you'd like to spin-up a local DA network for quicker iteration testing. -## Downloading SRS -KZG commitment verification requires constructing the SRS string from the proper trusted setup values (g1, g2, g2.power_of_tau). These values can be downloaded locally using the [srs_setup](https://github.com/Layr-Labs/eigenda-operator-setup/blob/master/srs_setup.sh) script in the operator setup repo. +## Downloading Mainnet SRS +KZG commitment verification requires constructing the SRS string from the proper trusted setup values (g1, g2, g2.power_of_tau). These values can be downloaded locally using the [operator-setup](https://github.com/Layr-Labs/eigenda-operator-setup) submodule via the following commands. + +1. `make submodules` +2. `make srs` ## Resources - [op-stack](https://github.com/ethereum-optimism/optimism) - [plasma spec](https://specs.optimism.io/experimental/plasma.html) - [eigen da](https://github.com/Layr-Labs/eigenda) + + +## Hardware Requirements +The following specs are recommended for running on a single production server: +* 12 GB SSD (assuming SRS values are stored on instance) +* 16 GB RAM +* 1-2 cores CPU diff --git a/cmd/daserver/flags.go b/cmd/daserver/flags.go index efb0835..a44913d 100644 --- a/cmd/daserver/flags.go +++ b/cmd/daserver/flags.go @@ -7,6 +7,7 @@ import ( "github.com/Layr-Labs/op-plasma-eigenda/eigenda" opservice "github.com/ethereum-optimism/optimism/op-service" + oplog "github.com/ethereum-optimism/optimism/op-service/log" opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics" ) @@ -41,6 +42,15 @@ var requiredFlags = []cli.Flag{ PortFlag, } +var optionalFlags = []cli.Flag{} + +func init() { + optionalFlags = append(optionalFlags, oplog.CLIFlags(EnvVarPrefix)...) + optionalFlags = append(optionalFlags, eigenda.CLIFlags(EnvVarPrefix)...) + optionalFlags = append(optionalFlags, opmetrics.CLIFlags(EnvVarPrefix)...) + Flags = append(requiredFlags, optionalFlags...) +} + // Flags contains the list of configuration options available to the binary. var Flags []cli.Flag @@ -54,6 +64,7 @@ type CLIConfig struct { func ReadCLIConfig(ctx *cli.Context) CLIConfig { return CLIConfig{ EigenDAConfig: eigenda.ReadConfig(ctx), + MetricsCfg: opmetrics.ReadCLIConfig(ctx), } } @@ -66,10 +77,6 @@ func (c CLIConfig) Check() error { return nil } -func (c CLIConfig) EigenDAEnabled() bool { - return c.EigenDAConfig.RPC != "" -} - func CheckRequired(ctx *cli.Context) error { for _, f := range requiredFlags { if !ctx.IsSet(f.Names()[0]) { diff --git a/server.go b/server.go index c470066..aeb8620 100644 --- a/server.go +++ b/server.go @@ -25,9 +25,7 @@ type PlasmaStore interface { // Get retrieves the given key if it's present in the key-value data store. Get(ctx context.Context, key []byte) ([]byte, error) // Put inserts the given value into the key-value data store. - PutWithComm(ctx context.Context, key []byte, value []byte) error - // Put inserts the given value into the key-value data store. - PutWithoutComm(ctx context.Context, value []byte) (key []byte, err error) + Put(ctx context.Context, value []byte) (key []byte, err error) } type DAServer struct { @@ -170,25 +168,10 @@ func (d *DAServer) HandlePut(w http.ResponseWriter, r *http.Request) { } var comm []byte - if r.URL.Path == "/put" || r.URL.Path == "/put/" { // without commitment - if comm, err = d.store.PutWithoutComm(r.Context(), input); err != nil { - d.log.Error("Failed to store commitment to the DA server", "err", err, "comm", comm) - w.WriteHeader(http.StatusInternalServerError) - return - } - } else { // with commitment (might be worth deleting if we never expect a commitment to be passed in the URL for this server type) - key := path.Base(r.URL.Path) - comm, err = hexutil.Decode(key) - if err != nil { - w.WriteHeader(http.StatusBadRequest) - return - } - - if err := d.store.PutWithComm(r.Context(), comm, input); err != nil { - d.log.Error("Failed to store commitment to the DA server", "err", err, "key", key) - w.WriteHeader(http.StatusInternalServerError) - return - } + if comm, err = d.store.Put(r.Context(), input); err != nil { + d.log.Error("Failed to store commitment to the DA server", "err", err, "comm", comm) + w.WriteHeader(http.StatusInternalServerError) + return } // write out encoded commitment diff --git a/store/eigenda.go b/store/eigenda.go index 20c66d2..7c74094 100644 --- a/store/eigenda.go +++ b/store/eigenda.go @@ -41,14 +41,8 @@ func (e EigenDAStore) Get(ctx context.Context, key []byte) ([]byte, error) { return blob, nil } -// PutWithCommitment attempts to insert the given key and value into the key-value data store -// Since EigenDA only has a commitment after blob dispersal this method is unsupported -func (e EigenDAStore) PutWithComm(ctx context.Context, key []byte, value []byte) error { - return fmt.Errorf("EigenDA plasma store does not support PutWithComm()") -} - -// PutWithoutComm inserts the given value into the key-value data store and returns the corresponding commitment -func (e EigenDAStore) PutWithoutComm(ctx context.Context, value []byte) (comm []byte, err error) { +// Put inserts the given value into the key-value data store and returns the corresponding commitment. +func (e EigenDAStore) Put(ctx context.Context, value []byte) (comm []byte, err error) { cert, err := e.client.DisperseBlob(ctx, value) if err != nil { return nil, err diff --git a/verify/verifier.go b/verify/verifier.go index 2f53e71..2785928 100644 --- a/verify/verifier.go +++ b/verify/verifier.go @@ -18,7 +18,7 @@ type Verifier struct { func NewVerifier(cfg *kzg.KzgConfig) (*Verifier, error) { - prover, err := prover.NewProver(cfg, true) + prover, err := prover.NewProver(cfg, false) if err != nil { return nil, err } @@ -34,7 +34,7 @@ func NewVerifier(cfg *kzg.KzgConfig) (*Verifier, error) { // TODO: Optimize implementation by opening a point on the commitment instead func (v *Verifier) Verify(cert eigenda.Cert, blob []byte) error { encoder, err := v.prover.GetKzgEncoder( - encoding.ParamsFromSysPar(6, 69, uint64(len(blob))), + encoding.ParamsFromSysPar(3, 4, uint64(len(blob))), ) if err != nil { return err