Commit 4cbc6d1e authored by Andreas Bigger's avatar Andreas Bigger

minor changes to move chain id into txmgr config

parent de98bbff
......@@ -80,6 +80,7 @@ func NewBatchSubmitterFromCLIConfig(cfg CLIConfig, l log.Logger, m metrics.Metri
NumConfirmations: cfg.NumConfirmations,
SafeAbortNonceTooLowCount: cfg.SafeAbortNonceTooLowCount,
From: fromAddress,
ChainID: rcfg.L1ChainID,
Signer: signer(rcfg.L1ChainID),
}
......
......@@ -51,6 +51,7 @@ func NewL2Proposer(t Testing, log log.Logger, cfg *ProposerCfg, l1 *ethclient.Cl
NumConfirmations: 1,
SafeAbortNonceTooLowCount: 4,
From: from,
ChainID: big.NewInt(420),
// Signer is loaded in `proposer.NewL2OutputSubmitter`
},
L1Client: l1,
......
......@@ -166,12 +166,18 @@ func NewL2OutputSubmitterFromCLIConfig(cfg CLIConfig, l log.Logger) (*L2OutputSu
return nil, err
}
chainID, err := l1Client.ChainID(context.Background())
if err != nil {
return nil, err
}
txMgrConfg := txmgr.Config{
ResubmissionTimeout: cfg.ResubmissionTimeout,
ReceiptQueryInterval: time.Second,
NumConfirmations: cfg.NumConfirmations,
SafeAbortNonceTooLowCount: cfg.SafeAbortNonceTooLowCount,
From: fromAddress,
ChainID: chainID,
}
proposerCfg := Config{
......
......@@ -41,6 +41,9 @@ type Config struct {
// attempted.
ResubmissionTimeout time.Duration
// ChainID is the chain ID of the L1 chain.
ChainID *big.Int
// NetworkTimeout is the allowed duration for a single network request.
// This is intended to be used for network requests that can be replayed.
//
......@@ -109,8 +112,6 @@ type ETHBackend interface {
/// EstimateGas returns an estimate of the amount of gas needed to execute the given
/// transaction against the current pending block.
EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, error)
// ChainID returns the chain ID for this ethereum chain.
ChainID(ctx context.Context) (*big.Int, error)
}
// SimpleTxManager is a implementation of TxManager that performs linear fee
......@@ -184,18 +185,6 @@ func (m *SimpleTxManager) CraftTx(ctx context.Context, candidate TxCandidate) (*
return nil, fmt.Errorf("failed to get nonce: %w", err)
}
// If the configured chain ID is nil (can occur if the fetch fails in the constructor),
// we need to try to fetch it again from the backend.
if m.chainID == nil {
childCtx, cancel := context.WithTimeout(ctx, m.Config.NetworkTimeout)
defer cancel()
chainID, err := m.backend.ChainID(childCtx)
if err != nil {
return nil, fmt.Errorf("failed to get chain ID: %w", err)
}
m.chainID = chainID
}
rawTx := &types.DynamicFeeTx{
ChainID: m.chainID,
Nonce: nonce,
......@@ -329,11 +318,8 @@ func NewSimpleTxManager(name string, l log.Logger, cfg Config, backend ETHBacken
cfg.NetworkTimeout = 2 * time.Second
}
// On error, ignore. We will try to get the chainID again when used.
chainID, _ := backend.ChainID(context.Background())
return &SimpleTxManager{
chainID: chainID,
chainID: cfg.ChainID,
name: name,
Config: cfg,
backend: backend,
......
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