Documentation
¶
Index ¶
- Constants
- Variables
- func SubmitBundleAndWait(ctx context.Context, logger *slog.Logger, ethRpc EthRpc, relayUrl string, ...) (bool, error)
- type Bundle
- func (b *Bundle) AddTransaction(tx *types.Transaction)
- func (b *Bundle) AddTransactions(txs []*types.Transaction)
- func (b *Bundle) Builders() []string
- func (b *Bundle) BundleHash() common.Hash
- func (b *Bundle) Copy() *Bundle
- func (b *Bundle) GetBundelsForNextNBlocks(n uint64) ([]*Bundle, error)
- func (b *Bundle) MaxTimestamp() int64
- func (b *Bundle) MaximumGasFeePaid() (feePaid *big.Int)
- func (b *Bundle) MinTimestamp() int64
- func (b *Bundle) ReplacementUuid() string
- func (b *Bundle) RevertingTxHashes() []string
- func (b *Bundle) SetMaxTimestamp(maxTimestamp int64) error
- func (b *Bundle) SetMinTimestamp(minTimestamp int64) error
- func (b *Bundle) SetReplacementUuid(replacementUuid string) error
- func (b *Bundle) SetRevertingTxHash(revertingTxHash string)
- func (b *Bundle) SetRevertingTxHashes(revertingTxHashes []string)
- func (b *Bundle) SetTargetBlockNumber(blocknumber uint64) error
- func (b *Bundle) TargetBlockNumber() uint64
- func (b *Bundle) Transactions() []*types.Transaction
- func (b *Bundle) UseAllBuilders(networkId uint64)
- type BundleStats
- type BundleStatsV2
- type ErrorType
- type EthRpc
- type FlashbotsClient
- func (client *FlashbotsClient) Call(method string, params ...interface{}) (json.RawMessage, error)
- func (client *FlashbotsClient) CallWithAdditionalHeaders(method string, headers map[string]string, params ...interface{}) (json.RawMessage, error)
- func (client *FlashbotsClient) CancelBundle(uuid string) error
- func (client *FlashbotsClient) CheckBundleIncusion(ctx context.Context, bundle *Bundle) (bool, error)
- func (client *FlashbotsClient) GetBundleStats(bundle *Bundle) (*BundleStats, error)
- func (client *FlashbotsClient) GetBundleStatsV2(bundle *Bundle) (*BundleStatsV2, error)
- func (client *FlashbotsClient) GetSbundleStats(bundle *Bundle) (*BundleStats, error)
- func (client *FlashbotsClient) SendBundle(bundle *Bundle) (common.Hash, bool, error)
- func (client *FlashbotsClient) SendBundleAndWait(ctx context.Context, bundle *Bundle) (bool, error)
- func (client *FlashbotsClient) SendBundleNTimes(originalBundle *Bundle, n uint64) (bundlesToSend []*Bundle, hash common.Hash, smart bool, err error)
- func (client *FlashbotsClient) SendNBundleAndWait(ctx context.Context, bundle *Bundle, n uint64) (bool, error)
- func (client *FlashbotsClient) SimulateBundle(bundle *Bundle, stateBlocknumber uint64) (*SimulationResultBundle, bool, error)
- func (client *FlashbotsClient) UpdateFeeRefundRecipient(newFeeRefundRecipient common.Address) error
- func (client *FlashbotsClient) WaitForBundleInclusion(ctx context.Context, bundle *Bundle) (bool, error)
- type RawSimulationResultBundle
- type RawSimulationResultTransaction
- type Request
- type Response
- type SimulationResultBundle
- type SimulationResultTransaction
Constants ¶
const ( JsonRpcParseError = -32700 JsonRpcInvalidRequest = -32600 JsonRpcMethodNotFound = -32601 JsonRpcInvalidParams = -32602 JsonRpcInternalError = -32603 )
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 ¶
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.
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 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) BundleHash ¶
func (*Bundle) GetBundelsForNextNBlocks ¶
func (*Bundle) MaxTimestamp ¶
func (*Bundle) MaximumGasFeePaid ¶
func (*Bundle) MinTimestamp ¶
func (*Bundle) ReplacementUuid ¶
func (*Bundle) RevertingTxHashes ¶
func (*Bundle) SetMaxTimestamp ¶
SetMaxTimestamp sets the maximum timestamp for which this bundle is valid, in seconds since the unix epoch
func (*Bundle) SetMinTimestamp ¶
SetMinTimestamp sets the minimum timestamp for which this bundle is valid, in seconds since the unix epoch
func (*Bundle) SetReplacementUuid ¶
SetReplacementUuid sets the replacement UUID for this bundle that can be used to cancel/replace this bundle
func (*Bundle) SetRevertingTxHash ¶
SetRevertingTxHash sets one transaction hash that is allowed to revert
func (*Bundle) SetRevertingTxHashes ¶
SetRevertingTxHashes sets the list of transaction hashes that are allowed to revert
func (*Bundle) SetTargetBlockNumber ¶
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 (*Bundle) Transactions ¶
func (b *Bundle) Transactions() []*types.Transaction
func (*Bundle) UseAllBuilders ¶
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 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 (*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 (*FlashbotsClient) SendBundleAndWait ¶
func (*FlashbotsClient) SendBundleNTimes ¶
func (*FlashbotsClient) SendNBundleAndWait ¶
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 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 Response ¶
type Response struct {
ID int `json:"id"`
JSONRPC string `json:"jsonrpc"`
Result json.RawMessage `json:"result"`
Error ErrorType `json:"error"`
}
type SimulationResultBundle ¶
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"`
}