Skip to content

Commit

Permalink
Merge branch 'develop' into bugfix/KS-412-validate-donid
Browse files Browse the repository at this point in the history
  • Loading branch information
bolekk authored Aug 8, 2024
2 parents 7cc4a6f + 4f0f780 commit b08b86d
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-kiwis-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

Added custom client error messages for Mantle to capture InsufficientEth and Fatal errors. #added
5 changes: 5 additions & 0 deletions .changeset/shy-windows-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#internal
8 changes: 8 additions & 0 deletions core/capabilities/targets/write_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ type EvmConfig struct {
}

func parseConfig(rawConfig *values.Map) (config EvmConfig, err error) {
if rawConfig == nil {
return config, fmt.Errorf("missing config field")
}

if err := rawConfig.UnwrapTo(&config); err != nil {
return config, err
}
Expand Down Expand Up @@ -117,6 +121,10 @@ func (cap *WriteTarget) Execute(ctx context.Context, request capabilities.Capabi
return nil, err
}

if request.Inputs == nil {
return nil, fmt.Errorf("missing inputs field")
}

signedReport, ok := request.Inputs.Underlying[signedReportField]
if !ok {
return nil, fmt.Errorf("missing required field %s", signedReportField)
Expand Down
32 changes: 28 additions & 4 deletions core/capabilities/targets/write_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ func TestWriteTarget(t *testing.T) {
})

t.Run("fails with invalid config", func(t *testing.T) {
invalidConfig, err := values.NewMap(map[string]any{
invalidConfig, err2 := values.NewMap(map[string]any{
"Address": "invalid-address",
})
require.NoError(t, err)
require.NoError(t, err2)

req := capabilities.CapabilityRequest{
Metadata: capabilities.RequestMetadata{
Expand All @@ -146,7 +146,31 @@ func TestWriteTarget(t *testing.T) {
Config: invalidConfig,
Inputs: validInputs,
}
_, err = writeTarget.Execute(ctx, req)
require.Error(t, err)
_, err2 = writeTarget.Execute(ctx, req)
require.Error(t, err2)
})

t.Run("fails with nil config", func(t *testing.T) {
req := capabilities.CapabilityRequest{
Metadata: capabilities.RequestMetadata{
WorkflowID: "test-id",
},
Config: nil,
Inputs: validInputs,
}
_, err2 := writeTarget.Execute(ctx, req)
require.Error(t, err2)
})

t.Run("fails with nil inputs", func(t *testing.T) {
req := capabilities.CapabilityRequest{
Metadata: capabilities.RequestMetadata{
WorkflowID: "test-id",
},
Config: config,
Inputs: nil,
}
_, err2 := writeTarget.Execute(ctx, req)
require.Error(t, err2)
})
}
7 changes: 6 additions & 1 deletion core/chains/evm/client/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,19 @@ var zkEvm = ClientErrors{
TerminallyStuck: regexp.MustCompile(`(?:: |^)not enough .* counters to continue the execution$`),
}

var mantle = ClientErrors{
InsufficientEth: regexp.MustCompile(`(: |^)'*insufficient funds for gas \* price \+ value`),
Fatal: regexp.MustCompile(`(: |^)'*invalid sender`),
}

const TerminallyStuckMsg = "transaction terminally stuck"

// Tx.Error messages that are set internally so they are not chain or client specific
var internal = ClientErrors{
TerminallyStuck: regexp.MustCompile(TerminallyStuckMsg),
}

var clients = []ClientErrors{parity, geth, arbitrum, metis, substrate, avalanche, nethermind, harmony, besu, erigon, klaytn, celo, zkSync, zkEvm, internal}
var clients = []ClientErrors{parity, geth, arbitrum, metis, substrate, avalanche, nethermind, harmony, besu, erigon, klaytn, celo, zkSync, zkEvm, mantle, internal}

// ClientErrorRegexes returns a map of compiled regexes for each error type
func ClientErrorRegexes(errsRegex config.ClientErrors) *ClientErrors {
Expand Down
3 changes: 3 additions & 0 deletions core/chains/evm/client/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ func Test_Eth_Errors(t *testing.T) {
{"insufficient funds for gas + value. balance: 42719769622667482000, fee: 48098250000000, value: 42719769622667482000", true, "celo"},
{"client error insufficient eth", true, "tomlConfig"},
{"transaction would cause overdraft", true, "Geth"},
{"failed to forward tx to sequencer, please try again. Error message: 'insufficient funds for gas * price + value'", true, "Mantle"},
}
for _, test := range tests {
err = evmclient.NewSendErrorS(test.message)
Expand Down Expand Up @@ -379,6 +380,8 @@ func Test_Eth_Errors_Fatal(t *testing.T) {
{"Failed to serialize transaction: max priority fee per gas higher than 2^64-1", true, "zkSync"},
{"Failed to serialize transaction: oversized data. max: 1000000; actual: 1000000", true, "zkSync"},

{"failed to forward tx to sequencer, please try again. Error message: 'invalid sender'", true, "Mantle"},

{"client error fatal", true, "tomlConfig"},
}

Expand Down

0 comments on commit b08b86d

Please sign in to comment.