flashbots

package
v1.20.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2026 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JsonRpcParseError     = -32700
	JsonRpcInvalidRequest = -32600
	JsonRpcMethodNotFound = -32601
	JsonRpcInvalidParams  = -32602
	JsonRpcInternalError  = -32603
)
View Source
const (
	DefaultBundleBlockCount  uint64 = 5
	DefaultSubmissionTimeout        = 70 * time.Second
)

Defaults for bundle submission: retry the bundle over the next 4 blocks (~48s on mainnet) and give inclusion polling a bit of margin on top of that.

Variables

View Source
var AllBuilders = []string{
	"flashbots",
	"f1b.io",
	"rsync",
	"beaverbuild.org",
	"builder0x69",
	"Titan",
	"EigenPhi",
	"boba-builder",
	"Gambit Labs",
	"payload",
	"Loki",
	"BuildAI",
	"JetBuilder",
	"tbuilder",
	"penguinbuild",
	"bobthebuilder",
	"BTCS",
	"bloXroute",
	"Blockbeelder",
}

AllBuilders is the list used by UseAllBuilders for broader inclusion chances on supported networks.

View Source
var FlashbotsUrlPerNetwork = map[uint64]string{
	1: "https://relay.flashbots.net",
}

Flashbots relay URLs per chain ID, used as a fallback when no relay URL is passed to NewClient explicitly (the Smart Node passes cfg.GetFlashbotsRelayUrl()).

Functions

func SubmitBundleAndWait

func SubmitBundleAndWait(ctx context.Context, logger *slog.Logger, ethRpc EthRpc, relayUrl string, txs []*types.Transaction, nBlocks uint64) (bool, error)

SubmitBundleAndWait bundles the given signed transactions, targets the next block, submits the bundle with redundancy across the next nBlocks blocks and waits for inclusion (cancelling the remaining bundles once one of them lands). If relayUrl is empty, the relay is resolved from the chain ID. Returns true if the bundle was included before ctx expired.

Types

type Bundle

type Bundle struct {
	// contains filtered or unexported fields
}

func NewBundle

func NewBundle() *Bundle

func NewBundleWithTransactions

func NewBundleWithTransactions(transactions []*types.Transaction) *Bundle

func (*Bundle) AddTransaction

func (b *Bundle) AddTransaction(tx *types.Transaction)

func (*Bundle) AddTransactions

func (b *Bundle) AddTransactions(txs []*types.Transaction)

func (*Bundle) Builders

func (b *Bundle) Builders() []string

func (*Bundle) BundleHash

func (b *Bundle) BundleHash() common.Hash

func (*Bundle) Copy

func (b *Bundle) Copy() *Bundle

func (*Bundle) GetBundelsForNextNBlocks

func (b *Bundle) GetBundelsForNextNBlocks(n uint64) ([]*Bundle, error)

func (*Bundle) MaxTimestamp

func (b *Bundle) MaxTimestamp() int64

func (*Bundle) MaximumGasFeePaid

func (b *Bundle) MaximumGasFeePaid() (feePaid *big.Int)

func (*Bundle) MinTimestamp

func (b *Bundle) MinTimestamp() int64

func (*Bundle) ReplacementUuid

func (b *Bundle) ReplacementUuid() string

func (*Bundle) RevertingTxHashes

func (b *Bundle) RevertingTxHashes() []string

func (*Bundle) SetMaxTimestamp

func (b *Bundle) SetMaxTimestamp(maxTimestamp int64) error

SetMaxTimestamp sets the maximum timestamp for which this bundle is valid, in seconds since the unix epoch

func (*Bundle) SetMinTimestamp

func (b *Bundle) SetMinTimestamp(minTimestamp int64) error

SetMinTimestamp sets the minimum timestamp for which this bundle is valid, in seconds since the unix epoch

func (*Bundle) SetReplacementUuid

func (b *Bundle) SetReplacementUuid(replacementUuid string) error

SetReplacementUuid sets the replacement UUID for this bundle that can be used to cancel/replace this bundle

func (*Bundle) SetRevertingTxHash

func (b *Bundle) SetRevertingTxHash(revertingTxHash string)

SetRevertingTxHash sets one transaction hash that is allowed to revert

func (*Bundle) SetRevertingTxHashes

func (b *Bundle) SetRevertingTxHashes(revertingTxHashes []string)

SetRevertingTxHashes sets the list of transaction hashes that are allowed to revert

func (*Bundle) SetTargetBlockNumber

func (b *Bundle) SetTargetBlockNumber(blocknumber uint64) error

SetBlockNumber sets the block number for which this bundle is valid If set to 0, the bundle is valid for the next block

func (*Bundle) TargetBlockNumber

func (b *Bundle) TargetBlockNumber() uint64

func (*Bundle) Transactions

func (b *Bundle) Transactions() []*types.Transaction

func (*Bundle) UseAllBuilders

func (b *Bundle) UseAllBuilders(networkId uint64)

type BundleStats

type BundleStats struct {
	IsHighPriority       bool   `json:"isHighPriority"`
	IsSimulated          bool   `json:"isSimulated"`
	SimulatedAt          string `json:"simulatedAt"`
	ReceivedAt           string `json:"receivedAt"`
	ConsideredByBuilders []struct {
		Pubkey    string `json:"pubkey"`
		Timestamp string `json:"timestamp"`
	} `json:"consideredByBuildersAt"`
	SealedByBuilders []struct {
		Pubkey    string `json:"pubkey"`
		Timestamp string `json:"timestamp"`
	} `json:"sealedByBuildersAt"`
}

type BundleStatsV2

type BundleStatsV2 struct {
	IsHighPriority       bool   `json:"isHighPriority"`
	IsSimulated          bool   `json:"isSimulated"`
	SimulatedAt          string `json:"simulatedAt"`
	ReceivedAt           string `json:"receivedAt"`
	ConsideredByBuilders []struct {
		Pubkey    string `json:"pubkey"`
		Timestamp string `json:"timestamp"`
	} `json:"consideredByBuildersAt"`
	SealedByBuilders []struct {
		Pubkey    string `json:"pubkey"`
		Timestamp string `json:"timestamp"`
	} `json:"sealedByBuildersAt"`
}

type ErrorType

type ErrorType struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type EthRpc

type EthRpc interface {
	ChainID(ctx context.Context) (*big.Int, error)
	BlockNumber(ctx context.Context) (uint64, error)
	TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
}

EthRpc is the minimal execution client surface needed by the Flashbots client. Both *ethclient.Client and the Smart Node's ExecutionClientManager satisfy it.

type FlashbotsClient

type FlashbotsClient struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(logger *slog.Logger, ethRpc EthRpc, relayUrl string, searcherSecret *ecdsa.PrivateKey) (*FlashbotsClient, error)

NewClient creates a Flashbots client using the given execution client for on-chain queries. If relayUrl is empty, the relay is resolved from FlashbotsUrlPerNetwork using the chain ID.

func NewClientRpcString

func NewClientRpcString(logger *slog.Logger, ethRpcStr string, relayUrl string, searcherSecret *ecdsa.PrivateKey) (*FlashbotsClient, error)

func (*FlashbotsClient) Call

func (client *FlashbotsClient) Call(method string, params ...interface{}) (json.RawMessage, error)

func (*FlashbotsClient) CallWithAdditionalHeaders

func (client *FlashbotsClient) CallWithAdditionalHeaders(method string, headers map[string]string, params ...interface{}) (json.RawMessage, error)

func (*FlashbotsClient) CancelBundle

func (client *FlashbotsClient) CancelBundle(uuid string) error

func (*FlashbotsClient) CheckBundleIncusion

func (client *FlashbotsClient) CheckBundleIncusion(ctx context.Context, bundle *Bundle) (bool, error)

func (*FlashbotsClient) GetBundleStats

func (client *FlashbotsClient) GetBundleStats(bundle *Bundle) (*BundleStats, error)

func (*FlashbotsClient) GetBundleStatsV2

func (client *FlashbotsClient) GetBundleStatsV2(bundle *Bundle) (*BundleStatsV2, error)

func (*FlashbotsClient) GetSbundleStats

func (client *FlashbotsClient) GetSbundleStats(bundle *Bundle) (*BundleStats, error)

func (*FlashbotsClient) SendBundle

func (client *FlashbotsClient) SendBundle(bundle *Bundle) (common.Hash, bool, error)

func (*FlashbotsClient) SendBundleAndWait

func (client *FlashbotsClient) SendBundleAndWait(ctx context.Context, bundle *Bundle) (bool, error)

func (*FlashbotsClient) SendBundleNTimes

func (client *FlashbotsClient) SendBundleNTimes(originalBundle *Bundle, n uint64) (bundlesToSend []*Bundle, hash common.Hash, smart bool, err error)

func (*FlashbotsClient) SendNBundleAndWait

func (client *FlashbotsClient) SendNBundleAndWait(ctx context.Context, bundle *Bundle, n uint64) (bool, error)

func (*FlashbotsClient) SimulateBundle

func (client *FlashbotsClient) SimulateBundle(bundle *Bundle, stateBlocknumber uint64) (*SimulationResultBundle, bool, error)

SimulateBundle simulates the execution of a bundle The stateBlocknumber parameter is the block number at which the simulation should start, 0 for the current block

func (*FlashbotsClient) UpdateFeeRefundRecipient

func (client *FlashbotsClient) UpdateFeeRefundRecipient(newFeeRefundRecipient common.Address) error

func (*FlashbotsClient) WaitForBundleInclusion

func (client *FlashbotsClient) WaitForBundleInclusion(ctx context.Context, bundle *Bundle) (bool, error)

WaitForBundleInclusion waits for a bundle to be included in a block

type RawSimulationResultBundle

type RawSimulationResultBundle struct {
	BundleGasPrice    string
	BundleHash        string
	CoinbaseDiff      string
	EthSentToCoinbase string
	GasFees           string
	Results           []RawSimulationResultTransaction
	StateBlockNumber  uint64
	TotalGasUsed      uint64
	FirstRevert       string
}

type RawSimulationResultTransaction

type RawSimulationResultTransaction struct {
	CoinbaseDiff      string `json:"coinbaseDiff"`
	EthSentToCoinbase string `json:"ethSentToCoinbase"`
	FromAddress       string `json:"fromAddress"`
	GasFees           string `json:"gasFees"`
	GasPrice          string `json:"gasPrice"`
	GasUsed           uint64 `json:"gasUsed"`
	ToAddress         string `json:"toAddress"`
	TxHash            string `json:"txHash"`
	Value             string `json:"value"`

	// revert related
	Error        string `json:"error"`
	RevertReason string `json:"revert"`
}

type Request

type Request struct {
	ID      int           `json:"id"`
	JSONRPC string        `json:"jsonrpc"`
	Method  string        `json:"method"`
	Params  []interface{} `json:"params"`
}

type Response

type Response struct {
	ID      int             `json:"id"`
	JSONRPC string          `json:"jsonrpc"`
	Result  json.RawMessage `json:"result"`
	Error   ErrorType       `json:"error"`
}

type SimulationResultBundle

type SimulationResultBundle struct {
	BundleGasPrice    *big.Int
	BundleHash        common.Hash
	CoinbaseDiff      *big.Int
	EthSentToCoinbase *big.Int
	GasFees           *big.Int
	Results           []SimulationResultTransaction
	StateBlockNumber  uint64
	TotalGasUsed      uint64
	FirstRevert       common.Hash
}

type SimulationResultTransaction

type SimulationResultTransaction struct {
	CoinbaseDiff      *big.Int       `json:"coinbaseDiff"`
	EthSentToCoinbase *big.Int       `json:"ethSentToCoinbase"`
	FromAddress       common.Address `json:"fromAddress"`
	GasFees           *big.Int       `json:"gasFees"`
	GasPrice          *big.Int       `json:"gasPrice"`
	GasUsed           uint64         `json:"gasUsed"`
	ToAddress         common.Address `json:"toAddress"`
	TxHash            common.Hash    `json:"txHash"`
	Value             *big.Int       `json:"value"`

	// revert related
	Error        string `json:"error"`
	RevertReason string `json:"revert"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL