Skip to content

Commit 78a59f1

Browse files
committed
review error messages once more
1 parent 90fa726 commit 78a59f1

File tree

7 files changed

+43
-88
lines changed

7 files changed

+43
-88
lines changed

seth/abi_finder.go

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -137,28 +137,8 @@ func (a *ABIFinder) FindABIByMethod(address string, signature []byte) (ABIFinder
137137
}
138138

139139
if result.Method == nil {
140-
abiCount := len(a.ContractStore.ABIs)
141-
abiSample := ""
142-
if abiCount > 0 {
143-
// Show first few ABIs as examples (max 5)
144-
sampleSize := min(abiCount, 5)
145-
samples := make([]string, 0, sampleSize)
146-
count := 0
147-
for abiName := range a.ContractStore.ABIs {
148-
if count >= sampleSize {
149-
break
150-
}
151-
samples = append(samples, strings.TrimSuffix(abiName, ".abi"))
152-
count++
153-
}
154-
abiSample = fmt.Sprintf("\nExample ABIs loaded: %s", strings.Join(samples, ", "))
155-
if abiCount > sampleSize {
156-
abiSample += fmt.Sprintf(" (and %d more)", abiCount-sampleSize)
157-
}
158-
}
159-
160140
return ABIFinderResult{}, fmt.Errorf("no ABI found with method signature %s for contract at address %s.\n"+
161-
"Checked %d ABIs but none matched.%s\n"+
141+
"Checked %d ABIs but none matched.\n"+
162142
"Possible causes:\n"+
163143
" 1. Contract ABI not loaded (check abi_dir and contract_map_file)\n"+
164144
" 2. Method signature doesn't match any function in loaded ABIs\n"+
@@ -170,7 +150,7 @@ func (a *ABIFinder) FindABIByMethod(address string, signature []byte) (ABIFinder
170150
" 3. Ensure ABI file exists in the directory specified by 'abi_dir'\n"+
171151
" 4. Review contract_map_file for address-to-name mappings\n"+
172152
" 5. Use ContractStore.AddABI() to manually add the ABI",
173-
stringSignature, address, abiCount, abiSample)
153+
stringSignature, address, len(a.ContractStore.ABIs))
174154
}
175155

176156
return result, nil

seth/client.go

Lines changed: 27 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ const (
3030
ErrEmptyConfigPath = "toml config path is empty, set SETH_CONFIG_PATH"
3131
ErrContractDeploymentFailed = "contract deployment failed"
3232

33+
// unused by Seth, but used by upstream
34+
ErrNoKeyLoaded = "failed to load private key"
35+
3336
ContractMapFilePattern = "deployed_contracts_%s_%s.toml"
3437
RevertedTransactionsFilePattern = "reverted_transactions_%s_%s.json"
3538
)
@@ -148,7 +151,13 @@ func NewClientWithConfig(cfg *Config) (*Client, error) {
148151
tr, err := NewTracer(cs, &abiFinder, cfg, contractAddressToNameMap, addrs)
149152
if err != nil {
150153
return nil, fmt.Errorf("failed to create transaction tracer: %w\n"+
151-
"This is usually caused by RPC connection issues. Verify your RPC endpoint is accessible",
154+
"Possible causes:\n"+
155+
" 1. RPC endpoint is not accessible\n"+
156+
" 2. RPC node doesn't support debug_traceTransaction API\n"+
157+
"Solutions:\n"+
158+
" 1. Verify RPC endpoint URL is correct and accessible\n"+
159+
" 2. Use an RPC node with debug API enabled (archive node recommended)\n"+
160+
" 3. Set tracing_level = 'NONE' in config to disable tracing",
152161
err)
153162
}
154163
opts = append(opts, WithTracer(tr))
@@ -181,7 +190,7 @@ func NewClientRaw(
181190
opts ...ClientOpt,
182191
) (*Client, error) {
183192
if cfg == nil {
184-
return nil, fmt.Errorf("Seth configuration is nil. " +
193+
return nil, fmt.Errorf("seth configuration is nil. " +
185194
"Provide a valid Config when calling NewClientRaw(). " +
186195
"Consider using NewClient() or NewClientWithConfig() instead")
187196
}
@@ -393,7 +402,13 @@ func NewClientRaw(
393402
tr, err := NewTracer(c.ContractStore, c.ABIFinder, cfg, c.ContractAddressToNameMap, addrs)
394403
if err != nil {
395404
return nil, fmt.Errorf("failed to create transaction tracer: %w\n"+
396-
"Ensure RPC endpoint supports debug_traceTransaction or set tracing_level = 'NONE'",
405+
"Possible causes:\n"+
406+
" 1. RPC endpoint is not accessible\n"+
407+
" 2. RPC node doesn't support debug_traceTransaction API\n"+
408+
"Solutions:\n"+
409+
" 1. Verify RPC endpoint URL is correct and accessible\n"+
410+
" 2. Use an RPC node with debug API enabled (archive node recommended)\n"+
411+
" 3. Set tracing_level = 'NONE' in config to disable tracing",
397412
err)
398413
}
399414

@@ -1280,70 +1295,29 @@ func (m *Client) DeployContractFromContractStore(auth *bind.TransactOpts, name s
12801295
"This usually means:\n" +
12811296
" 1. Seth client wasn't properly initialized\n" +
12821297
" 2. ABI directory path is incorrect in config\n" +
1283-
"Ensure 'abi_dir' and 'bin_dir' are set in seth.toml or use DeployContract() with explicit ABI/bytecode")
1298+
"Solutions:\n" +
1299+
" 1. Set 'abi_dir' and 'bin_dir' in seth.toml config file\n" +
1300+
" 2. Use ClientBuilder: builder.WithABIDir(path).WithBINDir(path)\n" +
1301+
" 3. Use DeployContract() method with explicit ABI/bytecode instead")
12841302
}
12851303

12861304
name = strings.TrimSuffix(name, ".abi")
12871305
name = strings.TrimSuffix(name, ".bin")
12881306

12891307
contractAbi, ok := m.ContractStore.ABIs[name+".abi"]
12901308
if !ok {
1291-
abiCount := len(m.ContractStore.ABIs)
1292-
abiSample := ""
1293-
if abiCount > 0 {
1294-
// Show first few ABIs as examples (max 5)
1295-
sampleSize := 5
1296-
if abiCount < sampleSize {
1297-
sampleSize = abiCount
1298-
}
1299-
samples := make([]string, 0, sampleSize)
1300-
count := 0
1301-
for abiName := range m.ContractStore.ABIs {
1302-
if count >= sampleSize {
1303-
break
1304-
}
1305-
samples = append(samples, strings.TrimSuffix(abiName, ".abi"))
1306-
count++
1307-
}
1308-
abiSample = fmt.Sprintf("\nExample ABIs available: %s", strings.Join(samples, ", "))
1309-
if abiCount > sampleSize {
1310-
abiSample += fmt.Sprintf(" (and %d more)", abiCount-sampleSize)
1311-
}
1312-
}
13131309
return DeploymentData{}, fmt.Errorf("ABI for contract '%s' not found in contract store.\n"+
1314-
"Total ABIs loaded: %d%s\n"+
1310+
"Total ABIs loaded: %d\n"+
13151311
"Ensure the ABI file '%s.abi' exists in the directory specified by 'abi_dir' in your config",
1316-
name, abiCount, abiSample, name)
1312+
name, len(m.ContractStore.ABIs), name)
13171313
}
13181314

13191315
bytecode, ok := m.ContractStore.BINs[name+".bin"]
13201316
if !ok {
1321-
binCount := len(m.ContractStore.BINs)
1322-
binSample := ""
1323-
if binCount > 0 {
1324-
// Show first few BINs as examples (max 5)
1325-
sampleSize := 5
1326-
if binCount < sampleSize {
1327-
sampleSize = binCount
1328-
}
1329-
samples := make([]string, 0, sampleSize)
1330-
count := 0
1331-
for binName := range m.ContractStore.BINs {
1332-
if count >= sampleSize {
1333-
break
1334-
}
1335-
samples = append(samples, strings.TrimSuffix(binName, ".bin"))
1336-
count++
1337-
}
1338-
binSample = fmt.Sprintf("\nExample BINs available: %s", strings.Join(samples, ", "))
1339-
if binCount > sampleSize {
1340-
binSample += fmt.Sprintf(" (and %d more)", binCount-sampleSize)
1341-
}
1342-
}
13431317
return DeploymentData{}, fmt.Errorf("bytecode (BIN) for contract '%s' not found in contract store.\n"+
1344-
"Total BINs loaded: %d%s\n"+
1318+
"Total BINs loaded: %d\n"+
13451319
"Ensure the BIN file '%s.bin' exists in the directory specified by 'bin_dir' in your config",
1346-
name, binCount, binSample, name)
1320+
name, len(m.ContractStore.BINs), name)
13471321
}
13481322

13491323
data, err := m.DeployContract(auth, name, contractAbi, bytecode, params...)
@@ -1587,7 +1561,7 @@ func (m *Client) validateAddressesKeyNum(keyNum int) error {
15871561
if len(m.Addresses) == 0 {
15881562
return fmt.Errorf("no addresses loaded, but tried to use key #%d.\n"+
15891563
"This should not happen if private keys were loaded correctly. "+
1590-
"Please report this as a bug",
1564+
"Please report this issue at https://github.com/smartcontractkit/chainlink-testing-framework/issues with the stack trace",
15911565
keyNum)
15921566
}
15931567
return fmt.Errorf("keyNum %d is out of range. Available addresses: 0-%d (total: %d addresses loaded).\n"+

seth/config.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,8 @@ func ReadConfig() (*Config, error) {
139139
if err != nil {
140140
return nil, fmt.Errorf("failed to read Seth config file at '%s': %w\n"+
141141
"Ensure:\n"+
142-
" 1. The file exists at the specified path\n"+
143-
" 2. You have read permissions for the file\n"+
144-
" 3. The path is correct (set via SETH_CONFIG_PATH or parameter)",
142+
" 1. The file exists at the specified path (set via SETH_CONFIG_PATH)\n"+
143+
" 2. You have read permissions for the file",
145144
cfgPath, err)
146145
}
147146
err = toml.Unmarshal(d, &cfg)
@@ -214,9 +213,8 @@ func ReadConfig() (*Config, error) {
214213
return nil, fmt.Errorf("no root private key was set. "+
215214
"You can provide the root private key via:\n"+
216215
" 1. %s environment variable (without 0x prefix)\n"+
217-
" 2. 'root_private_key' field in seth.toml\n"+
218-
" 3. WithPrivateKeys() when using ClientBuilder\n"+
219-
"WARNING: Never commit private keys to source control. Use environment variables or secure secret management",
216+
" 2. 'private_keys_secret' array in seth.toml [[networks]] section\n"+
217+
"WARNING: Never commit private keys to source control. We recommend to use the environment variable.",
220218
ROOT_PRIVATE_KEY_ENV_VAR)
221219
}
222220
cfg.Network.PrivateKeys = append(cfg.Network.PrivateKeys, rootPrivateKey)
@@ -298,7 +296,7 @@ func (c *Config) Validate() error {
298296
case TracingLevel_All:
299297
default:
300298
return fmt.Errorf("invalid tracing level '%s'. Must be one of: 'NONE', 'REVERTED', 'ALL'. "+
301-
"Set 'tracing_level' in your seth.toml config.\n"+
299+
"Set 'tracing_level' in your seth.toml config or via WithTracing() option, if using ClientBuilder().\n"+
302300
"Recommended: 'REVERTED' for debugging failed transactions, 'NONE' to disable tracing completely",
303301
c.TracingLevel)
304302
}
@@ -310,7 +308,7 @@ func (c *Config) Validate() error {
310308
case TraceOutput_DOT:
311309
default:
312310
return fmt.Errorf("invalid trace output '%s'. Must be one of: 'console', 'json', 'dot'. "+
313-
"Set 'trace_outputs' in your seth.toml config. "+
311+
"Set 'trace_outputs' in your seth.toml config or via WithTracing() option, if using ClientBuilder()"+
314312
"You can specify multiple outputs as an array",
315313
output)
316314
}

seth/contract_store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ func (c *ContractStore) loadGethWrappers(gethWrappersPaths []string) error {
243243
" 2. Generate wrappers using abigen:\n"+
244244
" abigen --abi contract.abi --bin contract.bin --pkg wrappers --out contract_wrapper.go\n"+
245245
" 3. Ensure wrapper files contain ABI metadata (check for 'ABI' variable)\n"+
246-
" 4. If not using geth wrappers, remove 'geth_wrappers_dirs' from config",
246+
" 4. If not using geth wrappers, remove 'geth_wrappers_dirs' from config (seth.toml or ClientBuilder)",
247247
gethWrappersPaths)
248248
}
249249

seth/decode.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,10 @@ func (m *Client) decodeTransaction(l zerolog.Logger, tx *types.Transaction, rece
440440
txInput, err = decodeTxInputs(l, txData, abiResult.Method)
441441
if err != nil {
442442
return defaultTxn, fmt.Errorf("failed to decode transaction input for method '%s': %w\n"+
443-
"The transaction data doesn't match the expected ABI method signature",
443+
"This could be due to:\n"+
444+
" 1. Transaction data doesn't match the ABI method signature\n"+
445+
" 2. Incorrect ABI for this contract\n"+
446+
" 3. Malformed transaction data",
444447
abiResult.Method.Name, err)
445448
}
446449

seth/gas_adjuster.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ func (m *Client) HistoricalFeeData(ctx context.Context, priority string) (baseFe
679679
percentileTip = 25
680680
default:
681681
err = fmt.Errorf("unsupported transaction priority '%s'. "+
682-
"Valid priorities: 'fast', 'standard', 'slow'. "+
682+
"Valid priorities: 'degen' (internal), 'fast', 'standard', 'slow'. "+
683683
"Set 'gas_price_estimation_tx_priority' in your config (seth.toml or ClientBuilder)",
684684
priority)
685685
L.Debug().
@@ -712,7 +712,7 @@ func (m *Client) HistoricalFeeData(ctx context.Context, priority string) (baseFe
712712
baseFee = stats.BaseFeePerc.Perc25
713713
default:
714714
err = fmt.Errorf("unsupported transaction priority '%s'. "+
715-
"Valid priorities: 'fast', 'standard', 'slow'. "+
715+
"Valid priorities: 'degen' (internal), 'fast', 'standard', 'slow'. "+
716716
"Set 'gas_price_estimation_tx_priority' in your config (seth.toml or ClientBuilder)",
717717
priority)
718718
L.Debug().

seth/nonce.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func validateNonceManagerConfig(nonceManagerCfg *NonceManagerCfg) error {
6565
// NewNonceManager creates a new nonce manager that tracks nonce for each address
6666
func NewNonceManager(cfg *Config, addrs []common.Address, privKeys []*ecdsa.PrivateKey) (*NonceManager, error) {
6767
if cfg == nil {
68-
return nil, fmt.Errorf("Seth configuration is nil. Cannot create nonce manager without valid configuration.\n" +
68+
return nil, fmt.Errorf("seth configuration is nil. Cannot create nonce manager without valid configuration.\n" +
6969
"This usually means you're trying to create a nonce manager before initializing Seth.\n" +
7070
"Solutions:\n" +
7171
" 1. Use NewClient() or NewClientWithConfig() to create a Seth client first\n" +

0 commit comments

Comments
 (0)