Skip to content

Commit 1e75633

Browse files
authored
Oev 771 flashbots batch (#346)
* First draft * Pass txStore in constructor * Update Flashbots client for bundles * Update bundle body * Add bundle config * Fix failed request error message format * Add parsing tests * Add doc link * Add test for latest attempt * Address feedback * Add nonce gap validation
1 parent 0de99d1 commit 1e75633

15 files changed

Lines changed: 701 additions & 21 deletions

CONFIG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ Enabled = false # Default
390390
BlockTime = '10s' # Example
391391
CustomURL = 'https://example.api.io' # Example
392392
DualBroadcast = false # Example
393+
Bundles = false # Example
393394
```
394395

395396

@@ -417,6 +418,12 @@ DualBroadcast = false # Example
417418
```
418419
DualBroadcast enables DualBroadcast functionality.
419420

421+
### Bundles
422+
```toml
423+
Bundles = false # Example
424+
```
425+
Bundles enables sending bundles for auctioning (not compatible with all OFAs).
426+
420427
## BalanceMonitor
421428
```toml
422429
[BalanceMonitor]

pkg/config/chain_scoped_transactions.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ func (t *transactionManagerV2Config) DualBroadcast() *bool {
6464
return t.c.DualBroadcast
6565
}
6666

67+
func (t *transactionManagerV2Config) Bundles() *bool {
68+
return t.c.Bundles
69+
}
70+
6771
func (t *transactionsConfig) AutoPurge() AutoPurgeConfig {
6872
return &autoPurgeConfig{c: t.c.AutoPurge}
6973
}

pkg/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ type TransactionManagerV2 interface {
133133
BlockTime() *time.Duration
134134
CustomURL() *url.URL
135135
DualBroadcast() *bool
136+
Bundles() *bool
136137
}
137138

138139
type GasEstimator interface {

pkg/config/toml/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ type TransactionManagerV2Config struct {
589589
BlockTime *commonconfig.Duration `toml:",omitempty"`
590590
CustomURL *commonconfig.URL `toml:",omitempty"`
591591
DualBroadcast *bool `toml:",omitempty"`
592+
Bundles *bool `toml:",omitempty"`
592593
}
593594

594595
func (t *TransactionManagerV2Config) setFrom(f *TransactionManagerV2Config) {
@@ -604,6 +605,9 @@ func (t *TransactionManagerV2Config) setFrom(f *TransactionManagerV2Config) {
604605
if v := f.DualBroadcast; v != nil {
605606
t.DualBroadcast = f.DualBroadcast
606607
}
608+
if v := f.Bundles; v != nil {
609+
t.Bundles = f.Bundles
610+
}
607611
}
608612

609613
func (t *TransactionManagerV2Config) ValidateConfig() (err error) {

pkg/config/toml/config_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func TestDefaults_fieldsNotNil(t *testing.T) {
6464
unknown.Transactions.TransactionManagerV2.BlockTime = new(config.Duration)
6565
unknown.Transactions.TransactionManagerV2.CustomURL = new(config.URL)
6666
unknown.Transactions.TransactionManagerV2.DualBroadcast = ptr(false)
67+
unknown.Transactions.TransactionManagerV2.Bundles = ptr(false)
6768
unknown.Transactions.AutoPurge.Threshold = ptr(uint32(0))
6869
unknown.Transactions.AutoPurge.MinAttempts = ptr(uint32(0))
6970
unknown.Transactions.AutoPurge.DetectionApiUrl = new(config.URL)
@@ -159,6 +160,7 @@ func TestDocs(t *testing.T) {
159160
docDefaults.Transactions.TransactionManagerV2.BlockTime = nil
160161
docDefaults.Transactions.TransactionManagerV2.CustomURL = nil
161162
docDefaults.Transactions.TransactionManagerV2.DualBroadcast = nil
163+
docDefaults.Transactions.TransactionManagerV2.Bundles = nil
162164

163165
// Fallback DA oracle is not set
164166
docDefaults.GasEstimator.DAOracle = DAOracle{}
@@ -283,6 +285,7 @@ var fullConfig = EVMConfig{
283285
TransactionManagerV2: TransactionManagerV2Config{
284286
Enabled: ptr(false),
285287
DualBroadcast: ptr(true),
288+
Bundles: ptr(false),
286289
BlockTime: config.MustNewDuration(42 * time.Second),
287290
CustomURL: config.MustParseURL("http://txs.org"),
288291
},

pkg/config/toml/docs.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ BlockTime = '10s' # Example
171171
CustomURL = 'https://example.api.io' # Example
172172
# DualBroadcast enables DualBroadcast functionality.
173173
DualBroadcast = false # Example
174+
# Bundles enables sending bundles for auctioning (not compatible with all OFAs).
175+
Bundles = false # Example
174176

175177
[BalanceMonitor]
176178
# Enabled balance monitoring for all keys.

pkg/config/toml/testdata/config-full.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Enabled = false
4747
BlockTime = '42s'
4848
CustomURL = 'http://txs.org'
4949
DualBroadcast = true
50+
Bundles = false
5051

5152
[BalanceMonitor]
5253
Enabled = true

0 commit comments

Comments
 (0)