Skip to content

Commit

Permalink
Merge pull request #6 from chainbound/jonas/feat/skip-sigverify
Browse files Browse the repository at this point in the history
feat: option to disable constraint signature verification
  • Loading branch information
mempirate authored Nov 9, 2024
2 parents 34b110f + d777789 commit 45fe6e9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
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

0 comments on commit 45fe6e9

Please sign in to comment.