From 0a0a311e200ddb71173cab0978c58f345863051d Mon Sep 17 00:00:00 2001 From: simsonraj Date: Mon, 19 Jun 2023 17:20:52 +0530 Subject: [PATCH 1/2] Modles.go evm prefix cleanup --- core/chains/evm/chain.go | 6 +- core/chains/evm/chain_set.go | 2 +- core/chains/evm/evm_txm.go | 4 +- core/chains/evm/txmgr/attempts.go | 24 +-- core/chains/evm/txmgr/attempts_test.go | 20 +- core/chains/evm/txmgr/broadcaster_test.go | 36 ++-- core/chains/evm/txmgr/builder.go | 48 ++--- core/chains/evm/txmgr/client.go | 12 +- core/chains/evm/txmgr/common.go | 2 +- core/chains/evm/txmgr/confirmer_test.go | 32 ++-- core/chains/evm/txmgr/evm_tx_store.go | 178 +++++++++--------- core/chains/evm/txmgr/evm_tx_store_test.go | 36 ++-- core/chains/evm/txmgr/models.go | 48 ++--- core/chains/evm/txmgr/nonce_syncer.go | 8 +- core/chains/evm/txmgr/reaper_test.go | 4 +- core/chains/evm/txmgr/transmitchecker.go | 24 +-- core/chains/evm/txmgr/transmitchecker_test.go | 22 +-- core/chains/evm/txmgr/txmgr_test.go | 28 +-- core/chains/evm/types/models_test.go | 4 +- core/internal/cltest/cltest.go | 2 +- core/internal/cltest/factories.go | 68 +++---- core/internal/testutils/evmtest/evmtest.go | 4 +- core/services/blockhashstore/batch_bhs.go | 6 +- core/services/blockhashstore/bhs.go | 8 +- core/services/blockhashstore/bhs_test.go | 8 +- .../fluxmonitorv2/flux_monitor_test.go | 2 +- core/services/fluxmonitorv2/orm.go | 4 +- core/services/fluxmonitorv2/orm_test.go | 4 +- core/services/keeper/upkeep_executer_test.go | 12 +- core/services/ocrcommon/transmitter.go | 8 +- .../ocrcommon/transmitter_pipeline.go | 2 +- core/services/ocrcommon/transmitter_test.go | 12 +- core/services/pipeline/task.eth_tx.go | 8 +- core/services/pipeline/task.eth_tx_test.go | 56 +++--- .../relay/evm/contract_transmitter.go | 6 +- .../relay/evm/contract_transmitter_test.go | 6 +- core/services/vrf/delegate_test.go | 4 +- core/services/vrf/integration_v2_test.go | 26 +-- core/services/vrf/listener_v1.go | 2 +- core/services/vrf/listener_v2.go | 16 +- core/services/vrf/listener_v2_test.go | 4 +- core/services/vrf/listener_v2_types.go | 6 +- core/web/eth_keys_controller_test.go | 2 +- core/web/loader/eth_transaction_attempt.go | 4 +- core/web/loader/getters.go | 4 +- core/web/loader/loader_test.go | 22 +-- core/web/presenters/eth_tx.go | 4 +- core/web/presenters/eth_tx_test.go | 4 +- core/web/resolver/eth_transaction.go | 14 +- core/web/resolver/eth_transaction_attempt.go | 10 +- core/web/resolver/eth_transaction_test.go | 18 +- 51 files changed, 447 insertions(+), 447 deletions(-) diff --git a/core/chains/evm/chain.go b/core/chains/evm/chain.go index d98c7e8f5b8..5a697ab8d8c 100644 --- a/core/chains/evm/chain.go +++ b/core/chains/evm/chain.go @@ -38,7 +38,7 @@ type Chain interface { Config() evmconfig.ChainScopedConfig LogBroadcaster() log.Broadcaster HeadBroadcaster() httypes.HeadBroadcaster - TxManager() txmgr.EvmTxManager + TxManager() txmgr.TxManager HeadTracker() httypes.HeadTracker Logger() logger.Logger BalanceMonitor() monitor.BalanceMonitor @@ -55,7 +55,7 @@ type chain struct { id *big.Int cfg evmconfig.ChainScopedConfig client evmclient.Client - txm txmgr.EvmTxManager + txm txmgr.TxManager logger logger.Logger headBroadcaster httypes.HeadBroadcaster headTracker httypes.HeadTracker @@ -272,7 +272,7 @@ func (c *chain) Config() evmconfig.ChainScopedConfig { return c.cfg } func (c *chain) LogBroadcaster() log.Broadcaster { return c.logBroadcaster } func (c *chain) LogPoller() logpoller.LogPoller { return c.logPoller } func (c *chain) HeadBroadcaster() httypes.HeadBroadcaster { return c.headBroadcaster } -func (c *chain) TxManager() txmgr.EvmTxManager { return c.txm } +func (c *chain) TxManager() txmgr.TxManager { return c.txm } func (c *chain) HeadTracker() httypes.HeadTracker { return c.headTracker } func (c *chain) Logger() logger.Logger { return c.logger } func (c *chain) BalanceMonitor() monitor.BalanceMonitor { return c.balanceMonitor } diff --git a/core/chains/evm/chain_set.go b/core/chains/evm/chain_set.go index b3714ddc1b4..a41b7484a83 100644 --- a/core/chains/evm/chain_set.go +++ b/core/chains/evm/chain_set.go @@ -260,7 +260,7 @@ type ChainSetOpts struct { GenLogBroadcaster func(*big.Int) log.Broadcaster GenLogPoller func(*big.Int) logpoller.LogPoller GenHeadTracker func(*big.Int, httypes.HeadBroadcaster) httypes.HeadTracker - GenTxManager func(*big.Int) txmgr.EvmTxManager + GenTxManager func(*big.Int) txmgr.TxManager GenGasEstimator func(*big.Int) gas.EvmFeeEstimator } diff --git a/core/chains/evm/evm_txm.go b/core/chains/evm/evm_txm.go index 6c756f21839..23d109c971d 100644 --- a/core/chains/evm/evm_txm.go +++ b/core/chains/evm/evm_txm.go @@ -23,13 +23,13 @@ func newEvmTxm( lggr logger.Logger, logPoller logpoller.LogPoller, opts ChainSetOpts, -) (txm txmgr.EvmTxManager, +) (txm txmgr.TxManager, estimator gas.EvmFeeEstimator, err error, ) { chainID := cfg.ChainID() if !evmRPCEnabled { - txm = &txmgr.NullEvmTxManager{ErrMsg: fmt.Sprintf("Ethereum is disabled for chain %d", chainID)} + txm = &txmgr.NullTxManager{ErrMsg: fmt.Sprintf("Ethereum is disabled for chain %d", chainID)} return txm, nil, nil } diff --git a/core/chains/evm/txmgr/attempts.go b/core/chains/evm/txmgr/attempts.go index 601a555b541..f9bb4b09f8d 100644 --- a/core/chains/evm/txmgr/attempts.go +++ b/core/chains/evm/txmgr/attempts.go @@ -22,7 +22,7 @@ type TxAttemptSigner[ADDR commontypes.Hashable] interface { SignTx(fromAddress ADDR, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) } -var _ EvmTxAttemptBuilder = (*evmTxAttemptBuilder)(nil) +var _ TxAttemptBuilder = (*evmTxAttemptBuilder)(nil) type evmTxAttemptBuilder struct { chainID big.Int @@ -48,7 +48,7 @@ func NewEvmTxAttemptBuilder(chainID big.Int, config evmTxAttemptBuilderConfig, f // NewTxAttempt builds an new attempt using the configured fee estimator + using the EIP1559 config to determine tx type // used for when a brand new transaction is being created in the txm -func (c *evmTxAttemptBuilder) NewTxAttempt(ctx context.Context, etx EvmTx, lggr logger.Logger, opts ...feetypes.Opt) (attempt EvmTxAttempt, fee gas.EvmFee, feeLimit uint32, retryable bool, err error) { +func (c *evmTxAttemptBuilder) NewTxAttempt(ctx context.Context, etx Tx, lggr logger.Logger, opts ...feetypes.Opt) (attempt TxAttempt, fee gas.EvmFee, feeLimit uint32, retryable bool, err error) { txType := 0x0 if c.feeConfig.EIP1559DynamicFees() { txType = 0x2 @@ -58,7 +58,7 @@ func (c *evmTxAttemptBuilder) NewTxAttempt(ctx context.Context, etx EvmTx, lggr // NewTxAttemptWithType builds a new attempt with a new fee estimation where the txType can be specified by the caller // used for L2 re-estimation on broadcasting (note EIP1559 must be disabled otherwise this will fail with mismatched fees + tx type) -func (c *evmTxAttemptBuilder) NewTxAttemptWithType(ctx context.Context, etx EvmTx, lggr logger.Logger, txType int, opts ...feetypes.Opt) (attempt EvmTxAttempt, fee gas.EvmFee, feeLimit uint32, retryable bool, err error) { +func (c *evmTxAttemptBuilder) NewTxAttemptWithType(ctx context.Context, etx Tx, lggr logger.Logger, txType int, opts ...feetypes.Opt) (attempt TxAttempt, fee gas.EvmFee, feeLimit uint32, retryable bool, err error) { keySpecificMaxGasPriceWei := c.config.KeySpecificMaxGasPriceWei(etx.FromAddress) fee, feeLimit, err = c.EvmFeeEstimator.GetFee(ctx, etx.EncodedPayload, etx.FeeLimit, keySpecificMaxGasPriceWei, opts...) if err != nil { @@ -71,7 +71,7 @@ func (c *evmTxAttemptBuilder) NewTxAttemptWithType(ctx context.Context, etx EvmT // NewBumpTxAttempt builds a new attempt with a bumped fee - based on the previous attempt tx type // used in the txm broadcaster + confirmer when tx ix rejected for too low fee or is not included in a timely manner -func (c *evmTxAttemptBuilder) NewBumpTxAttempt(ctx context.Context, etx EvmTx, previousAttempt EvmTxAttempt, priorAttempts []EvmTxAttempt, lggr logger.Logger) (attempt EvmTxAttempt, bumpedFee gas.EvmFee, bumpedFeeLimit uint32, retryable bool, err error) { +func (c *evmTxAttemptBuilder) NewBumpTxAttempt(ctx context.Context, etx Tx, previousAttempt TxAttempt, priorAttempts []TxAttempt, lggr logger.Logger) (attempt TxAttempt, bumpedFee gas.EvmFee, bumpedFeeLimit uint32, retryable bool, err error) { keySpecificMaxGasPriceWei := c.config.KeySpecificMaxGasPriceWei(etx.FromAddress) bumpedFee, bumpedFeeLimit, err = c.EvmFeeEstimator.BumpFee(ctx, previousAttempt.TxFee, etx.FeeLimit, keySpecificMaxGasPriceWei, newEvmPriorAttempts(priorAttempts)) @@ -85,7 +85,7 @@ func (c *evmTxAttemptBuilder) NewBumpTxAttempt(ctx context.Context, etx EvmTx, p // NewCustomTxAttempt is the lowest level func where the fee parameters + tx type must be passed in // used in the txm for force rebroadcast where fees and tx type are pre-determined without an estimator -func (c *evmTxAttemptBuilder) NewCustomTxAttempt(etx EvmTx, fee gas.EvmFee, gasLimit uint32, txType int, lggr logger.Logger) (attempt EvmTxAttempt, retryable bool, err error) { +func (c *evmTxAttemptBuilder) NewCustomTxAttempt(etx Tx, fee gas.EvmFee, gasLimit uint32, txType int, lggr logger.Logger) (attempt TxAttempt, retryable bool, err error) { switch txType { case 0x0: // legacy if fee.Legacy == nil { @@ -115,7 +115,7 @@ func (c *evmTxAttemptBuilder) NewCustomTxAttempt(etx EvmTx, fee gas.EvmFee, gasL } // NewEmptyTxAttempt is used in ForceRebroadcast to create a signed tx with zero value sent to the zero address -func (c *evmTxAttemptBuilder) NewEmptyTxAttempt(nonce evmtypes.Nonce, feeLimit uint32, fee gas.EvmFee, fromAddress common.Address) (attempt EvmTxAttempt, err error) { +func (c *evmTxAttemptBuilder) NewEmptyTxAttempt(nonce evmtypes.Nonce, feeLimit uint32, fee gas.EvmFee, fromAddress common.Address) (attempt TxAttempt, err error) { value := big.NewInt(0) payload := []byte{} @@ -136,7 +136,7 @@ func (c *evmTxAttemptBuilder) NewEmptyTxAttempt(nonce evmtypes.Nonce, feeLimit u } -func (c *evmTxAttemptBuilder) newDynamicFeeAttempt(etx EvmTx, fee gas.DynamicFee, gasLimit uint32) (attempt EvmTxAttempt, err error) { +func (c *evmTxAttemptBuilder) newDynamicFeeAttempt(etx Tx, fee gas.DynamicFee, gasLimit uint32) (attempt TxAttempt, err error) { if err = validateDynamicFeeGas(c.config, c.feeConfig.TipCapMin(), fee, gasLimit, etx); err != nil { return attempt, errors.Wrap(err, "error validating gas") } @@ -169,7 +169,7 @@ var Max256BitUInt = big.NewInt(0).Exp(big.NewInt(2), big.NewInt(256), nil) // validateDynamicFeeGas is a sanity check - we have other checks elsewhere, but this // makes sure we _never_ create an invalid attempt -func validateDynamicFeeGas(cfg evmTxAttemptBuilderConfig, tipCapMinimum *assets.Wei, fee gas.DynamicFee, gasLimit uint32, etx EvmTx) error { +func validateDynamicFeeGas(cfg evmTxAttemptBuilderConfig, tipCapMinimum *assets.Wei, fee gas.DynamicFee, gasLimit uint32, etx Tx) error { gasTipCap, gasFeeCap := fee.TipCap, fee.FeeCap if gasTipCap == nil { @@ -217,7 +217,7 @@ func newDynamicFeeTransaction(nonce uint64, to common.Address, value *big.Int, g } } -func (c *evmTxAttemptBuilder) newLegacyAttempt(etx EvmTx, gasPrice *assets.Wei, gasLimit uint32) (attempt EvmTxAttempt, err error) { +func (c *evmTxAttemptBuilder) newLegacyAttempt(etx Tx, gasPrice *assets.Wei, gasLimit uint32) (attempt TxAttempt, err error) { if err = validateLegacyGas(c.config, c.feeConfig.PriceMin(), gasPrice, gasLimit, etx); err != nil { return attempt, errors.Wrap(err, "error validating gas") } @@ -251,7 +251,7 @@ func (c *evmTxAttemptBuilder) newLegacyAttempt(etx EvmTx, gasPrice *assets.Wei, // validateLegacyGas is a sanity check - we have other checks elsewhere, but this // makes sure we _never_ create an invalid attempt -func validateLegacyGas(cfg evmTxAttemptBuilderConfig, minGasPriceWei, gasPrice *assets.Wei, gasLimit uint32, etx EvmTx) error { +func validateLegacyGas(cfg evmTxAttemptBuilderConfig, minGasPriceWei, gasPrice *assets.Wei, gasLimit uint32, etx Tx) error { if gasPrice == nil { panic("gas price missing") } @@ -266,7 +266,7 @@ func validateLegacyGas(cfg evmTxAttemptBuilderConfig, minGasPriceWei, gasPrice * return nil } -func (c *evmTxAttemptBuilder) newSignedAttempt(etx EvmTx, tx *types.Transaction) (attempt EvmTxAttempt, err error) { +func (c *evmTxAttemptBuilder) newSignedAttempt(etx Tx, tx *types.Transaction) (attempt TxAttempt, err error) { hash, signedTxBytes, err := c.SignTx(etx.FromAddress, tx) if err != nil { return attempt, errors.Wrapf(err, "error using account %s to sign transaction %v", etx.FromAddress.String(), etx.ID) @@ -305,7 +305,7 @@ func (c *evmTxAttemptBuilder) SignTx(address common.Address, tx *types.Transacti return txHash, rlp.Bytes(), nil } -func newEvmPriorAttempts(attempts []EvmTxAttempt) (prior []gas.EvmPriorAttempt) { +func newEvmPriorAttempts(attempts []TxAttempt) (prior []gas.EvmPriorAttempt) { for i := range attempts { priorAttempt := gas.EvmPriorAttempt{ ChainSpecificFeeLimit: attempts[i].ChainSpecificFeeLimit, diff --git a/core/chains/evm/txmgr/attempts_test.go b/core/chains/evm/txmgr/attempts_test.go index 0100afd872d..f2379daff6c 100644 --- a/core/chains/evm/txmgr/attempts_test.go +++ b/core/chains/evm/txmgr/attempts_test.go @@ -100,7 +100,7 @@ func TestTxm_NewDynamicFeeTx(t *testing.T) { cfg := evmtest.NewChainScopedConfig(t, gcfg) cks := txmgr.NewEvmTxAttemptBuilder(*big.NewInt(1), cfg.EVM(), newFeeConfig(), kst, nil) dynamicFee := gas.DynamicFee{TipCap: assets.GWei(100), FeeCap: assets.GWei(200)} - a, _, err := cks.NewCustomTxAttempt(txmgr.EvmTx{Sequence: &n, FromAddress: addr}, gas.EvmFee{ + a, _, err := cks.NewCustomTxAttempt(txmgr.Tx{Sequence: &n, FromAddress: addr}, gas.EvmFee{ DynamicTipCap: dynamicFee.TipCap, DynamicFeeCap: dynamicFee.FeeCap, }, 100, 0x2, lggr) @@ -142,7 +142,7 @@ func TestTxm_NewDynamicFeeTx(t *testing.T) { cfg := evmtest.NewChainScopedConfig(t, gcfg) cks := txmgr.NewEvmTxAttemptBuilder(*big.NewInt(1), cfg.EVM(), cfg.EVM().GasEstimator(), kst, nil) dynamicFee := gas.DynamicFee{TipCap: test.tipcap, FeeCap: test.feecap} - _, _, err := cks.NewCustomTxAttempt(txmgr.EvmTx{Sequence: &n, FromAddress: addr}, gas.EvmFee{ + _, _, err := cks.NewCustomTxAttempt(txmgr.Tx{Sequence: &n, FromAddress: addr}, gas.EvmFee{ DynamicTipCap: dynamicFee.TipCap, DynamicFeeCap: dynamicFee.FeeCap, }, 100, 0x2, lggr) @@ -172,7 +172,7 @@ func TestTxm_NewLegacyAttempt(t *testing.T) { t.Run("creates attempt with fields", func(t *testing.T) { var n evmtypes.Nonce - a, _, err := cks.NewCustomTxAttempt(txmgr.EvmTx{Sequence: &n, FromAddress: addr}, gas.EvmFee{Legacy: assets.NewWeiI(25)}, 100, 0x0, lggr) + a, _, err := cks.NewCustomTxAttempt(txmgr.Tx{Sequence: &n, FromAddress: addr}, gas.EvmFee{Legacy: assets.NewWeiI(25)}, 100, 0x0, lggr) require.NoError(t, err) assert.Equal(t, 100, int(a.ChainSpecificFeeLimit)) assert.NotNil(t, a.TxFee.Legacy) @@ -182,7 +182,7 @@ func TestTxm_NewLegacyAttempt(t *testing.T) { }) t.Run("verifies max gas price", func(t *testing.T) { - _, _, err := cks.NewCustomTxAttempt(txmgr.EvmTx{FromAddress: addr}, gas.EvmFee{Legacy: assets.NewWeiI(100)}, 100, 0x0, lggr) + _, _, err := cks.NewCustomTxAttempt(txmgr.Tx{FromAddress: addr}, gas.EvmFee{Legacy: assets.NewWeiI(100)}, 100, 0x0, lggr) require.Error(t, err) assert.Contains(t, err.Error(), fmt.Sprintf("specified gas price of 100 wei would exceed max configured gas price of 50 wei for key %s", addr.String())) }) @@ -200,7 +200,7 @@ func TestTxm_NewCustomTxAttempt_NonRetryableErrors(t *testing.T) { legacyFee := assets.NewWeiI(100) t.Run("dynamic fee with legacy tx type", func(t *testing.T) { - _, retryable, err := cks.NewCustomTxAttempt(txmgr.EvmTx{}, gas.EvmFee{ + _, retryable, err := cks.NewCustomTxAttempt(txmgr.Tx{}, gas.EvmFee{ DynamicTipCap: dynamicFee.TipCap, DynamicFeeCap: dynamicFee.FeeCap, }, 100, 0x0, lggr) @@ -208,13 +208,13 @@ func TestTxm_NewCustomTxAttempt_NonRetryableErrors(t *testing.T) { assert.False(t, retryable) }) t.Run("legacy fee with dynamic tx type", func(t *testing.T) { - _, retryable, err := cks.NewCustomTxAttempt(txmgr.EvmTx{}, gas.EvmFee{Legacy: legacyFee}, 100, 0x2, lggr) + _, retryable, err := cks.NewCustomTxAttempt(txmgr.Tx{}, gas.EvmFee{Legacy: legacyFee}, 100, 0x2, lggr) require.Error(t, err) assert.False(t, retryable) }) t.Run("invalid type", func(t *testing.T) { - _, retryable, err := cks.NewCustomTxAttempt(txmgr.EvmTx{}, gas.EvmFee{}, 100, 0xA, lggr) + _, retryable, err := cks.NewCustomTxAttempt(txmgr.Tx{}, gas.EvmFee{}, 100, 0xA, lggr) require.Error(t, err) assert.False(t, retryable) }) @@ -234,19 +234,19 @@ func TestTxm_EvmTxAttemptBuilder_RetryableEstimatorError(t *testing.T) { cks := txmgr.NewEvmTxAttemptBuilder(*big.NewInt(1), cfg, &feeConfig{eip1559DynamicFees: true}, kst, est) t.Run("NewAttempt", func(t *testing.T) { - _, _, _, retryable, err := cks.NewTxAttempt(ctx, txmgr.EvmTx{}, lggr) + _, _, _, retryable, err := cks.NewTxAttempt(ctx, txmgr.Tx{}, lggr) require.Error(t, err) assert.Contains(t, err.Error(), "failed to get fee") assert.True(t, retryable) }) t.Run("NewAttemptWithType", func(t *testing.T) { - _, _, _, retryable, err := cks.NewTxAttemptWithType(ctx, txmgr.EvmTx{}, lggr, 0x0) + _, _, _, retryable, err := cks.NewTxAttemptWithType(ctx, txmgr.Tx{}, lggr, 0x0) require.Error(t, err) assert.Contains(t, err.Error(), "failed to get fee") assert.True(t, retryable) }) t.Run("NewBumpAttempt", func(t *testing.T) { - _, _, _, retryable, err := cks.NewBumpTxAttempt(ctx, txmgr.EvmTx{}, txmgr.EvmTxAttempt{}, nil, lggr) + _, _, _, retryable, err := cks.NewBumpTxAttempt(ctx, txmgr.Tx{}, txmgr.TxAttempt{}, nil, lggr) require.Error(t, err) assert.Contains(t, err.Error(), "failed to bump fee") assert.True(t, retryable) diff --git a/core/chains/evm/txmgr/broadcaster_test.go b/core/chains/evm/txmgr/broadcaster_test.go index 5d90bad73d1..1ed95f2cf8e 100644 --- a/core/chains/evm/txmgr/broadcaster_test.go +++ b/core/chains/evm/txmgr/broadcaster_test.go @@ -56,9 +56,9 @@ func NewTestEthBroadcaster( ethClient evmclient.Client, keyStore keystore.Eth, config evmconfig.ChainScopedConfig, - checkerFactory txmgr.EvmTransmitCheckerFactory, + checkerFactory txmgr.TransmitCheckerFactory, nonceAutoSync bool, -) (*txmgr.EvmBroadcaster, error) { +) (*txmgr.Broadcaster, error) { t.Helper() eventBroadcaster := cltest.NewEventBroadcaster(t, config.Database().URL()) err := eventBroadcaster.Start(testutils.Context(t.(*testing.T))) @@ -181,7 +181,7 @@ func TestEthBroadcaster_ProcessUnstartedEthTxs_Success(t *testing.T) { nonce := evmtypes.Nonce(342) errStr := "some error" - etxUnconfirmed := txmgr.EvmTx{ + etxUnconfirmed := txmgr.Tx{ Sequence: &nonce, FromAddress: fromAddress, ToAddress: toAddress, @@ -193,7 +193,7 @@ func TestEthBroadcaster_ProcessUnstartedEthTxs_Success(t *testing.T) { Error: null.String{}, State: txmgrcommon.TxUnconfirmed, } - etxWithError := txmgr.EvmTx{ + etxWithError := txmgr.Tx{ Sequence: nil, FromAddress: fromAddress, ToAddress: toAddress, @@ -214,7 +214,7 @@ func TestEthBroadcaster_ProcessUnstartedEthTxs_Success(t *testing.T) { t.Run("sends 3 EthTxs in order with higher value last, and lower values starting from the earliest", func(t *testing.T) { // Higher value - expensiveEthTx := txmgr.EvmTx{ + expensiveEthTx := txmgr.Tx{ FromAddress: fromAddress, ToAddress: toAddress, EncodedPayload: []byte{42, 42, 0}, @@ -229,10 +229,10 @@ func TestEthBroadcaster_ProcessUnstartedEthTxs_Success(t *testing.T) { // Earlier tr := int32(99) - b, err := json.Marshal(txmgr.EvmTxMeta{JobID: &tr}) + b, err := json.Marshal(txmgr.TxMeta{JobID: &tr}) require.NoError(t, err) meta := datatypes.JSON(b) - earlierEthTx := txmgr.EvmTx{ + earlierEthTx := txmgr.Tx{ FromAddress: fromAddress, ToAddress: toAddress, EncodedPayload: []byte{42, 42, 0}, @@ -256,7 +256,7 @@ func TestEthBroadcaster_ProcessUnstartedEthTxs_Success(t *testing.T) { }), fromAddress).Return(clienttypes.Successful, nil).Once() // Later - laterEthTx := txmgr.EvmTx{ + laterEthTx := txmgr.Tx{ FromAddress: fromAddress, ToAddress: toAddress, EncodedPayload: []byte{42, 42, 1}, @@ -300,7 +300,7 @@ func TestEthBroadcaster_ProcessUnstartedEthTxs_Success(t *testing.T) { assert.NotNil(t, earlierTransaction.BroadcastAt) assert.NotNil(t, earlierTransaction.InitialBroadcastAt) assert.Len(t, earlierTransaction.TxAttempts, 1) - var m txmgr.EvmTxMeta + var m txmgr.TxMeta err = json.Unmarshal(*earlierEthTx.Meta, &m) require.NoError(t, err) assert.NotNil(t, m.JobID) @@ -395,7 +395,7 @@ func TestEthBroadcaster_ProcessUnstartedEthTxs_Success(t *testing.T) { t.Run("transaction simulation", func(t *testing.T) { t.Run("when simulation succeeds, sends tx as normal", func(t *testing.T) { - txRequest := txmgr.EvmTxRequest{ + txRequest := txmgr.TxRequest{ FromAddress: fromAddress, ToAddress: toAddress, EncodedPayload: []byte{42, 0, 0}, @@ -656,7 +656,7 @@ func TestEthBroadcaster_ProcessUnstartedEthTxs_Success_WithMultiplier(t *testing return true }), fromAddress).Return(clienttypes.Successful, nil).Once() - txRequest := txmgr.EvmTxRequest{ + txRequest := txmgr.TxRequest{ FromAddress: fromAddress, ToAddress: gethCommon.HexToAddress("0x6C03DDA95a2AEd917EeCc6eddD4b9D16E6380411"), EncodedPayload: []byte{42, 42, 0}, @@ -692,7 +692,7 @@ func TestEthBroadcaster_ProcessUnstartedEthTxs_ResumingFromCrash(t *testing.T) { ethKeyStore := cltest.NewKeyStore(t, db, cfg.Database()).Eth() _, fromAddress := cltest.MustInsertRandomKeyReturningState(t, ethKeyStore, nextNonce) - firstInProgress := txmgr.EvmTx{ + firstInProgress := txmgr.Tx{ FromAddress: fromAddress, Sequence: &firstNonce, ToAddress: toAddress, @@ -703,7 +703,7 @@ func TestEthBroadcaster_ProcessUnstartedEthTxs_ResumingFromCrash(t *testing.T) { State: txmgrcommon.TxInProgress, } - secondInProgress := txmgr.EvmTx{ + secondInProgress := txmgr.Tx{ FromAddress: fromAddress, Sequence: &secondNonce, ToAddress: toAddress, @@ -1018,7 +1018,7 @@ func TestEthBroadcaster_ProcessUnstartedEthTxs_Errors(t *testing.T) { // Check that the transaction was saved correctly with its attempt // We assume success and hand off to eth confirmer to eventually mark it as failed var latestID int64 - var etx1 txmgr.EvmTx + var etx1 txmgr.Tx require.NoError(t, db.Get(&latestID, "SELECT max(id) FROM eth_txes")) etx1, err = txStore.FindTxWithAttempts(latestID) require.NoError(t, err) @@ -1077,7 +1077,7 @@ func TestEthBroadcaster_ProcessUnstartedEthTxs_Errors(t *testing.T) { t.Run("with callback", func(t *testing.T) { run := cltest.MustInsertPipelineRun(t, db) tr := cltest.MustInsertUnfinishedPipelineTaskRun(t, db, run.ID) - etx := txmgr.EvmTx{ + etx := txmgr.Tx{ FromAddress: fromAddress, ToAddress: toAddress, EncodedPayload: encodedPayload, @@ -1392,7 +1392,7 @@ func TestEthBroadcaster_ProcessUnstartedEthTxs_Errors(t *testing.T) { assert.Equal(t, "30 gwei", attempt.TxFee.Legacy.String()) }) - etxUnfinished := txmgr.EvmTx{ + etxUnfinished := txmgr.Tx{ FromAddress: fromAddress, ToAddress: toAddress, EncodedPayload: encodedPayload, @@ -1892,8 +1892,8 @@ type testChecker struct { func (t *testChecker) Check( _ context.Context, _ logger.Logger, - _ txmgr.EvmTx, - _ txmgr.EvmTxAttempt, + _ txmgr.Tx, + _ txmgr.TxAttempt, ) error { return t.err } diff --git a/core/chains/evm/txmgr/builder.go b/core/chains/evm/txmgr/builder.go index a0b110f08a7..6cd29f9f7a9 100644 --- a/core/chains/evm/txmgr/builder.go +++ b/core/chains/evm/txmgr/builder.go @@ -33,10 +33,10 @@ func NewTxm( keyStore keystore.Eth, eventBroadcaster pg.EventBroadcaster, estimator gas.EvmFeeEstimator, -) (txm EvmTxManager, +) (txm TxManager, err error, ) { - var fwdMgr EvmFwdMgr + var fwdMgr FwdMgr if txConfig.ForwardersEnabled() { fwdMgr = forwarders.NewFwdMgr(db, client, logPoller, lggr, chainConfig, dbConfig) @@ -54,7 +54,7 @@ func NewTxm( txmClient := NewEvmTxmClient(client) // wrap Evm specific client ethBroadcaster := NewEvmBroadcaster(txStore, txmClient, txmCfg, feeCfg, txConfig, listenerConfig, keyStore, eventBroadcaster, txAttemptBuilder, txNonceSyncer, lggr, checker, chainConfig.NonceAutoSync()) ethConfirmer := NewEvmConfirmer(txStore, txmClient, txmCfg, feeCfg, txConfig, dbConfig, keyStore, txAttemptBuilder, lggr) - var ethResender *EvmResender + var ethResender *Resender if txConfig.ResendAfterThreshold() > 0 { ethResender = NewEvmResender(lggr, txStore, txmClient, keyStore, txmgr.DefaultResenderPollInterval, chainConfig, txConfig) } @@ -67,17 +67,17 @@ func NewEvmTxm( chainId *big.Int, cfg txmgrtypes.TransactionManagerChainConfig, txCfg txmgrtypes.TransactionManagerTransactionsConfig, - keyStore EvmKeyStore, + keyStore KeyStore, lggr logger.Logger, - checkerFactory EvmTransmitCheckerFactory, - fwdMgr EvmFwdMgr, - txAttemptBuilder EvmTxAttemptBuilder, + checkerFactory TransmitCheckerFactory, + fwdMgr FwdMgr, + txAttemptBuilder TxAttemptBuilder, txStore TxStore, - nonceSyncer EvmNonceSyncer, - broadcaster *EvmBroadcaster, - confirmer *EvmConfirmer, - resender *EvmResender, -) *EvmTxm { + nonceSyncer NonceSyncer, + broadcaster *Broadcaster, + confirmer *Confirmer, + resender *Resender, +) *Txm { return txmgr.NewTxm(chainId, cfg, txCfg, keyStore, lggr, checkerFactory, fwdMgr, txAttemptBuilder, txStore, nonceSyncer, broadcaster, confirmer, resender) } @@ -86,31 +86,31 @@ func NewEvmResender( lggr logger.Logger, txStore TransactionStore, client TransactionClient, - ks EvmKeyStore, + ks KeyStore, pollInterval time.Duration, config EvmResenderConfig, txConfig txmgrtypes.ResenderTransactionsConfig, -) *EvmResender { +) *Resender { return txmgr.NewResender(lggr, txStore, client, ks, pollInterval, config, txConfig) } // NewEvmReaper instantiates a new EVM-specific reaper object -func NewEvmReaper(lggr logger.Logger, store txmgrtypes.TxHistoryReaper[*big.Int], config EvmReaperConfig, txConfig txmgrtypes.ReaperTransactionsConfig, chainID *big.Int) *EvmReaper { +func NewEvmReaper(lggr logger.Logger, store txmgrtypes.TxHistoryReaper[*big.Int], config EvmReaperConfig, txConfig txmgrtypes.ReaperTransactionsConfig, chainID *big.Int) *Reaper { return txmgr.NewReaper(lggr, store, config, txConfig, chainID) } // NewEvmConfirmer instantiates a new EVM confirmer func NewEvmConfirmer( txStore TxStore, - client EvmTxmClient, + client TxmClient, chainConfig txmgrtypes.ConfirmerChainConfig, feeConfig txmgrtypes.ConfirmerFeeConfig, txConfig txmgrtypes.ConfirmerTransactionsConfig, dbConfig txmgrtypes.ConfirmerDatabaseConfig, - keystore EvmKeyStore, - txAttemptBuilder EvmTxAttemptBuilder, + keystore KeyStore, + txAttemptBuilder TxAttemptBuilder, lggr logger.Logger, -) *EvmConfirmer { +) *Confirmer { return txmgr.NewConfirmer(txStore, client, chainConfig, feeConfig, txConfig, dbConfig, keystore, txAttemptBuilder, lggr, func(r *evmtypes.Receipt) bool { return r == nil }) } @@ -122,13 +122,13 @@ func NewEvmBroadcaster( feeConfig txmgrtypes.BroadcasterFeeConfig, txConfig txmgrtypes.BroadcasterTransactionsConfig, listenerConfig txmgrtypes.BroadcasterListenerConfig, - keystore EvmKeyStore, + keystore KeyStore, eventBroadcaster pg.EventBroadcaster, - txAttemptBuilder EvmTxAttemptBuilder, - nonceSyncer EvmNonceSyncer, + txAttemptBuilder TxAttemptBuilder, + nonceSyncer NonceSyncer, logger logger.Logger, - checkerFactory EvmTransmitCheckerFactory, + checkerFactory TransmitCheckerFactory, autoSyncNonce bool, -) *EvmBroadcaster { +) *Broadcaster { return txmgr.NewBroadcaster(txStore, client, chainConfig, feeConfig, txConfig, listenerConfig, keystore, eventBroadcaster, txAttemptBuilder, nonceSyncer, logger, checkerFactory, autoSyncNonce, stringToGethAddress) } diff --git a/core/chains/evm/txmgr/client.go b/core/chains/evm/txmgr/client.go index b197803714c..ad18a2eeee4 100644 --- a/core/chains/evm/txmgr/client.go +++ b/core/chains/evm/txmgr/client.go @@ -21,7 +21,7 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/utils" ) -var _ EvmTxmClient = (*evmTxmClient)(nil) +var _ TxmClient = (*evmTxmClient)(nil) type evmTxmClient struct { client evmclient.Client @@ -39,7 +39,7 @@ func (c *evmTxmClient) ConfiguredChainID() *big.Int { return c.client.ConfiguredChainID() } -func (c *evmTxmClient) BatchSendTransactions(ctx context.Context, updateBroadcastTime func(now time.Time, txIDs []int64) error, attempts []EvmTxAttempt, batchSize int, lggr logger.Logger) (codes []clienttypes.SendTxReturnCode, txErrs []error, err error) { +func (c *evmTxmClient) BatchSendTransactions(ctx context.Context, updateBroadcastTime func(now time.Time, txIDs []int64) error, attempts []TxAttempt, batchSize int, lggr logger.Logger) (codes []clienttypes.SendTxReturnCode, txErrs []error, err error) { // preallocate codes = make([]clienttypes.SendTxReturnCode, len(attempts)) txErrs = make([]error, len(attempts)) @@ -77,7 +77,7 @@ func (c *evmTxmClient) BatchSendTransactions(ctx context.Context, updateBroadcas return } -func (c *evmTxmClient) SendTransactionReturnCode(ctx context.Context, etx EvmTx, attempt EvmTxAttempt, lggr logger.Logger) (clienttypes.SendTxReturnCode, error) { +func (c *evmTxmClient) SendTransactionReturnCode(ctx context.Context, etx Tx, attempt TxAttempt, lggr logger.Logger) (clienttypes.SendTxReturnCode, error) { signedTx, err := GetGethSignedTx(attempt.SignedRawTx) if err != nil { lggr.Criticalw("Fatal error signing transaction", "err", err, "etx", etx) @@ -102,7 +102,7 @@ func (c *evmTxmClient) SequenceAt(ctx context.Context, addr common.Address, bloc return c.client.SequenceAt(ctx, addr, blockNum) } -func (c *evmTxmClient) BatchGetReceipts(ctx context.Context, attempts []EvmTxAttempt) (txReceipt []*evmtypes.Receipt, txErr []error, funcErr error) { +func (c *evmTxmClient) BatchGetReceipts(ctx context.Context, attempts []TxAttempt) (txReceipt []*evmtypes.Receipt, txErr []error, funcErr error) { var reqs []rpc.BatchElem for _, attempt := range attempts { res := &evmtypes.Receipt{} @@ -129,7 +129,7 @@ func (c *evmTxmClient) BatchGetReceipts(ctx context.Context, attempts []EvmTxAtt // May be useful for clearing stuck nonces func (c *evmTxmClient) SendEmptyTransaction( ctx context.Context, - newTxAttempt func(seq evmtypes.Nonce, feeLimit uint32, fee gas.EvmFee, fromAddress common.Address) (attempt EvmTxAttempt, err error), + newTxAttempt func(seq evmtypes.Nonce, feeLimit uint32, fee gas.EvmFee, fromAddress common.Address) (attempt TxAttempt, err error), seq evmtypes.Nonce, gasLimit uint32, fee gas.EvmFee, @@ -151,7 +151,7 @@ func (c *evmTxmClient) SendEmptyTransaction( return signedTx.Hash().String(), err } -func (c *evmTxmClient) CallContract(ctx context.Context, a EvmTxAttempt, blockNumber *big.Int) (rpcErr fmt.Stringer, extractErr error) { +func (c *evmTxmClient) CallContract(ctx context.Context, a TxAttempt, blockNumber *big.Int) (rpcErr fmt.Stringer, extractErr error) { _, errCall := c.client.CallContract(ctx, ethereum.CallMsg{ From: a.Tx.FromAddress, To: &a.Tx.ToAddress, diff --git a/core/chains/evm/txmgr/common.go b/core/chains/evm/txmgr/common.go index 67f54c7ca02..80d95fb5caf 100644 --- a/core/chains/evm/txmgr/common.go +++ b/core/chains/evm/txmgr/common.go @@ -20,7 +20,7 @@ import ( func batchSendTransactions( ctx context.Context, updateBroadcastTime func(now time.Time, txIDs []int64) error, - attempts []EvmTxAttempt, + attempts []TxAttempt, batchSize int, logger logger.Logger, ethClient evmclient.Client) ([]rpc.BatchElem, error) { diff --git a/core/chains/evm/txmgr/confirmer_test.go b/core/chains/evm/txmgr/confirmer_test.go index 16475181dd4..b324da83387 100644 --- a/core/chains/evm/txmgr/confirmer_test.go +++ b/core/chains/evm/txmgr/confirmer_test.go @@ -46,7 +46,7 @@ func newTestChainScopedConfig(t *testing.T) evmconfig.ChainScopedConfig { return evmtest.NewChainScopedConfig(t, cfg) } -func newBroadcastLegacyEthTxAttempt(t *testing.T, etxID int64, gasPrice ...int64) txmgr.EvmTxAttempt { +func newBroadcastLegacyEthTxAttempt(t *testing.T, etxID int64, gasPrice ...int64) txmgr.TxAttempt { attempt := cltest.NewLegacyEthTxAttempt(t, etxID) attempt.State = txmgrtypes.TxAttemptBroadcast if len(gasPrice) > 0 { @@ -56,7 +56,7 @@ func newBroadcastLegacyEthTxAttempt(t *testing.T, etxID int64, gasPrice ...int64 return attempt } -func mustTxBeInState(t *testing.T, txStore txmgr.TestEvmTxStore, tx txmgr.EvmTx, expectedState txmgrtypes.TxState) { +func mustTxBeInState(t *testing.T, txStore txmgr.TestEvmTxStore, tx txmgr.Tx, expectedState txmgrtypes.TxState) { etx, err := txStore.FindTxWithAttempts(tx.ID) require.NoError(t, err) require.Equal(t, expectedState, etx.State) @@ -72,7 +72,7 @@ func newTxReceipt(hash gethCommon.Hash, blockNumber int, txIndex uint) evmtypes. } } -func newInProgressLegacyEthTxAttempt(t *testing.T, etxID int64, gasPrice ...int64) txmgr.EvmTxAttempt { +func newInProgressLegacyEthTxAttempt(t *testing.T, etxID int64, gasPrice ...int64) txmgr.TxAttempt { attempt := cltest.NewLegacyEthTxAttempt(t, etxID) attempt.State = txmgrtypes.TxAttemptInProgress if len(gasPrice) > 0 { @@ -82,7 +82,7 @@ func newInProgressLegacyEthTxAttempt(t *testing.T, etxID int64, gasPrice ...int6 return attempt } -func mustInsertInProgressEthTx(t *testing.T, txStore txmgr.TestEvmTxStore, nonce int64, fromAddress gethCommon.Address) txmgr.EvmTx { +func mustInsertInProgressEthTx(t *testing.T, txStore txmgr.TestEvmTxStore, nonce int64, fromAddress gethCommon.Address) txmgr.Tx { etx := cltest.NewEthTx(t, fromAddress) etx.State = txmgrcommon.TxInProgress n := evmtypes.Nonce(nonce) @@ -92,7 +92,7 @@ func mustInsertInProgressEthTx(t *testing.T, txStore txmgr.TestEvmTxStore, nonce return etx } -func mustInsertConfirmedEthTx(t *testing.T, txStore txmgr.TestEvmTxStore, nonce int64, fromAddress gethCommon.Address) txmgr.EvmTx { +func mustInsertConfirmedEthTx(t *testing.T, txStore txmgr.TestEvmTxStore, nonce int64, fromAddress gethCommon.Address) txmgr.Tx { etx := cltest.NewEthTx(t, fromAddress) etx.State = txmgrcommon.TxConfirmed n := evmtypes.Nonce(nonce) @@ -610,7 +610,7 @@ func TestEthConfirmer_CheckForReceipts_batching(t *testing.T) { ctx := testutils.Context(t) etx := cltest.MustInsertUnconfirmedEthTx(t, txStore, 0, fromAddress) - var attempts []txmgr.EvmTxAttempt + var attempts []txmgr.TxAttempt // Total of 5 attempts should lead to 3 batched fetches (2, 2, 1) for i := 0; i < 5; i++ { @@ -725,7 +725,7 @@ func TestEthConfirmer_CheckForReceipts_only_likely_confirmed(t *testing.T) { ctx := testutils.Context(t) - var attempts []txmgr.EvmTxAttempt + var attempts []txmgr.TxAttempt // inserting in DESC nonce order to test DB ASC ordering etx2 := cltest.MustInsertUnconfirmedEthTx(t, txStore, 1, fromAddress) for i := 0; i < 4; i++ { @@ -1842,7 +1842,7 @@ func TestEthConfirmer_RebroadcastWhereNecessary(t *testing.T) { require.Equal(t, etx.InitialBroadcastAt.Unix(), originalBroadcastAt.Unix()) }) - var attempt1_2 txmgr.EvmTxAttempt + var attempt1_2 txmgr.TxAttempt ethClient = evmtest.NewEthClientMockWithDefaultChain(t) ec.XXXTestSetClient(txmgr.NewEvmTxmClient(ethClient)) @@ -1892,7 +1892,7 @@ func TestEthConfirmer_RebroadcastWhereNecessary(t *testing.T) { require.Len(t, etx.TxAttempts, 2) }) require.NoError(t, db.Get(&dbAttempt, `UPDATE eth_tx_attempts SET broadcast_before_block_num=$1 WHERE id=$2 RETURNING *`, oldEnough, attempt1_2.ID)) - var attempt1_3 txmgr.EvmTxAttempt + var attempt1_3 txmgr.TxAttempt t.Run("creates new attempt with higher gas price if transaction is already in mempool (e.g. due to previous crash before we could save the new attempt)", func(t *testing.T) { expectedBumpedGasPrice := big.NewInt(25000000000) @@ -1930,7 +1930,7 @@ func TestEthConfirmer_RebroadcastWhereNecessary(t *testing.T) { }) require.NoError(t, db.Get(&dbAttempt, `UPDATE eth_tx_attempts SET broadcast_before_block_num=$1 WHERE id=$2 RETURNING *`, oldEnough, attempt1_3.ID)) - var attempt1_4 txmgr.EvmTxAttempt + var attempt1_4 txmgr.TxAttempt t.Run("saves new attempt even for transaction that has already been confirmed (nonce already used)", func(t *testing.T) { expectedBumpedGasPrice := big.NewInt(30000000000) @@ -1983,7 +1983,7 @@ func TestEthConfirmer_RebroadcastWhereNecessary(t *testing.T) { nonce++ attempt2_1 := etx2.TxAttempts[0] require.NoError(t, db.Get(&dbAttempt, `UPDATE eth_tx_attempts SET broadcast_before_block_num=$1 WHERE id=$2 RETURNING *`, oldEnough, attempt2_1.ID)) - var attempt2_2 txmgr.EvmTxAttempt + var attempt2_2 txmgr.TxAttempt t.Run("saves in_progress attempt on temporary error and returns error", func(t *testing.T) { expectedBumpedGasPrice := big.NewInt(20000000000) @@ -2091,7 +2091,7 @@ func TestEthConfirmer_RebroadcastWhereNecessary(t *testing.T) { attempt3_1 := etx3.TxAttempts[0] require.NoError(t, db.Get(&dbAttempt, `UPDATE eth_tx_attempts SET broadcast_before_block_num=$1, gas_price=$2 WHERE id=$3 RETURNING *`, oldEnough, assets.NewWeiI(35000000000), attempt3_1.ID)) - var attempt3_2 txmgr.EvmTxAttempt + var attempt3_2 txmgr.TxAttempt t.Run("saves attempt anyway if replacement transaction is underpriced because the bumped gas price is insufficiently higher than the previous one", func(t *testing.T) { expectedBumpedGasPrice := big.NewInt(42000000000) @@ -2128,7 +2128,7 @@ func TestEthConfirmer_RebroadcastWhereNecessary(t *testing.T) { }) require.NoError(t, db.Get(&dbAttempt, `UPDATE eth_tx_attempts SET broadcast_before_block_num=$1 WHERE id=$2 RETURNING *`, oldEnough, attempt3_2.ID)) - var attempt3_3 txmgr.EvmTxAttempt + var attempt3_3 txmgr.TxAttempt t.Run("handles case where transaction is already known somehow", func(t *testing.T) { expectedBumpedGasPrice := big.NewInt(50400000000) @@ -2163,7 +2163,7 @@ func TestEthConfirmer_RebroadcastWhereNecessary(t *testing.T) { }) require.NoError(t, db.Get(&dbAttempt, `UPDATE eth_tx_attempts SET broadcast_before_block_num=$1 WHERE id=$2 RETURNING *`, oldEnough, attempt3_3.ID)) - var attempt3_4 txmgr.EvmTxAttempt + var attempt3_4 txmgr.TxAttempt t.Run("pretends it was accepted and continues the cycle if rejected for being temporarily underpriced", func(t *testing.T) { // This happens if parity is rejecting transactions that are not priced high enough to even get into the mempool at all @@ -2258,7 +2258,7 @@ func TestEthConfirmer_RebroadcastWhereNecessary(t *testing.T) { attempt4_1 := etx4.TxAttempts[0] require.NoError(t, db.Get(&dbAttempt, `UPDATE eth_tx_attempts SET broadcast_before_block_num=$1, gas_tip_cap=$2, gas_fee_cap=$3 WHERE id=$4 RETURNING *`, oldEnough, assets.GWei(35), assets.GWei(100), attempt4_1.ID)) - var attempt4_2 txmgr.EvmTxAttempt + var attempt4_2 txmgr.TxAttempt t.Run("EIP-1559: bumps using EIP-1559 rules when existing attempts are of type 0x2", func(t *testing.T) { config.EVM[0].GasEstimator.PriceMax = (*assets.Wei)(assets.GWei(1000)) @@ -2503,7 +2503,7 @@ func TestEthConfirmer_RebroadcastWhereNecessary_WhenOutOfEth(t *testing.T) { attempt1_1 := etx.TxAttempts[0] dbAttempt := txmgr.DbEthTxAttemptFromEthTxAttempt(&attempt1_1) require.NoError(t, db.Get(&dbAttempt, `UPDATE eth_tx_attempts SET broadcast_before_block_num=$1 WHERE id=$2 RETURNING *`, oldEnough, attempt1_1.ID)) - var attempt1_2 txmgr.EvmTxAttempt + var attempt1_2 txmgr.TxAttempt insufficientEthError := errors.New("insufficient funds for gas * price + value") diff --git a/core/chains/evm/txmgr/evm_tx_store.go b/core/chains/evm/txmgr/evm_tx_store.go index f8c75ddd536..e8c94a61707 100644 --- a/core/chains/evm/txmgr/evm_tx_store.go +++ b/core/chains/evm/txmgr/evm_tx_store.go @@ -51,12 +51,12 @@ type EvmTxStore interface { // TxStoreWebApi encapsulates the methods that are not used by the txmgr and only used by the various web controllers and readers type TxStoreWebApi interface { - FindTxAttemptConfirmedByTxIDs(ids []int64) ([]EvmTxAttempt, error) - FindTxByHash(hash common.Hash) (*EvmTx, error) - Transactions(offset, limit int) ([]EvmTx, int, error) - TxAttempts(offset, limit int) ([]EvmTxAttempt, int, error) - TransactionsWithAttempts(offset, limit int) ([]EvmTx, int, error) - FindTxAttempt(hash common.Hash) (*EvmTxAttempt, error) + FindTxAttemptConfirmedByTxIDs(ids []int64) ([]TxAttempt, error) + FindTxByHash(hash common.Hash) (*Tx, error) + Transactions(offset, limit int) ([]Tx, int, error) + TxAttempts(offset, limit int) ([]TxAttempt, int, error) + TransactionsWithAttempts(offset, limit int) ([]Tx, int, error) + FindTxAttempt(hash common.Hash) (*TxAttempt, error) } type TestEvmTxStore interface { @@ -64,11 +64,11 @@ type TestEvmTxStore interface { // methods only used for testing purposes InsertReceipt(receipt *evmtypes.Receipt) (int64, error) - InsertTx(etx *EvmTx) error - FindTxAttemptsByTxIDs(ids []int64) ([]EvmTxAttempt, error) - FindTxWithAttempts(etxID int64) (etx EvmTx, err error) - InsertTxAttempt(attempt *EvmTxAttempt) error - LoadTxesAttempts(etxs []*EvmTx, qopts ...pg.QOpt) error + InsertTx(etx *Tx) error + FindTxAttemptsByTxIDs(ids []int64) ([]TxAttempt, error) + FindTxWithAttempts(etxID int64) (etx Tx, err error) + InsertTxAttempt(attempt *TxAttempt) error + LoadTxesAttempts(etxs []*Tx, qopts ...pg.QOpt) error } type evmTxStore struct { @@ -128,10 +128,10 @@ func fromDBReceipts(rs []dbReceipt) []*evmtypes.Receipt { return receipts } -func fromDBReceiptsPlus(rs []dbReceiptPlus) []EvmReceiptPlus { - receipts := make([]EvmReceiptPlus, len(rs)) +func fromDBReceiptsPlus(rs []dbReceiptPlus) []ReceiptPlus { + receipts := make([]ReceiptPlus, len(rs)) for i := 0; i < len(rs); i++ { - receipts[i] = EvmReceiptPlus{ + receipts[i] = ReceiptPlus{ ID: rs[i].ID, Receipt: &rs[i].Receipt, FailOnRevert: rs[i].FailOnRevert, @@ -181,7 +181,7 @@ type DbEthTx struct { InitialBroadcastAt *time.Time } -func DbEthTxFromEthTx(ethTx *EvmTx) DbEthTx { +func DbEthTxFromEthTx(ethTx *Tx) DbEthTx { tx := DbEthTx{ ID: ethTx.ID, FromAddress: ethTx.FromAddress, @@ -212,7 +212,7 @@ func DbEthTxFromEthTx(ethTx *EvmTx) DbEthTx { return tx } -func DbEthTxToEthTx(dbEthTx DbEthTx, evmEthTx *EvmTx) { +func DbEthTxToEthTx(dbEthTx DbEthTx, evmEthTx *Tx) { evmEthTx.ID = dbEthTx.ID if dbEthTx.Nonce != nil { n := evmtypes.Nonce(*dbEthTx.Nonce) @@ -236,17 +236,17 @@ func DbEthTxToEthTx(dbEthTx DbEthTx, evmEthTx *EvmTx) { evmEthTx.InitialBroadcastAt = dbEthTx.InitialBroadcastAt } -func dbEthTxsToEvmEthTxs(dbEthTxs []DbEthTx) []EvmTx { - evmEthTxs := make([]EvmTx, len(dbEthTxs)) +func dbEthTxsToEvmEthTxs(dbEthTxs []DbEthTx) []Tx { + evmEthTxs := make([]Tx, len(dbEthTxs)) for i, dbTx := range dbEthTxs { DbEthTxToEthTx(dbTx, &evmEthTxs[i]) } return evmEthTxs } -func dbEthTxsToEvmEthTxPtrs(dbEthTxs []DbEthTx, evmEthTxs []*EvmTx) { +func dbEthTxsToEvmEthTxPtrs(dbEthTxs []DbEthTx, evmEthTxs []*Tx) { for i, dbTx := range dbEthTxs { - evmEthTxs[i] = &EvmTx{} + evmEthTxs[i] = &Tx{} DbEthTxToEthTx(dbTx, evmEthTxs[i]) } } @@ -268,7 +268,7 @@ type DbEthTxAttempt struct { GasFeeCap *assets.Wei } -func DbEthTxAttemptFromEthTxAttempt(ethTxAttempt *EvmTxAttempt) DbEthTxAttempt { +func DbEthTxAttemptFromEthTxAttempt(ethTxAttempt *TxAttempt) DbEthTxAttempt { return DbEthTxAttempt{ ID: ethTxAttempt.ID, EthTxID: ethTxAttempt.TxID, @@ -285,7 +285,7 @@ func DbEthTxAttemptFromEthTxAttempt(ethTxAttempt *EvmTxAttempt) DbEthTxAttempt { } } -func DbEthTxAttemptToEthTxAttempt(dbEthTxAttempt DbEthTxAttempt, evmAttempt *EvmTxAttempt) { +func DbEthTxAttemptToEthTxAttempt(dbEthTxAttempt DbEthTxAttempt, evmAttempt *TxAttempt) { evmAttempt.ID = dbEthTxAttempt.ID evmAttempt.TxID = dbEthTxAttempt.EthTxID evmAttempt.SignedRawTx = dbEthTxAttempt.SignedRawTx @@ -302,8 +302,8 @@ func DbEthTxAttemptToEthTxAttempt(dbEthTxAttempt DbEthTxAttempt, evmAttempt *Evm } } -func dbEthTxAttemptsToEthTxAttempts(dbEthTxAttempt []DbEthTxAttempt) []EvmTxAttempt { - evmEthTxAttempt := make([]EvmTxAttempt, len(dbEthTxAttempt)) +func dbEthTxAttemptsToEthTxAttempts(dbEthTxAttempt []DbEthTxAttempt) []TxAttempt { + evmEthTxAttempt := make([]TxAttempt, len(dbEthTxAttempt)) for i, dbTxAttempt := range dbEthTxAttempt { DbEthTxAttemptToEthTxAttempt(dbTxAttempt, &evmEthTxAttempt[i]) } @@ -338,7 +338,7 @@ func (o *evmTxStore) Close() { o.ctxCancel() } -func (o *evmTxStore) preloadTxAttempts(txs []EvmTx) error { +func (o *evmTxStore) preloadTxAttempts(txs []Tx) error { // Preload TxAttempts var ids []int64 for _, tx := range txs { @@ -361,7 +361,7 @@ func (o *evmTxStore) preloadTxAttempts(txs []EvmTx) error { for _, dbAttempt := range dbAttempts { for i, tx := range txs { if tx.ID == dbAttempt.EthTxID { - var attempt EvmTxAttempt + var attempt TxAttempt DbEthTxAttemptToEthTxAttempt(dbAttempt, &attempt) txs[i].TxAttempts = append(txs[i].TxAttempts, attempt) } @@ -370,10 +370,10 @@ func (o *evmTxStore) preloadTxAttempts(txs []EvmTx) error { return nil } -func (o *evmTxStore) PreloadTxes(attempts []EvmTxAttempt, qopts ...pg.QOpt) error { - ethTxM := make(map[int64]EvmTx) +func (o *evmTxStore) PreloadTxes(attempts []TxAttempt, qopts ...pg.QOpt) error { + ethTxM := make(map[int64]Tx) for _, attempt := range attempts { - ethTxM[attempt.TxID] = EvmTx{} + ethTxM[attempt.TxID] = Tx{} } ethTxIDs := make([]int64, len(ethTxM)) var i int @@ -399,7 +399,7 @@ func (o *evmTxStore) PreloadTxes(attempts []EvmTxAttempt, qopts ...pg.QOpt) erro // Transactions returns all eth transactions without loaded relations // limited by passed parameters. -func (o *evmTxStore) Transactions(offset, limit int) (txs []EvmTx, count int, err error) { +func (o *evmTxStore) Transactions(offset, limit int) (txs []Tx, count int, err error) { sql := `SELECT count(*) FROM eth_txes WHERE id IN (SELECT DISTINCT eth_tx_id FROM eth_tx_attempts)` if err = o.q.Get(&count, sql); err != nil { return @@ -416,7 +416,7 @@ func (o *evmTxStore) Transactions(offset, limit int) (txs []EvmTx, count int, er // TransactionsWithAttempts returns all eth transactions with at least one attempt // limited by passed parameters. Attempts are sorted by id. -func (o *evmTxStore) TransactionsWithAttempts(offset, limit int) (txs []EvmTx, count int, err error) { +func (o *evmTxStore) TransactionsWithAttempts(offset, limit int) (txs []Tx, count int, err error) { sql := `SELECT count(*) FROM eth_txes WHERE id IN (SELECT DISTINCT eth_tx_id FROM eth_tx_attempts)` if err = o.q.Get(&count, sql); err != nil { return @@ -433,7 +433,7 @@ func (o *evmTxStore) TransactionsWithAttempts(offset, limit int) (txs []EvmTx, c } // TxAttempts returns the last tx attempts sorted by created_at descending. -func (o *evmTxStore) TxAttempts(offset, limit int) (txs []EvmTxAttempt, count int, err error) { +func (o *evmTxStore) TxAttempts(offset, limit int) (txs []TxAttempt, count int, err error) { sql := `SELECT count(*) FROM eth_tx_attempts` if err = o.q.Get(&count, sql); err != nil { return @@ -449,23 +449,23 @@ func (o *evmTxStore) TxAttempts(offset, limit int) (txs []EvmTxAttempt, count in return } -// FindTxAttempt returns an individual EvmTxAttempt -func (o *evmTxStore) FindTxAttempt(hash common.Hash) (*EvmTxAttempt, error) { +// FindTxAttempt returns an individual TxAttempt +func (o *evmTxStore) FindTxAttempt(hash common.Hash) (*TxAttempt, error) { dbTxAttempt := DbEthTxAttempt{} sql := `SELECT * FROM eth_tx_attempts WHERE hash = $1` if err := o.q.Get(&dbTxAttempt, sql, hash); err != nil { return nil, err } // reuse the preload - var attempt EvmTxAttempt + var attempt TxAttempt DbEthTxAttemptToEthTxAttempt(dbTxAttempt, &attempt) - attempts := []EvmTxAttempt{attempt} + attempts := []TxAttempt{attempt} err := o.PreloadTxes(attempts) return &attempts[0], err } // FindTxAttemptsByTxIDs returns a list of attempts by ETH Tx IDs -func (o *evmTxStore) FindTxAttemptsByTxIDs(ids []int64) ([]EvmTxAttempt, error) { +func (o *evmTxStore) FindTxAttemptsByTxIDs(ids []int64) ([]TxAttempt, error) { sql := `SELECT * FROM eth_tx_attempts WHERE eth_tx_id = ANY($1)` var dbTxAttempts []DbEthTxAttempt if err := o.q.Select(&dbTxAttempts, sql, ids); err != nil { @@ -474,7 +474,7 @@ func (o *evmTxStore) FindTxAttemptsByTxIDs(ids []int64) ([]EvmTxAttempt, error) return dbEthTxAttemptsToEthTxAttempts(dbTxAttempts), nil } -func (o *evmTxStore) FindTxByHash(hash common.Hash) (*EvmTx, error) { +func (o *evmTxStore) FindTxByHash(hash common.Hash) (*Tx, error) { var dbEtx DbEthTx err := o.q.Transaction(func(tx pg.Queryer) error { sql := `SELECT eth_txes.* FROM eth_txes WHERE id IN (SELECT DISTINCT eth_tx_id FROM eth_tx_attempts WHERE hash = $1)` @@ -484,13 +484,13 @@ func (o *evmTxStore) FindTxByHash(hash common.Hash) (*EvmTx, error) { return nil }, pg.OptReadOnlyTx()) - var etx EvmTx + var etx Tx DbEthTxToEthTx(dbEtx, &etx) return &etx, pkgerrors.Wrap(err, "FindEthTxByHash failed") } // InsertTx inserts a new evm tx into the database -func (o *evmTxStore) InsertTx(etx *EvmTx) error { +func (o *evmTxStore) InsertTx(etx *Tx) error { if etx.CreatedAt == (time.Time{}) { etx.CreatedAt = time.Now() } @@ -504,7 +504,7 @@ func (o *evmTxStore) InsertTx(etx *EvmTx) error { } // InsertTxAttempt inserts a new txAttempt into the database -func (o *evmTxStore) InsertTxAttempt(attempt *EvmTxAttempt) error { +func (o *evmTxStore) InsertTxAttempt(attempt *TxAttempt) error { dbTxAttempt := DbEthTxAttemptFromEthTxAttempt(attempt) err := o.q.GetNamed(insertIntoEthTxAttemptsQuery, &dbTxAttempt, &dbTxAttempt) DbEthTxAttemptToEthTxAttempt(dbTxAttempt, attempt) @@ -524,8 +524,8 @@ func (o *evmTxStore) InsertReceipt(receipt *evmtypes.Receipt) (int64, error) { return r.ID, pkgerrors.Wrap(err, "InsertReceipt failed") } -// FindTxWithAttempts finds the EvmTx with its attempts and receipts preloaded -func (o *evmTxStore) FindTxWithAttempts(etxID int64) (etx EvmTx, err error) { +// FindTxWithAttempts finds the Tx with its attempts and receipts preloaded +func (o *evmTxStore) FindTxWithAttempts(etxID int64) (etx Tx, err error) { err = o.q.Transaction(func(tx pg.Queryer) error { var dbEtx DbEthTx if err = tx.Get(&dbEtx, `SELECT * FROM eth_txes WHERE id = $1 ORDER BY created_at ASC, id ASC`, etxID); err != nil { @@ -543,8 +543,8 @@ func (o *evmTxStore) FindTxWithAttempts(etxID int64) (etx EvmTx, err error) { return etx, pkgerrors.Wrap(err, "FindTxWithAttempts failed") } -func (o *evmTxStore) FindTxAttemptConfirmedByTxIDs(ids []int64) ([]EvmTxAttempt, error) { - var txAttempts []EvmTxAttempt +func (o *evmTxStore) FindTxAttemptConfirmedByTxIDs(ids []int64) ([]TxAttempt, error) { + var txAttempts []TxAttempt err := o.q.Transaction(func(tx pg.Queryer) error { var dbAttempts []DbEthTxAttempt if err := tx.Select(&dbAttempts, `SELECT eta.* @@ -558,10 +558,10 @@ func (o *evmTxStore) FindTxAttemptConfirmedByTxIDs(ids []int64) ([]EvmTxAttempt, return txAttempts, pkgerrors.Wrap(err, "FindTxAttemptConfirmedByTxIDs failed") } -func (o *evmTxStore) LoadTxesAttempts(etxs []*EvmTx, qopts ...pg.QOpt) error { +func (o *evmTxStore) LoadTxesAttempts(etxs []*Tx, qopts ...pg.QOpt) error { qq := o.q.WithOpts(qopts...) ethTxIDs := make([]int64, len(etxs)) - ethTxesM := make(map[int64]*EvmTx, len(etxs)) + ethTxesM := make(map[int64]*Tx, len(etxs)) for i, etx := range etxs { etx.TxAttempts = nil // this will overwrite any previous preload ethTxIDs[i] = etx.ID @@ -573,27 +573,27 @@ func (o *evmTxStore) LoadTxesAttempts(etxs []*EvmTx, qopts ...pg.QOpt) error { } for _, dbAttempt := range dbTxAttempts { etx := ethTxesM[dbAttempt.EthTxID] - var attempt EvmTxAttempt + var attempt TxAttempt DbEthTxAttemptToEthTxAttempt(dbAttempt, &attempt) etx.TxAttempts = append(etx.TxAttempts, attempt) } return nil } -func (o *evmTxStore) LoadTxAttempts(etx *EvmTx, qopts ...pg.QOpt) error { - return o.LoadTxesAttempts([]*EvmTx{etx}, qopts...) +func (o *evmTxStore) LoadTxAttempts(etx *Tx, qopts ...pg.QOpt) error { + return o.LoadTxesAttempts([]*Tx{etx}, qopts...) } -func loadEthTxAttemptsReceipts(q pg.Queryer, etx *EvmTx) (err error) { - return loadEthTxesAttemptsReceipts(q, []*EvmTx{etx}) +func loadEthTxAttemptsReceipts(q pg.Queryer, etx *Tx) (err error) { + return loadEthTxesAttemptsReceipts(q, []*Tx{etx}) } -func loadEthTxesAttemptsReceipts(q pg.Queryer, etxs []*EvmTx) (err error) { +func loadEthTxesAttemptsReceipts(q pg.Queryer, etxs []*Tx) (err error) { if len(etxs) == 0 { return nil } - attemptHashM := make(map[common.Hash]*EvmTxAttempt, len(etxs)) // len here is lower bound - attemptHashes := make([][]byte, len(etxs)) // len here is lower bound + attemptHashM := make(map[common.Hash]*TxAttempt, len(etxs)) // len here is lower bound + attemptHashes := make([][]byte, len(etxs)) // len here is lower bound for _, etx := range etxs { for i, attempt := range etx.TxAttempts { attemptHashM[attempt.Hash] = &etx.TxAttempts[i] @@ -614,8 +614,8 @@ func loadEthTxesAttemptsReceipts(q pg.Queryer, etxs []*EvmTx) (err error) { return nil } -func loadConfirmedAttemptsReceipts(q pg.Queryer, attempts []EvmTxAttempt) error { - byHash := make(map[string]*EvmTxAttempt, len(attempts)) +func loadConfirmedAttemptsReceipts(q pg.Queryer, attempts []TxAttempt) error { + byHash := make(map[string]*TxAttempt, len(attempts)) hashes := make([][]byte, len(attempts)) for i, attempt := range attempts { byHash[attempt.Hash.String()] = &attempts[i] @@ -635,7 +635,7 @@ func loadConfirmedAttemptsReceipts(q pg.Queryer, attempts []EvmTxAttempt) error // FindTxAttemptsRequiringResend returns the highest priced attempt for each // eth_tx that was last sent before or at the given time (up to limit) -func (o *evmTxStore) FindTxAttemptsRequiringResend(olderThan time.Time, maxInFlightTransactions uint32, chainID *big.Int, address common.Address) (attempts []EvmTxAttempt, err error) { +func (o *evmTxStore) FindTxAttemptsRequiringResend(olderThan time.Time, maxInFlightTransactions uint32, chainID *big.Int, address common.Address) (attempts []TxAttempt, err error) { var limit null.Uint32 if maxInFlightTransactions > 0 { limit = null.Uint32From(maxInFlightTransactions) @@ -683,7 +683,7 @@ AND eth_txes.id = eth_tx_attempts.eth_tx_id AND eth_txes.evm_chain_id = $2`, return pkgerrors.Wrap(err, "SetBroadcastBeforeBlockNum failed") } -func (o *evmTxStore) FindTxAttemptsConfirmedMissingReceipt(chainID *big.Int) (attempts []EvmTxAttempt, err error) { +func (o *evmTxStore) FindTxAttemptsConfirmedMissingReceipt(chainID *big.Int) (attempts []TxAttempt, err error) { var dbAttempts []DbEthTxAttempt err = o.q.Select(&dbAttempts, `SELECT DISTINCT ON (eth_tx_attempts.eth_tx_id) eth_tx_attempts.* @@ -708,7 +708,7 @@ func (o *evmTxStore) UpdateTxsUnconfirmed(ids []int64) error { return nil } -func (o *evmTxStore) FindTxAttemptsRequiringReceiptFetch(chainID *big.Int) (attempts []EvmTxAttempt, err error) { +func (o *evmTxStore) FindTxAttemptsRequiringReceiptFetch(chainID *big.Int) (attempts []TxAttempt, err error) { err = o.q.Transaction(func(tx pg.Queryer) error { var dbAttempts []DbEthTxAttempt err = tx.Select(&dbAttempts, ` @@ -856,7 +856,7 @@ WHERE state = 'unconfirmed' return } -func (o *evmTxStore) GetInProgressTxAttempts(ctx context.Context, address common.Address, chainID *big.Int) (attempts []EvmTxAttempt, err error) { +func (o *evmTxStore) GetInProgressTxAttempts(ctx context.Context, address common.Address, chainID *big.Int) (attempts []TxAttempt, err error) { qq := o.q.WithOpts(pg.WithParentCtx(ctx)) err = qq.Transaction(func(tx pg.Queryer) error { var dbAttempts []DbEthTxAttempt @@ -875,7 +875,7 @@ WHERE eth_tx_attempts.state = 'in_progress' AND eth_txes.from_address = $1 AND e return attempts, pkgerrors.Wrap(err, "getInProgressEthTxAttempts failed") } -func (o *evmTxStore) FindReceiptsPendingConfirmation(ctx context.Context, blockNum int64, chainID *big.Int) (receiptsPlus []EvmReceiptPlus, err error) { +func (o *evmTxStore) FindReceiptsPendingConfirmation(ctx context.Context, blockNum int64, chainID *big.Int) (receiptsPlus []ReceiptPlus, err error) { var rs []dbReceiptPlus err = o.q.SelectContext(ctx, &rs, ` @@ -892,8 +892,8 @@ func (o *evmTxStore) FindReceiptsPendingConfirmation(ctx context.Context, blockN } // FindTxWithSequence returns any broadcast ethtx with the given nonce -func (o *evmTxStore) FindTxWithSequence(fromAddress common.Address, nonce evmtypes.Nonce) (etx *EvmTx, err error) { - etx = new(EvmTx) +func (o *evmTxStore) FindTxWithSequence(fromAddress common.Address, nonce evmtypes.Nonce) (etx *Tx, err error) { + etx = new(Tx) err = o.q.Transaction(func(tx pg.Queryer) error { var dbEtx DbEthTx err = tx.Get(&dbEtx, ` @@ -912,7 +912,7 @@ SELECT * FROM eth_txes WHERE from_address = $1 AND nonce = $2 AND state IN ('con return } -func updateEthTxAttemptUnbroadcast(q pg.Queryer, attempt EvmTxAttempt) error { +func updateEthTxAttemptUnbroadcast(q pg.Queryer, attempt TxAttempt) error { if attempt.State != txmgrtypes.TxAttemptBroadcast { return errors.New("expected eth_tx_attempt to be broadcast") } @@ -920,7 +920,7 @@ func updateEthTxAttemptUnbroadcast(q pg.Queryer, attempt EvmTxAttempt) error { return pkgerrors.Wrap(err, "updateEthTxAttemptUnbroadcast failed") } -func updateEthTxUnconfirm(q pg.Queryer, etx EvmTx) error { +func updateEthTxUnconfirm(q pg.Queryer, etx Tx) error { if etx.State != txmgr.TxConfirmed { return errors.New("expected eth_tx state to be confirmed") } @@ -938,7 +938,7 @@ AND eth_tx_attempts.eth_tx_id = $1 return pkgerrors.Wrap(err, "deleteEthReceipts failed") } -func (o *evmTxStore) UpdateTxForRebroadcast(etx EvmTx, etxAttempt EvmTxAttempt) error { +func (o *evmTxStore) UpdateTxForRebroadcast(etx Tx, etxAttempt TxAttempt) error { return o.q.Transaction(func(tx pg.Queryer) error { if err := deleteEthReceipts(tx, etx.ID); err != nil { return pkgerrors.Wrapf(err, "deleteEthReceipts failed for etx %v", etx.ID) @@ -950,7 +950,7 @@ func (o *evmTxStore) UpdateTxForRebroadcast(etx EvmTx, etxAttempt EvmTxAttempt) }) } -func (o *evmTxStore) FindTransactionsConfirmedInBlockRange(highBlockNumber, lowBlockNumber int64, chainID *big.Int) (etxs []*EvmTx, err error) { +func (o *evmTxStore) FindTransactionsConfirmedInBlockRange(highBlockNumber, lowBlockNumber int64, chainID *big.Int) (etxs []*Tx, err error) { err = o.q.Transaction(func(tx pg.Queryer) error { var dbEtxs []DbEthTx err = tx.Select(&dbEtxs, ` @@ -963,7 +963,7 @@ ORDER BY nonce ASC if err != nil { return pkgerrors.Wrap(err, "FindTransactionsConfirmedInBlockRange failed to load eth_txes") } - etxs = make([]*EvmTx, len(dbEtxs)) + etxs = make([]*Tx, len(dbEtxs)) dbEthTxsToEvmEthTxPtrs(dbEtxs, etxs) if err = o.LoadTxesAttempts(etxs, pg.WithQueryer(tx)); err != nil { return pkgerrors.Wrap(err, "FindTransactionsConfirmedInBlockRange failed to load eth_tx_attempts") @@ -974,7 +974,7 @@ ORDER BY nonce ASC return etxs, pkgerrors.Wrap(err, "FindTransactionsConfirmedInBlockRange failed") } -func saveAttemptWithNewState(q pg.Queryer, timeout time.Duration, logger logger.Logger, attempt EvmTxAttempt, broadcastAt time.Time) error { +func saveAttemptWithNewState(q pg.Queryer, timeout time.Duration, logger logger.Logger, attempt TxAttempt, broadcastAt time.Time) error { ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() return pg.SqlxTransaction(ctx, q, logger, func(tx pg.Queryer) error { @@ -989,7 +989,7 @@ func saveAttemptWithNewState(q pg.Queryer, timeout time.Duration, logger logger. }) } -func (o *evmTxStore) SaveInsufficientFundsAttempt(timeout time.Duration, attempt *EvmTxAttempt, broadcastAt time.Time) error { +func (o *evmTxStore) SaveInsufficientFundsAttempt(timeout time.Duration, attempt *TxAttempt, broadcastAt time.Time) error { if !(attempt.State == txmgrtypes.TxAttemptInProgress || attempt.State == txmgrtypes.TxAttemptInsufficientEth) { return errors.New("expected state to be either in_progress or insufficient_eth") } @@ -997,7 +997,7 @@ func (o *evmTxStore) SaveInsufficientFundsAttempt(timeout time.Duration, attempt return pkgerrors.Wrap(saveAttemptWithNewState(o.q, timeout, o.logger, *attempt, broadcastAt), "saveInsufficientEthAttempt failed") } -func saveSentAttempt(q pg.Queryer, timeout time.Duration, logger logger.Logger, attempt *EvmTxAttempt, broadcastAt time.Time) error { +func saveSentAttempt(q pg.Queryer, timeout time.Duration, logger logger.Logger, attempt *TxAttempt, broadcastAt time.Time) error { if attempt.State != txmgrtypes.TxAttemptInProgress { return errors.New("expected state to be in_progress") } @@ -1005,11 +1005,11 @@ func saveSentAttempt(q pg.Queryer, timeout time.Duration, logger logger.Logger, return pkgerrors.Wrap(saveAttemptWithNewState(q, timeout, logger, *attempt, broadcastAt), "saveSentAttempt failed") } -func (o *evmTxStore) SaveSentAttempt(timeout time.Duration, attempt *EvmTxAttempt, broadcastAt time.Time) error { +func (o *evmTxStore) SaveSentAttempt(timeout time.Duration, attempt *TxAttempt, broadcastAt time.Time) error { return saveSentAttempt(o.q, timeout, o.logger, attempt, broadcastAt) } -func (o *evmTxStore) SaveConfirmedMissingReceiptAttempt(ctx context.Context, timeout time.Duration, attempt *EvmTxAttempt, broadcastAt time.Time) error { +func (o *evmTxStore) SaveConfirmedMissingReceiptAttempt(ctx context.Context, timeout time.Duration, attempt *TxAttempt, broadcastAt time.Time) error { qq := o.q.WithOpts(pg.WithParentCtx(ctx)) err := qq.Transaction(func(tx pg.Queryer) error { if err := saveSentAttempt(tx, timeout, o.logger, attempt, broadcastAt); err != nil { @@ -1024,7 +1024,7 @@ func (o *evmTxStore) SaveConfirmedMissingReceiptAttempt(ctx context.Context, tim return pkgerrors.Wrap(err, "SaveConfirmedMissingReceiptAttempt failed") } -func (o *evmTxStore) DeleteInProgressAttempt(ctx context.Context, attempt EvmTxAttempt) error { +func (o *evmTxStore) DeleteInProgressAttempt(ctx context.Context, attempt TxAttempt) error { qq := o.q.WithOpts(pg.WithParentCtx(ctx)) if attempt.State != txmgrtypes.TxAttemptInProgress { @@ -1038,7 +1038,7 @@ func (o *evmTxStore) DeleteInProgressAttempt(ctx context.Context, attempt EvmTxA } // SaveInProgressAttempt inserts or updates an attempt -func (o *evmTxStore) SaveInProgressAttempt(attempt *EvmTxAttempt) error { +func (o *evmTxStore) SaveInProgressAttempt(attempt *TxAttempt) error { if attempt.State != txmgrtypes.TxAttemptInProgress { return errors.New("SaveInProgressAttempt failed: attempt state must be in_progress") } @@ -1073,7 +1073,7 @@ func (o *evmTxStore) SaveInProgressAttempt(attempt *EvmTxAttempt) error { // limited by limit pending transactions // // It also returns eth_txes that are unconfirmed with no eth_tx_attempts -func (o *evmTxStore) FindTxsRequiringGasBump(ctx context.Context, address common.Address, blockNum, gasBumpThreshold, depth int64, chainID *big.Int) (etxs []*EvmTx, err error) { +func (o *evmTxStore) FindTxsRequiringGasBump(ctx context.Context, address common.Address, blockNum, gasBumpThreshold, depth int64, chainID *big.Int) (etxs []*Tx, err error) { if gasBumpThreshold == 0 { return } @@ -1090,7 +1090,7 @@ ORDER BY nonce ASC if err = tx.Select(&dbEtxs, stmt, address, chainID.String(), depth, blockNum-gasBumpThreshold); err != nil { return pkgerrors.Wrap(err, "FindEthTxsRequiringGasBump failed to load eth_txes") } - etxs = make([]*EvmTx, len(dbEtxs)) + etxs = make([]*Tx, len(dbEtxs)) dbEthTxsToEvmEthTxPtrs(dbEtxs, etxs) err = o.LoadTxesAttempts(etxs, pg.WithQueryer(tx)) return pkgerrors.Wrap(err, "FindEthTxsRequiringGasBump failed to load eth_tx_attempts") @@ -1101,7 +1101,7 @@ ORDER BY nonce ASC // FindTxsRequiringResubmissionDueToInsufficientFunds returns transactions // that need to be re-sent because they hit an out-of-eth error on a previous // block -func (o *evmTxStore) FindTxsRequiringResubmissionDueToInsufficientFunds(address common.Address, chainID *big.Int, qopts ...pg.QOpt) (etxs []*EvmTx, err error) { +func (o *evmTxStore) FindTxsRequiringResubmissionDueToInsufficientFunds(address common.Address, chainID *big.Int, qopts ...pg.QOpt) (etxs []*Tx, err error) { qq := o.q.WithOpts(qopts...) err = qq.Transaction(func(tx pg.Queryer) error { var dbEtxs []DbEthTx @@ -1114,7 +1114,7 @@ ORDER BY nonce ASC if err != nil { return pkgerrors.Wrap(err, "FindEthTxsRequiringResubmissionDueToInsufficientEth failed to load eth_txes") } - etxs = make([]*EvmTx, len(dbEtxs)) + etxs = make([]*Tx, len(dbEtxs)) dbEthTxsToEvmEthTxPtrs(dbEtxs, etxs) err = o.LoadTxesAttempts(etxs, pg.WithQueryer(tx)) return pkgerrors.Wrap(err, "FindEthTxsRequiringResubmissionDueToInsufficientEth failed to load eth_tx_attempts") @@ -1220,7 +1220,7 @@ GROUP BY e.id }) } -func (o *evmTxStore) SaveReplacementInProgressAttempt(oldAttempt EvmTxAttempt, replacementAttempt *EvmTxAttempt, qopts ...pg.QOpt) error { +func (o *evmTxStore) SaveReplacementInProgressAttempt(oldAttempt TxAttempt, replacementAttempt *TxAttempt, qopts ...pg.QOpt) error { qq := o.q.WithOpts(qopts...) if oldAttempt.State != txmgrtypes.TxAttemptInProgress || replacementAttempt.State != txmgrtypes.TxAttemptInProgress { return errors.New("expected attempts to be in_progress") @@ -1244,7 +1244,7 @@ func (o *evmTxStore) SaveReplacementInProgressAttempt(oldAttempt EvmTxAttempt, r } // Finds earliest saved transaction that has yet to be broadcast from the given address -func (o *evmTxStore) FindNextUnstartedTransactionFromAddress(etx *EvmTx, fromAddress common.Address, chainID *big.Int, qopts ...pg.QOpt) error { +func (o *evmTxStore) FindNextUnstartedTransactionFromAddress(etx *Tx, fromAddress common.Address, chainID *big.Int, qopts ...pg.QOpt) error { qq := o.q.WithOpts(qopts...) var dbEtx DbEthTx err := qq.Get(&dbEtx, `SELECT * FROM eth_txes WHERE from_address = $1 AND state = 'unstarted' AND evm_chain_id = $2 ORDER BY value ASC, created_at ASC, id ASC`, fromAddress, chainID.String()) @@ -1252,7 +1252,7 @@ func (o *evmTxStore) FindNextUnstartedTransactionFromAddress(etx *EvmTx, fromAdd return pkgerrors.Wrap(err, "failed to FindNextUnstartedTransactionFromAddress") } -func (o *evmTxStore) UpdateTxFatalError(etx *EvmTx, qopts ...pg.QOpt) error { +func (o *evmTxStore) UpdateTxFatalError(etx *Tx, qopts ...pg.QOpt) error { qq := o.q.WithOpts(qopts...) if etx.State != txmgr.TxInProgress { @@ -1279,7 +1279,7 @@ func (o *evmTxStore) UpdateTxFatalError(etx *EvmTx, qopts ...pg.QOpt) error { // Updates eth attempt from in_progress to broadcast. Also updates the eth tx to unconfirmed. // Before it updates both tables though it increments the next nonce from the keystore // One of the more complicated signatures. We have to accept variable pg.QOpt and QueryerFunc arguments -func (o *evmTxStore) UpdateTxAttemptInProgressToBroadcast(etx *EvmTx, attempt EvmTxAttempt, NewAttemptState txmgrtypes.TxAttemptState, incrNextNonceCallback txmgrtypes.QueryerFunc, qopts ...pg.QOpt) error { +func (o *evmTxStore) UpdateTxAttemptInProgressToBroadcast(etx *Tx, attempt TxAttempt, NewAttemptState txmgrtypes.TxAttemptState, incrNextNonceCallback txmgrtypes.QueryerFunc, qopts ...pg.QOpt) error { qq := o.q.WithOpts(qopts...) if etx.BroadcastAt == nil { @@ -1317,7 +1317,7 @@ func (o *evmTxStore) UpdateTxAttemptInProgressToBroadcast(etx *EvmTx, attempt Ev } // Updates eth tx from unstarted to in_progress and inserts in_progress eth attempt -func (o *evmTxStore) UpdateTxUnstartedToInProgress(etx *EvmTx, attempt *EvmTxAttempt, qopts ...pg.QOpt) error { +func (o *evmTxStore) UpdateTxUnstartedToInProgress(etx *Tx, attempt *TxAttempt, qopts ...pg.QOpt) error { qq := o.q.WithOpts(qopts...) if etx.Sequence == nil { return errors.New("in_progress transaction must have nonce") @@ -1378,9 +1378,9 @@ func (o *evmTxStore) UpdateTxUnstartedToInProgress(etx *EvmTx, attempt *EvmTxAtt // an unfinished state because something went screwy the last time. Most likely // the node crashed in the middle of the ProcessUnstartedEthTxs loop. // It may or may not have been broadcast to an eth node. -func (o *evmTxStore) GetTxInProgress(fromAddress common.Address, qopts ...pg.QOpt) (etx *EvmTx, err error) { +func (o *evmTxStore) GetTxInProgress(fromAddress common.Address, qopts ...pg.QOpt) (etx *Tx, err error) { qq := o.q.WithOpts(qopts...) - etx = new(EvmTx) + etx = new(Tx) if err != nil { return etx, pkgerrors.Wrap(err, "getInProgressEthTx failed") } @@ -1468,7 +1468,7 @@ func (o *evmTxStore) CheckTxQueueCapacity(fromAddress common.Address, maxQueuedT return } -func (o *evmTxStore) CreateTransaction(txRequest EvmTxRequest, chainID *big.Int, qopts ...pg.QOpt) (tx EvmTx, err error) { +func (o *evmTxStore) CreateTransaction(txRequest TxRequest, chainID *big.Int, qopts ...pg.QOpt) (tx Tx, err error) { var dbEtx DbEthTx qq := o.q.WithOpts(qopts...) err = qq.Transaction(func(tx pg.Queryer) error { @@ -1504,7 +1504,7 @@ RETURNING "eth_txes".* } return nil }) - var etx EvmTx + var etx Tx DbEthTxToEthTx(dbEtx, &etx) return etx, err } diff --git a/core/chains/evm/txmgr/evm_tx_store_test.go b/core/chains/evm/txmgr/evm_tx_store_test.go index 646b7c239fe..e1f2c437877 100644 --- a/core/chains/evm/txmgr/evm_tx_store_test.go +++ b/core/chains/evm/txmgr/evm_tx_store_test.go @@ -124,7 +124,7 @@ func TestORM(t *testing.T) { _, fromAddress := cltest.MustInsertRandomKey(t, keyStore.Eth(), 0) var err error - var etx txmgr.EvmTx + var etx txmgr.Tx t.Run("InsertTx", func(t *testing.T) { etx = cltest.NewEthTx(t, fromAddress) err = orm.InsertTx(&etx) @@ -132,8 +132,8 @@ func TestORM(t *testing.T) { assert.Greater(t, int(etx.ID), 0) cltest.AssertCount(t, db, "eth_txes", 1) }) - var attemptL txmgr.EvmTxAttempt - var attemptD txmgr.EvmTxAttempt + var attemptL txmgr.TxAttempt + var attemptD txmgr.TxAttempt t.Run("InsertTxAttempt", func(t *testing.T) { attemptD = cltest.NewDynamicFeeEthTxAttempt(t, etx.ID) err = orm.InsertTxAttempt(&attemptD) @@ -149,7 +149,7 @@ func TestORM(t *testing.T) { assert.Greater(t, int(attemptL.ID), 0) cltest.AssertCount(t, db, "eth_tx_attempts", 2) }) - var r txmgr.EvmReceipt + var r txmgr.Receipt t.Run("InsertReceipt", func(t *testing.T) { r = cltest.NewEthReceipt(t, 42, utils.NewHash(), attemptD.Hash, 0x1) id, err := orm.InsertReceipt(&r.Receipt) @@ -259,7 +259,7 @@ func TestORM_FindTxAttemptsRequiringResend(t *testing.T) { e0 := cltest.MustInsertUnconfirmedEthTxWithBroadcastLegacyAttempt(t, txStore, 0, fromAddress, time.Unix(1616509100, 0)) e2 := cltest.MustInsertUnconfirmedEthTxWithBroadcastLegacyAttempt(t, txStore, 2, fromAddress, time.Unix(1616509300, 0)) - etxs := []txmgr.EvmTx{ + etxs := []txmgr.Tx{ e0, e1, e2, @@ -580,12 +580,12 @@ func TestORM_PreloadTxes(t *testing.T) { etx := cltest.MustInsertUnconfirmedEthTxWithBroadcastLegacyAttempt(t, txStore, int64(7), fromAddress) // create unloaded attempt - unloadedAttempt := txmgr.EvmTxAttempt{TxID: etx.ID} + unloadedAttempt := txmgr.TxAttempt{TxID: etx.ID} // uninitialized EthTx assert.Equal(t, int64(0), unloadedAttempt.Tx.ID) - attempts := []txmgr.EvmTxAttempt{unloadedAttempt} + attempts := []txmgr.TxAttempt{unloadedAttempt} err := txStore.PreloadTxes(attempts) require.NoError(t, err) @@ -594,7 +594,7 @@ func TestORM_PreloadTxes(t *testing.T) { }) t.Run("returns nil when attempts slice is empty", func(t *testing.T) { - emptyAttempts := []txmgr.EvmTxAttempt{} + emptyAttempts := []txmgr.TxAttempt{} err := txStore.PreloadTxes(emptyAttempts) require.NoError(t, err) }) @@ -1057,16 +1057,16 @@ func TestORM_LoadEthTxesAttempts(t *testing.T) { t.Run("load eth tx attempt", func(t *testing.T) { etx := cltest.MustInsertConfirmedMissingReceiptEthTxWithLegacyAttempt(t, txStore, 1, 7, time.Now(), fromAddress) - etx.TxAttempts = []txmgr.EvmTxAttempt{} + etx.TxAttempts = []txmgr.TxAttempt{} - err := txStore.LoadTxesAttempts([]*txmgr.EvmTx{&etx}) + err := txStore.LoadTxesAttempts([]*txmgr.Tx{&etx}) require.NoError(t, err) assert.Len(t, etx.TxAttempts, 1) }) t.Run("load new attempt inserted in current postgres transaction", func(t *testing.T) { etx := cltest.MustInsertConfirmedMissingReceiptEthTxWithLegacyAttempt(t, txStore, 3, 9, time.Now(), fromAddress) - etx.TxAttempts = []txmgr.EvmTxAttempt{} + etx.TxAttempts = []txmgr.TxAttempt{} q := pg.NewQ(db, logger.TestLogger(t), cfg.Database()) @@ -1079,7 +1079,7 @@ func TestORM_LoadEthTxesAttempts(t *testing.T) { _, err := tx.NamedExec(insertEthTxAttemptSQL, dbAttempt) require.NoError(t, err) - err = txStore.LoadTxesAttempts([]*txmgr.EvmTx{&etx}, pg.WithQueryer(tx)) + err = txStore.LoadTxesAttempts([]*txmgr.Tx{&etx}, pg.WithQueryer(tx)) require.NoError(t, err) assert.Len(t, etx.TxAttempts, 2) @@ -1087,8 +1087,8 @@ func TestORM_LoadEthTxesAttempts(t *testing.T) { }) require.NoError(t, err) // also check after postgres transaction is committed - etx.TxAttempts = []txmgr.EvmTxAttempt{} - err = txStore.LoadTxesAttempts([]*txmgr.EvmTx{&etx}) + etx.TxAttempts = []txmgr.TxAttempt{} + err = txStore.LoadTxesAttempts([]*txmgr.Tx{&etx}) require.NoError(t, err) assert.Len(t, etx.TxAttempts, 2) }) @@ -1132,14 +1132,14 @@ func TestORM_FindNextUnstartedTransactionFromAddress(t *testing.T) { t.Run("cannot find unstarted tx", func(t *testing.T) { cltest.MustInsertInProgressEthTxWithAttempt(t, txStore, 13, fromAddress) - resultEtx := new(txmgr.EvmTx) + resultEtx := new(txmgr.Tx) err := txStore.FindNextUnstartedTransactionFromAddress(resultEtx, fromAddress, ethClient.ConfiguredChainID()) assert.ErrorIs(t, err, sql.ErrNoRows) }) t.Run("finds unstarted tx", func(t *testing.T) { cltest.MustCreateUnstartedGeneratedTx(t, txStore, fromAddress, &cltest.FixtureChainID) - resultEtx := new(txmgr.EvmTx) + resultEtx := new(txmgr.Tx) err := txStore.FindNextUnstartedTransactionFromAddress(resultEtx, fromAddress, ethClient.ConfiguredChainID()) require.NoError(t, err) }) @@ -1526,7 +1526,7 @@ func TestORM_CreateTransaction(t *testing.T) { strategy := newMockTxStrategy(t) strategy.On("Subject").Return(uuid.NullUUID{UUID: subject, Valid: true}) strategy.On("PruneQueue", mock.AnythingOfType("*txmgr.evmTxStore"), mock.AnythingOfType("pg.QOpt")).Return(int64(0), nil) - etx, err := txStore.CreateTransaction(txmgr.EvmTxRequest{ + etx, err := txStore.CreateTransaction(txmgr.TxRequest{ FromAddress: fromAddress, ToAddress: toAddress, EncodedPayload: payload, @@ -1561,7 +1561,7 @@ func TestORM_CreateTransaction(t *testing.T) { t.Run("doesn't insert eth_tx if a matching tx already exists for that pipeline_task_run_id", func(t *testing.T) { id := uuid.New() - txRequest := txmgr.EvmTxRequest{ + txRequest := txmgr.TxRequest{ FromAddress: fromAddress, ToAddress: testutils.NewAddress(), EncodedPayload: []byte{1, 2, 3}, diff --git a/core/chains/evm/txmgr/models.go b/core/chains/evm/txmgr/models.go index db0d2332ca7..596224a7e1d 100644 --- a/core/chains/evm/txmgr/models.go +++ b/core/chains/evm/txmgr/models.go @@ -17,32 +17,32 @@ import ( // Type aliases for EVM type ( - EvmConfirmer = txmgr.Confirmer[*big.Int, *evmtypes.Head, common.Address, common.Hash, common.Hash, *evmtypes.Receipt, evmtypes.Nonce, gas.EvmFee] - EvmBroadcaster = txmgr.Broadcaster[*big.Int, *evmtypes.Head, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee] - EvmResender = txmgr.Resender[*big.Int, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee] - EvmReaper = txmgr.Reaper[*big.Int] - TxStore = txmgrtypes.TxStore[common.Address, *big.Int, common.Hash, common.Hash, *evmtypes.Receipt, evmtypes.Nonce, gas.EvmFee] - TransactionStore = txmgrtypes.TransactionStore[common.Address, *big.Int, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee] - EvmKeyStore = txmgrtypes.KeyStore[common.Address, *big.Int, evmtypes.Nonce] - EvmTxAttemptBuilder = txmgrtypes.TxAttemptBuilder[*big.Int, *evmtypes.Head, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee] - EvmNonceSyncer = txmgr.SequenceSyncer[common.Address, common.Hash, common.Hash] - EvmTransmitCheckerFactory = txmgr.TransmitCheckerFactory[*big.Int, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee] - EvmTxm = txmgr.Txm[*big.Int, *evmtypes.Head, common.Address, common.Hash, common.Hash, *evmtypes.Receipt, evmtypes.Nonce, gas.EvmFee] - EvmTxManager = txmgr.TxManager[*big.Int, *evmtypes.Head, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee] - NullEvmTxManager = txmgr.NullTxManager[*big.Int, *evmtypes.Head, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee] - EvmFwdMgr = txmgrtypes.ForwarderManager[common.Address] - EvmTxRequest = txmgrtypes.TxRequest[common.Address, common.Hash] - EvmTx = txmgrtypes.Tx[*big.Int, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee] - EvmTxMeta = txmgrtypes.TxMeta[common.Address, common.Hash] - EvmTxAttempt = txmgrtypes.TxAttempt[*big.Int, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee] - EvmReceipt = dbReceipt // EvmReceipt is the exported DB table model for receipts - EvmReceiptPlus = txmgrtypes.ReceiptPlus[*evmtypes.Receipt] - EvmTxmClient = txmgrtypes.TxmClient[*big.Int, common.Address, common.Hash, common.Hash, *evmtypes.Receipt, evmtypes.Nonce, gas.EvmFee] - TransactionClient = txmgrtypes.TransactionClient[*big.Int, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee] - EvmChainReceipt = txmgrtypes.ChainReceipt[common.Hash, common.Hash] + Confirmer = txmgr.Confirmer[*big.Int, *evmtypes.Head, common.Address, common.Hash, common.Hash, *evmtypes.Receipt, evmtypes.Nonce, gas.EvmFee] + Broadcaster = txmgr.Broadcaster[*big.Int, *evmtypes.Head, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee] + Resender = txmgr.Resender[*big.Int, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee] + Reaper = txmgr.Reaper[*big.Int] + TxStore = txmgrtypes.TxStore[common.Address, *big.Int, common.Hash, common.Hash, *evmtypes.Receipt, evmtypes.Nonce, gas.EvmFee] + TransactionStore = txmgrtypes.TransactionStore[common.Address, *big.Int, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee] + KeyStore = txmgrtypes.KeyStore[common.Address, *big.Int, evmtypes.Nonce] + TxAttemptBuilder = txmgrtypes.TxAttemptBuilder[*big.Int, *evmtypes.Head, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee] + NonceSyncer = txmgr.SequenceSyncer[common.Address, common.Hash, common.Hash] + TransmitCheckerFactory = txmgr.TransmitCheckerFactory[*big.Int, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee] + Txm = txmgr.Txm[*big.Int, *evmtypes.Head, common.Address, common.Hash, common.Hash, *evmtypes.Receipt, evmtypes.Nonce, gas.EvmFee] + TxManager = txmgr.TxManager[*big.Int, *evmtypes.Head, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee] + NullTxManager = txmgr.NullTxManager[*big.Int, *evmtypes.Head, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee] + FwdMgr = txmgrtypes.ForwarderManager[common.Address] + TxRequest = txmgrtypes.TxRequest[common.Address, common.Hash] + Tx = txmgrtypes.Tx[*big.Int, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee] + TxMeta = txmgrtypes.TxMeta[common.Address, common.Hash] + TxAttempt = txmgrtypes.TxAttempt[*big.Int, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee] + Receipt = dbReceipt // EvmReceipt is the exported DB table model for receipts + ReceiptPlus = txmgrtypes.ReceiptPlus[*evmtypes.Receipt] + TxmClient = txmgrtypes.TxmClient[*big.Int, common.Address, common.Hash, common.Hash, *evmtypes.Receipt, evmtypes.Nonce, gas.EvmFee] + TransactionClient = txmgrtypes.TransactionClient[*big.Int, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee] + ChainReceipt = txmgrtypes.ChainReceipt[common.Hash, common.Hash] ) -var _ EvmKeyStore = (keystore.Eth)(nil) // check interface in txmgr to avoid circular import +var _ KeyStore = (keystore.Eth)(nil) // check interface in txmgr to avoid circular import const ( // TransmitCheckerTypeSimulate is a checker that simulates the transaction before executing on diff --git a/core/chains/evm/txmgr/nonce_syncer.go b/core/chains/evm/txmgr/nonce_syncer.go index 99a0dc9927b..d057ff0e74a 100644 --- a/core/chains/evm/txmgr/nonce_syncer.go +++ b/core/chains/evm/txmgr/nonce_syncer.go @@ -51,10 +51,10 @@ var _ txmgr.SequenceSyncer[common.Address, common.Hash, common.Hash] = &nonceSyn type nonceSyncerImpl struct { txStore EvmTxStore - client EvmTxmClient + client TxmClient chainID *big.Int logger logger.Logger - kst EvmKeyStore + kst KeyStore } // NewNonceSyncer returns a new syncer @@ -62,8 +62,8 @@ func NewNonceSyncer( txStore EvmTxStore, lggr logger.Logger, ethClient evmclient.Client, - kst EvmKeyStore, -) EvmNonceSyncer { + kst KeyStore, +) NonceSyncer { lggr = lggr.Named("NonceSyncer") return &nonceSyncerImpl{ txStore: txStore, diff --git a/core/chains/evm/txmgr/reaper_test.go b/core/chains/evm/txmgr/reaper_test.go index ebbed1250c2..7f32761fa42 100644 --- a/core/chains/evm/txmgr/reaper_test.go +++ b/core/chains/evm/txmgr/reaper_test.go @@ -18,11 +18,11 @@ import ( "github.com/smartcontractkit/chainlink/v2/core/utils" ) -func newReaperWithChainID(t *testing.T, db txmgrtypes.TxHistoryReaper[*big.Int], cfg txmgrtypes.ReaperChainConfig, txConfig txmgrtypes.ReaperTransactionsConfig, cid *big.Int) *txmgr.EvmReaper { +func newReaperWithChainID(t *testing.T, db txmgrtypes.TxHistoryReaper[*big.Int], cfg txmgrtypes.ReaperChainConfig, txConfig txmgrtypes.ReaperTransactionsConfig, cid *big.Int) *txmgr.Reaper { return txmgr.NewEvmReaper(logger.TestLogger(t), db, cfg, txConfig, cid) } -func newReaper(t *testing.T, db txmgrtypes.TxHistoryReaper[*big.Int], cfg txmgrtypes.ReaperChainConfig, txConfig txmgrtypes.ReaperTransactionsConfig) *txmgr.EvmReaper { +func newReaper(t *testing.T, db txmgrtypes.TxHistoryReaper[*big.Int], cfg txmgrtypes.ReaperChainConfig, txConfig txmgrtypes.ReaperTransactionsConfig) *txmgr.Reaper { return newReaperWithChainID(t, db, cfg, txConfig, &cltest.FixtureChainID) } diff --git a/core/chains/evm/txmgr/transmitchecker.go b/core/chains/evm/txmgr/transmitchecker.go index 73af4944be7..3aba0962008 100644 --- a/core/chains/evm/txmgr/transmitchecker.go +++ b/core/chains/evm/txmgr/transmitchecker.go @@ -33,10 +33,10 @@ var ( // NoChecker is a TransmitChecker that always determines a transaction should be submitted. NoChecker EvmTransmitChecker = noChecker{} - _ EvmTransmitCheckerFactory = &CheckerFactory{} - _ EvmTransmitChecker = &SimulateChecker{} - _ EvmTransmitChecker = &VRFV1Checker{} - _ EvmTransmitChecker = &VRFV2Checker{} + _ TransmitCheckerFactory = &CheckerFactory{} + _ EvmTransmitChecker = &SimulateChecker{} + _ EvmTransmitChecker = &VRFV1Checker{} + _ EvmTransmitChecker = &VRFV2Checker{} ) // CheckerFactory is a real implementation of TransmitCheckerFactory. @@ -92,8 +92,8 @@ type noChecker struct{} func (noChecker) Check( _ context.Context, _ logger.Logger, - _ EvmTx, - _ EvmTxAttempt, + _ Tx, + _ TxAttempt, ) error { return nil } @@ -107,8 +107,8 @@ type SimulateChecker struct { func (s *SimulateChecker) Check( ctx context.Context, l logger.Logger, - tx EvmTx, - a EvmTxAttempt, + tx Tx, + a TxAttempt, ) error { // See: https://github.com/ethereum/go-ethereum/blob/acdf9238fb03d79c9b1c20c2fa476a7e6f4ac2ac/ethclient/gethclient/gethclient.go#L193 callArg := map[string]interface{}{ @@ -157,8 +157,8 @@ type VRFV1Checker struct { func (v *VRFV1Checker) Check( ctx context.Context, l logger.Logger, - tx EvmTx, - _ EvmTxAttempt, + tx Tx, + _ TxAttempt, ) error { meta, err := tx.GetMeta() if err != nil { @@ -267,8 +267,8 @@ type VRFV2Checker struct { func (v *VRFV2Checker) Check( ctx context.Context, l logger.Logger, - tx EvmTx, - _ EvmTxAttempt, + tx Tx, + _ TxAttempt, ) error { meta, err := tx.GetMeta() if err != nil { diff --git a/core/chains/evm/txmgr/transmitchecker_test.go b/core/chains/evm/txmgr/transmitchecker_test.go index 5ef9aea7d11..b884e7c0fb1 100644 --- a/core/chains/evm/txmgr/transmitchecker_test.go +++ b/core/chains/evm/txmgr/transmitchecker_test.go @@ -92,13 +92,13 @@ func TestTransmitCheckers(t *testing.T) { t.Run("no checker", func(t *testing.T) { checker := txmgr.NoChecker - require.NoError(t, checker.Check(ctx, log, txmgr.EvmTx{}, txmgr.EvmTxAttempt{})) + require.NoError(t, checker.Check(ctx, log, txmgr.Tx{}, txmgr.TxAttempt{})) }) t.Run("simulate", func(t *testing.T) { checker := txmgr.SimulateChecker{Client: client} - tx := txmgr.EvmTx{ + tx := txmgr.Tx{ FromAddress: common.HexToAddress("0xfe0629509E6CB8dfa7a99214ae58Ceb465d5b5A9"), ToAddress: common.HexToAddress("0xff0Aac13eab788cb9a2D662D3FB661Aa5f58FA21"), EncodedPayload: []byte{42, 0, 0}, @@ -107,7 +107,7 @@ func TestTransmitCheckers(t *testing.T) { CreatedAt: time.Unix(0, 0), State: txmgrcommon.TxUnstarted, } - attempt := txmgr.EvmTxAttempt{ + attempt := txmgr.TxAttempt{ Tx: tx, Hash: common.Hash{}, CreatedAt: tx.CreatedAt, @@ -158,10 +158,10 @@ func TestTransmitCheckers(t *testing.T) { testDefaultSubID := uint64(2) testDefaultMaxLink := "1000000000000000000" - txRequest := func(t *testing.T, vrfReqID [32]byte, nilTxHash bool) (txmgr.EvmTx, txmgr.EvmTxAttempt) { + txRequest := func(t *testing.T, vrfReqID [32]byte, nilTxHash bool) (txmgr.Tx, txmgr.TxAttempt) { h := common.BytesToHash(vrfReqID[:]) txHash := common.Hash{} - meta := txmgr.EvmTxMeta{ + meta := txmgr.TxMeta{ RequestID: &h, MaxLink: &testDefaultMaxLink, // 1 LINK SubID: &testDefaultSubID, @@ -176,7 +176,7 @@ func TestTransmitCheckers(t *testing.T) { require.NoError(t, err) metaJson := datatypes.JSON(b) - tx := txmgr.EvmTx{ + tx := txmgr.Tx{ FromAddress: common.HexToAddress("0xfe0629509E6CB8dfa7a99214ae58Ceb465d5b5A9"), ToAddress: common.HexToAddress("0xff0Aac13eab788cb9a2D662D3FB661Aa5f58FA21"), EncodedPayload: []byte{42, 0, 0}, @@ -186,7 +186,7 @@ func TestTransmitCheckers(t *testing.T) { State: txmgrcommon.TxUnstarted, Meta: &metaJson, } - return tx, txmgr.EvmTxAttempt{ + return tx, txmgr.TxAttempt{ Tx: tx, Hash: common.Hash{}, CreatedAt: tx.CreatedAt, @@ -269,9 +269,9 @@ func TestTransmitCheckers(t *testing.T) { testDefaultSubID := uint64(2) testDefaultMaxLink := "1000000000000000000" - txRequest := func(t *testing.T, vrfReqID *big.Int) (txmgr.EvmTx, txmgr.EvmTxAttempt) { + txRequest := func(t *testing.T, vrfReqID *big.Int) (txmgr.Tx, txmgr.TxAttempt) { h := common.BytesToHash(vrfReqID.Bytes()) - meta := txmgr.EvmTxMeta{ + meta := txmgr.TxMeta{ RequestID: &h, MaxLink: &testDefaultMaxLink, // 1 LINK SubID: &testDefaultSubID, @@ -281,7 +281,7 @@ func TestTransmitCheckers(t *testing.T) { require.NoError(t, err) metaJson := datatypes.JSON(b) - tx := txmgr.EvmTx{ + tx := txmgr.Tx{ FromAddress: common.HexToAddress("0xfe0629509E6CB8dfa7a99214ae58Ceb465d5b5A9"), ToAddress: common.HexToAddress("0xff0Aac13eab788cb9a2D662D3FB661Aa5f58FA21"), EncodedPayload: []byte{42, 0, 0}, @@ -291,7 +291,7 @@ func TestTransmitCheckers(t *testing.T) { State: txmgrcommon.TxUnstarted, Meta: &metaJson, } - return tx, txmgr.EvmTxAttempt{ + return tx, txmgr.TxAttempt{ Tx: tx, Hash: common.Hash{}, CreatedAt: tx.CreatedAt, diff --git a/core/chains/evm/txmgr/txmgr_test.go b/core/chains/evm/txmgr/txmgr_test.go index c293aa369c2..2a77b070dd2 100644 --- a/core/chains/evm/txmgr/txmgr_test.go +++ b/core/chains/evm/txmgr/txmgr_test.go @@ -42,7 +42,7 @@ import ( ) func makeTestEvmTxm( - t *testing.T, db *sqlx.DB, ethClient evmclient.Client, estimator gas.EvmFeeEstimator, ccfg txmgr.ChainConfig, fcfg txmgr.FeeConfig, txConfig evmconfig.Transactions, dbConfig txmgr.DatabaseConfig, listenerConfig txmgr.ListenerConfig, keyStore keystore.Eth, eventBroadcaster pg.EventBroadcaster) (txmgr.EvmTxManager, error) { + t *testing.T, db *sqlx.DB, ethClient evmclient.Client, estimator gas.EvmFeeEstimator, ccfg txmgr.ChainConfig, fcfg txmgr.FeeConfig, txConfig evmconfig.Transactions, dbConfig txmgr.DatabaseConfig, listenerConfig txmgr.ListenerConfig, keyStore keystore.Eth, eventBroadcaster pg.EventBroadcaster) (txmgr.TxManager, error) { lggr := logger.TestLogger(t) lp := logpoller.NewLogPoller(logpoller.NewORM(testutils.FixtureChainID, db, lggr, pgtest.NewQConfig(true)), ethClient, lggr, 100*time.Millisecond, 2, 3, 2, 1000) @@ -118,7 +118,7 @@ func TestTxm_CreateTransaction(t *testing.T) { strategy.On("Subject").Return(uuid.NullUUID{UUID: subject, Valid: true}) strategy.On("PruneQueue", mock.Anything, mock.AnythingOfType("pg.QOpt")).Return(int64(0), nil) evmConfig.maxQueued = uint64(1) - etx, err := txm.CreateTransaction(txmgr.EvmTxRequest{ + etx, err := txm.CreateTransaction(txmgr.TxRequest{ FromAddress: fromAddress, ToAddress: toAddress, EncodedPayload: payload, @@ -154,7 +154,7 @@ func TestTxm_CreateTransaction(t *testing.T) { t.Run("with queue at capacity does not insert eth_tx", func(t *testing.T) { evmConfig.maxQueued = uint64(1) - _, err := txm.CreateTransaction(txmgr.EvmTxRequest{ + _, err := txm.CreateTransaction(txmgr.TxRequest{ FromAddress: fromAddress, ToAddress: testutils.NewAddress(), EncodedPayload: []byte{1, 2, 3}, @@ -169,7 +169,7 @@ func TestTxm_CreateTransaction(t *testing.T) { t.Run("doesn't insert eth_tx if a matching tx already exists for that pipeline_task_run_id", func(t *testing.T) { evmConfig.maxQueued = uint64(3) id := uuid.New() - tx1, err := txm.CreateTransaction(txmgr.EvmTxRequest{ + tx1, err := txm.CreateTransaction(txmgr.TxRequest{ FromAddress: fromAddress, ToAddress: testutils.NewAddress(), EncodedPayload: []byte{1, 2, 3}, @@ -179,7 +179,7 @@ func TestTxm_CreateTransaction(t *testing.T) { }) assert.NoError(t, err) - tx2, err := txm.CreateTransaction(txmgr.EvmTxRequest{ + tx2, err := txm.CreateTransaction(txmgr.TxRequest{ FromAddress: fromAddress, ToAddress: testutils.NewAddress(), EncodedPayload: []byte{1, 2, 3}, @@ -194,7 +194,7 @@ func TestTxm_CreateTransaction(t *testing.T) { t.Run("returns error if eth key state is missing or doesn't match chain ID", func(t *testing.T) { rndAddr := testutils.NewAddress() - _, err := txm.CreateTransaction(txmgr.EvmTxRequest{ + _, err := txm.CreateTransaction(txmgr.TxRequest{ FromAddress: rndAddr, ToAddress: testutils.NewAddress(), EncodedPayload: []byte{1, 2, 3}, @@ -206,7 +206,7 @@ func TestTxm_CreateTransaction(t *testing.T) { _, otherAddress := cltest.MustInsertRandomKey(t, kst.Eth(), *utils.NewBigI(1337)) - _, err = txm.CreateTransaction(txmgr.EvmTxRequest{ + _, err = txm.CreateTransaction(txmgr.TxRequest{ FromAddress: otherAddress, ToAddress: testutils.NewAddress(), EncodedPayload: []byte{1, 2, 3}, @@ -224,7 +224,7 @@ func TestTxm_CreateTransaction(t *testing.T) { CheckerType: txmgr.TransmitCheckerTypeSimulate, } evmConfig.maxQueued = uint64(1) - etx, err := txm.CreateTransaction(txmgr.EvmTxRequest{ + etx, err := txm.CreateTransaction(txmgr.TxRequest{ FromAddress: fromAddress, ToAddress: toAddress, EncodedPayload: payload, @@ -250,7 +250,7 @@ func TestTxm_CreateTransaction(t *testing.T) { jobID := int32(25) requestID := gethcommon.HexToHash("abcd") requestTxHash := gethcommon.HexToHash("dcba") - meta := &txmgr.EvmTxMeta{ + meta := &txmgr.TxMeta{ JobID: &jobID, RequestID: &requestID, RequestTxHash: &requestTxHash, @@ -262,7 +262,7 @@ func TestTxm_CreateTransaction(t *testing.T) { CheckerType: txmgr.TransmitCheckerTypeVRFV2, VRFCoordinatorAddress: testutils.NewAddressPtr(), } - etx, err := txm.CreateTransaction(txmgr.EvmTxRequest{ + etx, err := txm.CreateTransaction(txmgr.TxRequest{ FromAddress: fromAddress, ToAddress: toAddress, EncodedPayload: payload, @@ -298,7 +298,7 @@ func TestTxm_CreateTransaction(t *testing.T) { require.NoError(t, err) require.Equal(t, fwdr.Address, fwdrAddr) - etx, err := txm.CreateTransaction(txmgr.EvmTxRequest{ + etx, err := txm.CreateTransaction(txmgr.TxRequest{ FromAddress: fromAddress, ToAddress: toAddress, EncodedPayload: payload, @@ -482,7 +482,7 @@ func TestTxm_CreateTransaction_OutOfEth(t *testing.T) { strategy.On("Subject").Return(uuid.NullUUID{}) strategy.On("PruneQueue", mock.Anything, mock.AnythingOfType("pg.QOpt")).Return(int64(0), nil) - etx, err := txm.CreateTransaction(txmgr.EvmTxRequest{ + etx, err := txm.CreateTransaction(txmgr.TxRequest{ FromAddress: evmFromAddress, ToAddress: toAddress, EncodedPayload: payload, @@ -506,7 +506,7 @@ func TestTxm_CreateTransaction_OutOfEth(t *testing.T) { strategy.On("Subject").Return(uuid.NullUUID{}) strategy.On("PruneQueue", mock.Anything, mock.AnythingOfType("pg.QOpt")).Return(int64(0), nil) - etx, err := txm.CreateTransaction(txmgr.EvmTxRequest{ + etx, err := txm.CreateTransaction(txmgr.TxRequest{ FromAddress: evmFromAddress, ToAddress: toAddress, EncodedPayload: payload, @@ -528,7 +528,7 @@ func TestTxm_CreateTransaction_OutOfEth(t *testing.T) { strategy.On("PruneQueue", mock.Anything, mock.AnythingOfType("pg.QOpt")).Return(int64(0), nil) evmConfig.maxQueued = uint64(1) - etx, err := txm.CreateTransaction(txmgr.EvmTxRequest{ + etx, err := txm.CreateTransaction(txmgr.TxRequest{ FromAddress: evmFromAddress, ToAddress: toAddress, EncodedPayload: payload, diff --git a/core/chains/evm/types/models_test.go b/core/chains/evm/types/models_test.go index 6662bd2275f..a4625f6f1c0 100644 --- a/core/chains/evm/types/models_test.go +++ b/core/chains/evm/types/models_test.go @@ -86,7 +86,7 @@ func TestHead_NextInt(t *testing.T) { } func TestEthTx_GetID(t *testing.T) { - tx := txmgr.EvmTx{ID: math.MinInt64} + tx := txmgr.Tx{ID: math.MinInt64} assert.Equal(t, "-9223372036854775808", tx.GetID()) } @@ -105,7 +105,7 @@ func TestEthTxAttempt_GetSignedTx(t *testing.T) { rlp := new(bytes.Buffer) require.NoError(t, signedTx.EncodeRLP(rlp)) - attempt := txmgr.EvmTxAttempt{SignedRawTx: rlp.Bytes()} + attempt := txmgr.TxAttempt{SignedRawTx: rlp.Bytes()} gotSignedTx, err := txmgr.GetGethSignedTx(attempt.SignedRawTx) require.NoError(t, err) diff --git a/core/internal/cltest/cltest.go b/core/internal/cltest/cltest.go index 698bc815cd8..4a1cfc238ee 100644 --- a/core/internal/cltest/cltest.go +++ b/core/internal/cltest/cltest.go @@ -214,7 +214,7 @@ func NewEventBroadcaster(t testing.TB, dbURL url.URL) pg.EventBroadcaster { return pg.NewEventBroadcaster(dbURL, 0, 0, lggr, uuid.New()) } -func NewEthConfirmer(t testing.TB, txStore txmgr.EvmTxStore, ethClient evmclient.Client, config evmconfig.ChainScopedConfig, ks keystore.Eth, fn txmgrcommon.ResumeCallback) (*txmgr.EvmConfirmer, error) { +func NewEthConfirmer(t testing.TB, txStore txmgr.EvmTxStore, ethClient evmclient.Client, config evmconfig.ChainScopedConfig, ks keystore.Eth, fn txmgrcommon.ResumeCallback) (*txmgr.Confirmer, error) { t.Helper() lggr := logger.TestLogger(t) ge := config.EVM().GasEstimator() diff --git a/core/internal/cltest/factories.go b/core/internal/cltest/factories.go index 4402d802823..0b07dce0909 100644 --- a/core/internal/cltest/factories.go +++ b/core/internal/cltest/factories.go @@ -134,8 +134,8 @@ func EmptyCLIContext() *cli.Context { return cli.NewContext(nil, set, nil) } -func NewEthTx(t *testing.T, fromAddress common.Address) txmgr.EvmTx { - return txmgr.EvmTx{ +func NewEthTx(t *testing.T, fromAddress common.Address) txmgr.Tx { + return txmgr.Tx{ FromAddress: fromAddress, ToAddress: testutils.NewAddress(), EncodedPayload: []byte{1, 2, 3}, @@ -145,7 +145,7 @@ func NewEthTx(t *testing.T, fromAddress common.Address) txmgr.EvmTx { } } -func MustInsertUnconfirmedEthTx(t *testing.T, txStore txmgr.TestEvmTxStore, nonce int64, fromAddress common.Address, opts ...interface{}) txmgr.EvmTx { +func MustInsertUnconfirmedEthTx(t *testing.T, txStore txmgr.TestEvmTxStore, nonce int64, fromAddress common.Address, opts ...interface{}) txmgr.Tx { broadcastAt := time.Now() chainID := &FixtureChainID for _, opt := range opts { @@ -168,7 +168,7 @@ func MustInsertUnconfirmedEthTx(t *testing.T, txStore txmgr.TestEvmTxStore, nonc return etx } -func MustInsertUnconfirmedEthTxWithBroadcastLegacyAttempt(t *testing.T, txStore txmgr.TestEvmTxStore, nonce int64, fromAddress common.Address, opts ...interface{}) txmgr.EvmTx { +func MustInsertUnconfirmedEthTxWithBroadcastLegacyAttempt(t *testing.T, txStore txmgr.TestEvmTxStore, nonce int64, fromAddress common.Address, opts ...interface{}) txmgr.Tx { etx := MustInsertUnconfirmedEthTx(t, txStore, nonce, fromAddress, opts...) attempt := NewLegacyEthTxAttempt(t, etx.ID) @@ -184,7 +184,7 @@ func MustInsertUnconfirmedEthTxWithBroadcastLegacyAttempt(t *testing.T, txStore return etx } -func MustInsertUnconfirmedEthTxWithAttemptState(t *testing.T, txStore txmgr.TestEvmTxStore, nonce int64, fromAddress common.Address, txAttemptState txmgrtypes.TxAttemptState, opts ...interface{}) txmgr.EvmTx { +func MustInsertUnconfirmedEthTxWithAttemptState(t *testing.T, txStore txmgr.TestEvmTxStore, nonce int64, fromAddress common.Address, txAttemptState txmgrtypes.TxAttemptState, opts ...interface{}) txmgr.Tx { etx := MustInsertUnconfirmedEthTx(t, txStore, nonce, fromAddress, opts...) attempt := NewLegacyEthTxAttempt(t, etx.ID) @@ -200,7 +200,7 @@ func MustInsertUnconfirmedEthTxWithAttemptState(t *testing.T, txStore txmgr.Test return etx } -func MustInsertUnconfirmedEthTxWithBroadcastDynamicFeeAttempt(t *testing.T, txStore txmgr.TestEvmTxStore, nonce int64, fromAddress common.Address, opts ...interface{}) txmgr.EvmTx { +func MustInsertUnconfirmedEthTxWithBroadcastDynamicFeeAttempt(t *testing.T, txStore txmgr.TestEvmTxStore, nonce int64, fromAddress common.Address, opts ...interface{}) txmgr.Tx { etx := MustInsertUnconfirmedEthTx(t, txStore, nonce, fromAddress, opts...) attempt := NewDynamicFeeEthTxAttempt(t, etx.ID) @@ -227,7 +227,7 @@ func MustInsertUnconfirmedEthTxWithBroadcastDynamicFeeAttempt(t *testing.T, txSt return etx } -func MustInsertUnconfirmedEthTxWithInsufficientEthAttempt(t *testing.T, txStore txmgr.TestEvmTxStore, nonce int64, fromAddress common.Address) txmgr.EvmTx { +func MustInsertUnconfirmedEthTxWithInsufficientEthAttempt(t *testing.T, txStore txmgr.TestEvmTxStore, nonce int64, fromAddress common.Address) txmgr.Tx { timeNow := time.Now() etx := NewEthTx(t, fromAddress) @@ -253,7 +253,7 @@ func MustInsertUnconfirmedEthTxWithInsufficientEthAttempt(t *testing.T, txStore func MustInsertConfirmedMissingReceiptEthTxWithLegacyAttempt( t *testing.T, txStore txmgr.TestEvmTxStore, nonce int64, broadcastBeforeBlockNum int64, - broadcastAt time.Time, fromAddress common.Address) txmgr.EvmTx { + broadcastAt time.Time, fromAddress common.Address) txmgr.Tx { etx := NewEthTx(t, fromAddress) etx.BroadcastAt = &broadcastAt @@ -270,7 +270,7 @@ func MustInsertConfirmedMissingReceiptEthTxWithLegacyAttempt( return etx } -func MustInsertConfirmedEthTxWithLegacyAttempt(t *testing.T, txStore txmgr.TestEvmTxStore, nonce int64, broadcastBeforeBlockNum int64, fromAddress common.Address) txmgr.EvmTx { +func MustInsertConfirmedEthTxWithLegacyAttempt(t *testing.T, txStore txmgr.TestEvmTxStore, nonce int64, broadcastBeforeBlockNum int64, fromAddress common.Address) txmgr.Tx { timeNow := time.Now() etx := NewEthTx(t, fromAddress) @@ -288,7 +288,7 @@ func MustInsertConfirmedEthTxWithLegacyAttempt(t *testing.T, txStore txmgr.TestE return etx } -func MustInsertInProgressEthTxWithAttempt(t *testing.T, txStore txmgr.TestEvmTxStore, nonce evmtypes.Nonce, fromAddress common.Address) txmgr.EvmTx { +func MustInsertInProgressEthTxWithAttempt(t *testing.T, txStore txmgr.TestEvmTxStore, nonce evmtypes.Nonce, fromAddress common.Address) txmgr.Tx { etx := NewEthTx(t, fromAddress) etx.Sequence = &nonce @@ -306,8 +306,8 @@ func MustInsertInProgressEthTxWithAttempt(t *testing.T, txStore txmgr.TestEvmTxS return etx } -func MustCreateUnstartedGeneratedTx(t testing.TB, txStore txmgr.EvmTxStore, fromAddress common.Address, chainID *big.Int, opts ...func(*txmgr.EvmTxRequest)) (tx txmgr.EvmTx) { - txRequest := txmgr.EvmTxRequest{ +func MustCreateUnstartedGeneratedTx(t testing.TB, txStore txmgr.EvmTxStore, fromAddress common.Address, chainID *big.Int, opts ...func(*txmgr.TxRequest)) (tx txmgr.Tx) { + txRequest := txmgr.TxRequest{ FromAddress: fromAddress, } @@ -320,8 +320,8 @@ func MustCreateUnstartedGeneratedTx(t testing.TB, txStore txmgr.EvmTxStore, from return MustCreateUnstartedTxFromEvmTxRequest(t, txStore, txRequest, chainID) } -func WithDefaults() func(*txmgr.EvmTxRequest) { - return func(tx *txmgr.EvmTxRequest) { +func WithDefaults() func(*txmgr.TxRequest) { + return func(tx *txmgr.TxRequest) { tx.ToAddress = testutils.NewAddress() tx.EncodedPayload = []byte{1, 2, 3} tx.Value = big.Int(assets.NewEthValue(142)) @@ -331,25 +331,25 @@ func WithDefaults() func(*txmgr.EvmTxRequest) { } } -func EvmTxRequestWithStrategy(strategy txmgrtypes.TxStrategy) func(*txmgr.EvmTxRequest) { - return func(tx *txmgr.EvmTxRequest) { +func EvmTxRequestWithStrategy(strategy txmgrtypes.TxStrategy) func(*txmgr.TxRequest) { + return func(tx *txmgr.TxRequest) { tx.Strategy = strategy } } -func EvmTxRequestWithChecker(checker txmgr.EvmTransmitCheckerSpec) func(*txmgr.EvmTxRequest) { - return func(tx *txmgr.EvmTxRequest) { +func EvmTxRequestWithChecker(checker txmgr.EvmTransmitCheckerSpec) func(*txmgr.TxRequest) { + return func(tx *txmgr.TxRequest) { tx.Checker = checker } } -func EvmTxRequestWithValue(value big.Int) func(*txmgr.EvmTxRequest) { - return func(tx *txmgr.EvmTxRequest) { +func EvmTxRequestWithValue(value big.Int) func(*txmgr.TxRequest) { + return func(tx *txmgr.TxRequest) { tx.Value = value } } -func MustCreateUnstartedTx(t testing.TB, txStore txmgr.EvmTxStore, fromAddress common.Address, toAddress common.Address, encodedPayload []byte, gasLimit uint32, value big.Int, chainID *big.Int, opts ...interface{}) (tx txmgr.EvmTx) { - txRequest := txmgr.EvmTxRequest{ +func MustCreateUnstartedTx(t testing.TB, txStore txmgr.EvmTxStore, fromAddress common.Address, toAddress common.Address, encodedPayload []byte, gasLimit uint32, value big.Int, chainID *big.Int, opts ...interface{}) (tx txmgr.Tx) { + txRequest := txmgr.TxRequest{ FromAddress: fromAddress, ToAddress: toAddress, EncodedPayload: encodedPayload, @@ -361,15 +361,15 @@ func MustCreateUnstartedTx(t testing.TB, txStore txmgr.EvmTxStore, fromAddress c return MustCreateUnstartedTxFromEvmTxRequest(t, txStore, txRequest, chainID) } -func MustCreateUnstartedTxFromEvmTxRequest(t testing.TB, txStore txmgr.EvmTxStore, txRequest txmgr.EvmTxRequest, chainID *big.Int) (tx txmgr.EvmTx) { +func MustCreateUnstartedTxFromEvmTxRequest(t testing.TB, txStore txmgr.EvmTxStore, txRequest txmgr.TxRequest, chainID *big.Int) (tx txmgr.Tx) { tx, err := txStore.CreateTransaction(txRequest, chainID) require.NoError(t, err) return tx } -func NewLegacyEthTxAttempt(t *testing.T, etxID int64) txmgr.EvmTxAttempt { +func NewLegacyEthTxAttempt(t *testing.T, etxID int64) txmgr.TxAttempt { gasPrice := assets.NewWeiI(1) - return txmgr.EvmTxAttempt{ + return txmgr.TxAttempt{ ChainSpecificFeeLimit: 42, TxID: etxID, TxFee: gas.EvmFee{Legacy: gasPrice}, @@ -381,10 +381,10 @@ func NewLegacyEthTxAttempt(t *testing.T, etxID int64) txmgr.EvmTxAttempt { } } -func NewDynamicFeeEthTxAttempt(t *testing.T, etxID int64) txmgr.EvmTxAttempt { +func NewDynamicFeeEthTxAttempt(t *testing.T, etxID int64) txmgr.TxAttempt { gasTipCap := assets.NewWeiI(1) gasFeeCap := assets.NewWeiI(1) - return txmgr.EvmTxAttempt{ + return txmgr.TxAttempt{ TxType: 0x2, TxID: etxID, TxFee: gas.EvmFee{ @@ -400,7 +400,7 @@ func NewDynamicFeeEthTxAttempt(t *testing.T, etxID int64) txmgr.EvmTxAttempt { } } -func NewEthReceipt(t *testing.T, blockNumber int64, blockHash common.Hash, txHash common.Hash, status uint64) txmgr.EvmReceipt { +func NewEthReceipt(t *testing.T, blockNumber int64, blockHash common.Hash, txHash common.Hash, status uint64) txmgr.Receipt { transactionIndex := uint(NewRandomPositiveInt64()) receipt := evmtypes.Receipt{ @@ -411,7 +411,7 @@ func NewEthReceipt(t *testing.T, blockNumber int64, blockHash common.Hash, txHas Status: status, } - r := txmgr.EvmReceipt{ + r := txmgr.Receipt{ BlockNumber: blockNumber, BlockHash: blockHash, TxHash: txHash, @@ -421,7 +421,7 @@ func NewEthReceipt(t *testing.T, blockNumber int64, blockHash common.Hash, txHas return r } -func MustInsertEthReceipt(t *testing.T, txStore txmgr.TestEvmTxStore, blockNumber int64, blockHash common.Hash, txHash common.Hash) txmgr.EvmReceipt { +func MustInsertEthReceipt(t *testing.T, txStore txmgr.TestEvmTxStore, blockNumber int64, blockHash common.Hash, txHash common.Hash) txmgr.Receipt { r := NewEthReceipt(t, blockNumber, blockHash, txHash, 0x1) id, err := txStore.InsertReceipt(&r.Receipt) require.NoError(t, err) @@ -429,7 +429,7 @@ func MustInsertEthReceipt(t *testing.T, txStore txmgr.TestEvmTxStore, blockNumbe return r } -func MustInsertRevertedEthReceipt(t *testing.T, txStore txmgr.TestEvmTxStore, blockNumber int64, blockHash common.Hash, txHash common.Hash) txmgr.EvmReceipt { +func MustInsertRevertedEthReceipt(t *testing.T, txStore txmgr.TestEvmTxStore, blockNumber int64, blockHash common.Hash, txHash common.Hash) txmgr.Receipt { r := NewEthReceipt(t, blockNumber, blockHash, txHash, 0x0) id, err := txStore.InsertReceipt(&r.Receipt) require.NoError(t, err) @@ -438,13 +438,13 @@ func MustInsertRevertedEthReceipt(t *testing.T, txStore txmgr.TestEvmTxStore, bl } // Inserts into eth_receipts but does not update eth_txes or eth_tx_attempts -func MustInsertConfirmedEthTxWithReceipt(t *testing.T, txStore txmgr.TestEvmTxStore, fromAddress common.Address, nonce, blockNum int64) (etx txmgr.EvmTx) { +func MustInsertConfirmedEthTxWithReceipt(t *testing.T, txStore txmgr.TestEvmTxStore, fromAddress common.Address, nonce, blockNum int64) (etx txmgr.Tx) { etx = MustInsertConfirmedEthTxWithLegacyAttempt(t, txStore, nonce, blockNum, fromAddress) MustInsertEthReceipt(t, txStore, blockNum, utils.NewHash(), etx.TxAttempts[0].Hash) return etx } -func MustInsertConfirmedEthTxBySaveFetchedReceipts(t *testing.T, txStore txmgr.TestEvmTxStore, fromAddress common.Address, nonce int64, blockNum int64, chainID big.Int) (etx txmgr.EvmTx) { +func MustInsertConfirmedEthTxBySaveFetchedReceipts(t *testing.T, txStore txmgr.TestEvmTxStore, fromAddress common.Address, nonce int64, blockNum int64, chainID big.Int) (etx txmgr.Tx) { etx = MustInsertConfirmedEthTxWithLegacyAttempt(t, txStore, nonce, blockNum, fromAddress) receipt := evmtypes.Receipt{ TxHash: etx.TxAttempts[0].Hash, @@ -457,7 +457,7 @@ func MustInsertConfirmedEthTxBySaveFetchedReceipts(t *testing.T, txStore txmgr.T return etx } -func MustInsertFatalErrorEthTx(t *testing.T, txStore txmgr.TestEvmTxStore, fromAddress common.Address) txmgr.EvmTx { +func MustInsertFatalErrorEthTx(t *testing.T, txStore txmgr.TestEvmTxStore, fromAddress common.Address) txmgr.Tx { etx := NewEthTx(t, fromAddress) etx.Error = null.StringFrom("something exploded") etx.State = txmgrcommon.TxFatalError diff --git a/core/internal/testutils/evmtest/evmtest.go b/core/internal/testutils/evmtest/evmtest.go index 3add5952037..5e6d9fea744 100644 --- a/core/internal/testutils/evmtest/evmtest.go +++ b/core/internal/testutils/evmtest/evmtest.go @@ -61,7 +61,7 @@ type TestChainOpts struct { GeneralConfig evm.GeneralConfig HeadTracker httypes.HeadTracker DB *sqlx.DB - TxManager txmgr.EvmTxManager + TxManager txmgr.TxManager KeyStore keystore.Eth MailMon *utils.MailboxMonitor GasEstimator gas.EvmFeeEstimator @@ -116,7 +116,7 @@ func NewChainSetOpts(t testing.TB, testopts TestChainOpts) evm.ChainSetOpts { } } if testopts.TxManager != nil { - opts.GenTxManager = func(*big.Int) txmgr.EvmTxManager { + opts.GenTxManager = func(*big.Int) txmgr.TxManager { return testopts.TxManager } } diff --git a/core/services/blockhashstore/batch_bhs.go b/core/services/blockhashstore/batch_bhs.go index 25344fbe4a5..96e5784a8cd 100644 --- a/core/services/blockhashstore/batch_bhs.go +++ b/core/services/blockhashstore/batch_bhs.go @@ -24,7 +24,7 @@ type batchBHSConfig interface { type BatchBlockhashStore struct { config batchBHSConfig - txm txmgr.EvmTxManager + txm txmgr.TxManager abi *abi.ABI batchbhs batch_blockhash_store.BatchBlockhashStoreInterface lggr logger.Logger @@ -33,7 +33,7 @@ type BatchBlockhashStore struct { func NewBatchBHS( config batchBHSConfig, fromAddresses []ethkey.EIP55Address, - txm txmgr.EvmTxManager, + txm txmgr.TxManager, batchbhs batch_blockhash_store.BatchBlockhashStoreInterface, chainID *big.Int, gethks keystore.Eth, @@ -66,7 +66,7 @@ func (b *BatchBlockhashStore) StoreVerifyHeader(ctx context.Context, blockNumber return errors.Wrap(err, "packing args") } - _, err = b.txm.CreateTransaction(txmgr.EvmTxRequest{ + _, err = b.txm.CreateTransaction(txmgr.TxRequest{ FromAddress: fromAddress, ToAddress: b.batchbhs.Address(), EncodedPayload: payload, diff --git a/core/services/blockhashstore/bhs.go b/core/services/blockhashstore/bhs.go index 8d5502b378f..adc1cdb354d 100644 --- a/core/services/blockhashstore/bhs.go +++ b/core/services/blockhashstore/bhs.go @@ -39,7 +39,7 @@ type BulletproofBHS struct { dbConfig bpBHSDatabaseConfig jobID uuid.UUID fromAddresses []ethkey.EIP55Address - txm txmgr.EvmTxManager + txm txmgr.TxManager abi *abi.ABI bhs blockhash_store.BlockhashStoreInterface chainID *big.Int @@ -51,7 +51,7 @@ func NewBulletproofBHS( config bpBHSConfig, dbConfig bpBHSDatabaseConfig, fromAddresses []ethkey.EIP55Address, - txm txmgr.EvmTxManager, + txm txmgr.TxManager, bhs blockhash_store.BlockhashStoreInterface, chainID *big.Int, gethks keystore.Eth, @@ -86,7 +86,7 @@ func (c *BulletproofBHS) Store(ctx context.Context, blockNum uint64) error { return errors.Wrap(err, "getting next from address") } - _, err = c.txm.CreateTransaction(txmgr.EvmTxRequest{ + _, err = c.txm.CreateTransaction(txmgr.TxRequest{ FromAddress: fromAddress, ToAddress: c.bhs.Address(), EncodedPayload: payload, @@ -134,7 +134,7 @@ func (c *BulletproofBHS) StoreEarliest(ctx context.Context) error { return errors.Wrap(err, "getting next from address") } - _, err = c.txm.CreateTransaction(txmgr.EvmTxRequest{ + _, err = c.txm.CreateTransaction(txmgr.TxRequest{ FromAddress: fromAddress, ToAddress: c.bhs.Address(), EncodedPayload: payload, diff --git a/core/services/blockhashstore/bhs_test.go b/core/services/blockhashstore/bhs_test.go index b7e9fa2d566..61332ecb0ab 100644 --- a/core/services/blockhashstore/bhs_test.go +++ b/core/services/blockhashstore/bhs_test.go @@ -55,13 +55,13 @@ func TestStoreRotatesFromAddresses(t *testing.T) { ) require.NoError(t, err) - txm.On("CreateTransaction", mock.MatchedBy(func(tx txmgr.EvmTxRequest) bool { + txm.On("CreateTransaction", mock.MatchedBy(func(tx txmgr.TxRequest) bool { return tx.FromAddress.String() == k1.Address.String() - }), mock.Anything).Once().Return(txmgr.EvmTx{}, nil) + }), mock.Anything).Once().Return(txmgr.Tx{}, nil) - txm.On("CreateTransaction", mock.MatchedBy(func(tx txmgr.EvmTxRequest) bool { + txm.On("CreateTransaction", mock.MatchedBy(func(tx txmgr.TxRequest) bool { return tx.FromAddress.String() == k2.Address.String() - }), mock.Anything).Once().Return(txmgr.EvmTx{}, nil) + }), mock.Anything).Once().Return(txmgr.Tx{}, nil) // store 2 blocks err = bhs.Store(context.Background(), 1) diff --git a/core/services/fluxmonitorv2/flux_monitor_test.go b/core/services/fluxmonitorv2/flux_monitor_test.go index e6c0f237a89..5e0b8171362 100644 --- a/core/services/fluxmonitorv2/flux_monitor_test.go +++ b/core/services/fluxmonitorv2/flux_monitor_test.go @@ -53,7 +53,7 @@ var ( type answerSet struct{ latestAnswer, polledAnswer int64 } -func newORM(t *testing.T, db *sqlx.DB, cfg pg.QConfig, txm txmgr.EvmTxManager) fluxmonitorv2.ORM { +func newORM(t *testing.T, db *sqlx.DB, cfg pg.QConfig, txm txmgr.TxManager) fluxmonitorv2.ORM { return fluxmonitorv2.NewORM(db, logger.TestLogger(t), cfg, txm, txmgrcommon.NewSendEveryStrategy(), txmgr.EvmTransmitCheckerSpec{}) } diff --git a/core/services/fluxmonitorv2/orm.go b/core/services/fluxmonitorv2/orm.go index 6dc8744fa8a..4990a0a512d 100644 --- a/core/services/fluxmonitorv2/orm.go +++ b/core/services/fluxmonitorv2/orm.go @@ -15,7 +15,7 @@ import ( ) type transmitter interface { - CreateTransaction(txRequest txmgr.EvmTxRequest, qopts ...pg.QOpt) (tx txmgr.EvmTx, err error) + CreateTransaction(txRequest txmgr.TxRequest, qopts ...pg.QOpt) (tx txmgr.Tx, err error) } //go:generate mockery --quiet --name ORM --output ./mocks/ --case=underscore @@ -121,7 +121,7 @@ func (o *orm) CreateEthTransaction( qopts ...pg.QOpt, ) (err error) { - _, err = o.txm.CreateTransaction(txmgr.EvmTxRequest{ + _, err = o.txm.CreateTransaction(txmgr.TxRequest{ FromAddress: fromAddress, ToAddress: toAddress, EncodedPayload: payload, diff --git a/core/services/fluxmonitorv2/orm_test.go b/core/services/fluxmonitorv2/orm_test.go index 64cd4b23623..40a4d1c5dc1 100644 --- a/core/services/fluxmonitorv2/orm_test.go +++ b/core/services/fluxmonitorv2/orm_test.go @@ -183,14 +183,14 @@ func TestORM_CreateEthTransaction(t *testing.T) { gasLimit = uint32(21000) ) - txm.On("CreateTransaction", txmgr.EvmTxRequest{ + txm.On("CreateTransaction", txmgr.TxRequest{ FromAddress: from, ToAddress: to, EncodedPayload: payload, FeeLimit: gasLimit, Meta: nil, Strategy: strategy, - }).Return(txmgr.EvmTx{}, nil).Once() + }).Return(txmgr.Tx{}, nil).Once() require.NoError(t, orm.CreateEthTransaction(from, to, payload, gasLimit)) } diff --git a/core/services/keeper/upkeep_executer_test.go b/core/services/keeper/upkeep_executer_test.go index f718cf09f9f..e30b49f961f 100644 --- a/core/services/keeper/upkeep_executer_test.go +++ b/core/services/keeper/upkeep_executer_test.go @@ -127,10 +127,10 @@ func Test_UpkeepExecuter_PerformsUpkeep_Happy(t *testing.T) { ethTxCreated := cltest.NewAwaiter() txm.On("CreateTransaction", - mock.MatchedBy(func(txRequest txmgr.EvmTxRequest) bool { return txRequest.FeeLimit == gasLimit }), + mock.MatchedBy(func(txRequest txmgr.TxRequest) bool { return txRequest.FeeLimit == gasLimit }), ). Once(). - Return(txmgr.EvmTx{ + Return(txmgr.Tx{ ID: 1, }, nil). Run(func(mock.Arguments) { ethTxCreated.ItHappened() }) @@ -170,10 +170,10 @@ func Test_UpkeepExecuter_PerformsUpkeep_Happy(t *testing.T) { ethTxCreated := cltest.NewAwaiter() txm.On("CreateTransaction", - mock.MatchedBy(func(txRequest txmgr.EvmTxRequest) bool { return txRequest.FeeLimit == gasLimit }), + mock.MatchedBy(func(txRequest txmgr.TxRequest) bool { return txRequest.FeeLimit == gasLimit }), ). Once(). - Return(txmgr.EvmTx{ + Return(txmgr.Tx{ ID: 1, }, nil). Run(func(mock.Arguments) { ethTxCreated.ItHappened() }) @@ -272,10 +272,10 @@ func Test_UpkeepExecuter_PerformsUpkeep_Happy(t *testing.T) { } gasLimit := 5_000_000 + config.Keeper().Registry().PerformGasOverhead() txm.On("CreateTransaction", - mock.MatchedBy(func(txRequest txmgr.EvmTxRequest) bool { return txRequest.FeeLimit == gasLimit }), + mock.MatchedBy(func(txRequest txmgr.TxRequest) bool { return txRequest.FeeLimit == gasLimit }), ). Once(). - Return(txmgr.EvmTx{}, nil). + Return(txmgr.Tx{}, nil). Run(func(mock.Arguments) { etxs[0].ItHappened() }) registryMock := cltest.NewContractMockReceiver(t, ethMock, keeper.Registry1_1ABI, registry.ContractAddress.Address()) diff --git a/core/services/ocrcommon/transmitter.go b/core/services/ocrcommon/transmitter.go index 88fe0633246..8b7433f59a4 100644 --- a/core/services/ocrcommon/transmitter.go +++ b/core/services/ocrcommon/transmitter.go @@ -17,11 +17,11 @@ type roundRobinKeystore interface { } type txManager interface { - CreateTransaction(txRequest txmgr.EvmTxRequest, qopts ...pg.QOpt) (tx txmgr.EvmTx, err error) + CreateTransaction(txRequest txmgr.TxRequest, qopts ...pg.QOpt) (tx txmgr.Tx, err error) } type Transmitter interface { - CreateEthTransaction(ctx context.Context, toAddress common.Address, payload []byte, txMeta *txmgr.EvmTxMeta) error + CreateEthTransaction(ctx context.Context, toAddress common.Address, payload []byte, txMeta *txmgr.TxMeta) error FromAddress() common.Address } @@ -65,14 +65,14 @@ func NewTransmitter( }, nil } -func (t *transmitter) CreateEthTransaction(ctx context.Context, toAddress common.Address, payload []byte, txMeta *txmgr.EvmTxMeta) error { +func (t *transmitter) CreateEthTransaction(ctx context.Context, toAddress common.Address, payload []byte, txMeta *txmgr.TxMeta) error { roundRobinFromAddress, err := t.keystore.GetRoundRobinAddress(t.chainID, t.fromAddresses...) if err != nil { return errors.Wrap(err, "skipped OCR transmission, error getting round-robin address") } - _, err = t.txm.CreateTransaction(txmgr.EvmTxRequest{ + _, err = t.txm.CreateTransaction(txmgr.TxRequest{ FromAddress: roundRobinFromAddress, ToAddress: toAddress, EncodedPayload: payload, diff --git a/core/services/ocrcommon/transmitter_pipeline.go b/core/services/ocrcommon/transmitter_pipeline.go index 88eec5c2132..e870737638b 100644 --- a/core/services/ocrcommon/transmitter_pipeline.go +++ b/core/services/ocrcommon/transmitter_pipeline.go @@ -64,7 +64,7 @@ func NewPipelineTransmitter( } } -func (t *pipelineTransmitter) CreateEthTransaction(ctx context.Context, toAddress common.Address, payload []byte, _ *txmgr.EvmTxMeta) error { +func (t *pipelineTransmitter) CreateEthTransaction(ctx context.Context, toAddress common.Address, payload []byte, _ *txmgr.TxMeta) error { // t.strategy is ignored currently as pipeline does not support passing this (sc-55115) vars := pipeline.NewVarsFrom(map[string]interface{}{ "jobSpec": map[string]interface{}{ diff --git a/core/services/ocrcommon/transmitter_test.go b/core/services/ocrcommon/transmitter_test.go index 90a36d576c8..f278ba5b8df 100644 --- a/core/services/ocrcommon/transmitter_test.go +++ b/core/services/ocrcommon/transmitter_test.go @@ -51,7 +51,7 @@ func Test_DefaultTransmitter_CreateEthTransaction(t *testing.T) { ) require.NoError(t, err) - txm.On("CreateTransaction", txmgr.EvmTxRequest{ + txm.On("CreateTransaction", txmgr.TxRequest{ FromAddress: fromAddress, ToAddress: toAddress, EncodedPayload: payload, @@ -59,7 +59,7 @@ func Test_DefaultTransmitter_CreateEthTransaction(t *testing.T) { ForwarderAddress: common.Address{}, Meta: nil, Strategy: strategy, - }, mock.Anything).Return(txmgr.EvmTx{}, nil).Once() + }, mock.Anything).Return(txmgr.Tx{}, nil).Once() require.NoError(t, transmitter.CreateEthTransaction(testutils.Context(t), toAddress, payload, nil)) } @@ -93,7 +93,7 @@ func Test_DefaultTransmitter_Forwarding_Enabled_CreateEthTransaction(t *testing. ) require.NoError(t, err) - txm.On("CreateTransaction", txmgr.EvmTxRequest{ + txm.On("CreateTransaction", txmgr.TxRequest{ FromAddress: fromAddress, ToAddress: toAddress, EncodedPayload: payload, @@ -101,8 +101,8 @@ func Test_DefaultTransmitter_Forwarding_Enabled_CreateEthTransaction(t *testing. ForwarderAddress: common.Address{}, Meta: nil, Strategy: strategy, - }, mock.Anything).Return(txmgr.EvmTx{}, nil).Once() - txm.On("CreateTransaction", txmgr.EvmTxRequest{ + }, mock.Anything).Return(txmgr.Tx{}, nil).Once() + txm.On("CreateTransaction", txmgr.TxRequest{ FromAddress: fromAddress2, ToAddress: toAddress, EncodedPayload: payload, @@ -110,7 +110,7 @@ func Test_DefaultTransmitter_Forwarding_Enabled_CreateEthTransaction(t *testing. ForwarderAddress: common.Address{}, Meta: nil, Strategy: strategy, - }, mock.Anything).Return(txmgr.EvmTx{}, nil).Once() + }, mock.Anything).Return(txmgr.Tx{}, nil).Once() require.NoError(t, transmitter.CreateEthTransaction(testutils.Context(t), toAddress, payload, nil)) require.NoError(t, transmitter.CreateEthTransaction(testutils.Context(t), toAddress, payload, nil)) } diff --git a/core/services/pipeline/task.eth_tx.go b/core/services/pipeline/task.eth_tx.go index 90dc5534ded..f8fcb9e5f87 100644 --- a/core/services/pipeline/task.eth_tx.go +++ b/core/services/pipeline/task.eth_tx.go @@ -136,7 +136,7 @@ func (t *ETHTxTask) Run(_ context.Context, lggr logger.Logger, vars Vars, inputs } } - txRequest := txmgr.EvmTxRequest{ + txRequest := txmgr.TxRequest{ FromAddress: fromAddr, ToAddress: common.Address(toAddr), EncodedPayload: []byte(data), @@ -165,8 +165,8 @@ func (t *ETHTxTask) Run(_ context.Context, lggr logger.Logger, vars Vars, inputs return Result{Value: nil}, runInfo } -func decodeMeta(metaMap MapParam) (*txmgr.EvmTxMeta, error) { - var txMeta txmgr.EvmTxMeta +func decodeMeta(metaMap MapParam) (*txmgr.TxMeta, error) { + var txMeta txmgr.TxMeta metaDecoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{ Result: &txMeta, ErrorUnused: true, @@ -231,7 +231,7 @@ func decodeTransmitChecker(checkerMap MapParam) (txmgr.EvmTransmitCheckerSpec, e } // txMeta is really only used for logging, so this is best-effort -func setJobIDOnMeta(lggr logger.Logger, vars Vars, meta *txmgr.EvmTxMeta) { +func setJobIDOnMeta(lggr logger.Logger, vars Vars, meta *txmgr.TxMeta) { jobID, err := vars.Get("jobSpec.databaseID") if err != nil { return diff --git a/core/services/pipeline/task.eth_tx_test.go b/core/services/pipeline/task.eth_tx_test.go index 9d896279730..8bfdb2bc4e9 100644 --- a/core/services/pipeline/task.eth_tx_test.go +++ b/core/services/pipeline/task.eth_tx_test.go @@ -75,14 +75,14 @@ func TestETHTxTask(t *testing.T) { gasLimit := uint32(12345) jobID := int32(321) addr := common.HexToAddress("0x2E396ecbc8223Ebc16EC45136228AE5EDB649943") - txMeta := &txmgr.EvmTxMeta{ + txMeta := &txmgr.TxMeta{ JobID: &jobID, RequestID: &reqID, RequestTxHash: &reqTxHash, FailOnRevert: null.BoolFrom(false), } keyStore.On("GetRoundRobinAddress", testutils.FixtureChainID, from).Return(from, nil) - txManager.On("CreateTransaction", txmgr.EvmTxRequest{ + txManager.On("CreateTransaction", txmgr.TxRequest{ FromAddress: from, ToAddress: to, EncodedPayload: data, @@ -93,7 +93,7 @@ func TestETHTxTask(t *testing.T) { CheckerType: txmgr.TransmitCheckerTypeVRFV2, VRFCoordinatorAddress: &addr, }, - }).Return(txmgr.EvmTx{}, nil) + }).Return(txmgr.Tx{}, nil) }, nil, nil, "", pipeline.RunInfo{}, }, @@ -122,21 +122,21 @@ func TestETHTxTask(t *testing.T) { func(keyStore *keystoremocks.Eth, txManager *txmmocks.MockEvmTxManager) { data := []byte("foobar") gasLimit := uint32(12345) - txMeta := &txmgr.EvmTxMeta{ + txMeta := &txmgr.TxMeta{ JobID: &jid, RequestID: &reqID, RequestTxHash: &reqTxHash, FailOnRevert: null.BoolFrom(false), } keyStore.On("GetRoundRobinAddress", testutils.FixtureChainID, from).Return(from, nil) - txManager.On("CreateTransaction", txmgr.EvmTxRequest{ + txManager.On("CreateTransaction", txmgr.TxRequest{ FromAddress: from, ToAddress: to, EncodedPayload: data, FeeLimit: gasLimit, Meta: txMeta, Strategy: txmgrcommon.NewSendEveryStrategy(), - }).Return(txmgr.EvmTx{}, nil) + }).Return(txmgr.Tx{}, nil) }, nil, nil, "", pipeline.RunInfo{}, }, @@ -166,9 +166,9 @@ func TestETHTxTask(t *testing.T) { func(keyStore *keystoremocks.Eth, txManager *txmmocks.MockEvmTxManager) { from := common.HexToAddress("0x882969652440ccf14a5dbb9bd53eb21cb1e11e5c") keyStore.On("GetRoundRobinAddress", testutils.FixtureChainID, from).Return(from, nil) - txManager.On("CreateTransaction", mock.MatchedBy(func(tx txmgr.EvmTxRequest) bool { + txManager.On("CreateTransaction", mock.MatchedBy(func(tx txmgr.TxRequest) bool { return tx.MinConfirmations == clnull.Uint32From(2) - })).Return(txmgr.EvmTx{}, nil) + })).Return(txmgr.Tx{}, nil) }, nil, nil, "", pipeline.RunInfo{IsPending: true}, }, @@ -199,21 +199,21 @@ func TestETHTxTask(t *testing.T) { func(keyStore *keystoremocks.Eth, txManager *txmmocks.MockEvmTxManager) { data := []byte("foobar") gasLimit := uint32(12345) - txMeta := &txmgr.EvmTxMeta{ + txMeta := &txmgr.TxMeta{ JobID: &jid, RequestID: &reqID, RequestTxHash: &reqTxHash, FailOnRevert: null.BoolFrom(false), } keyStore.On("GetRoundRobinAddress", testutils.FixtureChainID, from).Return(from, nil) - txManager.On("CreateTransaction", txmgr.EvmTxRequest{ + txManager.On("CreateTransaction", txmgr.TxRequest{ FromAddress: from, ToAddress: to, EncodedPayload: data, FeeLimit: gasLimit, Meta: txMeta, Strategy: txmgrcommon.NewSendEveryStrategy(), - }).Return(txmgr.EvmTx{}, nil) + }).Return(txmgr.Tx{}, nil) }, nil, nil, "", pipeline.RunInfo{}, }, @@ -244,21 +244,21 @@ func TestETHTxTask(t *testing.T) { func(keyStore *keystoremocks.Eth, txManager *txmmocks.MockEvmTxManager) { data := []byte("foobar") gasLimit := uint32(12345) - txMeta := &txmgr.EvmTxMeta{ + txMeta := &txmgr.TxMeta{ JobID: &jid, RequestID: &reqID, RequestTxHash: &reqTxHash, FailOnRevert: null.BoolFrom(false), } keyStore.On("GetRoundRobinAddress", testutils.FixtureChainID).Return(from, nil) - txManager.On("CreateTransaction", txmgr.EvmTxRequest{ + txManager.On("CreateTransaction", txmgr.TxRequest{ FromAddress: from, ToAddress: to, EncodedPayload: data, FeeLimit: gasLimit, Meta: txMeta, Strategy: txmgrcommon.NewSendEveryStrategy(), - }).Return(txmgr.EvmTx{}, nil) + }).Return(txmgr.Tx{}, nil) }, nil, nil, "", pipeline.RunInfo{}, }, @@ -279,16 +279,16 @@ func TestETHTxTask(t *testing.T) { func(keyStore *keystoremocks.Eth, txManager *txmmocks.MockEvmTxManager) { data := []byte("foobar") gasLimit := uint32(12345) - txMeta := &txmgr.EvmTxMeta{FailOnRevert: null.BoolFrom(false)} + txMeta := &txmgr.TxMeta{FailOnRevert: null.BoolFrom(false)} keyStore.On("GetRoundRobinAddress", testutils.FixtureChainID, from).Return(from, nil) - txManager.On("CreateTransaction", txmgr.EvmTxRequest{ + txManager.On("CreateTransaction", txmgr.TxRequest{ FromAddress: from, ToAddress: to, EncodedPayload: data, FeeLimit: gasLimit, Meta: txMeta, Strategy: txmgrcommon.NewSendEveryStrategy(), - }).Return(txmgr.EvmTx{}, nil) + }).Return(txmgr.Tx{}, nil) }, nil, nil, "", pipeline.RunInfo{}, }, @@ -308,21 +308,21 @@ func TestETHTxTask(t *testing.T) { nil, func(keyStore *keystoremocks.Eth, txManager *txmmocks.MockEvmTxManager) { data := []byte("foobar") - txMeta := &txmgr.EvmTxMeta{ + txMeta := &txmgr.TxMeta{ JobID: &jid, RequestID: &reqID, RequestTxHash: &reqTxHash, FailOnRevert: null.BoolFrom(false), } keyStore.On("GetRoundRobinAddress", testutils.FixtureChainID, from).Return(from, nil) - txManager.On("CreateTransaction", txmgr.EvmTxRequest{ + txManager.On("CreateTransaction", txmgr.TxRequest{ FromAddress: from, ToAddress: to, EncodedPayload: data, FeeLimit: drJobTypeGasLimit, Meta: txMeta, Strategy: txmgrcommon.NewSendEveryStrategy(), - }).Return(txmgr.EvmTx{}, nil) + }).Return(txmgr.Tx{}, nil) }, nil, nil, "", pipeline.RunInfo{}, }, @@ -342,21 +342,21 @@ func TestETHTxTask(t *testing.T) { nil, func(keyStore *keystoremocks.Eth, txManager *txmmocks.MockEvmTxManager) { data := []byte("foobar") - txMeta := &txmgr.EvmTxMeta{ + txMeta := &txmgr.TxMeta{ JobID: &jid, RequestID: &reqID, RequestTxHash: &reqTxHash, FailOnRevert: null.BoolFrom(false), } keyStore.On("GetRoundRobinAddress", testutils.FixtureChainID, from).Return(from, nil) - txManager.On("CreateTransaction", txmgr.EvmTxRequest{ + txManager.On("CreateTransaction", txmgr.TxRequest{ FromAddress: from, ToAddress: to, EncodedPayload: data, FeeLimit: specGasLimit, Meta: txMeta, Strategy: txmgrcommon.NewSendEveryStrategy(), - }).Return(txmgr.EvmTx{}, nil) + }).Return(txmgr.Tx{}, nil) }, nil, nil, "", pipeline.RunInfo{}, }, @@ -407,21 +407,21 @@ func TestETHTxTask(t *testing.T) { func(keyStore *keystoremocks.Eth, txManager *txmmocks.MockEvmTxManager) { data := []byte("foobar") gasLimit := uint32(12345) - txMeta := &txmgr.EvmTxMeta{ + txMeta := &txmgr.TxMeta{ JobID: &jid, RequestID: &reqID, RequestTxHash: &reqTxHash, FailOnRevert: null.BoolFrom(false), } keyStore.On("GetRoundRobinAddress", testutils.FixtureChainID, from).Return(from, nil) - txManager.On("CreateTransaction", txmgr.EvmTxRequest{ + txManager.On("CreateTransaction", txmgr.TxRequest{ FromAddress: from, ToAddress: to, EncodedPayload: data, FeeLimit: gasLimit, Meta: txMeta, Strategy: txmgrcommon.NewSendEveryStrategy(), - }).Return(txmgr.EvmTx{}, errors.New("uh oh")) + }).Return(txmgr.Tx{}, errors.New("uh oh")) }, nil, pipeline.ErrTaskRunFailed, "while creating transaction", pipeline.RunInfo{IsRetryable: true}, }, @@ -510,9 +510,9 @@ func TestETHTxTask(t *testing.T) { func(keyStore *keystoremocks.Eth, txManager *txmmocks.MockEvmTxManager) { from := common.HexToAddress("0x882969652440ccf14a5dbb9bd53eb21cb1e11e5c") keyStore.On("GetRoundRobinAddress", testutils.FixtureChainID, from).Return(from, nil) - txManager.On("CreateTransaction", mock.MatchedBy(func(tx txmgr.EvmTxRequest) bool { + txManager.On("CreateTransaction", mock.MatchedBy(func(tx txmgr.TxRequest) bool { return tx.MinConfirmations == clnull.Uint32From(3) && tx.PipelineTaskRunID != nil - })).Return(txmgr.EvmTx{}, nil) + })).Return(txmgr.Tx{}, nil) }, nil, nil, "", pipeline.RunInfo{IsPending: true}, }, diff --git a/core/services/relay/evm/contract_transmitter.go b/core/services/relay/evm/contract_transmitter.go index 9932e88e23c..d4a2c6204ca 100644 --- a/core/services/relay/evm/contract_transmitter.go +++ b/core/services/relay/evm/contract_transmitter.go @@ -30,13 +30,13 @@ type ContractTransmitter interface { var _ ContractTransmitter = &contractTransmitter{} type Transmitter interface { - CreateEthTransaction(ctx context.Context, toAddress gethcommon.Address, payload []byte, txMeta *txmgr.EvmTxMeta) error + CreateEthTransaction(ctx context.Context, toAddress gethcommon.Address, payload []byte, txMeta *txmgr.TxMeta) error FromAddress() gethcommon.Address } -type ReportToEthMetadata func([]byte) (*txmgr.EvmTxMeta, error) +type ReportToEthMetadata func([]byte) (*txmgr.TxMeta, error) -func reportToEvmTxMetaNoop([]byte) (*txmgr.EvmTxMeta, error) { +func reportToEvmTxMetaNoop([]byte) (*txmgr.TxMeta, error) { return nil, nil } diff --git a/core/services/relay/evm/contract_transmitter_test.go b/core/services/relay/evm/contract_transmitter_test.go index ea255ce24f7..73c9234a13e 100644 --- a/core/services/relay/evm/contract_transmitter_test.go +++ b/core/services/relay/evm/contract_transmitter_test.go @@ -25,7 +25,7 @@ var sampleAddress = testutils.NewAddress() type mockTransmitter struct{} -func (mockTransmitter) CreateEthTransaction(ctx context.Context, toAddress gethcommon.Address, payload []byte, _ *txmgr.EvmTxMeta) error { +func (mockTransmitter) CreateEthTransaction(ctx context.Context, toAddress gethcommon.Address, payload []byte, _ *txmgr.TxMeta) error { return nil } func (mockTransmitter) FromAddress() gethcommon.Address { return sampleAddress } @@ -44,8 +44,8 @@ func TestContractTransmitter(t *testing.T) { c.On("CallContract", mock.Anything, mock.Anything, mock.Anything).Return(digestAndEpochDontScanLogs, nil).Once() contractABI, _ := abi.JSON(strings.NewReader(ocr2aggregator.OCR2AggregatorABI)) lp.On("RegisterFilter", mock.Anything).Return(nil) - ot, err := NewOCRContractTransmitter(gethcommon.Address{}, c, contractABI, mockTransmitter{}, lp, lggr, func(b []byte) (*txmgr.EvmTxMeta, error) { - return &txmgr.EvmTxMeta{}, nil + ot, err := NewOCRContractTransmitter(gethcommon.Address{}, c, contractABI, mockTransmitter{}, lp, lggr, func(b []byte) (*txmgr.TxMeta, error) { + return &txmgr.TxMeta{}, nil }) require.NoError(t, err) digest, epoch, err := ot.LatestConfigDigestAndEpoch(testutils.Context(t)) diff --git a/core/services/vrf/delegate_test.go b/core/services/vrf/delegate_test.go index cbf32c0fb81..efeedb865f8 100644 --- a/core/services/vrf/delegate_test.go +++ b/core/services/vrf/delegate_test.go @@ -300,7 +300,7 @@ func TestDelegate_ValidLog(t *testing.T) { // Ensure we queue up a valid eth transaction // Linked to requestID vuni.txm.On("CreateTransaction", - mock.MatchedBy(func(txRequest txmgr.EvmTxRequest) bool { + mock.MatchedBy(func(txRequest txmgr.TxRequest) bool { meta := txRequest.Meta return txRequest.FromAddress == vuni.submitter && txRequest.ToAddress == common.HexToAddress(jb.VRFSpec.CoordinatorAddress.String()) && @@ -308,7 +308,7 @@ func TestDelegate_ValidLog(t *testing.T) { meta.JobID != nil && meta.RequestID != nil && meta.RequestTxHash != nil && (*meta.JobID > 0 && *meta.RequestID == tc.reqID && *meta.RequestTxHash == txHash) }), - ).Once().Return(txmgr.EvmTx{}, nil) + ).Once().Return(txmgr.Tx{}, nil) listener.HandleLog(log.NewLogBroadcast(tc.log, vuni.cid, nil)) // Wait until the log is present diff --git a/core/services/vrf/integration_v2_test.go b/core/services/vrf/integration_v2_test.go index a3ab8eb480a..608cb287772 100644 --- a/core/services/vrf/integration_v2_test.go +++ b/core/services/vrf/integration_v2_test.go @@ -760,7 +760,7 @@ func mineBatch(t *testing.T, requestIDs []*big.Int, subID uint64, uni coordinato `, subID) require.NoError(t, err) for _, tx := range txs { - var evmTx txmgr.EvmTx + var evmTx txmgr.Tx txmgr.DbEthTxToEthTx(tx, &evmTx) meta, err := evmTx.GetMeta() require.NoError(t, err) @@ -2105,7 +2105,7 @@ func TestMaliciousConsumer(t *testing.T) { // We expect the request to be serviced // by the node. - var attempts []txmgr.EvmTxAttempt + var attempts []txmgr.TxAttempt gomega.NewWithT(t).Eventually(func() bool { //runs, err = app.PipelineORM().GetAllRuns() attempts, _, err = app.TxmStorageService().TxAttempts(0, 1000) @@ -2392,21 +2392,21 @@ func TestStartingCountsV1(t *testing.T) { b := time.Now() n1, n2, n3, n4 := evmtypes.Nonce(0), evmtypes.Nonce(1), evmtypes.Nonce(2), evmtypes.Nonce(3) reqID := utils.PadByteToHash(0x10) - m1 := txmgr.EvmTxMeta{ + m1 := txmgr.TxMeta{ RequestID: &reqID, } md1, err := json.Marshal(&m1) require.NoError(t, err) md1_ := datatypes.JSON(md1) reqID2 := utils.PadByteToHash(0x11) - m2 := txmgr.EvmTxMeta{ + m2 := txmgr.TxMeta{ RequestID: &reqID2, } md2, err := json.Marshal(&m2) md2_ := datatypes.JSON(md2) require.NoError(t, err) chainID := utils.NewBig(big.NewInt(1337)) - confirmedTxes := []txmgr.EvmTx{ + confirmedTxes := []txmgr.Tx{ { Sequence: &n1, FromAddress: k.Address, @@ -2457,16 +2457,16 @@ func TestStartingCountsV1(t *testing.T) { }, } // add unconfirmed txes - unconfirmedTxes := []txmgr.EvmTx{} + unconfirmedTxes := []txmgr.Tx{} for i := int64(4); i < 6; i++ { reqID3 := utils.PadByteToHash(0x12) - md, err := json.Marshal(&txmgr.EvmTxMeta{ + md, err := json.Marshal(&txmgr.TxMeta{ RequestID: &reqID3, }) require.NoError(t, err) md1 := datatypes.JSON(md) newNonce := evmtypes.Nonce(i + 1) - unconfirmedTxes = append(unconfirmedTxes, txmgr.EvmTx{ + unconfirmedTxes = append(unconfirmedTxes, txmgr.Tx{ Sequence: &newNonce, FromAddress: k.Address, Error: null.String{}, @@ -2491,9 +2491,9 @@ VALUES (:nonce, :from_address, :to_address, :encoded_payload, :value, :gas_limit // add eth_tx_attempts for confirmed broadcastBlock := int64(1) - txAttempts := []txmgr.EvmTxAttempt{} + txAttempts := []txmgr.TxAttempt{} for i := range confirmedTxes { - txAttempts = append(txAttempts, txmgr.EvmTxAttempt{ + txAttempts = append(txAttempts, txmgr.TxAttempt{ TxID: int64(i + 1), TxFee: gas.EvmFee{Legacy: assets.NewWeiI(100)}, SignedRawTx: []byte(`blah`), @@ -2506,7 +2506,7 @@ VALUES (:nonce, :from_address, :to_address, :encoded_payload, :value, :gas_limit } // add eth_tx_attempts for unconfirmed for i := range unconfirmedTxes { - txAttempts = append(txAttempts, txmgr.EvmTxAttempt{ + txAttempts = append(txAttempts, txmgr.TxAttempt{ TxID: int64(i + 1 + len(confirmedTxes)), TxFee: gas.EvmFee{Legacy: assets.NewWeiI(100)}, SignedRawTx: []byte(`blah`), @@ -2529,9 +2529,9 @@ VALUES (:nonce, :from_address, :to_address, :encoded_payload, :value, :gas_limit } // add eth_receipts - receipts := []txmgr.EvmReceipt{} + receipts := []txmgr.Receipt{} for i := 0; i < 4; i++ { - receipts = append(receipts, txmgr.EvmReceipt{ + receipts = append(receipts, txmgr.Receipt{ BlockHash: utils.NewHash(), TxHash: txAttempts[i].Hash, BlockNumber: broadcastBlock, diff --git a/core/services/vrf/listener_v1.go b/core/services/vrf/listener_v1.go index 2d9d93f97a7..ff803653b29 100644 --- a/core/services/vrf/listener_v1.go +++ b/core/services/vrf/listener_v1.go @@ -53,7 +53,7 @@ type listenerV1 struct { job job.Job q pg.Q headBroadcaster httypes.HeadBroadcasterRegistry - txm txmgr.EvmTxManager + txm txmgr.TxManager gethks GethKeyStore mailMon *utils.MailboxMonitor reqLogs *utils.Mailbox[log.Broadcast] diff --git a/core/services/vrf/listener_v2.go b/core/services/vrf/listener_v2.go index 0867b8b4c0f..fa219b06f40 100644 --- a/core/services/vrf/listener_v2.go +++ b/core/services/vrf/listener_v2.go @@ -89,7 +89,7 @@ func newListenerV2( batchCoordinator batch_vrf_coordinator_v2.BatchVRFCoordinatorV2Interface, vrfOwner vrf_owner.VRFOwnerInterface, aggregator *aggregator_v3_interface.AggregatorV3Interface, - txm txmgr.EvmTxManager, + txm txmgr.TxManager, pipelineRunner pipeline.Runner, gethks keystore.Eth, job job.Job, @@ -160,7 +160,7 @@ type listenerV2 struct { ethClient evmclient.Client chainID *big.Int logBroadcaster log.Broadcaster - txm txmgr.EvmTxManager + txm txmgr.TxManager mailMon *utils.MailboxMonitor coordinator vrf_coordinator_v2.VRFCoordinatorV2Interface @@ -725,7 +725,7 @@ func (lsn *listenerV2) enqueueForceFulfillment( ctx context.Context, p vrfPipelineResult, fromAddress common.Address, -) (etx txmgr.EvmTx, err error) { +) (etx txmgr.Tx, err error) { if lsn.job.VRFSpec.VRFOwnerAddress == nil { err = errors.New("vrf owner address not set in job spec, recreate job and provide it to force-fulfill") return @@ -773,13 +773,13 @@ func (lsn *listenerV2) enqueueForceFulfillment( } requestID := common.BytesToHash(p.req.req.RequestId.Bytes()) - etx, err = lsn.txm.CreateTransaction(txmgr.EvmTxRequest{ + etx, err = lsn.txm.CreateTransaction(txmgr.TxRequest{ FromAddress: fromAddress, ToAddress: lsn.vrfOwner.Address(), EncodedPayload: txData, FeeLimit: uint32(estimateGasLimit), Strategy: txmgrcommon.NewSendEveryStrategy(), - Meta: &txmgr.EvmTxMeta{ + Meta: &txmgr.TxMeta{ RequestID: &requestID, SubID: &p.req.req.SubId, RequestTxHash: &p.req.req.Raw.TxHash, @@ -956,7 +956,7 @@ func (lsn *listenerV2) processRequestsPerSub( } ll.Infow("Enqueuing fulfillment") - var transaction txmgr.EvmTx + var transaction txmgr.Tx err = lsn.q.Transaction(func(tx pg.Queryer) error { if err = lsn.pipelineRunner.InsertFinishedRun(&p.run, true, pg.WithQueryer(tx)); err != nil { return err @@ -968,12 +968,12 @@ func (lsn *listenerV2) processRequestsPerSub( maxLinkString := p.maxLink.String() requestID := common.BytesToHash(p.req.req.RequestId.Bytes()) coordinatorAddress := lsn.coordinator.Address() - transaction, err = lsn.txm.CreateTransaction(txmgr.EvmTxRequest{ + transaction, err = lsn.txm.CreateTransaction(txmgr.TxRequest{ FromAddress: fromAddress, ToAddress: lsn.coordinator.Address(), EncodedPayload: hexutil.MustDecode(p.payload), FeeLimit: p.gasLimit, - Meta: &txmgr.EvmTxMeta{ + Meta: &txmgr.TxMeta{ RequestID: &requestID, MaxLink: &maxLinkString, SubID: &p.req.req.SubId, diff --git a/core/services/vrf/listener_v2_test.go b/core/services/vrf/listener_v2_test.go index cbbd8a1885a..a78ffc33f97 100644 --- a/core/services/vrf/listener_v2_test.go +++ b/core/services/vrf/listener_v2_test.go @@ -39,7 +39,7 @@ func addEthTx(t *testing.T, db *sqlx.DB, from common.Address, state txmgrtypes.T 0, // value 0, // limit state, - txmgr.EvmTxMeta{ + txmgr.TxMeta{ MaxLink: &maxLink, SubID: &subID, RequestTxHash: &reqTxHash, @@ -63,7 +63,7 @@ func addConfirmedEthTx(t *testing.T, db *sqlx.DB, from common.Address, maxLink s []byte(`blah`), // payload 0, // value 0, // limit - txmgr.EvmTxMeta{ + txmgr.TxMeta{ MaxLink: &maxLink, SubID: &subID, }, diff --git a/core/services/vrf/listener_v2_types.go b/core/services/vrf/listener_v2_types.go index d4c385d075c..65413530381 100644 --- a/core/services/vrf/listener_v2_types.go +++ b/core/services/vrf/listener_v2_types.go @@ -138,7 +138,7 @@ func (lsn *listenerV2) processBatch( "gasMultiplier", lsn.job.VRFSpec.BatchFulfillmentGasMultiplier, ) ll.Info("Enqueuing batch fulfillment") - var ethTX txmgr.EvmTx + var ethTX txmgr.Tx err = lsn.q.Transaction(func(tx pg.Queryer) error { if err = lsn.pipelineRunner.InsertFinishedRuns(batch.runs, true, pg.WithQueryer(tx)); err != nil { return errors.Wrap(err, "inserting finished pipeline runs") @@ -155,13 +155,13 @@ func (lsn *listenerV2) processBatch( for _, reqID := range batch.reqIDs { reqIDHashes = append(reqIDHashes, common.BytesToHash(reqID.Bytes())) } - ethTX, err = lsn.txm.CreateTransaction(txmgr.EvmTxRequest{ + ethTX, err = lsn.txm.CreateTransaction(txmgr.TxRequest{ FromAddress: fromAddress, ToAddress: lsn.batchCoordinator.Address(), EncodedPayload: payload, FeeLimit: totalGasLimitBumped, Strategy: txmgrcommon.NewSendEveryStrategy(), - Meta: &txmgr.EvmTxMeta{ + Meta: &txmgr.TxMeta{ RequestIDs: reqIDHashes, MaxLink: &maxLinkStr, SubID: &subID, diff --git a/core/web/eth_keys_controller_test.go b/core/web/eth_keys_controller_test.go index 42049697850..0c4b63ca4a9 100644 --- a/core/web/eth_keys_controller_test.go +++ b/core/web/eth_keys_controller_test.go @@ -398,7 +398,7 @@ func TestETHKeysController_ChainSuccess_ResetWithAbandon(t *testing.T) { strategy := commontxmmocks.NewTxStrategy(t) strategy.On("Subject").Return(uuid.NullUUID{UUID: subject, Valid: true}) strategy.On("PruneQueue", mock.AnythingOfType("*txmgr.evmTxStore"), mock.AnythingOfType("pg.QOpt")).Return(int64(0), nil) - _, err := chain.TxManager().CreateTransaction(txmgr.EvmTxRequest{ + _, err := chain.TxManager().CreateTransaction(txmgr.TxRequest{ FromAddress: addr, ToAddress: testutils.NewAddress(), EncodedPayload: []byte{1, 2, 3}, diff --git a/core/web/loader/eth_transaction_attempt.go b/core/web/loader/eth_transaction_attempt.go index 93b013302e4..c215574f490 100644 --- a/core/web/loader/eth_transaction_attempt.go +++ b/core/web/loader/eth_transaction_attempt.go @@ -34,7 +34,7 @@ func (b *ethTransactionAttemptBatcher) loadByEthTransactionIDs(ctx context.Conte } // Generate a map of attempts to txIDs - attemptsForTx := map[string][]txmgr.EvmTxAttempt{} + attemptsForTx := map[string][]txmgr.TxAttempt{} for _, a := range attempts { id := stringutils.FromInt64(a.TxID) @@ -54,7 +54,7 @@ func (b *ethTransactionAttemptBatcher) loadByEthTransactionIDs(ctx context.Conte // fill array positions without any attempts as an empty slice for _, ix := range keyOrder { - results[ix] = &dataloader.Result{Data: []txmgr.EvmTxAttempt{}, Error: nil} + results[ix] = &dataloader.Result{Data: []txmgr.TxAttempt{}, Error: nil} } return results diff --git a/core/web/loader/getters.go b/core/web/loader/getters.go index 5a24f83df65..8ca29cc9624 100644 --- a/core/web/loader/getters.go +++ b/core/web/loader/getters.go @@ -199,7 +199,7 @@ func GetJobByPipelineSpecID(ctx context.Context, id string) (*job.Job, error) { } // GetEthTxAttemptsByEthTxID fetches the attempts for an eth transaction. -func GetEthTxAttemptsByEthTxID(ctx context.Context, id string) ([]txmgr.EvmTxAttempt, error) { +func GetEthTxAttemptsByEthTxID(ctx context.Context, id string) ([]txmgr.TxAttempt, error) { ldr := For(ctx) thunk := ldr.EthTxAttemptsByEthTxIDLoader.Load(ctx, dataloader.StringKey(id)) @@ -208,7 +208,7 @@ func GetEthTxAttemptsByEthTxID(ctx context.Context, id string) ([]txmgr.EvmTxAtt return nil, err } - attempts, ok := result.([]txmgr.EvmTxAttempt) + attempts, ok := result.([]txmgr.TxAttempt) if !ok { return nil, ErrInvalidType } diff --git a/core/web/loader/loader_test.go b/core/web/loader/loader_test.go index b36f697077d..754abc45888 100644 --- a/core/web/loader/loader_test.go +++ b/core/web/loader/loader_test.go @@ -284,16 +284,16 @@ func TestLoader_EthTransactionsAttempts(t *testing.T) { ethTxIDs := []int64{1, 2, 3} - attempt1 := txmgr.EvmTxAttempt{ + attempt1 := txmgr.TxAttempt{ ID: int64(1), TxID: ethTxIDs[0], } - attempt2 := txmgr.EvmTxAttempt{ + attempt2 := txmgr.TxAttempt{ ID: int64(1), TxID: ethTxIDs[1], } - txStore.On("FindTxAttemptConfirmedByTxIDs", []int64{ethTxIDs[2], ethTxIDs[1], ethTxIDs[0]}).Return([]txmgr.EvmTxAttempt{ + txStore.On("FindTxAttemptConfirmedByTxIDs", []int64{ethTxIDs[2], ethTxIDs[1], ethTxIDs[0]}).Return([]txmgr.TxAttempt{ attempt1, attempt2, }, nil) app.On("TxmStorageService").Return(txStore) @@ -304,9 +304,9 @@ func TestLoader_EthTransactionsAttempts(t *testing.T) { found := batcher.loadByEthTransactionIDs(ctx, keys) require.Len(t, found, 3) - assert.Equal(t, []txmgr.EvmTxAttempt{}, found[0].Data) - assert.Equal(t, []txmgr.EvmTxAttempt{attempt2}, found[1].Data) - assert.Equal(t, []txmgr.EvmTxAttempt{attempt1}, found[2].Data) + assert.Equal(t, []txmgr.TxAttempt{}, found[0].Data) + assert.Equal(t, []txmgr.TxAttempt{attempt2}, found[1].Data) + assert.Equal(t, []txmgr.TxAttempt{attempt1}, found[2].Data) } func TestLoader_SpecErrorsByJobID(t *testing.T) { @@ -370,19 +370,19 @@ func TestLoader_loadByEthTransactionID(t *testing.T) { ethTxID := int64(3) ethTxHash := utils.NewHash() - receipt := txmgr.EvmReceipt{ + receipt := txmgr.Receipt{ ID: int64(1), TxHash: ethTxHash, } - attempt1 := txmgr.EvmTxAttempt{ + attempt1 := txmgr.TxAttempt{ ID: int64(1), TxID: ethTxID, Hash: ethTxHash, - Receipts: []txmgr.EvmChainReceipt{txmgr.DbReceiptToEvmReceipt(&receipt)}, + Receipts: []txmgr.ChainReceipt{txmgr.DbReceiptToEvmReceipt(&receipt)}, } - txStore.On("FindTxAttemptConfirmedByTxIDs", []int64{ethTxID}).Return([]txmgr.EvmTxAttempt{ + txStore.On("FindTxAttemptConfirmedByTxIDs", []int64{ethTxID}).Return([]txmgr.TxAttempt{ attempt1, }, nil) @@ -394,5 +394,5 @@ func TestLoader_loadByEthTransactionID(t *testing.T) { found := batcher.loadByEthTransactionIDs(ctx, keys) require.Len(t, found, 1) - assert.Equal(t, []txmgr.EvmTxAttempt{attempt1}, found[0].Data) + assert.Equal(t, []txmgr.TxAttempt{attempt1}, found[0].Data) } diff --git a/core/web/presenters/eth_tx.go b/core/web/presenters/eth_tx.go index 609366c4cd0..8878733d708 100644 --- a/core/web/presenters/eth_tx.go +++ b/core/web/presenters/eth_tx.go @@ -38,7 +38,7 @@ func (EthTxResource) GetName() string { // For backwards compatibility, there is no id set when initializing from an // EthTx as the id being used was the EthTxAttempt Hash. // This should really use it's proper id -func NewEthTxResource(tx txmgr.EvmTx) EthTxResource { +func NewEthTxResource(tx txmgr.Tx) EthTxResource { v := assets.Eth(tx.Value) r := EthTxResource{ Data: hexutil.Bytes(tx.EncodedPayload), @@ -55,7 +55,7 @@ func NewEthTxResource(tx txmgr.EvmTx) EthTxResource { return r } -func NewEthTxResourceFromAttempt(txa txmgr.EvmTxAttempt) EthTxResource { +func NewEthTxResourceFromAttempt(txa txmgr.TxAttempt) EthTxResource { tx := txa.Tx r := NewEthTxResource(tx) diff --git a/core/web/presenters/eth_tx_test.go b/core/web/presenters/eth_tx_test.go index 299f8613ab1..10f4ceab006 100644 --- a/core/web/presenters/eth_tx_test.go +++ b/core/web/presenters/eth_tx_test.go @@ -20,7 +20,7 @@ import ( func TestEthTxResource(t *testing.T) { t.Parallel() - tx := txmgr.EvmTx{ + tx := txmgr.Tx{ ID: 1, EncodedPayload: []byte(`{"data": "is wilding out"}`), FromAddress: common.HexToAddress("0x1"), @@ -68,7 +68,7 @@ func TestEthTxResource(t *testing.T) { ) tx.Sequence = &nonce - txa := txmgr.EvmTxAttempt{ + txa := txmgr.TxAttempt{ Tx: tx, Hash: hash, TxFee: gas.EvmFee{Legacy: gasPrice}, diff --git a/core/web/resolver/eth_transaction.go b/core/web/resolver/eth_transaction.go index 59dde817626..31a96727a9c 100644 --- a/core/web/resolver/eth_transaction.go +++ b/core/web/resolver/eth_transaction.go @@ -13,14 +13,14 @@ import ( ) type EthTransactionResolver struct { - tx txmgr.EvmTx + tx txmgr.Tx } -func NewEthTransaction(tx txmgr.EvmTx) *EthTransactionResolver { +func NewEthTransaction(tx txmgr.Tx) *EthTransactionResolver { return &EthTransactionResolver{tx: tx} } -func NewEthTransactions(results []txmgr.EvmTx) []*EthTransactionResolver { +func NewEthTransactions(results []txmgr.Tx) []*EthTransactionResolver { var resolver []*EthTransactionResolver for _, tx := range results { @@ -128,11 +128,11 @@ func (r *EthTransactionResolver) SentAt(ctx context.Context) *string { // -- EthTransaction Query -- type EthTransactionPayloadResolver struct { - tx *txmgr.EvmTx + tx *txmgr.Tx NotFoundErrorUnionType } -func NewEthTransactionPayload(tx *txmgr.EvmTx, err error) *EthTransactionPayloadResolver { +func NewEthTransactionPayload(tx *txmgr.Tx, err error) *EthTransactionPayloadResolver { e := NotFoundErrorUnionType{err: err, message: "transaction not found", isExpectedErrorFn: nil} return &EthTransactionPayloadResolver{tx: tx, NotFoundErrorUnionType: e} @@ -149,11 +149,11 @@ func (r *EthTransactionPayloadResolver) ToEthTransaction() (*EthTransactionResol // -- EthTransactions Query -- type EthTransactionsPayloadResolver struct { - results []txmgr.EvmTx + results []txmgr.Tx total int32 } -func NewEthTransactionsPayload(results []txmgr.EvmTx, total int32) *EthTransactionsPayloadResolver { +func NewEthTransactionsPayload(results []txmgr.Tx, total int32) *EthTransactionsPayloadResolver { return &EthTransactionsPayloadResolver{results: results, total: total} } diff --git a/core/web/resolver/eth_transaction_attempt.go b/core/web/resolver/eth_transaction_attempt.go index 568077ad083..1e21546bc35 100644 --- a/core/web/resolver/eth_transaction_attempt.go +++ b/core/web/resolver/eth_transaction_attempt.go @@ -8,14 +8,14 @@ import ( ) type EthTransactionAttemptResolver struct { - attmpt txmgr.EvmTxAttempt + attmpt txmgr.TxAttempt } -func NewEthTransactionAttempt(attmpt txmgr.EvmTxAttempt) *EthTransactionAttemptResolver { +func NewEthTransactionAttempt(attmpt txmgr.TxAttempt) *EthTransactionAttemptResolver { return &EthTransactionAttemptResolver{attmpt: attmpt} } -func NewEthTransactionsAttempts(results []txmgr.EvmTxAttempt) []*EthTransactionAttemptResolver { +func NewEthTransactionsAttempts(results []txmgr.TxAttempt) []*EthTransactionAttemptResolver { var resolver []*EthTransactionAttemptResolver for _, tx := range results { @@ -50,11 +50,11 @@ func (r *EthTransactionAttemptResolver) SentAt() *string { // -- EthTransactionAttempts Query -- type EthTransactionsAttemptsPayloadResolver struct { - results []txmgr.EvmTxAttempt + results []txmgr.TxAttempt total int32 } -func NewEthTransactionsAttemptsPayload(results []txmgr.EvmTxAttempt, total int32) *EthTransactionsAttemptsPayloadResolver { +func NewEthTransactionsAttemptsPayload(results []txmgr.TxAttempt, total int32) *EthTransactionsAttemptsPayloadResolver { return &EthTransactionsAttemptsPayloadResolver{results: results, total: total} } diff --git a/core/web/resolver/eth_transaction_test.go b/core/web/resolver/eth_transaction_test.go index 5a53094b855..959a4b467d8 100644 --- a/core/web/resolver/eth_transaction_test.go +++ b/core/web/resolver/eth_transaction_test.go @@ -63,7 +63,7 @@ func TestResolver_EthTransaction(t *testing.T) { name: "success", authenticated: true, before: func(f *gqlTestFramework) { - f.Mocks.txmStore.On("FindTxByHash", hash).Return(&txmgr.EvmTx{ + f.Mocks.txmStore.On("FindTxByHash", hash).Return(&txmgr.Tx{ ID: 1, ToAddress: common.HexToAddress("0x5431F5F973781809D18643b87B44921b11355d81"), FromAddress: common.HexToAddress("0x5431F5F973781809D18643b87B44921b11355d81"), @@ -74,7 +74,7 @@ func TestResolver_EthTransaction(t *testing.T) { ChainID: big.NewInt(22), Sequence: nil, }, nil) - f.Mocks.txmStore.On("FindTxAttemptConfirmedByTxIDs", []int64{1}).Return([]txmgr.EvmTxAttempt{ + f.Mocks.txmStore.On("FindTxAttemptConfirmedByTxIDs", []int64{1}).Return([]txmgr.TxAttempt{ { TxID: 1, Hash: hash, @@ -120,7 +120,7 @@ func TestResolver_EthTransaction(t *testing.T) { num := int64(2) nonce := evmtypes.Nonce(num) - f.Mocks.txmStore.On("FindTxByHash", hash).Return(&txmgr.EvmTx{ + f.Mocks.txmStore.On("FindTxByHash", hash).Return(&txmgr.Tx{ ID: 1, ToAddress: common.HexToAddress("0x5431F5F973781809D18643b87B44921b11355d81"), FromAddress: common.HexToAddress("0x5431F5F973781809D18643b87B44921b11355d81"), @@ -131,7 +131,7 @@ func TestResolver_EthTransaction(t *testing.T) { ChainID: big.NewInt(22), Sequence: &nonce, }, nil) - f.Mocks.txmStore.On("FindTxAttemptConfirmedByTxIDs", []int64{1}).Return([]txmgr.EvmTxAttempt{ + f.Mocks.txmStore.On("FindTxAttemptConfirmedByTxIDs", []int64{1}).Return([]txmgr.TxAttempt{ { TxID: 1, Hash: hash, @@ -247,7 +247,7 @@ func TestResolver_EthTransactions(t *testing.T) { before: func(f *gqlTestFramework) { num := int64(2) - f.Mocks.txmStore.On("Transactions", PageDefaultOffset, PageDefaultLimit).Return([]txmgr.EvmTx{ + f.Mocks.txmStore.On("Transactions", PageDefaultOffset, PageDefaultLimit).Return([]txmgr.Tx{ { ID: 1, ToAddress: common.HexToAddress("0x5431F5F973781809D18643b87B44921b11355d81"), @@ -259,7 +259,7 @@ func TestResolver_EthTransactions(t *testing.T) { ChainID: big.NewInt(22), }, }, 1, nil) - f.Mocks.txmStore.On("FindTxAttemptConfirmedByTxIDs", []int64{1}).Return([]txmgr.EvmTxAttempt{ + f.Mocks.txmStore.On("FindTxAttemptConfirmedByTxIDs", []int64{1}).Return([]txmgr.TxAttempt{ { TxID: 1, Hash: hash, @@ -345,13 +345,13 @@ func TestResolver_EthTransactionsAttempts(t *testing.T) { before: func(f *gqlTestFramework) { num := int64(2) - f.Mocks.txmStore.On("TxAttempts", PageDefaultOffset, PageDefaultLimit).Return([]txmgr.EvmTxAttempt{ + f.Mocks.txmStore.On("TxAttempts", PageDefaultOffset, PageDefaultLimit).Return([]txmgr.TxAttempt{ { Hash: hash, TxFee: gas.EvmFee{Legacy: assets.NewWeiI(12)}, SignedRawTx: []byte("something"), BroadcastBeforeBlockNum: &num, - Tx: txmgr.EvmTx{}, + Tx: txmgr.Tx{}, }, }, 1, nil) f.App.On("TxmStorageService").Return(f.Mocks.txmStore) @@ -376,7 +376,7 @@ func TestResolver_EthTransactionsAttempts(t *testing.T) { name: "success with nil values", authenticated: true, before: func(f *gqlTestFramework) { - f.Mocks.txmStore.On("TxAttempts", PageDefaultOffset, PageDefaultLimit).Return([]txmgr.EvmTxAttempt{ + f.Mocks.txmStore.On("TxAttempts", PageDefaultOffset, PageDefaultLimit).Return([]txmgr.TxAttempt{ { Hash: hash, TxFee: gas.EvmFee{Legacy: assets.NewWeiI(12)}, From 491a8d7693becb64b39764edc9205253ad938127 Mon Sep 17 00:00:00 2001 From: simsonraj Date: Mon, 19 Jun 2023 17:42:20 +0530 Subject: [PATCH 2/2] removed evm prefix for transmitchecker --- core/chains/evm/txmgr/broadcaster_test.go | 10 +++++----- core/chains/evm/txmgr/transmitchecker.go | 14 +++++++------- core/chains/evm/txmgr/transmitchecker_test.go | 12 ++++++------ core/chains/evm/txmgr/txmgr_test.go | 8 ++++---- core/internal/cltest/factories.go | 2 +- core/services/fluxmonitorv2/delegate.go | 2 +- core/services/fluxmonitorv2/flux_monitor_test.go | 2 +- core/services/fluxmonitorv2/orm.go | 4 ++-- core/services/fluxmonitorv2/orm_test.go | 2 +- core/services/ocr/delegate.go | 2 +- core/services/ocrcommon/transmitter.go | 4 ++-- core/services/ocrcommon/transmitter_pipeline.go | 4 ++-- .../ocrcommon/transmitter_pipeline_test.go | 2 +- core/services/ocrcommon/transmitter_test.go | 8 ++++---- core/services/pipeline/task.eth_tx.go | 4 ++-- core/services/pipeline/task.eth_tx_test.go | 2 +- core/services/relay/evm/evm.go | 4 ++-- core/services/vrf/listener_v2.go | 2 +- 18 files changed, 44 insertions(+), 44 deletions(-) diff --git a/core/chains/evm/txmgr/broadcaster_test.go b/core/chains/evm/txmgr/broadcaster_test.go index 1ed95f2cf8e..a262d91a3c6 100644 --- a/core/chains/evm/txmgr/broadcaster_test.go +++ b/core/chains/evm/txmgr/broadcaster_test.go @@ -159,7 +159,7 @@ func TestEthBroadcaster_ProcessUnstartedEthTxs_Success(t *testing.T) { encodedPayload := []byte{1, 2, 3} value := big.Int(assets.NewEthValue(142)) gasLimit := uint32(242) - checker := txmgr.EvmTransmitCheckerSpec{ + checker := txmgr.TransmitCheckerSpec{ CheckerType: txmgr.TransmitCheckerTypeSimulate, } @@ -402,7 +402,7 @@ func TestEthBroadcaster_ProcessUnstartedEthTxs_Success(t *testing.T) { Value: big.Int(assets.NewEthValue(442)), FeeLimit: gasLimit, Strategy: txmgrcommon.NewSendEveryStrategy(), - Checker: txmgr.EvmTransmitCheckerSpec{ + Checker: txmgr.TransmitCheckerSpec{ CheckerType: txmgr.TransmitCheckerTypeSimulate, }, } @@ -503,7 +503,7 @@ func TestEthBroadcaster_TransmitChecking(t *testing.T) { eb, err := NewTestEthBroadcaster(t, txStore, ethClient, ethKeyStore, evmcfg, checkerFactory, false) require.NoError(t, err) - checker := txmgr.EvmTransmitCheckerSpec{ + checker := txmgr.TransmitCheckerSpec{ CheckerType: txmgr.TransmitCheckerTypeSimulate, } t.Run("when transmit checking times out, sends tx as normal", func(t *testing.T) { @@ -1870,7 +1870,7 @@ func TestEthBroadcaster_SyncNonce(t *testing.T) { } -func checkerToJson(t *testing.T, checker txmgr.EvmTransmitCheckerSpec) *datatypes.JSON { +func checkerToJson(t *testing.T, checker txmgr.TransmitCheckerSpec) *datatypes.JSON { b, err := json.Marshal(checker) require.NoError(t, err) j := datatypes.JSON(b) @@ -1881,7 +1881,7 @@ type testCheckerFactory struct { err error } -func (t *testCheckerFactory) BuildChecker(spec txmgr.EvmTransmitCheckerSpec) (txmgr.EvmTransmitChecker, error) { +func (t *testCheckerFactory) BuildChecker(spec txmgr.TransmitCheckerSpec) (txmgr.TransmitChecker, error) { return &testChecker{t.err}, nil } diff --git a/core/chains/evm/txmgr/transmitchecker.go b/core/chains/evm/txmgr/transmitchecker.go index 3aba0962008..ad655d23d48 100644 --- a/core/chains/evm/txmgr/transmitchecker.go +++ b/core/chains/evm/txmgr/transmitchecker.go @@ -25,18 +25,18 @@ import ( ) type ( - EvmTransmitChecker = txmgr.TransmitChecker[*big.Int, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee] - EvmTransmitCheckerSpec = txmgrtypes.TransmitCheckerSpec[common.Address] + TransmitChecker = txmgr.TransmitChecker[*big.Int, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee] + TransmitCheckerSpec = txmgrtypes.TransmitCheckerSpec[common.Address] ) var ( // NoChecker is a TransmitChecker that always determines a transaction should be submitted. - NoChecker EvmTransmitChecker = noChecker{} + NoChecker TransmitChecker = noChecker{} _ TransmitCheckerFactory = &CheckerFactory{} - _ EvmTransmitChecker = &SimulateChecker{} - _ EvmTransmitChecker = &VRFV1Checker{} - _ EvmTransmitChecker = &VRFV2Checker{} + _ TransmitChecker = &SimulateChecker{} + _ TransmitChecker = &VRFV1Checker{} + _ TransmitChecker = &VRFV2Checker{} ) // CheckerFactory is a real implementation of TransmitCheckerFactory. @@ -45,7 +45,7 @@ type CheckerFactory struct { } // BuildChecker satisfies the TransmitCheckerFactory interface. -func (c *CheckerFactory) BuildChecker(spec EvmTransmitCheckerSpec) (EvmTransmitChecker, error) { +func (c *CheckerFactory) BuildChecker(spec TransmitCheckerSpec) (TransmitChecker, error) { switch spec.CheckerType { case TransmitCheckerTypeSimulate: return &SimulateChecker{c.Client}, nil diff --git a/core/chains/evm/txmgr/transmitchecker_test.go b/core/chains/evm/txmgr/transmitchecker_test.go index b884e7c0fb1..eb5da045c30 100644 --- a/core/chains/evm/txmgr/transmitchecker_test.go +++ b/core/chains/evm/txmgr/transmitchecker_test.go @@ -37,13 +37,13 @@ func TestFactory(t *testing.T) { factory := &txmgr.CheckerFactory{Client: client} t.Run("no checker", func(t *testing.T) { - c, err := factory.BuildChecker(txmgr.EvmTransmitCheckerSpec{}) + c, err := factory.BuildChecker(txmgr.TransmitCheckerSpec{}) require.NoError(t, err) require.Equal(t, txmgr.NoChecker, c) }) t.Run("vrf v1 checker", func(t *testing.T) { - c, err := factory.BuildChecker(txmgr.EvmTransmitCheckerSpec{ + c, err := factory.BuildChecker(txmgr.TransmitCheckerSpec{ CheckerType: txmgr.TransmitCheckerTypeVRFV1, VRFCoordinatorAddress: testutils.NewAddressPtr(), }) @@ -52,7 +52,7 @@ func TestFactory(t *testing.T) { }) t.Run("vrf v2 checker", func(t *testing.T) { - c, err := factory.BuildChecker(txmgr.EvmTransmitCheckerSpec{ + c, err := factory.BuildChecker(txmgr.TransmitCheckerSpec{ CheckerType: txmgr.TransmitCheckerTypeVRFV2, VRFCoordinatorAddress: testutils.NewAddressPtr(), VRFRequestBlockNumber: big.NewInt(1), @@ -61,7 +61,7 @@ func TestFactory(t *testing.T) { require.IsType(t, &txmgr.VRFV2Checker{}, c) // request block number not provided should error out. - c, err = factory.BuildChecker(txmgr.EvmTransmitCheckerSpec{ + c, err = factory.BuildChecker(txmgr.TransmitCheckerSpec{ CheckerType: txmgr.TransmitCheckerTypeVRFV2, VRFCoordinatorAddress: testutils.NewAddressPtr(), }) @@ -70,7 +70,7 @@ func TestFactory(t *testing.T) { }) t.Run("simulate checker", func(t *testing.T) { - c, err := factory.BuildChecker(txmgr.EvmTransmitCheckerSpec{ + c, err := factory.BuildChecker(txmgr.TransmitCheckerSpec{ CheckerType: txmgr.TransmitCheckerTypeSimulate, }) require.NoError(t, err) @@ -78,7 +78,7 @@ func TestFactory(t *testing.T) { }) t.Run("invalid checker type", func(t *testing.T) { - _, err := factory.BuildChecker(txmgr.EvmTransmitCheckerSpec{ + _, err := factory.BuildChecker(txmgr.TransmitCheckerSpec{ CheckerType: "invalid", }) require.EqualError(t, err, "unrecognized checker type: invalid") diff --git a/core/chains/evm/txmgr/txmgr_test.go b/core/chains/evm/txmgr/txmgr_test.go index 2a77b070dd2..a15ebbc0342 100644 --- a/core/chains/evm/txmgr/txmgr_test.go +++ b/core/chains/evm/txmgr/txmgr_test.go @@ -220,7 +220,7 @@ func TestTxm_CreateTransaction(t *testing.T) { t.Run("simulate transmit checker", func(t *testing.T) { pgtest.MustExec(t, db, `DELETE FROM eth_txes`) - checker := txmgr.EvmTransmitCheckerSpec{ + checker := txmgr.TransmitCheckerSpec{ CheckerType: txmgr.TransmitCheckerTypeSimulate, } evmConfig.maxQueued = uint64(1) @@ -237,7 +237,7 @@ func TestTxm_CreateTransaction(t *testing.T) { var dbEtx txmgr.DbEthTx require.NoError(t, db.Get(&dbEtx, `SELECT * FROM eth_txes ORDER BY id ASC LIMIT 1`)) - var c txmgr.EvmTransmitCheckerSpec + var c txmgr.TransmitCheckerSpec require.NotNil(t, etx.TransmitChecker) require.NoError(t, json.Unmarshal(*etx.TransmitChecker, &c)) require.Equal(t, checker, c) @@ -258,7 +258,7 @@ func TestTxm_CreateTransaction(t *testing.T) { SubID: &testDefaultSubID, } evmConfig.maxQueued = uint64(1) - checker := txmgr.EvmTransmitCheckerSpec{ + checker := txmgr.TransmitCheckerSpec{ CheckerType: txmgr.TransmitCheckerTypeVRFV2, VRFCoordinatorAddress: testutils.NewAddressPtr(), } @@ -280,7 +280,7 @@ func TestTxm_CreateTransaction(t *testing.T) { require.NoError(t, err) require.Equal(t, meta, m) - var c txmgr.EvmTransmitCheckerSpec + var c txmgr.TransmitCheckerSpec require.NotNil(t, etx.TransmitChecker) require.NoError(t, json.Unmarshal(*etx.TransmitChecker, &c)) require.Equal(t, checker, c) diff --git a/core/internal/cltest/factories.go b/core/internal/cltest/factories.go index 0b07dce0909..95986611aab 100644 --- a/core/internal/cltest/factories.go +++ b/core/internal/cltest/factories.go @@ -337,7 +337,7 @@ func EvmTxRequestWithStrategy(strategy txmgrtypes.TxStrategy) func(*txmgr.TxRequ } } -func EvmTxRequestWithChecker(checker txmgr.EvmTransmitCheckerSpec) func(*txmgr.TxRequest) { +func EvmTxRequestWithChecker(checker txmgr.TransmitCheckerSpec) func(*txmgr.TxRequest) { return func(tx *txmgr.TxRequest) { tx.Checker = checker } diff --git a/core/services/fluxmonitorv2/delegate.go b/core/services/fluxmonitorv2/delegate.go index 2b5d03c4e70..ba2edf9e0f0 100644 --- a/core/services/fluxmonitorv2/delegate.go +++ b/core/services/fluxmonitorv2/delegate.go @@ -69,7 +69,7 @@ func (d *Delegate) ServicesForSpec(jb job.Job) (services []job.ServiceCtx, err e } cfg := chain.Config() strategy := txmgrcommon.NewQueueingTxStrategy(jb.ExternalJobID, cfg.FluxMonitor().DefaultTransactionQueueDepth(), cfg.Database().DefaultQueryTimeout()) - var checker txmgr.EvmTransmitCheckerSpec + var checker txmgr.TransmitCheckerSpec if chain.Config().FluxMonitor().SimulateTransactions() { checker.CheckerType = txmgr.TransmitCheckerTypeSimulate } diff --git a/core/services/fluxmonitorv2/flux_monitor_test.go b/core/services/fluxmonitorv2/flux_monitor_test.go index 5e0b8171362..923658fef09 100644 --- a/core/services/fluxmonitorv2/flux_monitor_test.go +++ b/core/services/fluxmonitorv2/flux_monitor_test.go @@ -54,7 +54,7 @@ var ( type answerSet struct{ latestAnswer, polledAnswer int64 } func newORM(t *testing.T, db *sqlx.DB, cfg pg.QConfig, txm txmgr.TxManager) fluxmonitorv2.ORM { - return fluxmonitorv2.NewORM(db, logger.TestLogger(t), cfg, txm, txmgrcommon.NewSendEveryStrategy(), txmgr.EvmTransmitCheckerSpec{}) + return fluxmonitorv2.NewORM(db, logger.TestLogger(t), cfg, txm, txmgrcommon.NewSendEveryStrategy(), txmgr.TransmitCheckerSpec{}) } var ( diff --git a/core/services/fluxmonitorv2/orm.go b/core/services/fluxmonitorv2/orm.go index 4990a0a512d..c2f99c8345e 100644 --- a/core/services/fluxmonitorv2/orm.go +++ b/core/services/fluxmonitorv2/orm.go @@ -34,12 +34,12 @@ type orm struct { q pg.Q txm transmitter strategy types.TxStrategy - checker txmgr.EvmTransmitCheckerSpec + checker txmgr.TransmitCheckerSpec logger logger.Logger } // NewORM initializes a new ORM -func NewORM(db *sqlx.DB, lggr logger.Logger, cfg pg.QConfig, txm transmitter, strategy types.TxStrategy, checker txmgr.EvmTransmitCheckerSpec) ORM { +func NewORM(db *sqlx.DB, lggr logger.Logger, cfg pg.QConfig, txm transmitter, strategy types.TxStrategy, checker txmgr.TransmitCheckerSpec) ORM { namedLogger := lggr.Named("FluxMonitorORM") q := pg.NewQ(db, namedLogger, cfg) return &orm{ diff --git a/core/services/fluxmonitorv2/orm_test.go b/core/services/fluxmonitorv2/orm_test.go index 40a4d1c5dc1..90b5c5a4308 100644 --- a/core/services/fluxmonitorv2/orm_test.go +++ b/core/services/fluxmonitorv2/orm_test.go @@ -175,7 +175,7 @@ func TestORM_CreateEthTransaction(t *testing.T) { var ( txm = txmmocks.NewMockEvmTxManager(t) - orm = fluxmonitorv2.NewORM(db, logger.TestLogger(t), cfg, txm, strategy, txmgr.EvmTransmitCheckerSpec{}) + orm = fluxmonitorv2.NewORM(db, logger.TestLogger(t), cfg, txm, strategy, txmgr.TransmitCheckerSpec{}) _, from = cltest.MustInsertRandomKey(t, ethKeyStore, 0) to = testutils.NewAddress() diff --git a/core/services/ocr/delegate.go b/core/services/ocr/delegate.go index f7f594b20d9..f64acb659cb 100644 --- a/core/services/ocr/delegate.go +++ b/core/services/ocr/delegate.go @@ -222,7 +222,7 @@ func (d *Delegate) ServicesForSpec(jb job.Job) (services []job.ServiceCtx, err e cfg := chain.Config() strategy := txmgrcommon.NewQueueingTxStrategy(jb.ExternalJobID, cfg.OCR().DefaultTransactionQueueDepth(), cfg.Database().DefaultQueryTimeout()) - var checker txmgr.EvmTransmitCheckerSpec + var checker txmgr.TransmitCheckerSpec if chain.Config().OCR().SimulateTransactions() { checker.CheckerType = txmgr.TransmitCheckerTypeSimulate } diff --git a/core/services/ocrcommon/transmitter.go b/core/services/ocrcommon/transmitter.go index 8b7433f59a4..24e985048f0 100644 --- a/core/services/ocrcommon/transmitter.go +++ b/core/services/ocrcommon/transmitter.go @@ -31,7 +31,7 @@ type transmitter struct { gasLimit uint32 effectiveTransmitterAddress common.Address strategy types.TxStrategy - checker txmgr.EvmTransmitCheckerSpec + checker txmgr.TransmitCheckerSpec chainID *big.Int keystore roundRobinKeystore } @@ -43,7 +43,7 @@ func NewTransmitter( gasLimit uint32, effectiveTransmitterAddress common.Address, strategy types.TxStrategy, - checker txmgr.EvmTransmitCheckerSpec, + checker txmgr.TransmitCheckerSpec, chainID *big.Int, keystore roundRobinKeystore, ) (Transmitter, error) { diff --git a/core/services/ocrcommon/transmitter_pipeline.go b/core/services/ocrcommon/transmitter_pipeline.go index e870737638b..23b672a5e32 100644 --- a/core/services/ocrcommon/transmitter_pipeline.go +++ b/core/services/ocrcommon/transmitter_pipeline.go @@ -33,7 +33,7 @@ type pipelineTransmitter struct { gasLimit uint32 effectiveTransmitterAddress common.Address strategy types.TxStrategy - checker txmgr.EvmTransmitCheckerSpec + checker txmgr.TransmitCheckerSpec pr pipeline.Runner spec job.Job chainID string @@ -46,7 +46,7 @@ func NewPipelineTransmitter( gasLimit uint32, effectiveTransmitterAddress common.Address, strategy types.TxStrategy, - checker txmgr.EvmTransmitCheckerSpec, + checker txmgr.TransmitCheckerSpec, pr pipeline.Runner, spec job.Job, chainID string, diff --git a/core/services/ocrcommon/transmitter_pipeline_test.go b/core/services/ocrcommon/transmitter_pipeline_test.go index 6cad12b8be9..84294a1dde6 100644 --- a/core/services/ocrcommon/transmitter_pipeline_test.go +++ b/core/services/ocrcommon/transmitter_pipeline_test.go @@ -34,7 +34,7 @@ func Test_PipelineTransmitter_CreateEthTransaction(t *testing.T) { toAddress := testutils.NewAddress() payload := []byte{1, 2, 3} strategy := newMockTxStrategy(t) - checker := txmgr.EvmTransmitCheckerSpec{CheckerType: txmgr.TransmitCheckerTypeSimulate} + checker := txmgr.TransmitCheckerSpec{CheckerType: txmgr.TransmitCheckerTypeSimulate} runner := pipelinemocks.NewRunner(t) transmitter := ocrcommon.NewPipelineTransmitter( diff --git a/core/services/ocrcommon/transmitter_test.go b/core/services/ocrcommon/transmitter_test.go index f278ba5b8df..65a5f382830 100644 --- a/core/services/ocrcommon/transmitter_test.go +++ b/core/services/ocrcommon/transmitter_test.go @@ -45,7 +45,7 @@ func Test_DefaultTransmitter_CreateEthTransaction(t *testing.T) { gasLimit, effectiveTransmitterAddress, strategy, - txmgr.EvmTransmitCheckerSpec{}, + txmgr.TransmitCheckerSpec{}, chainID, ethKeyStore, ) @@ -87,7 +87,7 @@ func Test_DefaultTransmitter_Forwarding_Enabled_CreateEthTransaction(t *testing. gasLimit, effectiveTransmitterAddress, strategy, - txmgr.EvmTransmitCheckerSpec{}, + txmgr.TransmitCheckerSpec{}, chainID, ethKeyStore, ) @@ -138,7 +138,7 @@ func Test_DefaultTransmitter_Forwarding_Enabled_CreateEthTransaction_Round_Robin gasLimit, effectiveTransmitterAddress, strategy, - txmgr.EvmTransmitCheckerSpec{}, + txmgr.TransmitCheckerSpec{}, chainID, ethKeyStore, ) @@ -168,7 +168,7 @@ func Test_DefaultTransmitter_Forwarding_Enabled_CreateEthTransaction_No_Keystore gasLimit, effectiveTransmitterAddress, strategy, - txmgr.EvmTransmitCheckerSpec{}, + txmgr.TransmitCheckerSpec{}, chainID, nil, ) diff --git a/core/services/pipeline/task.eth_tx.go b/core/services/pipeline/task.eth_tx.go index f8fcb9e5f87..c0585b5448d 100644 --- a/core/services/pipeline/task.eth_tx.go +++ b/core/services/pipeline/task.eth_tx.go @@ -199,8 +199,8 @@ func decodeMeta(metaMap MapParam) (*txmgr.TxMeta, error) { return &txMeta, nil } -func decodeTransmitChecker(checkerMap MapParam) (txmgr.EvmTransmitCheckerSpec, error) { - var transmitChecker txmgr.EvmTransmitCheckerSpec +func decodeTransmitChecker(checkerMap MapParam) (txmgr.TransmitCheckerSpec, error) { + var transmitChecker txmgr.TransmitCheckerSpec checkerDecoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{ Result: &transmitChecker, ErrorUnused: true, diff --git a/core/services/pipeline/task.eth_tx_test.go b/core/services/pipeline/task.eth_tx_test.go index 8bfdb2bc4e9..0afd008d88e 100644 --- a/core/services/pipeline/task.eth_tx_test.go +++ b/core/services/pipeline/task.eth_tx_test.go @@ -89,7 +89,7 @@ func TestETHTxTask(t *testing.T) { FeeLimit: gasLimit, Meta: txMeta, Strategy: txmgrcommon.NewSendEveryStrategy(), - Checker: txmgr.EvmTransmitCheckerSpec{ + Checker: txmgr.TransmitCheckerSpec{ CheckerType: txmgr.TransmitCheckerTypeVRFV2, VRFCoordinatorAddress: &addr, }, diff --git a/core/services/relay/evm/evm.go b/core/services/relay/evm/evm.go index 679960821b3..9b8e21ced35 100644 --- a/core/services/relay/evm/evm.go +++ b/core/services/relay/evm/evm.go @@ -337,7 +337,7 @@ func newContractTransmitter(lggr logger.Logger, rargs relaytypes.RelayArgs, tran scoped := configWatcher.chain.Config() strategy := txmgrcommon.NewQueueingTxStrategy(rargs.ExternalJobID, scoped.OCR2().DefaultTransactionQueueDepth(), scoped.Database().DefaultQueryTimeout()) - var checker txm.EvmTransmitCheckerSpec + var checker txm.TransmitCheckerSpec if configWatcher.chain.Config().OCR2().SimulateTransactions() { checker.CheckerType = txm.TransmitCheckerTypeSimulate } @@ -388,7 +388,7 @@ func newPipelineContractTransmitter(lggr logger.Logger, rargs relaytypes.RelayAr scoped := configWatcher.chain.Config() strategy := txmgrcommon.NewQueueingTxStrategy(rargs.ExternalJobID, scoped.OCR2().DefaultTransactionQueueDepth(), scoped.Database().DefaultQueryTimeout()) - var checker txm.EvmTransmitCheckerSpec + var checker txm.TransmitCheckerSpec if configWatcher.chain.Config().OCR2().SimulateTransactions() { checker.CheckerType = txm.TransmitCheckerTypeSimulate } diff --git a/core/services/vrf/listener_v2.go b/core/services/vrf/listener_v2.go index fa219b06f40..411f1c9dc5e 100644 --- a/core/services/vrf/listener_v2.go +++ b/core/services/vrf/listener_v2.go @@ -980,7 +980,7 @@ func (lsn *listenerV2) processRequestsPerSub( RequestTxHash: &p.req.req.Raw.TxHash, }, Strategy: txmgrcommon.NewSendEveryStrategy(), - Checker: txmgr.EvmTransmitCheckerSpec{ + Checker: txmgr.TransmitCheckerSpec{ CheckerType: txmgr.TransmitCheckerTypeVRFV2, VRFCoordinatorAddress: &coordinatorAddress, VRFRequestBlockNumber: new(big.Int).SetUint64(p.req.req.Raw.BlockNumber),