|
8 | 8 | "path" |
9 | 9 | "path/filepath" |
10 | 10 | "strings" |
| 11 | + "time" |
11 | 12 |
|
12 | 13 | "github.com/base/base-bench/runner/payload" |
13 | 14 | ) |
@@ -87,13 +88,40 @@ func (s SnapshotDefinition) CreateSnapshot(nodeType string, outputDir string) er |
87 | 88 | return cmd.Run() |
88 | 89 | } |
89 | 90 |
|
| 91 | +// FlashblocksConfig holds top-level flashblocks configuration. |
| 92 | +type FlashblocksConfig struct { |
| 93 | + BlockTime string `yaml:"block_time"` |
| 94 | +} |
| 95 | + |
| 96 | +const DefaultFlashblocksBlockTime = "250ms" |
| 97 | +const DefaultBlockTime = "1s" |
| 98 | + |
90 | 99 | type BenchmarkConfig struct { |
91 | 100 | Name string `yaml:"name"` |
92 | 101 | Description *string `yaml:"description"` |
| 102 | + BlockTime *string `yaml:"block_time"` |
| 103 | + Flashblocks *FlashblocksConfig `yaml:"flashblocks"` |
93 | 104 | Benchmarks []TestDefinition `yaml:"benchmarks"` |
94 | 105 | TransactionPayloads []payload.Definition `yaml:"payloads"` |
95 | 106 | } |
96 | 107 |
|
| 108 | +// GetBlockTime returns the configured block time as a duration, or the default (1s). |
| 109 | +func (bc *BenchmarkConfig) GetBlockTime() (time.Duration, error) { |
| 110 | + raw := DefaultBlockTime |
| 111 | + if bc.BlockTime != nil && *bc.BlockTime != "" { |
| 112 | + raw = *bc.BlockTime |
| 113 | + } |
| 114 | + return time.ParseDuration(raw) |
| 115 | +} |
| 116 | + |
| 117 | +// FlashblocksBlockTime returns the configured flashblocks block time, or the default. |
| 118 | +func (bc *BenchmarkConfig) FlashblocksBlockTime() string { |
| 119 | + if bc.Flashblocks != nil && bc.Flashblocks.BlockTime != "" { |
| 120 | + return bc.Flashblocks.BlockTime |
| 121 | + } |
| 122 | + return DefaultFlashblocksBlockTime |
| 123 | +} |
| 124 | + |
97 | 125 | type DatadirConfig struct { |
98 | 126 | Sequencer *string `yaml:"sequencer"` |
99 | 127 | Validator *string `yaml:"validator"` |
|
0 commit comments