Skip to content

Commit

Permalink
SetupAutomationBasic test for v21 (#10111)
Browse files Browse the repository at this point in the history
  • Loading branch information
shileiwill authored Aug 10, 2023
1 parent b649cf2 commit a97e533
Show file tree
Hide file tree
Showing 8 changed files with 370 additions and 117 deletions.
11 changes: 11 additions & 0 deletions integration-tests/actions/automation_ocr_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,23 @@ func CreateOCRKeeperJobs(
registryAddr string,
chainID int64,
keyIndex int,
registryVersion ethereum.KeeperRegistryVersion,
) {
l := utils.GetTestLogger(t)
bootstrapNode := chainlinkNodes[0]
bootstrapP2PIds, err := bootstrapNode.MustReadP2PKeys()
require.NoError(t, err, "Shouldn't fail reading P2P keys from bootstrap node")
bootstrapP2PId := bootstrapP2PIds.Data[0].Attributes.PeerID

var contractVersion string
if registryVersion == ethereum.RegistryVersion_2_1 {
contractVersion = "v2.1"
} else if registryVersion == ethereum.RegistryVersion_2_0 {
contractVersion = "v2.0"
} else {
require.FailNow(t, "v2.0 and v2.1 are the only supported versions")
}

bootstrapSpec := &client.OCR2TaskJobSpec{
Name: "ocr2 bootstrap node " + registryAddr,
JobType: "bootstrap",
Expand Down Expand Up @@ -170,6 +180,7 @@ func CreateOCRKeeperJobs(
},
PluginConfig: map[string]interface{}{
"mercuryCredentialName": "\"cred1\"",
"contractVersion": "\"" + contractVersion + "\"",
},
ContractConfigTrackerPollInterval: *models.NewInterval(time.Second * 15),
ContractID: registryAddr, // registryAddr
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/chaos/automation_chaos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func TestAutomationChaos(t *testing.T) {
chainClient,
)

actions.CreateOCRKeeperJobs(t, chainlinkNodes, registry.Address(), network.ChainID, 0)
actions.CreateOCRKeeperJobs(t, chainlinkNodes, registry.Address(), network.ChainID, 0, eth_contracts.RegistryVersion_2_0)
nodesWithoutBootstrap := chainlinkNodes[1:]
ocrConfig, err := actions.BuildAutoOCR2ConfigVars(t, nodesWithoutBootstrap, defaultOCRRegistryConfig, registrar.Address(), 5*time.Second)
require.NoError(t, err, "Error building OCR config vars")
Expand Down
174 changes: 160 additions & 14 deletions integration-tests/contracts/contract_deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,25 @@ import (

eth_contracts "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_consumer_benchmark"
automationForwarderLogic "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_forwarder_logic"
registrar21 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_registrar_wrapper2_1"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/flags_wrapper"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/flux_aggregator_wrapper"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/functions_billing_registry_events_mock"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/functions_oracle_events_mock"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/gas_wrapper"
iregistry21 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_keeper_registry_master_wrapper_2_1"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registrar_wrapper1_2"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registrar_wrapper2_0"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_logic1_3"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_logic2_0"
registrylogica21 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_logic_a_wrapper_2_1"
registrylogicb21 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_logic_b_wrapper_2_1"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper1_1"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper1_2"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper1_3"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper2_0"
registry21 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/keeper_registry_wrapper_2_1"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/link_token_interface"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/mock_aggregator_proxy"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/mock_ethlink_aggregator_wrapper"
Expand Down Expand Up @@ -578,6 +584,35 @@ func (e *EthereumContractDeployer) DeployKeeperRegistrar(registryVersion eth_con
registrar20: instance.(*keeper_registrar_wrapper2_0.KeeperRegistrar),
address: address,
}, err
} else if registryVersion == eth_contracts.RegistryVersion_2_1 {
// deploy registrar 2.1
address, _, instance, err := e.client.DeployContract("AutomationRegistrar", func(
opts *bind.TransactOpts,
backend bind.ContractBackend,
) (common.Address, *types.Transaction, interface{}, error) {
// set default TriggerType to 0(conditional), AutoApproveConfigType to 2(auto approve enabled), AutoApproveMaxAllowed to 1000
triggerConfigs := []registrar21.AutomationRegistrar21InitialTriggerConfig{
{TriggerType: 0, AutoApproveType: 2, AutoApproveMaxAllowed: 1000},
}

return registrar21.DeployAutomationRegistrar(
opts,
backend,
common.HexToAddress(linkAddr),
common.HexToAddress(registrarSettings.RegistryAddr),
registrarSettings.MinLinkJuels,
triggerConfigs)
})

if err != nil {
return nil, err
}

return &EthereumKeeperRegistrar{
client: e.client,
registrar21: instance.(*registrar21.AutomationRegistrar),
address: address,
}, err
}
// non OCR registrar
address, _, instance, err := e.client.DeployContract("KeeperRegistrar", func(
Expand Down Expand Up @@ -617,21 +652,37 @@ func (e *EthereumContractDeployer) LoadKeeperRegistrar(address common.Address, r
client: e.client,
registrar: instance.(*keeper_registrar_wrapper1_2.KeeperRegistrar),
}, err
} else if registryVersion == eth_contracts.RegistryVersion_2_0 {
instance, err := e.client.LoadContract("KeeperRegistrar", address, func(
address common.Address,
backend bind.ContractBackend,
) (interface{}, error) {
return keeper_registrar_wrapper2_0.NewKeeperRegistrar(address, backend)
})
if err != nil {
return nil, err
}
return &EthereumKeeperRegistrar{
address: &address,
client: e.client,
registrar20: instance.(*keeper_registrar_wrapper2_0.KeeperRegistrar),
}, err
} else {
instance, err := e.client.LoadContract("AutomationRegistrar", address, func(
address common.Address,
backend bind.ContractBackend,
) (interface{}, error) {
return registrar21.NewAutomationRegistrar(address, backend)
})
if err != nil {
return nil, err
}
return &EthereumKeeperRegistrar{
address: &address,
client: e.client,
registrar21: instance.(*registrar21.AutomationRegistrar),
}, err
}
instance, err := e.client.LoadContract("KeeperRegistrar", address, func(
address common.Address,
backend bind.ContractBackend,
) (interface{}, error) {
return keeper_registrar_wrapper2_0.NewKeeperRegistrar(address, backend)
})
if err != nil {
return nil, err
}
return &EthereumKeeperRegistrar{
address: &address,
client: e.client,
registrar20: instance.(*keeper_registrar_wrapper2_0.KeeperRegistrar),
}, err
}

func (e *EthereumContractDeployer) DeployKeeperRegistry(
Expand Down Expand Up @@ -821,6 +872,86 @@ func (e *EthereumContractDeployer) DeployKeeperRegistry(
address: address,
}, err

case eth_contracts.RegistryVersion_2_1:
automationForwarderLogicAddr, _, _, err := e.client.DeployContract("automationForwarderLogic", func(
auth *bind.TransactOpts,
backend bind.ContractBackend,
) (common.Address, *types.Transaction, interface{}, error) {
return automationForwarderLogic.DeployAutomationForwarderLogic(auth, backend)
})

if err != nil {
return nil, err
}

if err := e.client.WaitForEvents(); err != nil {
return nil, err
}

registryLogicBAddr, _, _, err := e.client.DeployContract("KeeperRegistryLogicB2_1", func(
auth *bind.TransactOpts,
backend bind.ContractBackend,
) (common.Address, *types.Transaction, interface{}, error) {

return registrylogicb21.DeployKeeperRegistryLogicB(
auth,
backend,
mode,
common.HexToAddress(opts.LinkAddr),
common.HexToAddress(opts.ETHFeedAddr),
common.HexToAddress(opts.GasFeedAddr),
*automationForwarderLogicAddr,
)
})
if err != nil {
return nil, err
}

if err := e.client.WaitForEvents(); err != nil {
return nil, err
}

registryLogicAAddr, _, _, err := e.client.DeployContract("KeeperRegistryLogicA2_1", func(
auth *bind.TransactOpts,
backend bind.ContractBackend,
) (common.Address, *types.Transaction, interface{}, error) {

return registrylogica21.DeployKeeperRegistryLogicA(
auth,
backend,
*registryLogicBAddr,
)
})
if err != nil {
return nil, err
}
if err := e.client.WaitForEvents(); err != nil {
return nil, err
}

address, _, instance, err := e.client.DeployContract("KeeperRegistry2_0", func(
auth *bind.TransactOpts,
backend bind.ContractBackend,
) (common.Address, *types.Transaction, interface{}, error) {
return registry21.DeployKeeperRegistry(
auth,
backend,
*registryLogicAAddr,
)
})
if err != nil {
return nil, err
}
if err := e.client.WaitForEvents(); err != nil {
return nil, err
}

return &EthereumKeeperRegistry{
client: e.client,
version: eth_contracts.RegistryVersion_2_1,
registry2_1: instance.(*registry21.KeeperRegistry),
address: address,
}, err
default:
return nil, fmt.Errorf("keeper registry version %d is not supported", opts.RegistryVersion)
}
Expand Down Expand Up @@ -889,6 +1020,21 @@ func (e *EthereumContractDeployer) LoadKeeperRegistry(address common.Address, re
client: e.client,
registry2_0: instance.(*keeper_registry_wrapper2_0.KeeperRegistry),
}, err
case eth_contracts.RegistryVersion_2_1:
instance, err := e.client.LoadContract("KeeperRegistry", address, func(
address common.Address,
backend bind.ContractBackend,
) (interface{}, error) {
return iregistry21.NewIKeeperRegistryMaster(address, backend)
})
if err != nil {
return nil, err
}
return &EthereumKeeperRegistry{
address: &address,
client: e.client,
registry2_1: instance.(*registry21.KeeperRegistry),
}, err
default:
return nil, fmt.Errorf("keeper registry version %d is not supported", registryVersion)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ const (
RegistryVersion_1_2
RegistryVersion_1_3
RegistryVersion_2_0
RegistryVersion_2_1
)
Loading

0 comments on commit a97e533

Please sign in to comment.