Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(SHIP-2626) added custom error handling for Treasure #13981

Merged
merged 19 commits into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions .changeset/strong-dogs-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

feat: added error handling for Treasure
22 changes: 21 additions & 1 deletion core/chains/evm/client/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const (
Fatal
ServiceUnavailable
TerminallyStuck
InvalidSender
)

type ClientErrors map[int]*regexp.Regexp
Expand Down Expand Up @@ -161,6 +162,21 @@ var arbitrum = ClientErrors{
ServiceUnavailable: regexp.MustCompile(`(: |^)502 Bad Gateway: [\s\S]*$`),
}

// Treasure
// Derived from Arbitrum config due to similar behaviour
var treasureFatal = regexp.MustCompile(`(: |^)(invalid message format|forbidden sender address)$|(: |^)(execution reverted)(:|$)`)
var treasure = ClientErrors{
NonceTooLow: regexp.MustCompile(`(: |^)invalid transaction nonce$|(: |^)nonce too low(:|$)`),
NonceTooHigh: regexp.MustCompile(`(: |^)nonce too high(:|$)`),
TerminallyUnderpriced: regexp.MustCompile(`(: |^)gas price too low$`),
InsufficientEth: regexp.MustCompile(`(: |^)(not enough funds for gas|insufficient funds for gas \* price \+ value)`),
Fatal: treasureFatal,
L2FeeTooLow: regexp.MustCompile(`(: |^)max fee per gas less than block base fee(:|$)`),
L2Full: regexp.MustCompile(`(: |^)(queue full|sequencer pending tx pool full, please try again)(:|$)`),
ServiceUnavailable: regexp.MustCompile(`(: |^)502 Bad Gateway: [\s\S]*$`),
InvalidSender: regexp.MustCompile(`(: |^)invalid chain id for signer(:|$)`),
}
amit-momin marked this conversation as resolved.
Show resolved Hide resolved

var celo = ClientErrors{
TxFeeExceedsCap: regexp.MustCompile(`(: |^)tx fee \([0-9\.]+ of currency celo\) exceeds the configured cap \([0-9\.]+ [a-zA-Z]+\)$`),
TerminallyUnderpriced: regexp.MustCompile(`(: |^)gasprice is less than gas price minimum floor`),
Expand Down Expand Up @@ -257,7 +273,7 @@ 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, internal, treasure}

// ClientErrorRegexes returns a map of compiled regexes for each error type
func ClientErrorRegexes(errsRegex config.ClientErrors) *ClientErrors {
Expand Down Expand Up @@ -333,6 +349,10 @@ func (s *SendError) IsInsufficientEth(configErrors *ClientErrors) bool {
return s.is(InsufficientEth, configErrors)
}

func (s *SendError) IsInvalidSenderError(configErrors *ClientErrors) bool {
amaechiokolobi marked this conversation as resolved.
Show resolved Hide resolved
return s.is(InvalidSender, configErrors)
}

// IsTxFeeExceedsCap returns true if the transaction and gas price are combined in
// some way that makes the total transaction too expensive for the eth node to
// accept at all. No amount of retrying at this or higher gas prices can ever
Expand Down
15 changes: 15 additions & 0 deletions core/chains/evm/client/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ func Test_Eth_Errors(t *testing.T) {
}
})

t.Run("IsInvalidSender", func(t *testing.T) {
tests := []errorCase{
{"invalid chain id for signer", true, "Treasure"},
}

for _, test := range tests {
t.Run(test.network, func(t *testing.T) {
err = evmclient.NewSendErrorS(test.message)
assert.Equal(t, err.IsInvalidSenderError(clientErrors), test.expect)
err = newSendErrorWrapped(test.message)
assert.Equal(t, err.IsInvalidSenderError(clientErrors), test.expect)
})
}
})

t.Run("IsNonceTooHigh", func(t *testing.T) {
tests := []errorCase{
{"call failed: NonceGap", true, "Nethermind"},
Expand Down
Loading