Skip to content

Commit c484dd5

Browse files
committed
feat: mem store - change to proxy name
1 parent 7c05ece commit c484dd5

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

eigenda/config.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,40 +90,40 @@ func CLIFlags(envPrefix string) []cli.Flag {
9090
&cli.StringFlag{
9191
Name: RPCFlagName,
9292
Usage: "RPC endpoint of the EigenDA disperser.",
93-
EnvVars: prefixEnvVars("EIGENDA_RPC"),
93+
EnvVars: prefixEnvVars("TARGET_RPC"),
9494
},
9595
&cli.DurationFlag{
9696
Name: StatusQueryTimeoutFlagName,
9797
Usage: "Timeout for aborting an EigenDA blob dispersal if the disperser does not report that the blob has been confirmed dispersed.",
9898
Value: 25 * time.Minute,
99-
EnvVars: prefixEnvVars("EIGENDA_STATUS_QUERY_TIMEOUT"),
99+
EnvVars: prefixEnvVars("TARGET_STATUS_QUERY_TIMEOUT"),
100100
},
101101
&cli.DurationFlag{
102102
Name: StatusQueryRetryIntervalFlagName,
103103
Usage: "Wait time between retries of EigenDA blob status queries (made while waiting for a blob to be confirmed by).",
104104
Value: 5 * time.Second,
105-
EnvVars: prefixEnvVars("EIGENDA_STATUS_QUERY_INTERVAL"),
105+
EnvVars: prefixEnvVars("TARGET_STATUS_QUERY_INTERVAL"),
106106
},
107107
&cli.BoolFlag{
108108
Name: UseTlsFlagName,
109109
Usage: "Use TLS when connecting to the EigenDA disperser.",
110110
Value: true,
111-
EnvVars: prefixEnvVars("EIGENDA_GRPC_USE_TLS"),
111+
EnvVars: prefixEnvVars("TARGET_GRPC_USE_TLS"),
112112
},
113113
&cli.StringFlag{
114114
Name: G1PathFlagName,
115115
Usage: "Directory path to g1.point file",
116-
EnvVars: prefixEnvVars("EIGENDA_KZG_G1_PATH"),
116+
EnvVars: prefixEnvVars("TARGET_KZG_G1_PATH"),
117117
},
118118
&cli.StringFlag{
119119
Name: G2TauFlagName,
120120
Usage: "Directory path to g2.point.powerOf2 file",
121-
EnvVars: prefixEnvVars("EIGENDA_G2_TAU_PATH"),
121+
EnvVars: prefixEnvVars("TARGET_G2_TAU_PATH"),
122122
},
123123
&cli.StringFlag{
124124
Name: CachePathFlagName,
125125
Usage: "Directory path to SRS tables",
126-
EnvVars: prefixEnvVars("EIGENDA_CACHE_PATH"),
126+
EnvVars: prefixEnvVars("TARGET_CACHE_PATH"),
127127
},
128128
}
129129
}

store/memory.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package store
22

33
import (
44
"context"
5+
"crypto/rand"
56
"fmt"
67
"sync"
78
"time"
@@ -81,7 +82,7 @@ func (e *MemStore) Get(ctx context.Context, commit []byte) ([]byte, error) {
8182
e.RLock()
8283
defer e.RUnlock()
8384

84-
key := "0x" + common.Bytes2Hex(commit)
85+
key := common.Bytes2Hex(commit)
8586
if _, exists := e.store[key]; !exists {
8687
return nil, fmt.Errorf("commitment key not found")
8788
}
@@ -94,17 +95,24 @@ func (e *MemStore) Put(ctx context.Context, value []byte) ([]byte, error) {
9495
e.Lock()
9596
defer e.Unlock()
9697

97-
commit := crypto.Keccak256Hash(value)
98+
fingerprint := crypto.Keccak256Hash(value)
99+
// add some entropy to commit to emulate randomness seen in EigenDA
100+
// when generating operator BLS signature certificates
101+
entropy := make([]byte, 10)
102+
rand.Read(entropy)
98103

99-
if _, exists := e.store[commit.Hex()]; exists {
104+
rawCommit := append(fingerprint.Bytes(), entropy...)
105+
commit := common.Bytes2Hex(rawCommit)
106+
107+
if _, exists := e.store[commit]; exists {
100108
return nil, fmt.Errorf("commitment key already exists")
101109
}
102110

103-
e.store[commit.Hex()] = value
111+
e.store[commit] = value
104112
// add expiration
105-
e.keyStarts[commit.Hex()] = time.Now()
113+
e.keyStarts[commit] = time.Now()
106114

107-
return commit.Bytes(), nil
115+
return rawCommit, nil
108116
}
109117

110118
func ReadConfig(ctx *cli.Context) MemStoreConfig {

0 commit comments

Comments
 (0)