Skip to content

Commit

Permalink
Merge branch 'develop' into BCI-2702-Apply-LimitMultiplier-to-gas-lim…
Browse files Browse the repository at this point in the history
…it-in-all-gas-estimators
  • Loading branch information
silaslenihan authored Mar 26, 2024
2 parents d84c214 + 7292d46 commit da360f7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 57 deletions.
5 changes: 5 additions & 0 deletions .changeset/tiny-rabbits-crave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

Handle zkSync specific known transaction error
3 changes: 2 additions & 1 deletion core/chains/evm/client/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ var zkSync = ClientErrors{
// can't start a transaction from a non-account - trying to send from an invalid address, e.g. estimating a contract -> contract tx
// max fee per gas higher than 2^64-1 - uint64 overflow
// oversized data - data too large
Fatal: regexp.MustCompile(`(?:: |^)(?:exceeds block gas limit|intrinsic gas too low|Not enough gas for transaction validation|Failed to pay the fee to the operator|Error function_selector = 0x, data = 0x|invalid sender. can't start a transaction from a non-account|max(?: priority)? fee per (?:gas|pubdata byte) higher than 2\^64-1|oversized data. max: \d+; actual: \d+)$`),
Fatal: regexp.MustCompile(`(?:: |^)(?:exceeds block gas limit|intrinsic gas too low|Not enough gas for transaction validation|Failed to pay the fee to the operator|Error function_selector = 0x, data = 0x|invalid sender. can't start a transaction from a non-account|max(?: priority)? fee per (?:gas|pubdata byte) higher than 2\^64-1|oversized data. max: \d+; actual: \d+)$`),
TransactionAlreadyInMempool: regexp.MustCompile(`known transaction. transaction with hash .* is already in the system`),
}

var clients = []ClientErrors{parity, geth, arbitrum, metis, substrate, avalanche, nethermind, harmony, besu, erigon, klaytn, celo, zkSync}
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 @@ -127,6 +127,9 @@ func Test_Eth_Errors(t *testing.T) {
{"call failed: AlreadyKnown", true, "Nethermind"},
{"call failed: OwnNonceAlreadyUsed", true, "Nethermind"},
{"known transaction", true, "Klaytn"},
{"known transaction. transaction with hash 0x6013…3053 is already in the system", true, "zkSync"},
// This seems to be an erroneous message from the zkSync client, we'll have to match it anyway
{"ErrorObject { code: ServerError(3), message: \\\"known transaction. transaction with hash 0xf016…ad63 is already in the system\\\", data: Some(RawValue(\\\"0x\\\")) }", true, "zkSync"},
}
for _, test := range tests {
err = evmclient.NewSendErrorS(test.message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"math/big"
"net/http"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -149,9 +148,6 @@ func NewMercuryConfig(credentials *types.MercuryCredentials, abi abi.ABI) *Mercu
}

func (c *MercuryConfig) Credentials() *types.MercuryCredentials {
// remove the trailing slash from the URL if it exists
c.cred.URL = strings.TrimRight(c.cred.URL, "/")
c.cred.LegacyURL = strings.TrimRight(c.cred.LegacyURL, "/")
return c.cred
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@ import (
"testing"
"time"

"github.com/patrickmn/go-cache"
types2 "github.com/smartcontractkit/chainlink-automation/pkg/v3/types"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
coreTypes "github.com/ethereum/go-ethereum/core/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"

types2 "github.com/smartcontractkit/chainlink-automation/pkg/v3/types"
"github.com/smartcontractkit/chainlink-common/pkg/types"

types3 "github.com/smartcontractkit/chainlink/v2/core/chains/evm/headtracker/types"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller/mocks"
Expand All @@ -32,54 +29,6 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/logprovider"
)

func TestCredentials_RemoveTrailingSlash(t *testing.T) {
tests := []struct {
Name string
URL string
LegacyURL string
}{
{
Name: "Both have trailing slashes",
URL: "http://example.com/",
LegacyURL: "http://legacy.example.com/",
},
{
Name: "One has trailing slashes",
URL: "http://example.com",
LegacyURL: "http://legacy.example.com/",
},
{
Name: "Neither has trailing slashes",
URL: "http://example.com",
LegacyURL: "http://legacy.example.com",
},
}

for _, test := range tests {
t.Run(test.Name, func(t *testing.T) {
mockConfig := &MercuryConfig{
cred: &types.MercuryCredentials{
URL: test.URL,
LegacyURL: test.LegacyURL,
Username: "user",
Password: "pass",
},
Abi: core.StreamsCompatibleABI,
AllowListCache: cache.New(defaultPluginRetryExpiration, cleanupInterval),
pluginRetryCache: cache.New(defaultPluginRetryExpiration, cleanupInterval),
}

result := mockConfig.Credentials()

// Assert that trailing slashes are removed
assert.Equal(t, "http://example.com", result.URL)
assert.Equal(t, "http://legacy.example.com", result.LegacyURL)
assert.Equal(t, "user", result.Username)
assert.Equal(t, "pass", result.Password)
})
}
}

func TestPollLogs(t *testing.T) {
tests := []struct {
Name string
Expand Down

0 comments on commit da360f7

Please sign in to comment.