From 58f1c85ad471a545f8f00bfd32b3241657f38e8f Mon Sep 17 00:00:00 2001 From: David Date: Fri, 30 Aug 2024 12:30:31 +0800 Subject: [PATCH] fix(taiko-client): initialize private mempool transaction sender in `InitFromConfig` (#18005) --- packages/taiko-client/cmd/flags/common.go | 10 +++++----- packages/taiko-client/proposer/config.go | 2 +- packages/taiko-client/proposer/proposer.go | 13 ++++++++++++- packages/taiko-client/prover/config.go | 2 +- packages/taiko-client/prover/prover.go | 2 +- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/packages/taiko-client/cmd/flags/common.go b/packages/taiko-client/cmd/flags/common.go index c03e38ac20f..834dd8d3d67 100644 --- a/packages/taiko-client/cmd/flags/common.go +++ b/packages/taiko-client/cmd/flags/common.go @@ -28,11 +28,11 @@ var ( Category: commonCategory, EnvVars: []string{"L1_WS"}, } - L1PrivateTxEndpoint = &cli.StringFlag{ - Name: "l1.privateTx", - Usage: "RPC endpoint of a L1 private tx ethereum node", + L1PrivateEndpoint = &cli.StringFlag{ + Name: "l1.private", + Usage: "RPC endpoint of a L1 node with private mempool", Category: commonCategory, - EnvVars: []string{"L1_PRIVATE_TX"}, + EnvVars: []string{"L1_PRIVATE"}, } L2WSEndpoint = &cli.StringFlag{ Name: "l2.ws", @@ -173,7 +173,7 @@ var CommonFlags = []cli.Flag{ BackOffMaxRetries, BackOffRetryInterval, RPCTimeout, - L1PrivateTxEndpoint, + L1PrivateEndpoint, } // MergeFlags merges the given flag slices. diff --git a/packages/taiko-client/proposer/config.go b/packages/taiko-client/proposer/config.go index 481e415c3c0..d8444e080ea 100644 --- a/packages/taiko-client/proposer/config.go +++ b/packages/taiko-client/proposer/config.go @@ -107,7 +107,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { c, ), PrivateTxmgrConfigs: pkgFlags.InitTxmgrConfigsFromCli( - c.String(flags.L1PrivateTxEndpoint.Name), + c.String(flags.L1PrivateEndpoint.Name), l1ProposerPrivKey, c, ), diff --git a/packages/taiko-client/proposer/proposer.go b/packages/taiko-client/proposer/proposer.go index a7552e8f005..89211a78d3d 100644 --- a/packages/taiko-client/proposer/proposer.go +++ b/packages/taiko-client/proposer/proposer.go @@ -58,7 +58,7 @@ type Proposer struct { wg sync.WaitGroup } -// InitFromCli New initializes the given proposer instance based on the command line flags. +// InitFromCli initializes the given proposer instance based on the command line flags. func (p *Proposer) InitFromCli(ctx context.Context, c *cli.Context) error { cfg, err := NewConfigFromCliContext(c) if err != nil { @@ -104,6 +104,17 @@ func (p *Proposer) InitFromConfig( } } + if privateTxMgr == nil && cfg.PrivateTxmgrConfigs != nil && len(cfg.PrivateTxmgrConfigs.L1RPCURL) > 0 { + if privateTxMgr, err = txmgr.NewSimpleTxManager( + "privateMempoolProposer", + log.Root(), + &metrics.TxMgrMetrics, + *cfg.PrivateTxmgrConfigs, + ); err != nil { + return err + } + } + p.txmgrSelector = utils.NewTxMgrSelector(txMgr, privateTxMgr, nil) chainConfig := config.NewChainConfig(p.protocolConfigs) diff --git a/packages/taiko-client/prover/config.go b/packages/taiko-client/prover/config.go index 2b12120bd10..0709f4be3df 100644 --- a/packages/taiko-client/prover/config.go +++ b/packages/taiko-client/prover/config.go @@ -179,7 +179,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) { c, ), PrivateTxmgrConfigs: pkgFlags.InitTxmgrConfigsFromCli( - c.String(flags.L1PrivateTxEndpoint.Name), + c.String(flags.L1PrivateEndpoint.Name), l1ProverPrivKey, c, ), diff --git a/packages/taiko-client/prover/prover.go b/packages/taiko-client/prover/prover.go index 1a657e3a38e..81710ff7d8d 100644 --- a/packages/taiko-client/prover/prover.go +++ b/packages/taiko-client/prover/prover.go @@ -169,7 +169,7 @@ func InitFromConfig( } else { if cfg.PrivateTxmgrConfigs != nil && len(cfg.PrivateTxmgrConfigs.L1RPCURL) > 0 { if p.privateTxmgr, err = txmgr.NewSimpleTxManager( - "privateTxProver", + "privateMempoolProver", log.Root(), &metrics.TxMgrMetrics, *cfg.PrivateTxmgrConfigs,