Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Txmv2 enablement #15286

Draft
wants to merge 143 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
10e27f7
TXMv2 alpha version
dimriou Oct 11, 2024
174c605
TXM fixes
dimriou Oct 14, 2024
9764be1
Merge branch 'develop' into txmv2
dimriou Oct 14, 2024
adecb3c
Fix
dimriou Oct 14, 2024
79c5a20
Merge branch 'develop' into txmv2
dimriou Oct 21, 2024
b92c3e4
Update orchestrator
dimriou Oct 21, 2024
9821731
Merge branch 'develop' into txmv2
dimriou Oct 21, 2024
610228f
Add builder
dimriou Oct 22, 2024
cc49673
Merge branch 'develop' into txmv2
dimriou Oct 23, 2024
117d8f1
Add txmv2 tests
dimriou Oct 23, 2024
501326c
Merge branch 'develop' into txmv2
dimriou Oct 29, 2024
bfdb9a4
Update retry logic
dimriou Oct 29, 2024
1c18bd7
Add backoff mechanism
dimriou Oct 29, 2024
93889ae
Add multi address support
dimriou Nov 1, 2024
a83d89b
Merge branch 'develop' into txmv2
dimriou Nov 1, 2024
3375df3
Add backoff mechanism for broadcasting and backfilling
dimriou Nov 1, 2024
d596e70
Merge branch 'develop' into txmv2
dimriou Nov 1, 2024
50fd300
Minor fix
dimriou Nov 1, 2024
f004bc4
Add check to dummy keystore
dimriou Nov 1, 2024
2e97d64
Fix inmemory store logging per address
dimriou Nov 2, 2024
80c70e1
Remove unnecessary const
dimriou Nov 4, 2024
f97eeaa
Stuck tx detector alpha
dimriou Nov 5, 2024
7e7d697
Update stuck tx detection
dimriou Nov 5, 2024
5556d84
Merge branch 'develop' into txmv2
dimriou Nov 7, 2024
b6c26f9
Merge branch 'txmv2' into txmv2_stuck_tx_detection
dimriou Nov 7, 2024
2dcdbab
Merge branch 'develop' into txmv2
dimriou Nov 7, 2024
80b09ed
Merge branch 'txmv2' into txmv2_stuck_tx_detection
dimriou Nov 7, 2024
9eeb6fe
Add stuck_tx_detection and dual broadcast client
dimriou Nov 8, 2024
25f54be
Merge branch 'develop' into txmv2
dimriou Nov 8, 2024
f9af9e1
Add support for TXMv2
dimriou Nov 12, 2024
5704dba
Merge branch 'develop' into txmv2
dimriou Nov 12, 2024
0bfe011
Fix txm to work with enabled addresses from keystore
dimriou Nov 12, 2024
f428bdc
Merge branch 'txmv2' into txmv2_stuck_tx_detection
dimriou Nov 12, 2024
45beb8e
Fix orchestrator's monitoring call
dimriou Nov 12, 2024
8786bc5
Fix AttemptBuilder
dimriou Nov 12, 2024
331a45d
Enable DualBroadcast client
dimriou Nov 12, 2024
8f51afe
Enable dual broadcast
dimriou Nov 13, 2024
6121fdf
AttemptBuilder fixes
dimriou Nov 13, 2024
f62a9c1
Merge branch 'develop' into txmv2
dimriou Nov 13, 2024
52b4bfb
Merge branch 'txmv2' into txmv2_stuck_tx_detection
dimriou Nov 13, 2024
14fc5de
Merge branch 'txmv2_stuck_tx_detection' into txmv2_enablement
dimriou Nov 13, 2024
9d7c5a0
Add AttemptBuilder service exception
dimriou Nov 13, 2024
7831151
Add AttemptBuilder close
dimriou Nov 13, 2024
b62a5ee
Merge branch 'txmv2' into txmv2_stuck_tx_detection
dimriou Nov 13, 2024
ce3fe11
Merge branch 'txmv2_stuck_tx_detection' into txmv2_enablement
dimriou Nov 13, 2024
fc33337
Minor updates
dimriou Nov 13, 2024
eaa8e74
Merge branch 'txmv2' into txmv2_stuck_tx_detection
dimriou Nov 13, 2024
87497a0
Switch DualBroadcast params to pointers
dimriou Nov 13, 2024
257fcf4
Merge branch 'txmv2_stuck_tx_detection' into txmv2_enablement
dimriou Nov 13, 2024
015f1bf
Update DualBroadcast types to pointers
dimriou Nov 13, 2024
fc11ca1
Make purgable attempts empty
dimriou Nov 15, 2024
5f5541c
Merge branch 'develop' into txmv2
dimriou Nov 15, 2024
906a8be
Merge branch 'txmv2' into txmv2_stuck_tx_detection
dimriou Nov 15, 2024
e6e8b09
Merge branch 'txmv2_stuck_tx_detection' into txmv2_enablement
dimriou Nov 15, 2024
cb38104
Merge branch 'develop' into txmv2
dimriou Nov 15, 2024
cb9c321
Merge branch 'txmv2' into txmv2_stuck_tx_detection
dimriou Nov 15, 2024
2f196a5
Merge branch 'txmv2_stuck_tx_detection' into txmv2_enablement
dimriou Nov 15, 2024
d2dc53b
Fix Idempotency in Store Manager
dimriou Nov 15, 2024
c56bb81
Merge branch 'txmv2' into txmv2_stuck_tx_detection
dimriou Nov 15, 2024
750b96a
Merge branch 'txmv2_stuck_tx_detection' into txmv2_enablement
dimriou Nov 15, 2024
9abccc7
Update trigger
dimriou Nov 19, 2024
c2c1c4f
Fix lint
dimriou Nov 19, 2024
18fac77
Merge branch 'develop' into txmv2
dimriou Nov 19, 2024
3edfc00
Merge branch 'txmv2' into txmv2_stuck_tx_detection
dimriou Nov 19, 2024
22f2795
Merge branch 'txmv2_stuck_tx_detection' into txmv2_enablement
dimriou Nov 19, 2024
a04b458
Add context to client
dimriou Nov 19, 2024
0d7b1c4
Merge branch 'txmv2_stuck_tx_detection' into txmv2_enablement
dimriou Nov 19, 2024
3250b19
Merge branch 'develop' into txmv2
dimriou Nov 19, 2024
54a59d4
Merge branch 'txmv2' into txmv2_stuck_tx_detection
dimriou Nov 19, 2024
409ac1a
Merge branch 'txmv2_stuck_tx_detection' into txmv2_enablement
dimriou Nov 19, 2024
8044bef
Fix more lint
dimriou Nov 19, 2024
946d2cb
Merge branch 'txmv2' into txmv2_stuck_tx_detection
dimriou Nov 19, 2024
6828e38
Merge branch 'txmv2_stuck_tx_detection' into txmv2_enablement
dimriou Nov 19, 2024
5032336
Fix lint
dimriou Nov 19, 2024
31e9e83
Merge branch 'txmv2' into txmv2_stuck_tx_detection
dimriou Nov 19, 2024
b16643d
Fix lint
dimriou Nov 19, 2024
3ba3a31
Merge branch 'txmv2_stuck_tx_detection' into txmv2_enablement
dimriou Nov 19, 2024
feb243a
Fix lint
dimriou Nov 19, 2024
e3bb10b
Merge branch 'txmv2' into txmv2_stuck_tx_detection
dimriou Nov 19, 2024
338f2da
Fix DualBroadcast client
dimriou Nov 19, 2024
82a5469
Merge branch 'txmv2_stuck_tx_detection' into txmv2_enablement
dimriou Nov 19, 2024
8a4e25f
More lint fixes
dimriou Nov 19, 2024
717868e
Merge branch 'txmv2' into txmv2_stuck_tx_detection
dimriou Nov 19, 2024
83d15ab
More lint fixes
dimriou Nov 19, 2024
7636236
Merge branch 'txmv2_stuck_tx_detection' into txmv2_enablement
dimriou Nov 19, 2024
ee67544
Fix lint
dimriou Nov 20, 2024
d119a13
Merge branch 'develop' into txmv2
dimriou Nov 20, 2024
7454696
Merge branch 'txmv2' into txmv2_stuck_tx_detection
dimriou Nov 20, 2024
c05c875
Fix lint
dimriou Nov 20, 2024
6e717e7
Merge branch 'txmv2_stuck_tx_detection' into txmv2_enablement
dimriou Nov 20, 2024
0f707a1
Fix lint final
dimriou Nov 20, 2024
3829f87
Merge branch 'txmv2' into txmv2_stuck_tx_detection
dimriou Nov 20, 2024
d167c46
Merge branch 'txmv2_stuck_tx_detection' into txmv2_enablement
dimriou Nov 20, 2024
291bbc0
Fix races
dimriou Nov 20, 2024
6c4f710
Merge branch 'txmv2' into txmv2_stuck_tx_detection
dimriou Nov 20, 2024
ed45103
Merge branch 'txmv2_stuck_tx_detection' into txmv2_enablement
dimriou Nov 20, 2024
d45090b
Update logs
dimriou Nov 25, 2024
942a400
Merge branch 'txmv2' into txmv2_stuck_tx_detection
dimriou Nov 25, 2024
f3e39e3
Merge branch 'txmv2_stuck_tx_detection' into txmv2_enablement
dimriou Nov 25, 2024
43ed971
Fix lint
dimriou Nov 25, 2024
cb15055
Merge branch 'txmv2' into txmv2_stuck_tx_detection
dimriou Nov 25, 2024
e4f1649
Merge branch 'txmv2_stuck_tx_detection' into txmv2_enablement
dimriou Nov 25, 2024
21ff676
Start documentation
dimriou Nov 25, 2024
6036910
Merge branch 'develop' into txmv2
dimriou Nov 25, 2024
887e199
Update DummyKeystore Add method
dimriou Nov 27, 2024
e331d81
Merge branch 'develop' into txmv2
dimriou Nov 27, 2024
cecb0e1
Txmv2 stuck tx detection (#15436)
dimriou Nov 27, 2024
91e35ea
Make nonce nullable
dimriou Nov 27, 2024
15ff37a
Merge branch 'txmv2' into txmv2_enablement
dimriou Nov 27, 2024
78e0690
Update configs
dimriou Nov 27, 2024
2c551f6
Merge branch 'txmv2' into txmv2_enablement
dimriou Nov 27, 2024
272ba06
Add prom metrics
dimriou Nov 28, 2024
79895a7
Add prom metrics
dimriou Nov 28, 2024
4df641a
Merge branch 'txmv2' into txmv2_enablement
dimriou Nov 28, 2024
7b0a1d1
Add transaction confirmation metric
dimriou Dec 2, 2024
5f55245
Improve logs
dimriou Dec 2, 2024
bb18095
Merge branch 'txmv2' into txmv2_enablement
dimriou Dec 2, 2024
6bc27a2
Add Abandon support
dimriou Dec 2, 2024
926bf67
Address feedback
dimriou Dec 3, 2024
5fdc190
Merge branch 'txmv2' into txmv2_enablement
dimriou Dec 4, 2024
a4eacaa
Update tests
dimriou Dec 4, 2024
ecfdfb9
Fix orchestrator log
dimriou Dec 4, 2024
1c4cc3e
Merge branch 'txmv2' into txmv2_enablement
dimriou Dec 4, 2024
0ff44e9
Fix Nonce log
dimriou Dec 4, 2024
f61a10c
Merge branch 'txmv2' into txmv2_enablement
dimriou Dec 4, 2024
cecb7f6
Improvements
dimriou Dec 4, 2024
e6ab384
Merge branch 'txmv2' into txmv2_enablement
dimriou Dec 4, 2024
103f0d8
Update tests
dimriou Dec 4, 2024
0fb3bcc
Merge branch 'txmv2' into txmv2_enablement
dimriou Dec 5, 2024
cc0b9eb
Add fixes
dimriou Dec 6, 2024
6a17e0a
Improvements
dimriou Dec 6, 2024
8d870fb
Improve logs
dimriou Dec 9, 2024
a2f1544
Move initialization of nonce
dimriou Dec 10, 2024
5b023a4
Add Beholder metrics
dimriou Dec 10, 2024
86ce03a
Improve InMemoryStorage
dimriou Dec 12, 2024
5b73b73
Support different priceMax per key
dimriou Dec 12, 2024
08f4851
Upgrades
dimriou Dec 13, 2024
ec1be22
Merge branch 'txmv2' into txmv2_enablement
dimriou Dec 13, 2024
ccf8be7
Fix config tests
dimriou Dec 13, 2024
7fb2e3a
Merge branch 'develop' into txmv2
dimriou Dec 13, 2024
8cb5d9c
Merge branch 'txmv2' into txmv2_enablement
dimriou Dec 13, 2024
98d0b53
Fix docs
dimriou Dec 14, 2024
9774fcd
Merge branch 'txmv2' into txmv2_enablement
dimriou Dec 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ packages:
BalanceMonitor:
config:
dir: "{{ .InterfaceDir }}/../mocks"
github.com/smartcontractkit/chainlink/v2/core/chains/evm/txm:
interfaces:
Client:
TxStore:
AttemptBuilder:
Keystore:
github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr:
interfaces:
ChainConfig:
Expand Down
39 changes: 38 additions & 1 deletion common/txmgr/txmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@ type TxManager[
GetTransactionStatus(ctx context.Context, transactionID string) (state commontypes.TransactionStatus, err error)
}

type TxmV2Wrapper[
CHAIN_ID types.ID,
HEAD types.Head[BLOCK_HASH],
ADDR types.Hashable,
TX_HASH types.Hashable,
BLOCK_HASH types.Hashable,
SEQ types.Sequence,
FEE feetypes.Fee,
] interface {
services.Service
CreateTransaction(ctx context.Context, txRequest txmgrtypes.TxRequest[ADDR, TX_HASH]) (etx txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], err error)
Reset(addr ADDR, abandon bool) error
}

type reset struct {
// f is the function to execute between stopping/starting the
// Broadcaster and Confirmer
Expand Down Expand Up @@ -112,6 +126,7 @@ type Txm[
fwdMgr txmgrtypes.ForwarderManager[ADDR]
txAttemptBuilder txmgrtypes.TxAttemptBuilder[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]
newErrorClassifier NewErrorClassifier
txmv2wrapper TxmV2Wrapper[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]
}

func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) RegisterResumeCallback(fn ResumeCallback) {
Expand Down Expand Up @@ -147,6 +162,7 @@ func NewTxm[
tracker *Tracker[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE],
finalizer txmgrtypes.Finalizer[BLOCK_HASH, HEAD],
newErrorClassifierFunc NewErrorClassifier,
txmv2wrapper TxmV2Wrapper[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE],
) *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE] {
b := Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]{
logger: logger.Sugared(lggr),
Expand All @@ -169,6 +185,7 @@ func NewTxm[
tracker: tracker,
newErrorClassifier: newErrorClassifierFunc,
finalizer: finalizer,
txmv2wrapper: txmv2wrapper,
}

if txCfg.ResendAfterThreshold() <= 0 {
Expand Down Expand Up @@ -207,6 +224,12 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) Start(ctx
return fmt.Errorf("Txm: Finalizer failed to start: %w", err)
}

if b.txmv2wrapper != nil {
if err := ms.Start(ctx, b.txmv2wrapper); err != nil {
return fmt.Errorf("Txm: Txmv2 failed to start: %w", err)
}
}

b.logger.Info("Txm starting runLoop")
b.wg.Add(1)
go b.runLoop()
Expand Down Expand Up @@ -237,6 +260,11 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) Reset(addr
f := func() {
if abandon {
err = b.abandon(addr)
if b.txmv2wrapper != nil {
if err2 := b.txmv2wrapper.Reset(addr, abandon); err2 != nil {
b.logger.Error("failed to abandon transactions for dual broadcast", "err", err2)
}
}
}
}

Expand Down Expand Up @@ -460,6 +488,12 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) runLoop()
if err != nil && (!errors.Is(err, services.ErrAlreadyStopped) || !errors.Is(err, services.ErrCannotStopUnstarted)) {
b.logger.Errorw(fmt.Sprintf("Failed to Close Finalizer: %v", err), "err", err)
}
if b.txmv2wrapper != nil {
err = b.txmv2wrapper.Close()
if err != nil && (!errors.Is(err, services.ErrAlreadyStopped) || !errors.Is(err, services.ErrCannotStopUnstarted)) {
b.logger.Errorw(fmt.Sprintf("Failed to Close Finalizer: %v", err), "err", err)
}
}
return
case <-keysChanged:
// This check prevents the weird edge-case where you can select
Expand Down Expand Up @@ -513,11 +547,14 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) Trigger(ad
func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) CreateTransaction(ctx context.Context, txRequest txmgrtypes.TxRequest[ADDR, TX_HASH]) (tx txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE], err error) {
// Check for existing Tx with IdempotencyKey. If found, return the Tx and do nothing
// Skipping CreateTransaction to avoid double send
if b.txmv2wrapper != nil && txRequest.Meta != nil && txRequest.Meta.DualBroadcast != nil && *txRequest.Meta.DualBroadcast {
return b.txmv2wrapper.CreateTransaction(ctx, txRequest)
}
if txRequest.IdempotencyKey != nil {
var existingTx *txmgrtypes.Tx[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]
existingTx, err = b.txStore.FindTxWithIdempotencyKey(ctx, *txRequest.IdempotencyKey, b.chainID)
if err != nil {
return tx, fmt.Errorf("Failed to search for transaction with IdempotencyKey: %w", err)
return tx, fmt.Errorf("failed to search for transaction with IdempotencyKey: %w", err)
}
if existingTx != nil {
b.logger.Infow("Found a Tx with IdempotencyKey. Returning existing Tx without creating a new one.", "IdempotencyKey", *txRequest.IdempotencyKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,8 @@ func makeTestEvmTxm(
lp,
keyStore,
estimator,
ht)
ht,
nil)
require.NoError(t, err, "can't create tx manager")

_, unsub := broadcaster.Subscribe(txm)
Expand Down
4 changes: 4 additions & 0 deletions core/chains/evm/config/chain_scoped.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ func (e *EVMConfig) BalanceMonitor() BalanceMonitor {
return &balanceMonitorConfig{c: e.C.BalanceMonitor}
}

func (e *EVMConfig) TxmV2() TxmV2 {
return &txmv2Config{c: e.C.TxmV2}
}

func (e *EVMConfig) Transactions() Transactions {
return &transactionsConfig{c: e.C.Transactions}
}
Expand Down
25 changes: 25 additions & 0 deletions core/chains/evm/config/chain_scoped_txmv2.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package config

import (
"net/url"
"time"

"github.com/smartcontractkit/chainlink/v2/core/chains/evm/config/toml"
)

type txmv2Config struct {
c toml.TxmV2
}

func (t *txmv2Config) Enabled() bool {
return *t.c.Enabled
}

func (t *txmv2Config) BlockTime() *time.Duration {
d := t.c.BlockTime.Duration()
return &d
}

func (t *txmv2Config) CustomURL() *url.URL {
return t.c.CustomURL.URL()
}
6 changes: 5 additions & 1 deletion core/chains/evm/config/chaintype/chaintype.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const (
ChainZkEvm ChainType = "zkevm"
ChainZkSync ChainType = "zksync"
ChainZircuit ChainType = "zircuit"
ChainDualBroadcast ChainType = "dualBroadcast"
)

// IsL2 returns true if this chain is a Layer 2 chain. Notably:
Expand All @@ -39,7 +40,7 @@ func (c ChainType) IsL2() bool {

func (c ChainType) IsValid() bool {
switch c {
case "", ChainArbitrum, ChainAstar, ChainCelo, ChainGnosis, ChainHedera, ChainKroma, ChainMantle, ChainMetis, ChainOptimismBedrock, ChainScroll, ChainWeMix, ChainXLayer, ChainZkEvm, ChainZkSync, ChainZircuit:
case "", ChainArbitrum, ChainAstar, ChainCelo, ChainGnosis, ChainHedera, ChainKroma, ChainMantle, ChainMetis, ChainOptimismBedrock, ChainScroll, ChainWeMix, ChainXLayer, ChainZkEvm, ChainZkSync, ChainZircuit, ChainDualBroadcast:
return true
}
return false
Expand Down Expand Up @@ -77,6 +78,8 @@ func FromSlug(slug string) ChainType {
return ChainZkSync
case "zircuit":
return ChainZircuit
case "dualBroadcast":
return ChainDualBroadcast
default:
return ChainType(slug)
}
Expand Down Expand Up @@ -144,4 +147,5 @@ var ErrInvalid = fmt.Errorf("must be one of %s or omitted", strings.Join([]strin
string(ChainZkEvm),
string(ChainZkSync),
string(ChainZircuit),
string(ChainDualBroadcast),
}, ", "))
7 changes: 7 additions & 0 deletions core/chains/evm/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
type EVM interface {
HeadTracker() HeadTracker
BalanceMonitor() BalanceMonitor
TxmV2() TxmV2
Transactions() Transactions
GasEstimator() GasEstimator
OCR() OCR
Expand Down Expand Up @@ -102,6 +103,12 @@ type ClientErrors interface {
TooManyResults() string
}

type TxmV2 interface {
Enabled() bool
BlockTime() *time.Duration
CustomURL() *url.URL
}

type Transactions interface {
ForwardersEnabled() bool
ReaperInterval() time.Duration
Expand Down
55 changes: 53 additions & 2 deletions core/chains/evm/config/toml/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/url"
"slices"
"strconv"
"time"

"github.com/ethereum/go-ethereum/core/txpool/legacypool"
"github.com/pelletier/go-toml/v2"
Expand Down Expand Up @@ -300,8 +301,10 @@ func (c *EVMConfig) ValidateConfig() (err error) {
is := c.ChainType.ChainType()
if is != must {
if must == "" {
err = multierr.Append(err, commonconfig.ErrInvalid{Name: "ChainType", Value: c.ChainType.ChainType(),
Msg: "must not be set with this chain id"})
if c.ChainType.ChainType() != chaintype.ChainDualBroadcast {
err = multierr.Append(err, commonconfig.ErrInvalid{Name: "ChainType", Value: c.ChainType.ChainType(),
Msg: "must not be set with this chain id"})
}
} else {
err = multierr.Append(err, commonconfig.ErrInvalid{Name: "ChainType", Value: c.ChainType.ChainType(),
Msg: fmt.Sprintf("only %q can be used with this chain id", must)})
Expand Down Expand Up @@ -387,6 +390,7 @@ type Chain struct {
FinalizedBlockOffset *uint32
NoNewFinalizedHeadsThreshold *commonconfig.Duration

TxmV2 TxmV2 `toml:",omitempty"`
Transactions Transactions `toml:",omitempty"`
BalanceMonitor BalanceMonitor `toml:",omitempty"`
GasEstimator GasEstimator `toml:",omitempty"`
Expand Down Expand Up @@ -448,6 +452,20 @@ func (c *Chain) ValidateConfig() (err error) {
err = multierr.Append(err, commonconfig.ErrInvalid{Name: "GasEstimator.BumpThreshold", Value: 0, Msg: fmt.Sprintf("cannot be 0 if Transactions.AutoPurge.MinAttempts is set for %s", chainType)})
}
}
case chaintype.ChainDualBroadcast:
if c.Transactions.AutoPurge.DetectionApiUrl == nil {
err = multierr.Append(err, commonconfig.ErrMissing{Name: "Transactions.AutoPurge.DetectionApiUrl", Msg: fmt.Sprintf("must be set for %s", chainType)})
}
if c.Transactions.AutoPurge.Threshold == nil {
err = multierr.Append(err, commonconfig.ErrMissing{Name: "Transactions.AutoPurge.Threshold", Msg: fmt.Sprintf("needs to be set if auto-purge feature is enabled for %s", chainType)})
} else if *c.Transactions.AutoPurge.Threshold == 0 {
err = multierr.Append(err, commonconfig.ErrInvalid{Name: "Transactions.AutoPurge.Threshold", Value: 0, Msg: fmt.Sprintf("cannot be 0 if auto-purge feature is enabled for %s", chainType)})
}
if c.TxmV2.Enabled != nil && *c.TxmV2.Enabled {
if c.TxmV2.CustomURL == nil {
err = multierr.Append(err, commonconfig.ErrMissing{Name: "TxmV2.CustomURL", Msg: fmt.Sprintf("must be set for %s", chainType)})
}
}
default:
// Bump Threshold is required because the stuck tx heuristic relies on a minimum number of bump attempts to exist
if c.GasEstimator.BumpThreshold == nil {
Expand All @@ -471,6 +489,39 @@ func (c *Chain) ValidateConfig() (err error) {
return
}

type TxmV2 struct {
Enabled *bool `toml:",omitempty"`
BlockTime *commonconfig.Duration `toml:",omitempty"`
CustomURL *commonconfig.URL `toml:",omitempty"`
}

func (t *TxmV2) setFrom(f *TxmV2) {
if v := f.Enabled; v != nil {
t.Enabled = f.Enabled
}

if v := f.BlockTime; v != nil {
t.BlockTime = f.BlockTime
}

if v := f.CustomURL; v != nil {
t.CustomURL = f.CustomURL
}
}

func (t *TxmV2) ValidateConfig() (err error) {
if t.Enabled != nil && *t.Enabled {
if t.BlockTime == nil {
err = multierr.Append(err, commonconfig.ErrMissing{Name: "TxmV2.BlockTime", Msg: "must be set if txmv2 feature is enabled"})
return
}
if t.BlockTime.Duration() < 2*time.Second {
err = multierr.Append(err, commonconfig.ErrInvalid{Name: "TxmV2.BlockTime", Msg: "must be equal to or greater than 2 seconds"})
}
}
return
}

type Transactions struct {
ForwardersEnabled *bool
MaxInFlight *uint32
Expand Down
1 change: 1 addition & 0 deletions core/chains/evm/config/toml/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ func (c *Chain) SetFrom(f *Chain) {
c.NoNewFinalizedHeadsThreshold = v
}

c.TxmV2.setFrom(&f.TxmV2)
c.Transactions.setFrom(&f.Transactions)
c.BalanceMonitor.setFrom(&f.BalanceMonitor)
c.GasEstimator.setFrom(&f.GasEstimator)
Expand Down
3 changes: 3 additions & 0 deletions core/chains/evm/config/toml/defaults/fallback.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ FinalizedBlockOffset = 0
NoNewFinalizedHeadsThreshold = '0'
LogBroadcasterEnabled = true

[TxmV2]
Enabled = false

[Transactions]
ForwardersEnabled = false
MaxInFlight = 16
Expand Down
1 change: 1 addition & 0 deletions core/chains/evm/keystore/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ type Eth interface {
CheckEnabled(ctx context.Context, address common.Address, chainID *big.Int) error
EnabledAddressesForChain(ctx context.Context, chainID *big.Int) (addresses []common.Address, err error)
SignTx(ctx context.Context, fromAddress common.Address, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)
SignMessage(ctx context.Context, address common.Address, message []byte) ([]byte, error)
SubscribeToKeyChanges(ctx context.Context) (ch chan struct{}, unsub func())
}
60 changes: 60 additions & 0 deletions core/chains/evm/keystore/mocks/eth.go

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

Loading
Loading