@@ -2,7 +2,6 @@ package seth
22
33import (
44 "context"
5- "errors"
65 "fmt"
76 "math"
87 "math/big"
4443// according to selected strategy.
4544func (m * Client ) CalculateNetworkCongestionMetric (blocksNumber uint64 , strategy string ) (float64 , error ) {
4645 if m .HeaderCache == nil {
47- return 0 , fmt .Errorf ("header cache is nil" )
46+ return 0 , fmt .Errorf ("header cache is not initialized. " +
47+ "This is an internal error that shouldn't happen. " +
48+ "If you see this, please open a GitHub issue at https://github.com/smartcontractkit/chainlink-testing-framework/issues with your configuration details" )
4849 }
4950 var getHeaderData = func (bn * big.Int ) (* types.Header , error ) {
5051 if bn == nil {
@@ -128,7 +129,18 @@ func (m *Client) CalculateNetworkCongestionMetric(blocksNumber uint64, strategy
128129
129130 minBlockCount := int (float64 (blocksNumber ) * 0.8 )
130131 if len (headers ) < minBlockCount {
131- return 0 , fmt .Errorf ("%s. Wanted at least %d, got %d" , BlockFetchingErr , minBlockCount , len (headers ))
132+ return 0 , fmt .Errorf ("failed to fetch sufficient block headers for gas estimation. " +
133+ "Needed at least %d blocks, but only got %d (%.1f%% success rate).\n " +
134+ "This usually indicates:\n " +
135+ " 1. RPC node is experiencing high latency or load\n " +
136+ " 2. Network connectivity issues\n " +
137+ " 3. RPC rate limiting\n " +
138+ "Solutions:\n " +
139+ " 1. Retry the transaction (temporary RPC issue)\n " +
140+ " 2. Use a different RPC endpoint\n " +
141+ " 3. Disable gas estimation: set gas_price_estimation_enabled = false\n " +
142+ " 4. Reduce gas_price_estimation_blocks to fetch fewer blocks" ,
143+ minBlockCount , len (headers ), float64 (len (headers ))/ float64 (blocksNumber )* 100 )
132144 }
133145
134146 switch strategy {
@@ -137,7 +149,10 @@ func (m *Client) CalculateNetworkCongestionMetric(blocksNumber uint64, strategy
137149 case CongestionStrategy_NewestFirst :
138150 return calculateNewestFirstNetworkCongestionMetric (headers ), nil
139151 default :
140- return 0 , fmt .Errorf ("unknown congestion strategy: %s" , strategy )
152+ return 0 , fmt .Errorf ("unknown network congestion strategy '%s'. " +
153+ "Valid strategies are: 'simple' (equal weight) or 'newest_first' (recent blocks weighted more).\n " +
154+ "This is likely a configuration error. Check your gas estimation settings" ,
155+ strategy )
141156 }
142157}
143158
@@ -202,7 +217,12 @@ func (m *Client) GetSuggestedEIP1559Fees(ctx context.Context, priority string) (
202217 }
203218 // defensive programming
204219 if baseFee == nil || currentGasTip == nil {
205- err = errors .New (ZeroGasSuggestedErr )
220+ err = fmt .Errorf ("RPC node returned nil gas price or zero gas tip. " +
221+ "This indicates the node's gas estimation is not working properly.\n " +
222+ "Solutions:\n " +
223+ " 1. Use a different RPC endpoint\n " +
224+ " 2. Disable gas estimation: set gas_price_estimation_enabled = false in config\n " +
225+ " 3. Set explicit gas values: gas_price, gas_fee_cap, and gas_tip_cap (in your config (seth.toml or ClientBuilder)" )
206226 return
207227 }
208228
@@ -606,7 +626,10 @@ func getAdjustmentFactor(priority string) (float64, error) {
606626 case Priority_Slow :
607627 return 0.8 , nil
608628 default :
609- return 0 , fmt .Errorf ("unsupported priority: %s" , priority )
629+ return 0 , fmt .Errorf ("unsupported transaction priority '%s'. " +
630+ "Valid priorities: 'fast', 'standard', 'slow', 'auto'. " +
631+ "Set 'gas_price_estimation_tx_priority' in your config (seth.toml or ClientBuilder)" ,
632+ priority )
610633 }
611634}
612635
@@ -621,7 +644,10 @@ func getCongestionFactor(congestionClassification string) (float64, error) {
621644 case Congestion_VeryHigh :
622645 return 1.40 , nil
623646 default :
624- return 0 , fmt .Errorf ("unsupported congestion classification: %s" , congestionClassification )
647+ return 0 , fmt .Errorf ("unsupported congestion classification '%s'. " +
648+ "Valid classifications: 'low', 'medium', 'high', 'extreme'. " +
649+ "This is likely an internal error. Please open a GitHub issue at https://github.com/smartcontractkit/chainlink-testing-framework/issues" ,
650+ congestionClassification )
625651 }
626652}
627653
@@ -652,7 +678,10 @@ func (m *Client) HistoricalFeeData(ctx context.Context, priority string) (baseFe
652678 case Priority_Slow :
653679 percentileTip = 25
654680 default :
655- err = fmt .Errorf ("unknown priority: %s" , priority )
681+ err = fmt .Errorf ("unsupported transaction priority '%s'. " +
682+ "Valid priorities: 'fast', 'standard', 'slow'. " +
683+ "Set 'gas_price_estimation_tx_priority' in your config (seth.toml or ClientBuilder)" ,
684+ priority )
656685 L .Debug ().
657686 Str ("Priority" , priority ).
658687 Msgf ("Unknown priority: %s" , err .Error ())
@@ -682,7 +711,10 @@ func (m *Client) HistoricalFeeData(ctx context.Context, priority string) (baseFe
682711 case Priority_Slow :
683712 baseFee = stats .BaseFeePerc .Perc25
684713 default :
685- err = fmt .Errorf ("unsupported priority: %s" , priority )
714+ err = fmt .Errorf ("unsupported transaction priority '%s'. " +
715+ "Valid priorities: 'fast', 'standard', 'slow'. " +
716+ "Set 'gas_price_estimation_tx_priority' in your config (seth.toml or ClientBuilder)" ,
717+ priority )
686718 L .Debug ().
687719 Str ("Priority" , priority ).
688720 Msgf ("Unsupported priority: %s" , err .Error ())
0 commit comments