Skip to content

Commit

Permalink
BCF-3258 - Fix QueryKey test case flakiness (#13529)
Browse files Browse the repository at this point in the history
* Fix QueryKey test case flakiness

* Handle Aptos not needing a CoreRelayerChainInteroperator
  • Loading branch information
ilija42 authored Jun 18, 2024
1 parent f5a70eb commit e56d5d6
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 21 deletions.
3 changes: 2 additions & 1 deletion core/chains/evm/logpoller/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const (
timestampFieldName = "block_timestamp"
txHashFieldName = "tx_hash"
eventSigFieldName = "event_sig"
defaultSort = "block_number DESC, log_index DESC"
)

var (
Expand Down Expand Up @@ -305,7 +306,7 @@ func (v *pgDSLParser) orderClause(limiter query.LimitAndSort) (string, error) {
}

if len(sorting) == 0 {
return "", nil
return fmt.Sprintf("ORDER BY %s", defaultSort), nil
}

sort := make([]string, len(sorting))
Expand Down
17 changes: 9 additions & 8 deletions core/chains/evm/logpoller/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestDSLParser(t *testing.T) {
result, args, err := parser.buildQuery(chainID, expressions, limiter)

require.NoError(t, err)
assert.Equal(t, "SELECT evm.logs.* FROM evm.logs WHERE evm_chain_id = :evm_chain_id", result)
assert.Equal(t, "SELECT evm.logs.* FROM evm.logs WHERE evm_chain_id = :evm_chain_id ORDER BY "+defaultSort, result)

assertArgs(t, args, 1)
})
Expand Down Expand Up @@ -84,6 +84,7 @@ func TestDSLParser(t *testing.T) {
"FROM evm.logs " +
"WHERE evm_chain_id = :evm_chain_id " +
"AND (address = :address_0 AND event_sig = :event_sig_0) " +
"ORDER BY " + defaultSort + " " +
"LIMIT 20"

require.NoError(t, err)
Expand Down Expand Up @@ -177,7 +178,7 @@ func TestDSLParser(t *testing.T) {
expected := "SELECT evm.logs.* " +
"FROM evm.logs " +
"WHERE evm_chain_id = :evm_chain_id " +
"AND block_number <= (SELECT finalized_block_number FROM evm.log_poller_blocks WHERE evm_chain_id = :evm_chain_id ORDER BY block_number DESC LIMIT 1)"
"AND block_number <= (SELECT finalized_block_number FROM evm.log_poller_blocks WHERE evm_chain_id = :evm_chain_id ORDER BY block_number DESC LIMIT 1) ORDER BY " + defaultSort

require.NoError(t, err)
assert.Equal(t, expected, result)
Expand All @@ -196,7 +197,7 @@ func TestDSLParser(t *testing.T) {
expected := "SELECT evm.logs.* " +
"FROM evm.logs " +
"WHERE evm_chain_id = :evm_chain_id " +
"AND block_number <= (SELECT greatest(block_number - :confs_0, 0) FROM evm.log_poller_blocks WHERE evm_chain_id = :evm_chain_id ORDER BY block_number DESC LIMIT 1)"
"AND block_number <= (SELECT greatest(block_number - :confs_0, 0) FROM evm.log_poller_blocks WHERE evm_chain_id = :evm_chain_id ORDER BY block_number DESC LIMIT 1) ORDER BY " + defaultSort

require.NoError(t, err)
assert.Equal(t, expected, result)
Expand All @@ -215,7 +216,7 @@ func TestDSLParser(t *testing.T) {
expected := "SELECT evm.logs.* " +
"FROM evm.logs " +
"WHERE evm_chain_id = :evm_chain_id " +
"AND block_number <= (SELECT greatest(block_number - :confs_0, 0) FROM evm.log_poller_blocks WHERE evm_chain_id = :evm_chain_id ORDER BY block_number DESC LIMIT 1)"
"AND block_number <= (SELECT greatest(block_number - :confs_0, 0) FROM evm.log_poller_blocks WHERE evm_chain_id = :evm_chain_id ORDER BY block_number DESC LIMIT 1) ORDER BY " + defaultSort

require.NoError(t, err)
assert.Equal(t, expected, result)
Expand Down Expand Up @@ -245,7 +246,7 @@ func TestDSLParser(t *testing.T) {
expected := "SELECT evm.logs.* " +
"FROM evm.logs " +
"WHERE evm_chain_id = :evm_chain_id " +
"AND substring(data from 32*:word_index_0+1 for 32) > :word_value_0"
"AND substring(data from 32*:word_index_0+1 for 32) > :word_value_0 ORDER BY " + defaultSort

require.NoError(t, err)
assert.Equal(t, expected, result)
Expand All @@ -270,7 +271,7 @@ func TestDSLParser(t *testing.T) {
expected := "SELECT evm.logs.* " +
"FROM evm.logs " +
"WHERE evm_chain_id = :evm_chain_id " +
"AND topics[:topic_index_0] > :topic_value_0 AND topics[:topic_index_0] < :topic_value_1"
"AND topics[:topic_index_0] > :topic_value_0 AND topics[:topic_index_0] < :topic_value_1 ORDER BY " + defaultSort

require.NoError(t, err)
assert.Equal(t, expected, result)
Expand Down Expand Up @@ -308,7 +309,7 @@ func TestDSLParser(t *testing.T) {
"WHERE evm_chain_id = :evm_chain_id " +
"AND (block_timestamp >= :block_timestamp_0 " +
"AND (tx_hash = :tx_hash_0 " +
"OR block_number <= (SELECT greatest(block_number - :confs_0, 0) FROM evm.log_poller_blocks WHERE evm_chain_id = :evm_chain_id ORDER BY block_number DESC LIMIT 1)))"
"OR block_number <= (SELECT greatest(block_number - :confs_0, 0) FROM evm.log_poller_blocks WHERE evm_chain_id = :evm_chain_id ORDER BY block_number DESC LIMIT 1))) ORDER BY " + defaultSort

require.NoError(t, err)
assert.Equal(t, expected, result)
Expand Down Expand Up @@ -359,7 +360,7 @@ func TestDSLParser(t *testing.T) {
"AND (tx_hash = :tx_hash_0 " +
"OR (block_number <= (SELECT greatest(block_number - :confs_0, 0) FROM evm.log_poller_blocks WHERE evm_chain_id = :evm_chain_id ORDER BY block_number DESC LIMIT 1) " +
"AND substring(data from 32*:word_index_0+1 for 32) > :word_value_0 " +
"AND substring(data from 32*:word_index_0+1 for 32) <= :word_value_1)))"
"AND substring(data from 32*:word_index_0+1 for 32) <= :word_value_1))) ORDER BY " + defaultSort

require.NoError(t, err)
assert.Equal(t, expected, result)
Expand Down
2 changes: 1 addition & 1 deletion core/scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/prometheus/client_golang v1.17.0
github.com/shopspring/decimal v1.3.1
github.com/smartcontractkit/chainlink-automation v1.0.4
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240614134652-1fb0b48758af
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240617140013-160ae09880da
github.com/smartcontractkit/chainlink-vrf v0.0.0-20240222010609-cd67d123c772
github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000
github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c
Expand Down
4 changes: 2 additions & 2 deletions core/scripts/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1212,8 +1212,8 @@ github.com/smartcontractkit/chain-selectors v1.0.10 h1:t9kJeE6B6G+hKD0GYR4kGJSCq
github.com/smartcontractkit/chain-selectors v1.0.10/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8=
github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240614134652-1fb0b48758af h1:YVw8iLZJEj9cJQGX1wggB9Lv1liMnudGvR1eC3CsWrg=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240614134652-1fb0b48758af/go.mod h1:L32xvCpk84Nglit64OhySPMP1tM3TTBK7Tw0qZl7Sd4=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240617140013-160ae09880da h1:s3wq2II/FQ1YNcPWnvp44A7Nc874bkMicrkXNpNNHs4=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240617140013-160ae09880da/go.mod h1:L32xvCpk84Nglit64OhySPMP1tM3TTBK7Tw0qZl7Sd4=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240524214833-c362c2ebbd2d h1:5tgMC5Gi2UAOKZ+m28W8ubjLeR0pQCAcrz6eQ0rW510=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240524214833-c362c2ebbd2d/go.mod h1:0UNuO3nDt9MFsZPaHJBEUolxVkN0iC69j1ccDp95e8k=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240220203239-09be0ea34540 h1:xFSv8561jsLtF6gYZr/zW2z5qUUAkcFkApin2mnbYTo=
Expand Down
3 changes: 3 additions & 0 deletions core/services/chainlink/relayer_chain_interoperators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@ func TestCoreRelayerChainInteroperators(t *testing.T) {
expectedChainCnt, expectedNodeCnt = tt.expectedSolanaChainCnt, tt.expectedSolanaNodeCnt
case types.NetworkStarkNet:
expectedChainCnt, expectedNodeCnt = tt.expectedStarknetChainCnt, tt.expectedStarknetNodeCnt
case types.NetworkAptos:
t.Skip("aptos doesn't need a CoreRelayerChainInteroperator")

default:
require.Fail(t, "untested relay network", relayNetwork)
}
Expand Down
3 changes: 3 additions & 0 deletions core/services/job/orm.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,9 @@ func validateKeyStoreMatchForRelay(ctx context.Context, network string, keyStore
if err != nil {
return errors.Errorf("no Starknet key matching: %q", key)
}
case types.NetworkAptos:
// TODO BCI-2953
return nil
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ require (
github.com/shopspring/decimal v1.3.1
github.com/smartcontractkit/chain-selectors v1.0.10
github.com/smartcontractkit/chainlink-automation v1.0.4
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240614134652-1fb0b48758af
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240617140013-160ae09880da
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240524214833-c362c2ebbd2d
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240220203239-09be0ea34540
github.com/smartcontractkit/chainlink-feeds v0.0.0-20240522213638-159fb2d99917
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1171,8 +1171,8 @@ github.com/smartcontractkit/chain-selectors v1.0.10 h1:t9kJeE6B6G+hKD0GYR4kGJSCq
github.com/smartcontractkit/chain-selectors v1.0.10/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8=
github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240614134652-1fb0b48758af h1:YVw8iLZJEj9cJQGX1wggB9Lv1liMnudGvR1eC3CsWrg=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240614134652-1fb0b48758af/go.mod h1:L32xvCpk84Nglit64OhySPMP1tM3TTBK7Tw0qZl7Sd4=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240617140013-160ae09880da h1:s3wq2II/FQ1YNcPWnvp44A7Nc874bkMicrkXNpNNHs4=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240617140013-160ae09880da/go.mod h1:L32xvCpk84Nglit64OhySPMP1tM3TTBK7Tw0qZl7Sd4=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240524214833-c362c2ebbd2d h1:5tgMC5Gi2UAOKZ+m28W8ubjLeR0pQCAcrz6eQ0rW510=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240524214833-c362c2ebbd2d/go.mod h1:0UNuO3nDt9MFsZPaHJBEUolxVkN0iC69j1ccDp95e8k=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240220203239-09be0ea34540 h1:xFSv8561jsLtF6gYZr/zW2z5qUUAkcFkApin2mnbYTo=
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ require (
github.com/shopspring/decimal v1.3.1
github.com/slack-go/slack v0.12.2
github.com/smartcontractkit/chainlink-automation v1.0.4
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240614134652-1fb0b48758af
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240617140013-160ae09880da
github.com/smartcontractkit/chainlink-testing-framework v1.30.9
github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868
github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1512,8 +1512,8 @@ github.com/smartcontractkit/chain-selectors v1.0.10 h1:t9kJeE6B6G+hKD0GYR4kGJSCq
github.com/smartcontractkit/chain-selectors v1.0.10/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8=
github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240614134652-1fb0b48758af h1:YVw8iLZJEj9cJQGX1wggB9Lv1liMnudGvR1eC3CsWrg=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240614134652-1fb0b48758af/go.mod h1:L32xvCpk84Nglit64OhySPMP1tM3TTBK7Tw0qZl7Sd4=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240617140013-160ae09880da h1:s3wq2II/FQ1YNcPWnvp44A7Nc874bkMicrkXNpNNHs4=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240617140013-160ae09880da/go.mod h1:L32xvCpk84Nglit64OhySPMP1tM3TTBK7Tw0qZl7Sd4=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240524214833-c362c2ebbd2d h1:5tgMC5Gi2UAOKZ+m28W8ubjLeR0pQCAcrz6eQ0rW510=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240524214833-c362c2ebbd2d/go.mod h1:0UNuO3nDt9MFsZPaHJBEUolxVkN0iC69j1ccDp95e8k=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240220203239-09be0ea34540 h1:xFSv8561jsLtF6gYZr/zW2z5qUUAkcFkApin2mnbYTo=
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/load/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/rs/zerolog v1.30.0
github.com/slack-go/slack v0.12.2
github.com/smartcontractkit/chainlink-automation v1.0.4
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240614134652-1fb0b48758af
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240617140013-160ae09880da
github.com/smartcontractkit/chainlink-testing-framework v1.30.9
github.com/smartcontractkit/chainlink/integration-tests v0.0.0-20240214231432-4ad5eb95178c
github.com/smartcontractkit/chainlink/v2 v2.9.0-beta0.0.20240216210048-da02459ddad8
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/load/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1502,8 +1502,8 @@ github.com/smartcontractkit/chain-selectors v1.0.10 h1:t9kJeE6B6G+hKD0GYR4kGJSCq
github.com/smartcontractkit/chain-selectors v1.0.10/go.mod h1:d4Hi+E1zqjy9HqMkjBE5q1vcG9VGgxf5VxiRHfzi2kE=
github.com/smartcontractkit/chainlink-automation v1.0.4 h1:iyW181JjKHLNMnDleI8umfIfVVlwC7+n5izbLSFgjw8=
github.com/smartcontractkit/chainlink-automation v1.0.4/go.mod h1:u4NbPZKJ5XiayfKHD/v3z3iflQWqvtdhj13jVZXj/cM=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240614134652-1fb0b48758af h1:YVw8iLZJEj9cJQGX1wggB9Lv1liMnudGvR1eC3CsWrg=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240614134652-1fb0b48758af/go.mod h1:L32xvCpk84Nglit64OhySPMP1tM3TTBK7Tw0qZl7Sd4=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240617140013-160ae09880da h1:s3wq2II/FQ1YNcPWnvp44A7Nc874bkMicrkXNpNNHs4=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240617140013-160ae09880da/go.mod h1:L32xvCpk84Nglit64OhySPMP1tM3TTBK7Tw0qZl7Sd4=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240524214833-c362c2ebbd2d h1:5tgMC5Gi2UAOKZ+m28W8ubjLeR0pQCAcrz6eQ0rW510=
github.com/smartcontractkit/chainlink-cosmos v0.4.1-0.20240524214833-c362c2ebbd2d/go.mod h1:0UNuO3nDt9MFsZPaHJBEUolxVkN0iC69j1ccDp95e8k=
github.com/smartcontractkit/chainlink-data-streams v0.0.0-20240220203239-09be0ea34540 h1:xFSv8561jsLtF6gYZr/zW2z5qUUAkcFkApin2mnbYTo=
Expand Down

0 comments on commit e56d5d6

Please sign in to comment.