Skip to content

Commit

Permalink
enforce only sending specific bundles to replacement-supporting builders
Browse files Browse the repository at this point in the history
  • Loading branch information
TymKh committed May 14, 2024
1 parent c94ec26 commit efd7bfe
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions mevshare/builders.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type BuildersConfig struct {
} `yaml:"builders"`
OrderflowHeader bool `yaml:"orderflowHeader,omitempty"`
OrderflowHeaderValue string `yaml:"orderflowHeaderValue,omitempty"`
RestrictedAddress string `yaml:"restrictedAddress"`
}

// LoadBuilderConfig parses a builder config from a file
Expand Down Expand Up @@ -124,8 +125,9 @@ func LoadBuilderConfig(file string) (BuildersBackend, error) {
}

return BuildersBackend{
externalBuilders: externalBuilderMap,
internalBuilders: internalBuilders,
externalBuilders: externalBuilderMap,
internalBuilders: internalBuilders,
RestrictedAddress: config.RestrictedAddress,
}, nil
}

Expand Down Expand Up @@ -190,8 +192,9 @@ func (b *JSONRPCBuilderBackend) CancelBundleByHash(ctx context.Context, hash com
}

type BuildersBackend struct {
externalBuilders map[string]JSONRPCBuilderBackend
internalBuilders []JSONRPCBuilderBackend
externalBuilders map[string]JSONRPCBuilderBackend
internalBuilders []JSONRPCBuilderBackend
RestrictedAddress string
}

// SendBundle sends a bundle to all builders.
Expand Down Expand Up @@ -240,6 +243,13 @@ func (b *BuildersBackend) SendBundle(ctx context.Context, logger *zap.Logger, bu
for idx, builder := range b.internalBuilders {
// if bundle needs to be replaceable, only send to builders that support replacement
if isReplaceable && builder.API != BuilderAPIMevShareBeta1Replacement {
internalBuildersSuccess[idx] = true
continue
}
// if address only allows sending to replacement supporting builders we skip
if strings.ToLower(iArgs.Metadata.Signer.String()) == strings.ToLower(b.RestrictedAddress) && builder.API != BuilderAPIMevShareBeta1Replacement {

Check failure on line 250 in mevshare/builders.go

View workflow job for this annotation

GitHub Actions / Lint

should use strings.EqualFold instead (SA6005)

Check failure on line 250 in mevshare/builders.go

View workflow job for this annotation

GitHub Actions / Lint

should use strings.EqualFold instead (SA6005)
logger.Debug("Skipping restricted address", zap.String("restrictedAddress", b.RestrictedAddress))
internalBuildersSuccess[idx] = true
continue
}
wg.Add(1)
Expand Down

0 comments on commit efd7bfe

Please sign in to comment.