Skip to content

Commit

Permalink
support mercury v0.3 (#10989)
Browse files Browse the repository at this point in the history
  • Loading branch information
shileiwill authored Oct 18, 2023
1 parent e5ef778 commit 5908487
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 22 deletions.
1 change: 1 addition & 0 deletions integration-tests/contracts/ethereum_keeper_contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -1724,6 +1724,7 @@ func (v *EthereumAutomationStreamsLookupUpkeepConsumer) Start() error {
return err
}

// The default values of ParamKeys are "feedIDs" and "timestamp" which are for v0.3
tx, err := v.consumer.SetParamKeys(txOpts, "feedIdHex", "blockNumber")
if err != nil {
return err
Expand Down
58 changes: 37 additions & 21 deletions integration-tests/smoke/automation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ func TestAutomationBasic(t *testing.T) {
func SetupAutomationBasic(t *testing.T, nodeUpgrade bool) {
t.Parallel()
registryVersions := map[string]ethereum.KeeperRegistryVersion{
"registry_2_0": ethereum.RegistryVersion_2_0,
"registry_2_1_conditional": ethereum.RegistryVersion_2_1,
"registry_2_1_logtrigger": ethereum.RegistryVersion_2_1,
"registry_2_1_mercury": ethereum.RegistryVersion_2_1,
"registry_2_0": ethereum.RegistryVersion_2_0,
"registry_2_1_conditional": ethereum.RegistryVersion_2_1,
"registry_2_1_logtrigger": ethereum.RegistryVersion_2_1,
"registry_2_1_with_mercury_v02": ethereum.RegistryVersion_2_1,
"registry_2_1_with_mercury_v03": ethereum.RegistryVersion_2_1,
}

for n, rv := range registryVersions {
Expand All @@ -120,10 +121,12 @@ func SetupAutomationBasic(t *testing.T, nodeUpgrade bool) {

// Use the name to determine if this is a log trigger or mercury
isLogTrigger := name == "registry_2_1_logtrigger"
isMercury := name == "registry_2_1_mercury"
isMercuryV02 := name == "registry_2_1_conditional_with_mercury_v02"
isMercuryV03 := name == "registry_2_1_conditional_with_mercury_v03"
isMercury := isMercuryV02 || isMercuryV03

chainClient, _, contractDeployer, linkToken, registry, registrar, testEnv := setupAutomationTestDocker(
t, testName, registryVersion, defaultOCRRegistryConfig, nodeUpgrade, isMercury,
t, testName, registryVersion, defaultOCRRegistryConfig, nodeUpgrade, isMercuryV02, isMercuryV03,
)

consumers, upkeepIDs := actions.DeployConsumers(
Expand All @@ -141,8 +144,11 @@ func SetupAutomationBasic(t *testing.T, nodeUpgrade bool) {
)

for i := 0; i < len(upkeepIDs); i++ {
if err := consumers[i].Start(); err != nil {
return
if isLogTrigger || isMercuryV02 {
if err := consumers[i].Start(); err != nil {
l.Error().Msg("Error when starting consumer")
return
}
}

if isMercury {
Expand All @@ -151,6 +157,7 @@ func SetupAutomationBasic(t *testing.T, nodeUpgrade bool) {
MercuryEnabled: true,
})
if err := registry.SetUpkeepPrivilegeConfig(upkeepIDs[i], privilegeConfigBytes); err != nil {
l.Error().Msg("Error when setting upkeep privilege config")
return
}
}
Expand Down Expand Up @@ -232,7 +239,7 @@ func TestSetUpkeepTriggerConfig(t *testing.T) {
l := logging.GetTestLogger(t)

chainClient, _, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker(
t, "set-trigger-config", ethereum.RegistryVersion_2_1, defaultOCRRegistryConfig, false, false,
t, "set-trigger-config", ethereum.RegistryVersion_2_1, defaultOCRRegistryConfig, false, false, false,
)

consumers, upkeepIDs := actions.DeployConsumers(
Expand Down Expand Up @@ -407,7 +414,7 @@ func TestAutomationAddFunds(t *testing.T) {
t.Run(name, func(t *testing.T) {
t.Parallel()
chainClient, _, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker(
t, "add-funds", registryVersion, defaultOCRRegistryConfig, false, false,
t, "add-funds", registryVersion, defaultOCRRegistryConfig, false, false, false,
)

consumers, upkeepIDs := actions.DeployConsumers(t, registry, registrar, linkToken, contractDeployer, chainClient, defaultAmountOfUpkeeps, big.NewInt(1), automationDefaultUpkeepGasLimit, false, false)
Expand Down Expand Up @@ -458,7 +465,7 @@ func TestAutomationPauseUnPause(t *testing.T) {
t.Parallel()
l := logging.GetTestLogger(t)
chainClient, _, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker(
t, "pause-unpause", registryVersion, defaultOCRRegistryConfig, false, false,
t, "pause-unpause", registryVersion, defaultOCRRegistryConfig, false, false, false,
)

consumers, upkeepIDs := actions.DeployConsumers(t, registry, registrar, linkToken, contractDeployer, chainClient, defaultAmountOfUpkeeps, big.NewInt(automationDefaultLinkFunds), automationDefaultUpkeepGasLimit, false, false)
Expand Down Expand Up @@ -541,7 +548,7 @@ func TestAutomationRegisterUpkeep(t *testing.T) {
t.Parallel()
l := logging.GetTestLogger(t)
chainClient, _, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker(
t, "register-upkeep", registryVersion, defaultOCRRegistryConfig, false, false,
t, "register-upkeep", registryVersion, defaultOCRRegistryConfig, false, false, false,
)

consumers, upkeepIDs := actions.DeployConsumers(t, registry, registrar, linkToken, contractDeployer, chainClient, defaultAmountOfUpkeeps, big.NewInt(automationDefaultLinkFunds), automationDefaultUpkeepGasLimit, false, false)
Expand Down Expand Up @@ -612,7 +619,7 @@ func TestAutomationPauseRegistry(t *testing.T) {
t.Run(name, func(t *testing.T) {
t.Parallel()
chainClient, _, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker(
t, "pause-registry", registryVersion, defaultOCRRegistryConfig, false, false,
t, "pause-registry", registryVersion, defaultOCRRegistryConfig, false, false, false,
)

consumers, upkeepIDs := actions.DeployConsumers(t, registry, registrar, linkToken, contractDeployer, chainClient, defaultAmountOfUpkeeps, big.NewInt(automationDefaultLinkFunds), automationDefaultUpkeepGasLimit, false, false)
Expand Down Expand Up @@ -670,7 +677,7 @@ func TestAutomationKeeperNodesDown(t *testing.T) {
t.Parallel()
l := logging.GetTestLogger(t)
chainClient, chainlinkNodes, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker(
t, "keeper-nodes-down", registryVersion, defaultOCRRegistryConfig, false, false,
t, "keeper-nodes-down", registryVersion, defaultOCRRegistryConfig, false, false, false,
)

consumers, upkeepIDs := actions.DeployConsumers(t, registry, registrar, linkToken, contractDeployer, chainClient, defaultAmountOfUpkeeps, big.NewInt(automationDefaultLinkFunds), automationDefaultUpkeepGasLimit, false, false)
Expand Down Expand Up @@ -755,7 +762,7 @@ func TestAutomationPerformSimulation(t *testing.T) {
t.Run(name, func(t *testing.T) {
t.Parallel()
chainClient, _, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker(
t, "perform-simulation", registryVersion, defaultOCRRegistryConfig, false, false,
t, "perform-simulation", registryVersion, defaultOCRRegistryConfig, false, false, false,
)

consumersPerformance, _ := actions.DeployPerformanceConsumers(
Expand Down Expand Up @@ -819,7 +826,7 @@ func TestAutomationCheckPerformGasLimit(t *testing.T) {
t.Parallel()
l := logging.GetTestLogger(t)
chainClient, chainlinkNodes, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker(
t, "gas-limit", registryVersion, defaultOCRRegistryConfig, false, false,
t, "gas-limit", registryVersion, defaultOCRRegistryConfig, false, false, false,
)

consumersPerformance, upkeepIDs := actions.DeployPerformanceConsumers(
Expand Down Expand Up @@ -933,7 +940,7 @@ func TestUpdateCheckData(t *testing.T) {
t.Parallel()
l := logging.GetTestLogger(t)
chainClient, _, contractDeployer, linkToken, registry, registrar, _ := setupAutomationTestDocker(
t, "update-check-data", registryVersion, defaultOCRRegistryConfig, false, false,
t, "update-check-data", registryVersion, defaultOCRRegistryConfig, false, false, false,
)

performDataChecker, upkeepIDs := actions.DeployPerformDataCheckerConsumers(
Expand Down Expand Up @@ -998,7 +1005,8 @@ func setupAutomationTestDocker(
registryVersion ethereum.KeeperRegistryVersion,
registryConfig contracts.KeeperRegistrySettings,
statefulDb bool,
isMercury bool,
isMercuryV02 bool,
isMercuryV03 bool,
) (
blockchain.EVMClient,
[]*client.ChainlinkClient,
Expand All @@ -1008,6 +1016,8 @@ func setupAutomationTestDocker(
contracts.KeeperRegistrar,
*test_env.CLClusterTestEnv,
) {
require.False(t, isMercuryV02 && isMercuryV03, "Cannot run test with both Mercury V02 and V03 on")

l := logging.GetTestLogger(t)
// Add registry version to config
registryConfig.RegistryVersion = registryVersion
Expand All @@ -1029,7 +1039,7 @@ func setupAutomationTestDocker(
var env *test_env.CLClusterTestEnv
var err error
clNodesCount := 5
if isMercury {
if isMercuryV02 || isMercuryV03 {
env, err = test_env.NewCLTestEnvBuilder().
WithTestLogger(t).
WithGeth().
Expand Down Expand Up @@ -1061,8 +1071,14 @@ func setupAutomationTestDocker(
err = env.StartClCluster(clNodeConfig, clNodesCount, secretsConfig)
require.NoError(t, err, "Error starting CL nodes test environment for Mercury")

output := `{"chainlinkBlob":"0x0001c38d71fed6c320b90e84b6f559459814d068e2a1700adc931ca9717d4fe70000000000000000000000000000000000000000000000000000000001a80b52b4bf1233f9cb71144a253a1791b202113c4ab4a92fa1b176d684b4959666ff8200000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001004254432d5553442d415242495452554d2d544553544e4554000000000000000000000000000000000000000000000000000000000000000000000000645570be000000000000000000000000000000000000000000000000000002af2b818dc5000000000000000000000000000000000000000000000000000002af2426faf3000000000000000000000000000000000000000000000000000002af32dc209700000000000000000000000000000000000000000000000000000000012130f8df0a9745bb6ad5e2df605e158ba8ad8a33ef8a0acf9851f0f01668a3a3f2b68600000000000000000000000000000000000000000000000000000000012130f60000000000000000000000000000000000000000000000000000000000000002c4a7958dce105089cf5edb68dad7dcfe8618d7784eb397f97d5a5fade78c11a58275aebda478968e545f7e3657aba9dcbe8d44605e4c6fde3e24edd5e22c94270000000000000000000000000000000000000000000000000000000000000002459c12d33986018a8959566d145225f0c4a4e61a9a3f50361ccff397899314f0018162cf10cd89897635a0bb62a822355bd199d09f4abe76e4d05261bb44733d"}`
env.MockAdapter.SetStringValuePath("/client", []string{http.MethodGet, http.MethodPost}, map[string]string{"Content-Type": "application/json"}, output)
if isMercuryV02 {
output := `{"chainlinkBlob":"0x0001c38d71fed6c320b90e84b6f559459814d068e2a1700adc931ca9717d4fe70000000000000000000000000000000000000000000000000000000001a80b52b4bf1233f9cb71144a253a1791b202113c4ab4a92fa1b176d684b4959666ff8200000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001004254432d5553442d415242495452554d2d544553544e4554000000000000000000000000000000000000000000000000000000000000000000000000645570be000000000000000000000000000000000000000000000000000002af2b818dc5000000000000000000000000000000000000000000000000000002af2426faf3000000000000000000000000000000000000000000000000000002af32dc209700000000000000000000000000000000000000000000000000000000012130f8df0a9745bb6ad5e2df605e158ba8ad8a33ef8a0acf9851f0f01668a3a3f2b68600000000000000000000000000000000000000000000000000000000012130f60000000000000000000000000000000000000000000000000000000000000002c4a7958dce105089cf5edb68dad7dcfe8618d7784eb397f97d5a5fade78c11a58275aebda478968e545f7e3657aba9dcbe8d44605e4c6fde3e24edd5e22c94270000000000000000000000000000000000000000000000000000000000000002459c12d33986018a8959566d145225f0c4a4e61a9a3f50361ccff397899314f0018162cf10cd89897635a0bb62a822355bd199d09f4abe76e4d05261bb44733d"}`
env.MockAdapter.SetStringValuePath("/client", []string{http.MethodGet, http.MethodPost}, map[string]string{"Content-Type": "application/json"}, output)
}
if isMercuryV03 {
output := `{"reports":[{"feedID":"0x4554482d5553442d415242495452554d2d544553544e45540000000000000000","validFromTimestamp":0,"observationsTimestamp":0,"fullReport":"0x00066dfcd1ed2d95b18c948dbc5bd64c687afe93e4ca7d663ddec14c20090ad80000000000000000000000000000000000000000000000000000000000081401000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000002200000000000000000000000000000000000000000000000000000000000000280000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001204554482d5553442d415242495452554d2d544553544e455400000000000000000000000000000000000000000000000000000000000000000000000064891c98000000000000000000000000000000000000000000000000000000289ad8d367000000000000000000000000000000000000000000000000000000289acf0b38000000000000000000000000000000000000000000000000000000289b3da40000000000000000000000000000000000000000000000000000000000018ae7ce74d9fa252a8983976eab600dc7590c778d04813430841bc6e765c34cd81a168d00000000000000000000000000000000000000000000000000000000018ae7cb0000000000000000000000000000000000000000000000000000000064891c98000000000000000000000000000000000000000000000000000000000000000260412b94e525ca6cedc9f544fd86f77606d52fe731a5d069dbe836a8bfc0fb8c911963b0ae7a14971f3b4621bffb802ef0605392b9a6c89c7fab1df8633a5ade00000000000000000000000000000000000000000000000000000000000000024500c2f521f83fba5efc2bf3effaaedde43d0a4adff785c1213b712a3aed0d8157642a84324db0cf9695ebd27708d4608eb0337e0dd87b0e43f0fa70c700d911"}]}`
env.MockAdapter.SetStringValuePath("/api/v1/reports/bulk", []string{http.MethodGet, http.MethodPost}, map[string]string{"Content-Type": "application/json"}, output)
}
} else {
env, err = test_env.NewCLTestEnvBuilder().
WithTestLogger(t).
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/smoke/automation_test.go_test_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "TestAutomationBasic",
"label": "ubuntu20.04-32cores-128GB",
"nodes": 4
"nodes": 5
},
{
"name": "TestSetUpkeepTriggerConfig"
Expand Down

0 comments on commit 5908487

Please sign in to comment.