generated from flashbots/flashbots-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 269
Add timing games feature for bid optimization #839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
faheelsattar
wants to merge
8
commits into
flashbots:develop
Choose a base branch
from
faheelsattar:feat/timing-games
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+911
β236
Open
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0de9893
enable timing games
faheelsattar 0cf0bf6
fix lint
faheelsattar 89bc53e
add example
faheelsattar 551974a
remove quotations
faheelsattar ebd6330
upd config value
faheelsattar 05fccad
upd config
faheelsattar 4f7136e
add tests
faheelsattar 28af7d9
add id to relay config
faheelsattar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package cli | ||
|
||
import ( | ||
"os" | ||
"strings" | ||
|
||
"github.com/flashbots/mev-boost/server/types" | ||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
type RelayConfigYAML struct { | ||
URL string `yaml:"url"` | ||
EnableTimingGames bool `yaml:"enable_timing_games"` | ||
TargetFirstRequestMs uint64 `yaml:"target_first_request_ms"` | ||
FrequencyGetHeaderMs uint64 `yaml:"frequency_getheader_ms"` | ||
} | ||
|
||
// LoadRelayConfigFile loads relay configurations from a YAML file | ||
func LoadRelayConfigFile(configPath string) (map[string]types.RelayConfig, error) { | ||
data, err := os.ReadFile(configPath) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var relays []RelayConfigYAML | ||
if err := yaml.Unmarshal(data, &relays); err != nil { | ||
return nil, err | ||
} | ||
|
||
configMap := make(map[string]types.RelayConfig) | ||
for _, relay := range relays { | ||
relayEntry, err := types.NewRelayEntry(strings.TrimSpace(relay.URL)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
relayConfig := types.RelayConfig{ | ||
RelayEntry: relayEntry, | ||
EnableTimingGames: relay.EnableTimingGames, | ||
TargetFirstRequestMs: relay.TargetFirstRequestMs, | ||
FrequencyGetHeaderMs: relay.FrequencyGetHeaderMs, | ||
} | ||
configMap[relayEntry.String()] = relayConfig | ||
} | ||
|
||
return configMap, nil | ||
} | ||
|
||
// MergeRelayConfigs merges relays passed via --relays to config file settings. | ||
// this allows the users to still use --relays if they dont want to provide a config file | ||
func MergeRelayConfigs(relays []types.RelayEntry, configMap map[string]types.RelayConfig) []types.RelayConfig { | ||
configs := make([]types.RelayConfig, 0, len(relays)) | ||
|
||
for _, entry := range relays { | ||
if config, exists := configMap[entry.String()]; exists { | ||
config.RelayEntry = entry | ||
configs = append(configs, config) | ||
} else { | ||
configs = append(configs, types.NewRelayConfig(entry)) | ||
} | ||
} | ||
|
||
return configs | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Example relay configuration with timing games for mev-boost | ||
relays: | ||
# relay with timing games enabled | ||
- url: "https://0x9000009807ed12c1f08bf4e81c6da3ba8e3fc3d953898ce0102433094e5f22f21102ec057841fcb81978ed1ea0fa8246@relay.relayer1.net" | ||
jtraglia marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
enable_timing_games: true | ||
# time in ms from slot start for the first getHeader request | ||
target_first_request_ms: 500 | ||
# time in ms between subsequent getHeader requests | ||
frequency_getheader_ms: 100 | ||
|
||
# relay with timing games disabled (standard behavior) | ||
- url: "https://0x9000009807ed12c1f08bf4e81c6da3ba8e3fc3d953898ce0102433094e5f22f21102ec057841fcb81978ed1ea0fa8246@relay.relayer2.com" | ||
enable_timing_games: false | ||
target_first_request_ms: 0 | ||
frequency_getheader_ms: 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.