Skip to content

Commit

Permalink
Use TxManager interface in DriverSetup and BatcherService (ethereum-o…
Browse files Browse the repository at this point in the history
  • Loading branch information
mdehoog authored Sep 22, 2024
1 parent 4c6bc7e commit de7f8d9
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 4 deletions.
2 changes: 1 addition & 1 deletion op-batcher/batcher/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ type DriverSetup struct {
Metr metrics.Metricer
RollupConfig *rollup.Config
Config BatcherConfig
Txmgr *txmgr.SimpleTxManager
Txmgr txmgr.TxManager
L1Client L1Client
EndpointProvider dial.L2EndpointProvider
ChannelConfig ChannelConfigProvider
Expand Down
2 changes: 1 addition & 1 deletion op-batcher/batcher/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type BatcherService struct {
Metrics metrics.Metricer
L1Client *ethclient.Client
EndpointProvider dial.L2EndpointProvider
TxManager *txmgr.SimpleTxManager
TxManager txmgr.TxManager
AltDA *altda.DAClient

BatcherConfig
Expand Down
6 changes: 5 additions & 1 deletion op-batcher/batcher/test_batch_submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ func (l *TestBatchSubmitter) JamTxPool(ctx context.Context) error {
return err
}

simpleTxMgr, ok := l.Txmgr.(*txmgr.SimpleTxManager)
if !ok {
return errors.New("txmgr is not a SimpleTxManager")
}
l.ttm = &txmgr.TestTxManager{
SimpleTxManager: l.Txmgr,
SimpleTxManager: simpleTxMgr,
}
l.Log.Info("sending txpool blocking test tx")
if err := l.ttm.JamTxPool(ctx, *candidate); err != nil {
Expand Down
5 changes: 5 additions & 0 deletions op-challenger/sender/sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package sender
import (
"context"
"fmt"
"math/big"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -181,3 +182,7 @@ func (s *stubTxMgr) API() rpc.API {

func (s *stubTxMgr) Close() {
}

func (s *stubTxMgr) SuggestGasPriceCaps(context.Context) (*big.Int, *big.Int, *big.Int, error) {
panic("unimplemented")
}
4 changes: 4 additions & 0 deletions op-e2e/actions/helpers/l2_proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ func (f fakeTxMgr) API() rpc.API {
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 {
proposerConfig := proposer.ProposerConfig{
PollInterval: time.Second,
Expand Down
45 changes: 45 additions & 0 deletions op-service/txmgr/mocks/TxManager.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion op-service/txmgr/txmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ type TxManager interface {
// Close the underlying connection
Close()
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
Expand Down Expand Up @@ -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
// 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) {
cCtx, cancel := context.WithTimeout(ctx, m.cfg.NetworkTimeout)
defer cancel()
Expand Down

0 comments on commit de7f8d9

Please sign in to comment.