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

Fix LP tests filters check and add to smoke tests in CI #11649

Merged
merged 39 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
8669b49
fix hasFilters, fix cancelling log emission in case of errors, add so…
Tofel Dec 21, 2023
5cd31c7
fix replay test
Tofel Dec 21, 2023
2bd609c
fix lints
Tofel Dec 21, 2023
3c7ec93
shorten chaos log poller test
Tofel Dec 21, 2023
4f029dc
remove debug logs
Tofel Dec 21, 2023
74248fe
disable backup poller. DO NOT MERGE THIS
Tofel Dec 22, 2023
bc8afe6
make it configurable which container is paused: cl node or postgres
Tofel Dec 22, 2023
2344b9a
Merge branch 'develop' into lp_tests_final_fix_and_ci
Tofel Jan 8, 2024
b7ed75c
try Domino's way of stopping log poller
Tofel Jan 8, 2024
e509bbe
fix smoke test job name
Tofel Jan 8, 2024
9f09b95
remove unnecessary check
Tofel Jan 8, 2024
428505f
Merge branch 'develop' into lp_tests_final_fix_and_ci
Tofel Jan 9, 2024
eefb8ba
Merge branch 'develop' into lp_tests_final_fix_and_ci
Tofel Jan 10, 2024
bcb5b39
Merge branch 'lp_tests_final_fix_and_ci' of github.com:smartcontractk…
Tofel Jan 10, 2024
1d6355e
try executing postgress pausing lp test, more debug info about missin…
Tofel Jan 10, 2024
095b18b
Merge branch 'develop' into lp_tests_final_fix_and_ci
Tofel Jan 10, 2024
1c0469f
fix lints
Tofel Jan 10, 2024
3986381
Merge branch 'develop' into lp_tests_final_fix_and_ci
Tofel Jan 10, 2024
84c2268
Merge branch 'develop' into lp_tests_final_fix_and_ci
Tofel Jan 11, 2024
c9a4f11
revert disabling of backpolling, simplify some code, less logs
Tofel Jan 11, 2024
5017d47
make optional parameters not required in lp on demand test
Tofel Jan 11, 2024
c6561fe
run lp smoke tests in a separate job
Tofel Jan 12, 2024
c39a46a
prepare log poller json test list
Tofel Jan 12, 2024
28201c6
add missing comma, revert some comments
Tofel Jan 15, 2024
470be1d
Merge branch 'develop' into lp_tests_final_fix_and_ci
Tofel Jan 15, 2024
a79a60d
fix filename for lp matrix job
Tofel Jan 15, 2024
fd53328
Merge branch 'develop' into lp_tests_final_fix_and_ci
Tofel Jan 19, 2024
d8e50c4
Merge branch 'develop' into lp_tests_final_fix_and_ci
Tofel Jan 22, 2024
bbcd6b6
Merge branch 'develop' into lp_tests_final_fix_and_ci
Tofel Jan 22, 2024
cf37f31
Merge branch 'develop' into lp_tests_final_fix_and_ci
Tofel Jan 22, 2024
623033a
move log poller scenarios to test file, remove unused load test
Tofel Jan 22, 2024
2b41ffc
Merge branch 'develop' into lp_tests_final_fix_and_ci
Tofel Jan 23, 2024
af7db75
reduce code duplication in lp tests
Tofel Jan 23, 2024
7de3fd7
fix lp tests, fix smoke workflow
Tofel Jan 23, 2024
34243da
Merge branch 'develop' into lp_tests_final_fix_and_ci
Tofel Jan 23, 2024
62ee2d1
Merge branch 'develop' into lp_tests_final_fix_and_ci
Tofel Jan 23, 2024
451d457
remove commented out sections, remove cosmossdk.io/errors
Tofel Jan 23, 2024
f52c011
Merge branch 'lp_tests_final_fix_and_ci' of github.com:smartcontractk…
Tofel Jan 23, 2024
157e683
removed trailing spaces, added comments to functions
Tofel Jan 23, 2024
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
Prev Previous commit
Next Next commit
revert disabling of backpolling, simplify some code, less logs
  • Loading branch information
Tofel committed Jan 11, 2024
commit c9a4f1168a4b473bf08cbb8c0034b75a0b7a803e
3 changes: 2 additions & 1 deletion .github/workflows/on-demand-log-poller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ on:
required: true
selectedNetworks:
type: choice
description: Networks to test on
options:
- "SIMULATED"
- "SEPOLIA"
Expand Down Expand Up @@ -84,4 +85,4 @@ jobs:
run: |
cd integration-tests
go mod download
go test -v -timeout 5h -v -count=1 -run ^TestLogPollerFromEnv$ ./reorg/log_poller_maybe_reorg_test.go
go test -v -timeout 5h -v -count=1 -run ^TestLogPollerFewFiltersFixedDepth$ ./smoke/log_poller_test.go
2 changes: 1 addition & 1 deletion core/chains/evm/logpoller/log_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ func (lp *logPoller) run() {
defer lp.wg.Done()
logPollTick := time.After(0)
// stagger these somewhat, so they don't all run back-to-back
backupLogPollTick := time.After(100 * time.Hour)
backupLogPollTick := time.After(100 * time.Millisecond)
blockPruneTick := time.After(3 * time.Second)
logPruneTick := time.After(5 * time.Second)
filtersLoaded := false
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/load/log_poller/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ experiment_count = 10

[looped]
[looped.contract]
execution_count = 300
execution_count = 3000

[looped.fuzz]
min_emit_wait_time_ms = 100
Expand Down
43 changes: 0 additions & 43 deletions integration-tests/reorg/log_poller_maybe_reorg_test.go

This file was deleted.

8 changes: 7 additions & 1 deletion integration-tests/smoke/log_poller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ func TestLogPollerFewFiltersFixedDepth(t *testing.T) {

cfg.General.EventsToEmit = eventsToEmit

// this was added only to support triggering tests from CI with custom values
err := cfg.OverrideFromEnv()
if err != nil {
t.Errorf("failed to override config from env: %v", err)
t.FailNow()
Tofel marked this conversation as resolved.
Show resolved Hide resolved
}

logpoller.ExecuteBasicLogPollerTest(t, &cfg)
}

Expand Down Expand Up @@ -198,7 +205,6 @@ func TestLogPollerWithChaosFinalityTag(t *testing.T) {
}

func TestLogPollerWithChaosPostgresFixedDepth(t *testing.T) {
// t.Skip("This one reliably fails, we need to discover whether it's a test or app bug")
cfg := logpoller.Config{
General: &logpoller.General{
Generator: logpoller.GeneratorType_Looped,
Expand Down
74 changes: 55 additions & 19 deletions integration-tests/universal/log_poller/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,21 +380,21 @@ var clNodesHaveExpectedLogCount = func(startBlock, endBlock int64, chainID *big.
err error
}

queryCh := make(chan logQueryResult, len(nodes.Nodes)-1)
resultChan := make(chan logQueryResult, len(nodes.Nodes)-1)
ctx, cancelFn := context.WithCancel(context.Background())

for i := 1; i < len(nodes.Nodes); i++ {
wg.Add(1)

go func(clNode *test_env.ClNode, r chan logQueryResult) {
go func(clNode *test_env.ClNode, resultChan chan logQueryResult) {
defer wg.Done()
select {
case <-ctx.Done():
return
default:
orm, db, err := NewOrm(coreLogger, chainID, clNode.PostgresDb)
if err != nil {
r <- logQueryResult{
resultChan <- logQueryResult{
nodeName: clNode.ContainerName,
logCount: 0,
hasExpectedCount: false,
Expand All @@ -408,7 +408,7 @@ var clNodesHaveExpectedLogCount = func(startBlock, endBlock int64, chainID *big.
for _, filter := range expectedFilters {
logs, err := orm.SelectLogs(startBlock, endBlock, filter.emitterAddress, filter.topic)
if err != nil {
r <- logQueryResult{
resultChan <- logQueryResult{
nodeName: clNode.ContainerName,
logCount: 0,
hasExpectedCount: false,
Expand All @@ -419,22 +419,22 @@ var clNodesHaveExpectedLogCount = func(startBlock, endBlock int64, chainID *big.
foundLogsCount += len(logs)
}

r <- logQueryResult{
resultChan <- logQueryResult{
nodeName: clNode.ContainerName,
logCount: foundLogsCount,
hasExpectedCount: foundLogsCount >= expectedLogCount,
err: err,
err: nil,
}
}
}(nodes.Nodes[i], queryCh)
}(nodes.Nodes[i], resultChan)
}

var err error
allFoundCh := make(chan bool, 1)

go func() {
foundMap := make(map[string]bool, 0)
for r := range queryCh {
for r := range resultChan {
if r.err != nil {
err = r.err
cancelFn()
Expand All @@ -443,15 +443,22 @@ var clNodesHaveExpectedLogCount = func(startBlock, endBlock int64, chainID *big.

foundMap[r.nodeName] = r.hasExpectedCount
if r.hasExpectedCount {
l.Info().Str("Node name", r.nodeName).Int("Logs count", r.logCount).Msg("Expected log count found in CL node")
l.Debug().
Str("Node name", r.nodeName).
Int("Logs count", r.logCount).
Msg("Expected log count found in CL node")
} else {
l.Warn().Str("Node name", r.nodeName).Str("Found/Expected logs", fmt.Sprintf("%d/%d", r.logCount, expectedLogCount)).Int("Missing logs", expectedLogCount-r.logCount).Msg("Too low log count found in CL node")
l.Debug().
Str("Node name", r.nodeName).
Str("Found/Expected logs", fmt.Sprintf("%d/%d", r.logCount, expectedLogCount)).
Int("Missing logs", expectedLogCount-r.logCount).
Msg("Too low log count found in CL node")
}

if len(foundMap) == len(nodes.Nodes)-1 {
allFound := true
for _, v := range foundMap {
if !v {
for _, hadAllLogs := range foundMap {
if !hadAllLogs {
allFound = false
break
}
Expand All @@ -464,7 +471,7 @@ var clNodesHaveExpectedLogCount = func(startBlock, endBlock int64, chainID *big.
}()

wg.Wait()
close(queryCh)
close(resultChan)

return <-allFoundCh, err
}
Expand Down Expand Up @@ -505,7 +512,7 @@ var getMissingLogs = func(startBlock, endBlock int64, logEmitters []*contracts.L
default:
nodeName := clnodeCluster.Nodes[i].ContainerName

l.Info().Str("Node name", nodeName).Msg("Fetching log poller logs")
l.Debug().Str("Node name", nodeName).Msg("Fetching log poller logs")
orm, db, err := NewOrm(coreLogger, evmClient.GetChainID(), clnodeCluster.Nodes[i].PostgresDb)
if err != nil {
r <- dbQueryResult{
Expand All @@ -522,7 +529,7 @@ var getMissingLogs = func(startBlock, endBlock int64, logEmitters []*contracts.L
address := (*logEmitters[j]).Address()

for _, event := range cfg.General.EventsToEmit {
l.Debug().Str("Event name", event.Name).Str("Emitter address", address.String()).Msg("Fetching single emitter's logs")
l.Trace().Str("Event name", event.Name).Str("Emitter address", address.String()).Msg("Fetching single emitter's logs")
result, err := orm.SelectLogs(startBlock, endBlock, address, event.ID)
if err != nil {
r <- dbQueryResult{
Expand All @@ -538,7 +545,7 @@ var getMissingLogs = func(startBlock, endBlock int64, logEmitters []*contracts.L

logs = append(logs, result...)

l.Debug().Str("Event name", event.Name).Str("Emitter address", address.String()).Int("Log count", len(result)).Msg("Logs found per node")
l.Trace().Str("Event name", event.Name).Str("Emitter address", address.String()).Int("Log count", len(result)).Msg("Logs found per node")
}
}

Expand Down Expand Up @@ -598,7 +605,7 @@ var getMissingLogs = func(startBlock, endBlock int64, logEmitters []*contracts.L
go func(i int, result chan missingLogResult) {
defer wg.Done()
nodeName := clnodeCluster.Nodes[i].ContainerName
l.Info().Str("Node name", nodeName).Str("Progress", fmt.Sprintf("0/%d", evmLogCount)).Msg("Comparing single CL node's logs with EVM logs")
l.Info().Str("Node name", nodeName).Str("Progress", fmt.Sprintf("0/%d", evmLogCount)).Msg("Comparing single CL node's logs with EVM logs (this might take a while)")

missingLogs := make([]geth_types.Log, 0)
for i, evmLog := range allLogsInEVMNode {
Expand All @@ -612,7 +619,7 @@ var getMissingLogs = func(startBlock, endBlock int64, logEmitters []*contracts.L
}

if i%10000 == 0 && i != 0 {
l.Info().Str("Node name", nodeName).Str("Progress", fmt.Sprintf("%d/%d", i, evmLogCount)).Msg("Comparing single CL node's logs with EVM logs")
l.Debug().Str("Node name", nodeName).Str("Progress", fmt.Sprintf("%d/%d", i, evmLogCount)).Msg("Comparing single CL node's logs with EVM logs")
}

if !logFound {
Expand Down Expand Up @@ -644,7 +651,9 @@ var getMissingLogs = func(startBlock, endBlock int64, logEmitters []*contracts.L

expectedTotalLogsEmitted := getExpectedLogCount(cfg)
if int64(len(allLogsInEVMNode)) != expectedTotalLogsEmitted {
l.Warn().Str("Actual/Expected", fmt.Sprintf("%d/%d", expectedTotalLogsEmitted, len(allLogsInEVMNode))).Msg("Some of the test logs were not found in EVM node. This is a bug in the test")
l.Warn().
Str("Actual/Expected", fmt.Sprintf("%d/%d", expectedTotalLogsEmitted, len(allLogsInEVMNode))).
Msg("Some of the test logs were not found in EVM node. This is a bug in the test")
}

return missingLogs, nil
Expand Down Expand Up @@ -1270,3 +1279,30 @@ func registerFiltersAndAssertUniquness(l zerolog.Logger, registry contracts.Keep

return nil
}

func fluentlyCheckIfAllNodesHaveLogCount(duration string, startBlock, endBlock int64, expectedLogCount int, expectedFilters []ExpectedFilter, l zerolog.Logger, coreLogger core_logger.SugaredLogger, testEnv *test_env.CLClusterTestEnv) (bool, error) {
logCountWaitDuration, err := time.ParseDuration(duration)
if err != nil {
return false, err
}
endTime := time.Now().Add(logCountWaitDuration)

// not using gomega here, because I want to see which logs were missing
allNodesLogCountMatches := false
for time.Now().Before(endTime) {
logCountMatches, clErr := clNodesHaveExpectedLogCount(startBlock, endBlock, testEnv.EVMClient.GetChainID(), expectedLogCount, expectedFilters, l, coreLogger, testEnv.ClCluster)
if clErr != nil {
l.Warn().
Err(clErr).
Msg("Error checking if CL nodes have expected log count. Retrying...")
}
if logCountMatches {
allNodesLogCountMatches = true
break
}
l.Warn().
Msg("At least one CL node did not have expected log count. Retrying...")
}

return allNodesLogCountMatches, nil
}
Loading
Loading