Skip to content

Commit

Permalink
feat: Data domain filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
epociask committed May 25, 2024
1 parent 834f866 commit f459eb5
Show file tree
Hide file tree
Showing 7 changed files with 291 additions and 202 deletions.
2 changes: 1 addition & 1 deletion cmd/daserver/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/urfave/cli/v2"

proxy "github.com/Layr-Labs/op-plasma-eigenda"
proxy "github.com/Layr-Labs/op-plasma-eigenda/server"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
"github.com/ethereum-optimism/optimism/op-service/opio"
)
Expand Down
29 changes: 29 additions & 0 deletions common/common.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
package common

import "fmt"

var (
ErrInvalidDomainType = fmt.Errorf("invalid domain type")
)

// DomainType is a enumeration type for the different data domains for which a
// blob can exist between
type DomainType uint8

const (
BinaryDomain DomainType = iota
PolyDomain
UnknownDomain
)

func StrToDomainType(s string) DomainType {
switch s {
case "binary":
return BinaryDomain
case "polynomial":
return PolyDomain
default:
return UnknownDomain
}
}

// Helper utility functions //

func EqualSlices[P comparable](s1, s2 []P) bool {
if len(s1) != len(s2) {
return false
Expand Down
6 changes: 6 additions & 0 deletions eigenda/commitment.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"

op_plasma "github.com/ethereum-optimism/optimism/op-plasma"
"github.com/ethereum/go-ethereum/common/hexutil"
)

// ErrCommitmentLength is returned when the commitment length is invalid.
Expand Down Expand Up @@ -35,6 +36,11 @@ func (c Commitment) Encode() []byte {
return append([]byte{byte(EigenDA), byte(EigenV0)}, c...)
}

func StringToCommit(key string) (Commitment, error) {
comm, _ := hexutil.Decode(key)
return DecodeCommitment(comm)
}

// DecodeCommitment verifies and decodes an EigenDACommit from raw encoded bytes.
func DecodeCommitment(commitment []byte) (Commitment, error) {
if len(commitment) <= 3 {
Expand Down
197 changes: 0 additions & 197 deletions server.go

This file was deleted.

28 changes: 28 additions & 0 deletions server/params.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package proxy

import (
"net/http"

"github.com/Layr-Labs/op-plasma-eigenda/common"
)

const (
GetRoute = "/get"
PutRoute = "/put"

DomainFilterKey = "domain"
)

func ReadDomainFilter(r *http.Request) (common.DomainType, error) {
query := r.URL.Query()
key := query.Get(DomainFilterKey)
if key == "" { // default
return common.BinaryDomain, nil
}
dt := common.StrToDomainType(key)
if dt == common.UnknownDomain {
return common.UnknownDomain, common.ErrInvalidDomainType
}

return dt, nil
}
Loading

0 comments on commit f459eb5

Please sign in to comment.