Skip to content
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

feat: option to disable constraint signature verification #6

Merged
merged 3 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ type Builder struct {
relay IRelay
eth IEthereumService
dryRun bool
verifyConstraints bool
ignoreLatePayloadAttributes bool
validator *blockvalidation.BlockValidationAPI
beaconClient IBeaconClient
Expand Down Expand Up @@ -123,6 +124,7 @@ type BuilderArgs struct {
discardRevertibleTxOnErr bool
eth IEthereumService
dryRun bool
verifyConstraints bool
ignoreLatePayloadAttributes bool
validator *blockvalidation.BlockValidationAPI
beaconClient IBeaconClient
Expand Down Expand Up @@ -189,6 +191,7 @@ func NewBuilder(args BuilderArgs) (*Builder, error) {
relay: args.relay,
eth: args.eth,
dryRun: args.dryRun,
verifyConstraints: args.verifyConstraints,
ignoreLatePayloadAttributes: args.ignoreLatePayloadAttributes,
validator: args.validator,
beaconClient: args.beaconClient,
Expand Down Expand Up @@ -286,7 +289,7 @@ func (b *Builder) subscribeToRelayForConstraints(relayBaseEndpoint string) error

// Main loop to reconnect to the relay
for {
log.Info("Attempting to subscribe to constraints...", "relayBaseEndpoint", relayBaseEndpoint)
log.Info("Attempting to subscribe to constraints...", "relayBaseEndpoint", relayBaseEndpoint, "verifyConstertraints", b.verifyConstraints)

if attempts >= maxAttempts {
log.Error(fmt.Sprintf("Failed to subscribe to constraints after %d attempts", maxAttempts), "relayBaseEndpoint", relayBaseEndpoint)
Expand Down Expand Up @@ -376,10 +379,12 @@ func (b *Builder) subscribeToRelayForConstraints(relayBaseEndpoint string) error
continue
}

valid, err := constraint.VerifySignature(constraint.Message.Pubkey, b.GetConstraintsDomain())
if err != nil || !valid {
log.Error("Failed to verify constraint signature", "err", err)
continue
if b.verifyConstraints {
valid, err := constraint.VerifySignature(constraint.Message.Pubkey, b.GetConstraintsDomain())
if err != nil || !valid {
log.Error("Failed to verify constraint signature", "err", err)
continue
}
}

decodedConstraints, err := DecodeConstraints(constraint)
Expand Down
2 changes: 2 additions & 0 deletions builder/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type Config struct {
DiscardRevertibleTxOnErr bool `toml:",omitempty"`
EnableCancellations bool `toml:",omitempty"`
BlockProcessorURL string `toml:",omitempty"`
VerifyConstraints bool `toml:",omitempty"`
}

// DefaultConfig is the default config for the builder.
Expand Down Expand Up @@ -58,6 +59,7 @@ var DefaultConfig = Config{
BuilderRateLimitMaxBurst: RateLimitBurstDefault,
DiscardRevertibleTxOnErr: false,
EnableCancellations: false,
VerifyConstraints: true,
}

// RelayConfig is the config for a single remote relay.
Expand Down
7 changes: 7 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,12 @@ var (
Usage: "Enable the validator checks",
Category: flags.BuilderCategory,
}
BuilderVerifyConstraints = &cli.BoolFlag{
Name: "builder.verify_constraints",
Usage: "Verify signatures on incoming constraints",
Value: true,
Category: flags.BuilderCategory,
}
BuilderBlockValidationBlacklistSourceFilePath = &cli.StringFlag{
Name: "builder.blacklist",
Usage: "Path to file containing blacklisted addresses, json-encoded list of strings. " +
Expand Down Expand Up @@ -1610,6 +1616,7 @@ func SetBuilderConfig(ctx *cli.Context, cfg *builder.Config) {
cfg.SecondsInSlot = ctx.Uint64(BuilderSecondsInSlot.Name)
cfg.DisableBundleFetcher = ctx.IsSet(BuilderDisableBundleFetcher.Name)
cfg.DryRun = ctx.IsSet(BuilderDryRun.Name)
cfg.VerifyConstraints = ctx.Bool(BuilderVerifyConstraints.Name)
cfg.IgnoreLatePayloadAttributes = ctx.IsSet(BuilderIgnoreLatePayloadAttributes.Name)
cfg.BuilderSecretKey = ctx.String(BuilderSecretKey.Name)
cfg.RelaySecretKey = ctx.String(BuilderRelaySecretKey.Name)
Expand Down
Loading