Skip to content

Commit ecaaa52

Browse files
authored
Merge pull request #81 from ethpandaops/feat/full-exp-cfg
feat: experiment cfg
2 parents bc03a0e + 205ef04 commit ecaaa52

56 files changed

Lines changed: 3800 additions & 8752 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

backend/pkg/api/v1/proto/public.pb.go

Lines changed: 336 additions & 901 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/pkg/api/v1/proto/public.proto

Lines changed: 7 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
syntax = "proto3";
22
package api.v1;
33

4+
import "google/protobuf/struct.proto";
5+
46
option go_package = "github.com/ethpandaops/lab/backend/pkg/api/v1/proto";
57

68
// This file defines the public REST API layer for all Lab data.
@@ -110,8 +112,7 @@ message GetConfigResponse {
110112
// FrontendConfig represents the complete frontend configuration for public API consumption.
111113
message FrontendConfig {
112114
EthereumConfig ethereum = 1;
113-
ModulesConfig modules = 2;
114-
ExperimentsConfig experiments = 3;
115+
repeated ExperimentConfig experiments = 2;
115116
}
116117

117118
// EthereumConfig contains Ethereum-related configuration for public API consumption.
@@ -126,9 +127,8 @@ message NetworkConfig {
126127
int64 chain_id = 3 [json_name = "chainId"];
127128
string description = 4;
128129
int64 genesis_time = 5 [json_name = "genesisTime"];
129-
map<string, string> service_urls = 6 [json_name = "serviceUrls"];
130-
ForkConfig forks = 7;
131-
string last_updated = 8 [json_name = "lastUpdated"];
130+
ForkConfig forks = 6;
131+
string last_updated = 7 [json_name = "lastUpdated"];
132132
}
133133

134134
// ForkConfig contains fork information for public API consumption.
@@ -147,49 +147,6 @@ message ForkInfo {
147147
map<string, string> min_client_versions = 2 [json_name = "minClientVersions"];
148148
}
149149

150-
// ModulesConfig contains all module configurations for public API consumption.
151-
message ModulesConfig {
152-
BeaconChainTimingsModule beacon_chain_timings = 1 [json_name = "beaconChainTimings"];
153-
XatuPublicContributorsModule xatu_public_contributors = 2 [json_name = "xatuPublicContributors"];
154-
BeaconModule beacon = 3;
155-
}
156-
157-
// BeaconChainTimingsModule configuration for public API consumption.
158-
message BeaconChainTimingsModule {
159-
repeated string networks = 1;
160-
repeated TimeWindow time_windows = 2 [json_name = "timeWindows"];
161-
string path_prefix = 3 [json_name = "pathPrefix"];
162-
}
163-
164-
// XatuPublicContributorsModule configuration for public API consumption.
165-
message XatuPublicContributorsModule {
166-
repeated string networks = 1;
167-
repeated TimeWindow time_windows = 2 [json_name = "timeWindows"];
168-
string path_prefix = 3 [json_name = "pathPrefix"];
169-
bool enabled = 4;
170-
}
171-
172-
// BeaconModule configuration for public API consumption.
173-
message BeaconModule {
174-
bool enabled = 1;
175-
string description = 2;
176-
string path_prefix = 3 [json_name = "pathPrefix"];
177-
map<string, BeaconNetworkConfig> networks = 4;
178-
}
179-
180-
// BeaconNetworkConfig contains beacon-specific network configuration for public API consumption.
181-
message BeaconNetworkConfig {
182-
int32 head_lag_slots = 1 [json_name = "headLagSlots"];
183-
int32 backlog_days = 2 [json_name = "backlogDays"];
184-
}
185-
186-
// TimeWindow represents a time window configuration for public API consumption.
187-
message TimeWindow {
188-
string file = 1;
189-
string step = 2;
190-
string range = 3;
191-
string label = 4;
192-
}
193150

194151
// ExperimentsConfig contains all experiments configuration for public API consumption.
195152
message ExperimentsConfig {
@@ -201,7 +158,8 @@ message ExperimentConfig {
201158
string id = 1;
202159
bool enabled = 2;
203160
repeated string networks = 3;
204-
map<string, ExperimentDataAvailability> data_availability = 4 [json_name = "dataAvailability"];
161+
google.protobuf.Struct config = 4;
162+
map<string, ExperimentDataAvailability> data_availability = 5 [json_name = "dataAvailability"];
205163
}
206164

207165
// ExperimentDataAvailability contains data availability information for an experiment on a specific network.

backend/pkg/api/v1/rest/handler.go

Lines changed: 25 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,6 @@ func convertConfigToAPIProto(config *configpb.FrontendConfig) *apiv1.FrontendCon
252252
LastUpdated: network.LastUpdated,
253253
}
254254

255-
// Add service URLs if present
256-
if len(network.ServiceUrls) > 0 {
257-
networkConfig.ServiceUrls = network.ServiceUrls
258-
}
259-
260255
// Add forks if present
261256
if network.Forks != nil && network.Forks.Consensus != nil && network.Forks.Consensus.Electra != nil {
262257
networkConfig.Forks = &apiv1.ForkConfig{
@@ -275,78 +270,41 @@ func convertConfigToAPIProto(config *configpb.FrontendConfig) *apiv1.FrontendCon
275270
result.Ethereum = ethereum
276271
}
277272

278-
// Convert Modules config
279-
if config.Modules != nil {
280-
modules := &apiv1.ModulesConfig{}
281-
282-
// Beacon Chain Timings module
283-
if config.Modules.BeaconChainTimings != nil {
284-
bct := &apiv1.BeaconChainTimingsModule{
285-
Networks: config.Modules.BeaconChainTimings.Networks,
286-
PathPrefix: config.Modules.BeaconChainTimings.PathPrefix,
287-
}
288-
289-
if config.Modules.BeaconChainTimings.TimeWindows != nil {
290-
timeWindows := make([]*apiv1.TimeWindow, 0, len(config.Modules.BeaconChainTimings.TimeWindows))
291-
for _, tw := range config.Modules.BeaconChainTimings.TimeWindows {
292-
timeWindows = append(timeWindows, &apiv1.TimeWindow{
293-
File: tw.File,
294-
Step: tw.Step,
295-
Range: tw.Range,
296-
Label: tw.Label,
297-
})
298-
}
299-
300-
bct.TimeWindows = timeWindows
273+
// Convert Experiments config
274+
if config.Experiments != nil {
275+
expConfigs := make([]*apiv1.ExperimentConfig, 0, len(config.Experiments))
276+
for _, exp := range config.Experiments {
277+
expConfig := &apiv1.ExperimentConfig{
278+
Id: exp.Id,
279+
Enabled: exp.Enabled,
280+
Networks: exp.Networks,
301281
}
302282

303-
modules.BeaconChainTimings = bct
304-
}
305-
306-
// Beacon module
307-
if config.Modules.Beacon != nil {
308-
beacon := &apiv1.BeaconModule{
309-
Enabled: config.Modules.Beacon.Enabled,
310-
Description: config.Modules.Beacon.Description,
311-
PathPrefix: config.Modules.Beacon.PathPrefix,
283+
// Include config if present
284+
if exp.Config != nil {
285+
expConfig.Config = exp.Config
312286
}
313287

314-
if len(config.Modules.Beacon.Networks) > 0 {
315-
beaconNetworks := make(map[string]*apiv1.BeaconNetworkConfig)
316-
for name, netCfg := range config.Modules.Beacon.Networks {
317-
beaconNetworks[name] = &apiv1.BeaconNetworkConfig{
318-
HeadLagSlots: netCfg.HeadLagSlots,
319-
BacklogDays: netCfg.BacklogDays,
288+
// Include data availability if present
289+
if exp.DataAvailability != nil {
290+
expConfig.DataAvailability = make(map[string]*apiv1.ExperimentDataAvailability)
291+
for network, da := range exp.DataAvailability {
292+
expConfig.DataAvailability[network] = &apiv1.ExperimentDataAvailability{
293+
AvailableFromTimestamp: da.AvailableFromTimestamp,
294+
AvailableUntilTimestamp: da.AvailableUntilTimestamp,
295+
MinSlot: da.MinSlot,
296+
MaxSlot: da.MaxSlot,
297+
SafeSlot: da.SafeSlot,
298+
HeadSlot: da.HeadSlot,
299+
HasData: da.HasData,
320300
}
321301
}
322-
323-
beacon.Networks = beaconNetworks
324-
}
325-
326-
modules.Beacon = beacon
327-
}
328-
329-
result.Modules = modules
330-
}
331-
332-
// Convert Experiments config
333-
if config.Experiments != nil {
334-
experiments := &apiv1.ExperimentsConfig{}
335-
336-
if config.Experiments.Experiments != nil {
337-
expConfigs := make([]*apiv1.ExperimentConfig, 0, len(config.Experiments.Experiments))
338-
for _, exp := range config.Experiments.Experiments {
339-
expConfigs = append(expConfigs, &apiv1.ExperimentConfig{
340-
Id: exp.Id,
341-
Enabled: exp.Enabled,
342-
Networks: exp.Networks,
343-
})
344302
}
345303

346-
experiments.Experiments = expConfigs
304+
expConfigs = append(expConfigs, expConfig)
347305
}
348306

349-
result.Experiments = experiments
307+
result.Experiments = expConfigs
350308
}
351309

352310
return result

backend/pkg/server/config.go

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,23 @@ import (
77
"github.com/ethpandaops/lab/backend/pkg/internal/lab/geolocation"
88
"github.com/ethpandaops/lab/backend/pkg/internal/lab/storage"
99
"github.com/ethpandaops/lab/backend/pkg/server/internal/grpc"
10-
"github.com/ethpandaops/lab/backend/pkg/server/internal/service/beacon_chain_timings"
11-
"github.com/ethpandaops/lab/backend/pkg/server/internal/service/beacon_slots"
1210
"github.com/ethpandaops/lab/backend/pkg/server/internal/service/cartographoor"
1311
"github.com/ethpandaops/lab/backend/pkg/server/internal/service/experiments"
1412
"github.com/ethpandaops/lab/backend/pkg/server/internal/service/xatu_cbt"
1513
)
1614

1715
type Config struct {
18-
LogLevel string `yaml:"logLevel" default:"info"`
19-
Server *grpc.Config `yaml:"grpc"`
20-
Storage *storage.Config `yaml:"storage"`
21-
Modules map[string]*ModuleConfig `yaml:"modules"`
22-
Cache *cache.Config `yaml:"cache"`
23-
Geolocation *geolocation.Config `yaml:"geolocation"`
24-
XatuCBT *xatu_cbt.Config `yaml:"xatu_cbt"`
25-
Cartographoor *cartographoor.Config `yaml:"cartographoor"`
26-
Experiments *experiments.Config `yaml:"experiments"`
27-
}
28-
29-
type ModuleConfig struct {
30-
BeaconChainTimings *beacon_chain_timings.Config `yaml:"beacon_chain_timings"`
31-
BeaconSlots *beacon_slots.Config `yaml:"beacon_slots"`
16+
LogLevel string `yaml:"logLevel" default:"info"`
17+
Server *grpc.Config `yaml:"grpc"`
18+
Storage *storage.Config `yaml:"storage"`
19+
Cache *cache.Config `yaml:"cache"`
20+
Geolocation *geolocation.Config `yaml:"geolocation"`
21+
XatuCBT *xatu_cbt.Config `yaml:"xatu_cbt"`
22+
Cartographoor *cartographoor.Config `yaml:"cartographoor"`
23+
Experiments *experiments.Config `yaml:"experiments"`
3224
}
3325

3426
func (x *Config) Validate() error {
35-
if x.Modules == nil {
36-
return fmt.Errorf("modules config is required")
37-
}
38-
3927
if x.Geolocation == nil {
4028
return fmt.Errorf("geolocation config is required")
4129
}

backend/pkg/server/internal/grpc/beacon_chain_timings.go

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)