Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 21 additions & 0 deletions CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,27 @@ ResendAfterThreshold = '1m' # Default
```
ResendAfterThreshold controls how long to wait before re-broadcasting a transaction that has not yet been confirmed.

## Transactions.HederaBroadcastValidation
```toml
[Transactions.HederaBroadcastValidation]
SequencePollTimeout = '30s' # Example
SequencePollInterval = '2s' # Example
```


### SequencePollTimeout
```toml
SequencePollTimeout = '30s' # Example
```
SequencePollTimeout is the total time to poll the mined nonce after a successful Hedera send.
Unset keeps legacy single-check behavior. When set, TXM polls until the nonce advances or the timeout elapses.

### SequencePollInterval
```toml
SequencePollInterval = '2s' # Example
```
SequencePollInterval is the delay between mined nonce checks while polling. Defaults to 2s in TXM when unset.

## Transactions.AutoPurge
```toml
[Transactions.AutoPurge]
Expand Down
16 changes: 16 additions & 0 deletions pkg/config/chain_scoped_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,22 @@ func (t *transactionsConfig) AutoPurge() AutoPurgeConfig {
return &autoPurgeConfig{c: t.c.AutoPurge}
}

func (t *transactionsConfig) HederaSequencePollTimeout() *time.Duration {
if t.c.HederaBroadcastValidation.SequencePollTimeout == nil {
return nil
}
d := t.c.HederaBroadcastValidation.SequencePollTimeout.Duration()
return &d
}

func (t *transactionsConfig) HederaSequencePollInterval() *time.Duration {
if t.c.HederaBroadcastValidation.SequencePollInterval == nil {
return nil
}
d := t.c.HederaBroadcastValidation.SequencePollInterval.Duration()
return &d
}

type autoPurgeConfig struct {
c toml.AutoPurgeConfig
}
Expand Down
67 changes: 67 additions & 0 deletions pkg/config/chain_scoped_transactions_hedera_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package config

import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config"
"github.com/smartcontractkit/chainlink-evm/pkg/config/toml"
)

func TestTransactionsConfig_HederaBroadcastValidation(t *testing.T) {
t.Parallel()

t.Run("returns nil when unset", func(t *testing.T) {
t.Parallel()

cfg := &transactionsConfig{c: toml.Transactions{}}
assert.Nil(t, cfg.HederaSequencePollTimeout())
assert.Nil(t, cfg.HederaSequencePollInterval())
})

t.Run("returns configured values", func(t *testing.T) {
t.Parallel()

timeout := commonconfig.MustNewDuration(30 * time.Second)
interval := commonconfig.MustNewDuration(2 * time.Second)
cfg := &transactionsConfig{c: toml.Transactions{
HederaBroadcastValidation: toml.HederaBroadcastValidationConfig{
SequencePollTimeout: timeout,
SequencePollInterval: interval,
},
}}

gotTimeout := cfg.HederaSequencePollTimeout()
require.NotNil(t, gotTimeout)
assert.Equal(t, 30*time.Second, *gotTimeout)

gotInterval := cfg.HederaSequencePollInterval()
require.NotNil(t, gotInterval)
assert.Equal(t, 2*time.Second, *gotInterval)
})
}

func TestHederaBroadcastValidationConfig_ValidateConfig(t *testing.T) {
t.Parallel()

t.Run("accepts valid config", func(t *testing.T) {
t.Parallel()

cfg := toml.HederaBroadcastValidationConfig{
SequencePollTimeout: commonconfig.MustNewDuration(time.Second),
}
require.NoError(t, cfg.ValidateConfig())
})

t.Run("rejects interval without timeout", func(t *testing.T) {
t.Parallel()

cfg := toml.HederaBroadcastValidationConfig{
SequencePollInterval: commonconfig.MustNewDuration(time.Second),
}
require.Error(t, cfg.ValidateConfig())
})
}
38 changes: 36 additions & 2 deletions pkg/config/toml/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,9 @@ func (c *Transactions) ValidateConfig() (err error) {
err = multierr.Append(err, commonconfig.ErrInvalid{Name: "AutoPurge.Threshold", Value: 0, Msg: "cannot be 0 if auto-purge feature is enabled"})
}
}
if err2 := c.HederaBroadcastValidation.ValidateConfig(); err2 != nil {
err = multierr.Append(err, err2)
}
return
}

Expand All @@ -545,8 +548,9 @@ type Transactions struct {
ResendAfterThreshold *commonconfig.Duration
ConfirmationTimeout *commonconfig.Duration

AutoPurge AutoPurgeConfig `toml:",omitempty"`
TransactionManagerV2 TransactionManagerV2Config `toml:",omitempty"`
AutoPurge AutoPurgeConfig `toml:",omitempty"`
HederaBroadcastValidation HederaBroadcastValidationConfig `toml:",omitempty"`
TransactionManagerV2 TransactionManagerV2Config `toml:",omitempty"`
}

func (t *Transactions) setFrom(f *Transactions) {
Expand Down Expand Up @@ -575,6 +579,7 @@ func (t *Transactions) setFrom(f *Transactions) {
t.ConfirmationTimeout = v
}
t.AutoPurge.setFrom(&f.AutoPurge)
t.HederaBroadcastValidation.setFrom(&f.HederaBroadcastValidation)
t.TransactionManagerV2.setFrom(&f.TransactionManagerV2)
}

Expand All @@ -600,6 +605,35 @@ func (a *AutoPurgeConfig) setFrom(f *AutoPurgeConfig) {
}
}

// HederaBroadcastValidationConfig controls optional post-send mined-nonce polling on Hedera.
// Unset or zero SequencePollTimeout keeps legacy single-check behavior.
type HederaBroadcastValidationConfig struct {
SequencePollTimeout *commonconfig.Duration `toml:",omitempty"`
SequencePollInterval *commonconfig.Duration `toml:",omitempty"`
}

func (h *HederaBroadcastValidationConfig) setFrom(f *HederaBroadcastValidationConfig) {
if v := f.SequencePollTimeout; v != nil {
h.SequencePollTimeout = v
}
if v := f.SequencePollInterval; v != nil {
h.SequencePollInterval = v
}
}

func (h *HederaBroadcastValidationConfig) ValidateConfig() (err error) {
if h.SequencePollTimeout != nil && h.SequencePollTimeout.Duration() <= 0 {
err = multierr.Append(err, commonconfig.ErrInvalid{Name: "HederaBroadcastValidation.SequencePollTimeout", Value: h.SequencePollTimeout, Msg: "must be greater than zero when set"})
}
if h.SequencePollInterval != nil && h.SequencePollInterval.Duration() <= 0 {
err = multierr.Append(err, commonconfig.ErrInvalid{Name: "HederaBroadcastValidation.SequencePollInterval", Value: h.SequencePollInterval, Msg: "must be greater than zero when set"})
}
if h.SequencePollInterval != nil && (h.SequencePollTimeout == nil || h.SequencePollTimeout.Duration() <= 0) {
err = multierr.Append(err, commonconfig.ErrMissing{Name: "HederaBroadcastValidation.SequencePollTimeout", Msg: "must be set when SequencePollInterval is set"})
}
Comment on lines +631 to +633
return
}

type TransactionManagerV2Config struct {
Enabled *bool `toml:",omitempty"`
BlockTime *commonconfig.Duration `toml:",omitempty"`
Expand Down
9 changes: 9 additions & 0 deletions pkg/config/toml/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ func TestDefaults_fieldsNotNil(t *testing.T) {
unknown.Transactions.AutoPurge.Threshold = ptr(uint32(0))
unknown.Transactions.AutoPurge.MinAttempts = ptr(uint32(0))
unknown.Transactions.AutoPurge.DetectionApiUrl = new(config.URL)
unknown.Transactions.HederaBroadcastValidation.SequencePollTimeout = new(config.Duration)
unknown.Transactions.HederaBroadcastValidation.SequencePollInterval = new(config.Duration)
unknown.GasEstimator.BlockHistory.EIP1559FeeCapBufferBlocks = ptr[uint16](10)
unknown.GasEstimator.SenderAddress = asEIP55Address(t, "0xae4E781a6218A8031764928E88d457937A954fC3")
oracleType := DAOracleOPStack
Expand Down Expand Up @@ -217,6 +219,9 @@ func TestDocs(t *testing.T) {
docDefaults.Transactions.TransactionManagerV2.FastlaneAuctionRequestTimeout = nil
docDefaults.Transactions.TransactionManagerV2.FeeBoost = nil

// HederaBroadcastValidation configs are optional and only documented as examples
docDefaults.Transactions.HederaBroadcastValidation = HederaBroadcastValidationConfig{}

// Fallback DA oracle is not set
docDefaults.GasEstimator.DAOracle = DAOracle{}

Expand Down Expand Up @@ -342,6 +347,10 @@ var fullConfig = EVMConfig{
MinAttempts: ptr[uint32](13),
DetectionApiUrl: config.MustParseURL("http://example.net"),
},
HederaBroadcastValidation: HederaBroadcastValidationConfig{
SequencePollTimeout: config.MustNewDuration(30 * time.Second),
SequencePollInterval: config.MustNewDuration(2 * time.Second),
},
TransactionManagerV2: TransactionManagerV2Config{
Enabled: ptr(false),
DualBroadcast: ptr(true),
Expand Down
5 changes: 5 additions & 0 deletions pkg/config/toml/defaults/Hedera_Mainnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ EstimateLimit = true
# Accounting for Node syncs & avoid re-sending txns before fetching the receipt, setting to 2m
ResendAfterThreshold = '2m'

# Optional: wait for mined nonce to advance after a successful send before gas-bumping.
# Omit to keep legacy single-check behavior. CCIP example: 30s timeout, 2s poll interval.
# [Transactions.HederaBroadcastValidation]
# SequencePollTimeout = '30s'
# SequencePollInterval = '2s'

[NodePool]
SyncThreshold = 10
5 changes: 5 additions & 0 deletions pkg/config/toml/defaults/Hedera_Testnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ EstimateLimit = true
# Accounting for Node syncs & avoid re-sending txns before fetching the receipt, setting to 2m
ResendAfterThreshold = '2m'

# Optional: wait for mined nonce to advance after a successful send before gas-bumping.
# Omit to keep legacy single-check behavior. CCIP example: 30s timeout, 2s poll interval.
# [Transactions.HederaBroadcastValidation]
# SequencePollTimeout = '30s'
# SequencePollInterval = '2s'

[NodePool]
SyncThreshold = 10
7 changes: 7 additions & 0 deletions pkg/config/toml/docs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ ReaperThreshold = '168h' # Default
# ResendAfterThreshold controls how long to wait before re-broadcasting a transaction that has not yet been confirmed.
ResendAfterThreshold = '1m' # Default

[Transactions.HederaBroadcastValidation]
# SequencePollTimeout is the total time to poll the mined nonce after a successful Hedera send.
# Unset keeps legacy single-check behavior. When set, TXM polls until the nonce advances or the timeout elapses.
SequencePollTimeout = '30s' # Example
# SequencePollInterval is the delay between mined nonce checks while polling. Defaults to 2s in TXM when unset.
SequencePollInterval = '2s' # Example

[Transactions.AutoPurge]
# Enabled enables or disables automatically purging transactions that have been idenitified as terminally stuck (will never be included on-chain). This feature is only expected to be used by ZK chains.
Enabled = false # Default
Expand Down
4 changes: 4 additions & 0 deletions pkg/config/toml/testdata/config-full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Threshold = 42
MinAttempts = 13
DetectionApiUrl = 'http://example.net'

[Transactions.HederaBroadcastValidation]
SequencePollTimeout = '30s'
SequencePollInterval = '2s'

[Transactions.TransactionManagerV2]
Enabled = false
BlockTime = '42s'
Expand Down
3 changes: 3 additions & 0 deletions pkg/txmgr/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ func (t *transactionsConfig) ReaperThreshold() time.Duration { return t.e.
func (t *transactionsConfig) ResendAfterThreshold() time.Duration { return t.e.ResendAfterThreshold }
func (t *transactionsConfig) AutoPurge() evmconfig.AutoPurgeConfig { return t.autoPurge }

func (t *transactionsConfig) HederaSequencePollTimeout() *time.Duration { return nil }
func (t *transactionsConfig) HederaSequencePollInterval() *time.Duration { return nil }

type autoPurgeConfig struct {
evmconfig.AutoPurgeConfig
}
Expand Down
Loading