Skip to content

Commit

Permalink
code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofel committed May 8, 2024
1 parent 37a6d36 commit edc4a24
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 276 deletions.
17 changes: 17 additions & 0 deletions integration-tests/actions/seth/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1075,3 +1075,20 @@ func GetReportStalenessData(t *testing.T, chainClient *seth.Client, startBlock,

return
}

func GetStalenessReportCleanupFn(t *testing.T, logger zerolog.Logger, chainClient *seth.Client, startBlock uint64, registry contracts.KeeperRegistry, registryVersion ethereum.KeeperRegistryVersion) func() {
return func() {
if t.Failed() {
endBlock, err := chainClient.Client.BlockNumber(context.Background())
require.NoError(t, err, "Failed to get end block")

total, ok, reverted, stale, err := GetReportStalenessData(t, chainClient, big.NewInt(int64(startBlock)), big.NewInt(int64(endBlock)), registry, registryVersion)
require.NoError(t, err, "Failed to get staleness data")
if stale > 0 || reverted > 0 {
logger.Warn().Int("Total upkeeps", total).Int("Successful upkeeps", ok).Int("Reverted Upkeeps", reverted).Int("Stale Upkeeps", stale).Msg("Staleness data")
} else {
logger.Info().Int("Total upkeeps", total).Int("Successful upkeeps", ok).Int("Reverted Upkeeps", reverted).Int("Stale Upkeeps", stale).Msg("Staleness data")
}
}
}
}
8 changes: 4 additions & 4 deletions integration-tests/actions/seth/automation_ocr_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func DeployAutoOCRRegistryAndRegistrar(
}

// DeployConsumers deploys and registers keeper consumers. If ephemeral addresses are enabled, it will deploy and register the consumers from ephemeral addresses, but each upkpeep will be registered with root key address as the admin. Which means
// that functions like setting upkeep configuration, pausing, unpausing, etc. will be done by the root key address. It deployes mutlicall contract and sends link funds to each deployment address.
// that functions like setting upkeep configuration, pausing, unpausing, etc. will be done by the root key address. It deploys multicall contract and sends link funds to each deployment address.
func DeployConsumers(t *testing.T, chainClient *seth.Client, registry contracts.KeeperRegistry, registrar contracts.KeeperRegistrar, linkToken contracts.LinkToken, numberOfUpkeeps int, linkFundsForEachUpkeep *big.Int, upkeepGasLimit uint32, isLogTrigger bool, isMercury bool) ([]contracts.KeeperConsumer, []*big.Int) {
err := DeployMultiCallAndFundDeploymentAddresses(chainClient, linkToken, numberOfUpkeeps, linkFundsForEachUpkeep)
require.NoError(t, err, "Sending link funds to deployment addresses shouldn't fail")
Expand All @@ -47,8 +47,8 @@ func DeployConsumers(t *testing.T, chainClient *seth.Client, registry contracts.
return upkeeps, upkeepIds
}

// DeployPerformanceConsumers deploys and registers keeper performance consumers. If ephemeral addresses are enabled, it will deploy and register the consumers from ephemeral addresses, but each upkpeep will be registered with root key address as the admin.
// that functions like setting upkeep configuration, pausing, unpausing, etc. will be done by the root key address. It deployes mutlicall contract and sends link funds to each deployment address.
// DeployPerformanceConsumers deploys and registers keeper performance consumers. If ephemeral addresses are enabled, it will deploy and register the consumers from ephemeral addresses, but each upkeep will be registered with root key address as the admin.
// that functions like setting upkeep configuration, pausing, unpausing, etc. will be done by the root key address. It deploys multicall contract and sends link funds to each deployment address.
func DeployPerformanceConsumers(
t *testing.T,
chainClient *seth.Client,
Expand Down Expand Up @@ -79,7 +79,7 @@ func DeployPerformanceConsumers(
}

// DeployPerformDataCheckerConsumers deploys and registers keeper performance data checkers consumers. If ephemeral addresses are enabled, it will deploy and register the consumers from ephemeral addresses, but each upkpeep will be registered with root key address as the admin.
// that functions like setting upkeep configuration, pausing, unpausing, etc. will be done by the root key address. It deployes mutlicall contract and sends link funds to each deployment address.
// that functions like setting upkeep configuration, pausing, unpausing, etc. will be done by the root key address. It deployes multicall contract and sends link funds to each deployment address.
func DeployPerformDataCheckerConsumers(
t *testing.T,
chainClient *seth.Client,
Expand Down
2 changes: 0 additions & 2 deletions integration-tests/load/automationv2_1/automationv2_1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,6 @@ Load Config:
l.Error().Err(err).Msg("Error sending slack notification")
}

// a.ChainClient.Cfg.PendingNonceProtectionEnabled = false

g, err := wasp.NewGenerator(&wasp.Config{
T: t,
LoadType: wasp.RPS,
Expand Down
143 changes: 20 additions & 123 deletions integration-tests/smoke/automation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,7 @@ func SetupAutomationBasic(t *testing.T, nodeUpgrade bool) {
startTime := time.Now()

t.Cleanup(func() {
if t.Failed() {
eb, err := a.ChainClient.Client.BlockNumber(context.Background())
require.NoError(t, err, "Failed to get end block")

total, ok, reverted, stale, err := actions_seth.GetReportStalenessData(t, a.ChainClient, big.NewInt(int64(sb)), big.NewInt(int64(eb)), a.Registry, registryVersion)
require.NoError(t, err, "Failed to get staleness data")
if stale > 0 || reverted > 0 {
l.Warn().Int("Total upkeeps", total).Int("Successful upkeeps", ok).Int("Reverted Upkeeps", reverted).Int("Stale Upkeeps", stale).Msg("Staleness data")
} else {
l.Info().Int("Total upkeeps", total).Int("Successful upkeeps", ok).Int("Reverted Upkeeps", reverted).Int("Stale Upkeeps", stale).Msg("Staleness data")
}
}
actions_seth.GetStalenessReportCleanupFn(t, a.Logger, a.ChainClient, sb, a.Registry, registryVersion)()
})

// TODO Tune this timeout window after stress testing
Expand Down Expand Up @@ -301,18 +290,9 @@ func TestSetUpkeepTriggerConfig(t *testing.T) {
}
}

if t.Failed() {
eb, err := a.ChainClient.Client.BlockNumber(context.Background())
require.NoError(t, err, "Failed to get end block")

total, ok, reverted, stale, err := actions_seth.GetReportStalenessData(t, a.ChainClient, big.NewInt(int64(sb)), big.NewInt(int64(eb)), a.Registry, registryVersion)
require.NoError(t, err, "Failed to get staleness data")
if stale > 0 || reverted > 0 {
l.Warn().Int("Total upkeeps", total).Int("Successful upkeeps", ok).Int("Reverted Upkeeps", reverted).Int("Stale Upkeeps", stale).Msg("Staleness data")
} else {
l.Info().Int("Total upkeeps", total).Int("Successful upkeeps", ok).Int("Reverted Upkeeps", reverted).Int("Stale Upkeeps", stale).Msg("Staleness data")
}
}
t.Cleanup(func() {
actions_seth.GetStalenessReportCleanupFn(t, a.Logger, a.ChainClient, sb, a.Registry, registryVersion)()
})

l.Info().Msg("Waiting for all upkeeps to perform")
gom := gomega.NewGomegaWithT(t)
Expand Down Expand Up @@ -484,18 +464,7 @@ func TestAutomationAddFunds(t *testing.T) {
)

t.Cleanup(func() {
if t.Failed() {
eb, err := a.ChainClient.Client.BlockNumber(context.Background())
require.NoError(t, err, "Failed to get end block")

total, ok, reverted, stale, err := actions_seth.GetReportStalenessData(t, a.ChainClient, big.NewInt(int64(sb)), big.NewInt(int64(eb)), a.Registry, registryVersion)
require.NoError(t, err, "Failed to get staleness data")
if stale > 0 || reverted > 0 {
l.Warn().Int("Total upkeeps", total).Int("Successful upkeeps", ok).Int("Reverted Upkeeps", reverted).Int("Stale Upkeeps", stale).Msg("Staleness data")
} else {
l.Info().Int("Total upkeeps", total).Int("Successful upkeeps", ok).Int("Reverted Upkeeps", reverted).Int("Stale Upkeeps", stale).Msg("Staleness data")
}
}
actions_seth.GetStalenessReportCleanupFn(t, a.Logger, a.ChainClient, sb, a.Registry, registryVersion)()
})

l.Info().Msg("Making sure for 2m no upkeeps are performed")
Expand Down Expand Up @@ -573,18 +542,7 @@ func TestAutomationPauseUnPause(t *testing.T) {
)

t.Cleanup(func() {
if t.Failed() {
eb, err := a.ChainClient.Client.BlockNumber(context.Background())
require.NoError(t, err, "Failed to get end block")

total, ok, reverted, stale, err := actions_seth.GetReportStalenessData(t, a.ChainClient, big.NewInt(int64(sb)), big.NewInt(int64(eb)), a.Registry, registryVersion)
require.NoError(t, err, "Failed to get staleness data")
if stale > 0 || reverted > 0 {
l.Warn().Int("Total upkeeps", total).Int("Successful upkeeps", ok).Int("Reverted Upkeeps", reverted).Int("Stale Upkeeps", stale).Msg("Staleness data")
} else {
l.Info().Int("Total upkeeps", total).Int("Successful upkeeps", ok).Int("Reverted Upkeeps", reverted).Int("Stale Upkeeps", stale).Msg("Staleness data")
}
}
actions_seth.GetStalenessReportCleanupFn(t, a.Logger, a.ChainClient, sb, a.Registry, registryVersion)()
})

gom := gomega.NewGomegaWithT(t)
Expand Down Expand Up @@ -683,18 +641,7 @@ func TestAutomationRegisterUpkeep(t *testing.T) {
)

t.Cleanup(func() {
if t.Failed() {
eb, err := a.ChainClient.Client.BlockNumber(context.Background())
require.NoError(t, err, "Failed to get end block")

total, ok, reverted, stale, err := actions_seth.GetReportStalenessData(t, a.ChainClient, big.NewInt(int64(sb)), big.NewInt(int64(eb)), a.Registry, registryVersion)
require.NoError(t, err, "Failed to get staleness data")
if stale > 0 || reverted > 0 {
l.Warn().Int("Total upkeeps", total).Int("Successful upkeeps", ok).Int("Reverted Upkeeps", reverted).Int("Stale Upkeeps", stale).Msg("Staleness data")
} else {
l.Info().Int("Total upkeeps", total).Int("Successful upkeeps", ok).Int("Reverted Upkeeps", reverted).Int("Stale Upkeeps", stale).Msg("Staleness data")
}
}
actions_seth.GetStalenessReportCleanupFn(t, a.Logger, a.ChainClient, sb, a.Registry, registryVersion)()
})

var initialCounters = make([]*big.Int, len(upkeepIDs))
Expand Down Expand Up @@ -763,7 +710,6 @@ func TestAutomationPauseRegistry(t *testing.T) {
registryVersion := rv
t.Run(name, func(t *testing.T) {
t.Parallel()
l := logging.GetTestLogger(t)

config, err := tc.GetConfig("Smoke", tc.Automation)
require.NoError(t, err, "Failed to get config")
Expand All @@ -789,18 +735,7 @@ func TestAutomationPauseRegistry(t *testing.T) {
)

t.Cleanup(func() {
if t.Failed() {
eb, err := a.ChainClient.Client.BlockNumber(context.Background())
require.NoError(t, err, "Failed to get end block")

total, ok, reverted, stale, err := actions_seth.GetReportStalenessData(t, a.ChainClient, big.NewInt(int64(sb)), big.NewInt(int64(eb)), a.Registry, registryVersion)
require.NoError(t, err, "Failed to get staleness data")
if stale > 0 || reverted > 0 {
l.Warn().Int("Total upkeeps", total).Int("Successful upkeeps", ok).Int("Reverted Upkeeps", reverted).Int("Stale Upkeeps", stale).Msg("Staleness data")
} else {
l.Info().Int("Total upkeeps", total).Int("Successful upkeeps", ok).Int("Reverted Upkeeps", reverted).Int("Stale Upkeeps", stale).Msg("Staleness data")
}
}
actions_seth.GetStalenessReportCleanupFn(t, a.Logger, a.ChainClient, sb, a.Registry, registryVersion)()
})

gom := gomega.NewGomegaWithT(t)
Expand Down Expand Up @@ -878,18 +813,7 @@ func TestAutomationKeeperNodesDown(t *testing.T) {
)

t.Cleanup(func() {
if t.Failed() {
eb, err := a.ChainClient.Client.BlockNumber(context.Background())
require.NoError(t, err, "Failed to get end block")

total, ok, reverted, stale, err := actions_seth.GetReportStalenessData(t, a.ChainClient, big.NewInt(int64(sb)), big.NewInt(int64(eb)), a.Registry, registryVersion)
require.NoError(t, err, "Failed to get staleness data")
if stale > 0 || reverted > 0 {
l.Warn().Int("Total upkeeps", total).Int("Successful upkeeps", ok).Int("Reverted Upkeeps", reverted).Int("Stale Upkeeps", stale).Msg("Staleness data")
} else {
l.Info().Int("Total upkeeps", total).Int("Successful upkeeps", ok).Int("Reverted Upkeeps", reverted).Int("Stale Upkeeps", stale).Msg("Staleness data")
}
}
actions_seth.GetStalenessReportCleanupFn(t, a.Logger, a.ChainClient, sb, a.Registry, registryVersion)()
})

gom := gomega.NewGomegaWithT(t)
Expand Down Expand Up @@ -971,7 +895,6 @@ func TestAutomationPerformSimulation(t *testing.T) {
registryVersion := rv
t.Run(name, func(t *testing.T) {
t.Parallel()
l := logging.GetTestLogger(t)
config, err := tc.GetConfig("Smoke", tc.Automation)
require.NoError(t, err, "Failed to get config")

Expand All @@ -998,18 +921,7 @@ func TestAutomationPerformSimulation(t *testing.T) {
)

t.Cleanup(func() {
if t.Failed() {
eb, err := a.ChainClient.Client.BlockNumber(context.Background())
require.NoError(t, err, "Failed to get end block")

total, ok, reverted, stale, err := actions_seth.GetReportStalenessData(t, a.ChainClient, big.NewInt(int64(sb)), big.NewInt(int64(eb)), a.Registry, registryVersion)
require.NoError(t, err, "Failed to get staleness data")
if stale > 0 || reverted > 0 {
l.Warn().Int("Total upkeeps", total).Int("Successful upkeeps", ok).Int("Reverted Upkeeps", reverted).Int("Stale Upkeeps", stale).Msg("Staleness data")
} else {
l.Info().Int("Total upkeeps", total).Int("Successful upkeeps", ok).Int("Reverted Upkeeps", reverted).Int("Stale Upkeeps", stale).Msg("Staleness data")
}
}
actions_seth.GetStalenessReportCleanupFn(t, a.Logger, a.ChainClient, sb, a.Registry, registryVersion)()
})

gom := gomega.NewGomegaWithT(t)
Expand Down Expand Up @@ -1080,18 +992,7 @@ func TestAutomationCheckPerformGasLimit(t *testing.T) {
)

t.Cleanup(func() {
if t.Failed() {
eb, err := a.ChainClient.Client.BlockNumber(context.Background())
require.NoError(t, err, "Failed to get end block")

total, ok, reverted, stale, err := actions_seth.GetReportStalenessData(t, a.ChainClient, big.NewInt(int64(sb)), big.NewInt(int64(eb)), a.Registry, registryVersion)
require.NoError(t, err, "Failed to get staleness data")
if stale > 0 || reverted > 0 {
l.Warn().Int("Total upkeeps", total).Int("Successful upkeeps", ok).Int("Reverted Upkeeps", reverted).Int("Stale Upkeeps", stale).Msg("Staleness data")
} else {
l.Info().Int("Total upkeeps", total).Int("Successful upkeeps", ok).Int("Reverted Upkeeps", reverted).Int("Stale Upkeeps", stale).Msg("Staleness data")
}
}
actions_seth.GetStalenessReportCleanupFn(t, a.Logger, a.ChainClient, sb, a.Registry, registryVersion)()
})

gom := gomega.NewGomegaWithT(t)
Expand Down Expand Up @@ -1243,18 +1144,7 @@ func TestUpdateCheckData(t *testing.T) {
)

t.Cleanup(func() {
if t.Failed() {
eb, err := a.ChainClient.Client.BlockNumber(context.Background())
require.NoError(t, err, "Failed to get end block")

total, ok, reverted, stale, err := actions_seth.GetReportStalenessData(t, a.ChainClient, big.NewInt(int64(sb)), big.NewInt(int64(eb)), a.Registry, registryVersion)
require.NoError(t, err, "Failed to get staleness data")
if stale > 0 || reverted > 0 {
l.Warn().Int("Total upkeeps", total).Int("Successful upkeeps", ok).Int("Reverted Upkeeps", reverted).Int("Stale Upkeeps", stale).Msg("Staleness data")
} else {
l.Info().Int("Total upkeeps", total).Int("Successful upkeeps", ok).Int("Reverted Upkeeps", reverted).Int("Stale Upkeeps", stale).Msg("Staleness data")
}
}
actions_seth.GetStalenessReportCleanupFn(t, a.Logger, a.ChainClient, sb, a.Registry, registryVersion)()
})

gom := gomega.NewGomegaWithT(t)
Expand Down Expand Up @@ -1319,6 +1209,9 @@ func TestSetOffchainConfigWithMaxGasPrice(t *testing.T) {
t, registryVersion, automationDefaultRegistryConfig(config), false, false, &config,
)

sb, err := a.ChainClient.Client.BlockNumber(context.Background())
require.NoError(t, err, "Failed to get start block")

consumers, upkeepIDs := actions_seth.DeployConsumers(
t,
a.ChainClient,
Expand All @@ -1331,8 +1224,12 @@ func TestSetOffchainConfigWithMaxGasPrice(t *testing.T) {
false,
false,
)
gom := gomega.NewGomegaWithT(t)

t.Cleanup(func() {
actions_seth.GetStalenessReportCleanupFn(t, a.Logger, a.ChainClient, sb, a.Registry, registryVersion)()
})

gom := gomega.NewGomegaWithT(t)
l.Info().Msg("waiting for all upkeeps to be performed at least once")
gom.Eventually(func(g gomega.Gomega) {
for i := 0; i < len(upkeepIDs); i++ {
Expand Down
Loading

0 comments on commit edc4a24

Please sign in to comment.