Skip to content

Commit

Permalink
Merge branch 'txmv2_stuck_tx_detection' into txmv2_enablement
Browse files Browse the repository at this point in the history
  • Loading branch information
dimriou committed Nov 15, 2024
2 parents 2f196a5 + c56bb81 commit 750b96a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions core/chains/evm/txm/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ type OrchestratorKeystore interface {
EnabledAddressesForChain(ctx context.Context, chainID *big.Int) (addresses []common.Address, err error)
}

type OrchestratorAttemptBuilder interface {
type OrchestratorAttemptBuilder[
BLOCK_HASH types.Hashable,
HEAD types.Head[BLOCK_HASH],
] interface {
services.Service
OnNewLongestChain(ctx context.Context, head HEAD)
}

// Generics are necessary to keep TXMv2 backwards compatible
Expand All @@ -53,7 +57,7 @@ type Orchestrator[
txStore OrchestratorTxStore
fwdMgr *forwarders.FwdMgr
keystore OrchestratorKeystore
attemptBuilder OrchestratorAttemptBuilder
attemptBuilder OrchestratorAttemptBuilder[BLOCK_HASH, HEAD]
resumeCallback txmgr.ResumeCallback
}

Expand All @@ -64,7 +68,7 @@ func NewTxmOrchestrator[BLOCK_HASH types.Hashable, HEAD types.Head[BLOCK_HASH]](
txStore OrchestratorTxStore,
fwdMgr *forwarders.FwdMgr,
keystore OrchestratorKeystore,
attemptBuilder OrchestratorAttemptBuilder,
attemptBuilder OrchestratorAttemptBuilder[BLOCK_HASH, HEAD],
) *Orchestrator[BLOCK_HASH, HEAD] {
return &Orchestrator[BLOCK_HASH, HEAD]{
lggr: logger.Sugared(logger.Named(lggr, "Orchestrator")),
Expand Down Expand Up @@ -159,6 +163,12 @@ func (o *Orchestrator[BLOCK_HASH, HEAD]) Reset(addr common.Address, abandon bool
}

func (o *Orchestrator[BLOCK_HASH, HEAD]) OnNewLongestChain(ctx context.Context, head HEAD) {
ok := o.IfStarted(func() {
o.attemptBuilder.OnNewLongestChain(ctx, head)
})
if !ok {
o.lggr.Debugw("Not started; ignoring head", "head", head, "state", o.State())
}
}

func (o *Orchestrator[BLOCK_HASH, HEAD]) CreateTransaction(ctx context.Context, request txmgrtypes.TxRequest[common.Address, common.Hash]) (tx txmgrtypes.Tx[*big.Int, common.Address, common.Hash, common.Hash, evmtypes.Nonce, gas.EvmFee], err error) {
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/txm/storage/inmemory_store_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,5 @@ func (m *InMemoryStoreManager) FindTxWithIdempotencyKey(_ context.Context, idemp
return tx, nil
}
}
return nil, fmt.Errorf("key not found")
return nil, nil
}

0 comments on commit 750b96a

Please sign in to comment.