Commit de7f8d9b authored by Michael de Hoog's avatar Michael de Hoog Committed by GitHub

Use TxManager interface in DriverSetup and BatcherService (#12040)

parent 4c6bc7e5
...@@ -80,7 +80,7 @@ type DriverSetup struct { ...@@ -80,7 +80,7 @@ type DriverSetup struct {
Metr metrics.Metricer Metr metrics.Metricer
RollupConfig *rollup.Config RollupConfig *rollup.Config
Config BatcherConfig Config BatcherConfig
Txmgr *txmgr.SimpleTxManager Txmgr txmgr.TxManager
L1Client L1Client L1Client L1Client
EndpointProvider dial.L2EndpointProvider EndpointProvider dial.L2EndpointProvider
ChannelConfig ChannelConfigProvider ChannelConfig ChannelConfigProvider
......
...@@ -53,7 +53,7 @@ type BatcherService struct { ...@@ -53,7 +53,7 @@ type BatcherService struct {
Metrics metrics.Metricer Metrics metrics.Metricer
L1Client *ethclient.Client L1Client *ethclient.Client
EndpointProvider dial.L2EndpointProvider EndpointProvider dial.L2EndpointProvider
TxManager *txmgr.SimpleTxManager TxManager txmgr.TxManager
AltDA *altda.DAClient AltDA *altda.DAClient
BatcherConfig BatcherConfig
......
...@@ -37,8 +37,12 @@ func (l *TestBatchSubmitter) JamTxPool(ctx context.Context) error { ...@@ -37,8 +37,12 @@ func (l *TestBatchSubmitter) JamTxPool(ctx context.Context) error {
return err return err
} }
simpleTxMgr, ok := l.Txmgr.(*txmgr.SimpleTxManager)
if !ok {
return errors.New("txmgr is not a SimpleTxManager")
}
l.ttm = &txmgr.TestTxManager{ l.ttm = &txmgr.TestTxManager{
SimpleTxManager: l.Txmgr, SimpleTxManager: simpleTxMgr,
} }
l.Log.Info("sending txpool blocking test tx") l.Log.Info("sending txpool blocking test tx")
if err := l.ttm.JamTxPool(ctx, *candidate); err != nil { if err := l.ttm.JamTxPool(ctx, *candidate); err != nil {
......
...@@ -3,6 +3,7 @@ package sender ...@@ -3,6 +3,7 @@ package sender
import ( import (
"context" "context"
"fmt" "fmt"
"math/big"
"sync" "sync"
"testing" "testing"
"time" "time"
...@@ -181,3 +182,7 @@ func (s *stubTxMgr) API() rpc.API { ...@@ -181,3 +182,7 @@ func (s *stubTxMgr) API() rpc.API {
func (s *stubTxMgr) Close() { func (s *stubTxMgr) Close() {
} }
func (s *stubTxMgr) SuggestGasPriceCaps(context.Context) (*big.Int, *big.Int, *big.Int, error) {
panic("unimplemented")
}
...@@ -84,6 +84,10 @@ func (f fakeTxMgr) API() rpc.API { ...@@ -84,6 +84,10 @@ func (f fakeTxMgr) API() rpc.API {
panic("unimplemented") panic("unimplemented")
} }
func (f fakeTxMgr) SuggestGasPriceCaps(context.Context) (*big.Int, *big.Int, *big.Int, error) {
panic("unimplemented")
}
func NewL2Proposer(t Testing, log log.Logger, cfg *ProposerCfg, l1 *ethclient.Client, rollupCl *sources.RollupClient) *L2Proposer { func NewL2Proposer(t Testing, log log.Logger, cfg *ProposerCfg, l1 *ethclient.Client, rollupCl *sources.RollupClient) *L2Proposer {
proposerConfig := proposer.ProposerConfig{ proposerConfig := proposer.ProposerConfig{
PollInterval: time.Second, PollInterval: time.Second,
......
...@@ -4,6 +4,7 @@ package mocks ...@@ -4,6 +4,7 @@ package mocks
import ( import (
context "context" context "context"
big "math/big"
common "github.com/ethereum/go-ethereum/common" common "github.com/ethereum/go-ethereum/common"
...@@ -125,6 +126,50 @@ func (_m *TxManager) SendAsync(ctx context.Context, candidate txmgr.TxCandidate, ...@@ -125,6 +126,50 @@ func (_m *TxManager) SendAsync(ctx context.Context, candidate txmgr.TxCandidate,
_m.Called(ctx, candidate, ch) _m.Called(ctx, candidate, ch)
} }
// SuggestGasPriceCaps provides a mock function with given fields: ctx
func (_m *TxManager) SuggestGasPriceCaps(ctx context.Context) (*big.Int, *big.Int, *big.Int, error) {
ret := _m.Called(ctx)
var r0 *big.Int
var r1 *big.Int
var r2 *big.Int
var r3 error
if rf, ok := ret.Get(0).(func(context.Context) (*big.Int, *big.Int, *big.Int, error)); ok {
return rf(ctx)
}
if rf, ok := ret.Get(0).(func(context.Context) *big.Int); ok {
r0 = rf(ctx)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*big.Int)
}
}
if rf, ok := ret.Get(1).(func(context.Context) *big.Int); ok {
r1 = rf(ctx)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(*big.Int)
}
}
if rf, ok := ret.Get(2).(func(context.Context) *big.Int); ok {
r2 = rf(ctx)
} else {
if ret.Get(2) != nil {
r2 = ret.Get(2).(*big.Int)
}
}
if rf, ok := ret.Get(3).(func(context.Context) error); ok {
r3 = rf(ctx)
} else {
r3 = ret.Error(3)
}
return r0, r1, r2, r3
}
type mockConstructorTestingTNewTxManager interface { type mockConstructorTestingTNewTxManager interface {
mock.TestingT mock.TestingT
Cleanup(func()) Cleanup(func())
......
...@@ -90,6 +90,10 @@ type TxManager interface { ...@@ -90,6 +90,10 @@ type TxManager interface {
// Close the underlying connection // Close the underlying connection
Close() Close()
IsClosed() bool IsClosed() bool
// SuggestGasPriceCaps suggests what the new tip, base fee, and blob base fee should be based on
// the current L1 conditions. `blobBaseFee` will be nil if 4844 is not yet active.
SuggestGasPriceCaps(ctx context.Context) (tipCap *big.Int, baseFee *big.Int, blobBaseFee *big.Int, err error)
} }
// ETHBackend is the set of methods that the transaction manager uses to resubmit gas & determine // ETHBackend is the set of methods that the transaction manager uses to resubmit gas & determine
...@@ -857,7 +861,7 @@ func (m *SimpleTxManager) increaseGasPrice(ctx context.Context, tx *types.Transa ...@@ -857,7 +861,7 @@ func (m *SimpleTxManager) increaseGasPrice(ctx context.Context, tx *types.Transa
} }
// SuggestGasPriceCaps suggests what the new tip, base fee, and blob base fee should be based on // SuggestGasPriceCaps suggests what the new tip, base fee, and blob base fee should be based on
// the current L1 conditions. blobfee will be nil if 4844 is not yet active. // the current L1 conditions. `blobBaseFee` will be nil if 4844 is not yet active.
func (m *SimpleTxManager) SuggestGasPriceCaps(ctx context.Context) (*big.Int, *big.Int, *big.Int, error) { func (m *SimpleTxManager) SuggestGasPriceCaps(ctx context.Context) (*big.Int, *big.Int, *big.Int, error) {
cCtx, cancel := context.WithTimeout(ctx, m.cfg.NetworkTimeout) cCtx, cancel := context.WithTimeout(ctx, m.cfg.NetworkTimeout)
defer cancel() defer cancel()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment