Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shileiwill committed Jun 21, 2024
1 parent 11844e9 commit a2ff55c
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ authorized_receiver: ../../contracts/solc/v0.8.19/AuthorizedReceiver/AuthorizedR
automation_compatible_utils: ../../contracts/solc/v0.8.19/AutomationCompatibleUtils/AutomationCompatibleUtils.abi ../../contracts/solc/v0.8.19/AutomationCompatibleUtils/AutomationCompatibleUtils.bin dfe88f4f40d124b8cb5f36a7e9f9328008ca57f7ec5d07a28d949d569d5f2834
automation_consumer_benchmark: ../../contracts/solc/v0.8.16/AutomationConsumerBenchmark/AutomationConsumerBenchmark.abi ../../contracts/solc/v0.8.16/AutomationConsumerBenchmark/AutomationConsumerBenchmark.bin f52c76f1aaed4be541d82d97189d70f5aa027fc9838037dd7a7d21910c8c488e
automation_forwarder_logic: ../../contracts/solc/v0.8.16/AutomationForwarderLogic/AutomationForwarderLogic.abi ../../contracts/solc/v0.8.16/AutomationForwarderLogic/AutomationForwarderLogic.bin 15ae0c367297955fdab4b552dbb10e1f2be80a8fde0efec4a4d398693e9d72b5
automation_mock_ethusd_aggregator: ../../contracts/solc/v0.8.19/AutomationMockETHUSDAggregator/AutomationMockETHUSDAggregator.abi ../../contracts/solc/v0.8.19/AutomationMockETHUSDAggregator/AutomationMockETHUSDAggregator.bin 76322d6157c16580412ac820468509fcffc0352cba10e017b37b0453d531af36
automation_registrar_wrapper2_1: ../../contracts/solc/v0.8.16/AutomationRegistrar2_1/AutomationRegistrar2_1.abi ../../contracts/solc/v0.8.16/AutomationRegistrar2_1/AutomationRegistrar2_1.bin eb06d853aab39d3196c593b03e555851cbe8386e0fe54a74c2479f62d14b3c42
automation_registrar_wrapper2_3: ../../contracts/solc/v0.8.19/AutomationRegistrar2_3/AutomationRegistrar2_3.abi ../../contracts/solc/v0.8.19/AutomationRegistrar2_3/AutomationRegistrar2_3.bin 41f4b045cb783a8ad6e786b54216cc3666101abe75851784252e71aae3b00a99
automation_registry_logic_a_wrapper_2_2: ../../contracts/solc/v0.8.19/AutomationRegistryLogicA2_2/AutomationRegistryLogicA2_2.abi ../../contracts/solc/v0.8.19/AutomationRegistryLogicA2_2/AutomationRegistryLogicA2_2.bin 2f267fb8467a15c587ce4586ac56069f7229344ad3936430d7c7624c0528a171
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/actions/automationv2/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/lib/pq"
"github.com/rs/zerolog"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_automation_registry_master_wrapper_2_3"
"github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper"
ocr2 "github.com/smartcontractkit/libocr/offchainreporting2plus/confighelper"
ocr3 "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3confighelper"
Expand All @@ -26,6 +25,8 @@ import (
"golang.org/x/sync/errgroup"
"gopkg.in/guregu/null.v4"

"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_automation_registry_master_wrapper_2_3"

ocr2keepers20config "github.com/smartcontractkit/chainlink-automation/pkg/v2/config"
ocr2keepers30config "github.com/smartcontractkit/chainlink-automation/pkg/v3/config"

Expand Down
23 changes: 12 additions & 11 deletions integration-tests/contracts/ethereum_contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_automation_registry_master_wrapper_2_3"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/mock_ethusd_aggregator_wrapper"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/weth9_wrapper"
"github.com/smartcontractkit/libocr/gethwrappers/offchainaggregator"
"github.com/smartcontractkit/libocr/gethwrappers2/ocr2aggregator"
ocrConfigHelper "github.com/smartcontractkit/libocr/offchainreporting/confighelper"
ocrTypes "github.com/smartcontractkit/libocr/offchainreporting/types"
"github.com/smartcontractkit/seth"

"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_automation_registry_master_wrapper_2_3"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/mock_ethusd_aggregator_wrapper"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/weth9_wrapper"

contractsethereum "github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/functions/generated/functions_coordinator"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/functions/generated/functions_load_test_client"
Expand Down Expand Up @@ -1608,13 +1609,13 @@ func (l *EthereumMockETHUSDFeed) Decimals() uint {
return 8
}

func (v *EthereumMockETHUSDFeed) Address() string {
return v.address.Hex()
func (l *EthereumMockETHUSDFeed) Address() string {
return l.address.Hex()
}

func (v *EthereumMockETHUSDFeed) LatestRoundData() (*big.Int, error) {
data, err := v.feed.LatestRoundData(&bind.CallOpts{
From: v.client.Addresses[0],
func (l *EthereumMockETHUSDFeed) LatestRoundData() (*big.Int, error) {
data, err := l.feed.LatestRoundData(&bind.CallOpts{
From: l.client.Addresses[0],
Context: context.Background(),
})
if err != nil {
Expand All @@ -1623,9 +1624,9 @@ func (v *EthereumMockETHUSDFeed) LatestRoundData() (*big.Int, error) {
return data.Ans, nil
}

func (v *EthereumMockETHUSDFeed) LatestRoundDataUpdatedAt() (*big.Int, error) {
data, err := v.feed.LatestRoundData(&bind.CallOpts{
From: v.client.Addresses[0],
func (l *EthereumMockETHUSDFeed) LatestRoundDataUpdatedAt() (*big.Int, error) {
data, err := l.feed.LatestRoundData(&bind.CallOpts{
From: l.client.Addresses[0],
Context: context.Background(),
})
if err != nil {
Expand Down
76 changes: 69 additions & 7 deletions integration-tests/contracts/ethereum_contracts_automation.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/rs/zerolog"
"github.com/smartcontractkit/seth"

cltypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types"
registrylogicc23 "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/automation_registry_logic_c_wrapper_2_3"
"github.com/smartcontractkit/seth"

"github.com/smartcontractkit/chainlink-testing-framework/blockchain"
"github.com/smartcontractkit/chainlink-testing-framework/networks"
Expand Down Expand Up @@ -170,6 +171,9 @@ func (v *EthereumKeeperRegistry) RegistryOwnerAddress() common.Address {
}

switch v.version {
case ethereum.RegistryVersion_2_3:
ownerAddress, _ := v.registry2_3.Owner(callOpts)
return ownerAddress
case ethereum.RegistryVersion_2_2:
ownerAddress, _ := v.registry2_2.Owner(callOpts)
return ownerAddress
Expand Down Expand Up @@ -302,8 +306,8 @@ func (v *EthereumKeeperRegistry) SetConfig(config KeeperRegistrySettings, ocrCon
ocrConfig.OffchainConfig,
))
return err
case ethereum.RegistryVersion_2_1, ethereum.RegistryVersion_2_2:
return fmt.Errorf("registry version 2.1 and 2.2 must use setConfigTypeSafe function")
case ethereum.RegistryVersion_2_1, ethereum.RegistryVersion_2_2, ethereum.RegistryVersion_2_3:
return fmt.Errorf("registry version 2.1 2.2 and 2.3 must use setConfigTypeSafe function")
default:
return fmt.Errorf("keeper registry version %d is not supported", v.version)
}
Expand All @@ -320,6 +324,9 @@ func (v *EthereumKeeperRegistry) SetUpkeepOffchainConfig(id *big.Int, offchainCo
case ethereum.RegistryVersion_2_2:
_, err := v.client.Decode(v.registry2_2.SetUpkeepOffchainConfig(v.client.NewTXOpts(), id, offchainConfig))
return err
case ethereum.RegistryVersion_2_3:
_, err := v.client.Decode(v.registry2_3.SetUpkeepOffchainConfig(v.client.NewTXOpts(), id, offchainConfig))
return err
default:
return fmt.Errorf("SetUpkeepOffchainConfig is not supported by keeper registry version %d", v.version)
}
Expand All @@ -343,6 +350,8 @@ func (v *EthereumKeeperRegistry) Pause() error {
_, err = v.client.Decode(v.registry2_1.Pause(txOpts))
case ethereum.RegistryVersion_2_2:
_, err = v.client.Decode(v.registry2_2.Pause(txOpts))
case ethereum.RegistryVersion_2_3:
_, err = v.client.Decode(v.registry2_3.Pause(txOpts))
default:
return fmt.Errorf("keeper registry version %d is not supported", v.version)
}
Expand Down Expand Up @@ -427,6 +436,8 @@ func (v *EthereumKeeperRegistry) AddUpkeepFundsFromKey(id *big.Int, amount *big.
_, err = v.client.Decode(v.registry2_1.AddFunds(opts, id, amount))
case ethereum.RegistryVersion_2_2:
_, err = v.client.Decode(v.registry2_2.AddFunds(opts, id, amount))
case ethereum.RegistryVersion_2_3:
_, err = v.client.Decode(v.registry2_3.AddFunds(opts, id, amount))
}

return err
Expand Down Expand Up @@ -523,6 +534,8 @@ func (v *EthereumKeeperRegistry) GetUpkeepInfo(ctx context.Context, id *big.Int)
}, nil
case ethereum.RegistryVersion_2_2:
return v.getUpkeepInfo22(opts, id)
case ethereum.RegistryVersion_2_3:
return v.getUpkeepInfo23(opts, id)
}

return nil, fmt.Errorf("keeper registry version %d is not supported", v.version)
Expand All @@ -547,6 +560,25 @@ func (v *EthereumKeeperRegistry) getUpkeepInfo22(opts *bind.CallOpts, id *big.In
}, nil
}

func (v *EthereumKeeperRegistry) getUpkeepInfo23(opts *bind.CallOpts, id *big.Int) (*UpkeepInfo, error) {
uk, err := v.registry2_3.GetUpkeep(opts, id)
if err != nil {
return nil, err
}
return &UpkeepInfo{
Target: uk.Target.Hex(),
ExecuteGas: uk.PerformGas,
CheckData: uk.CheckData,
Balance: uk.Balance,
Admin: uk.Admin.Hex(),
MaxValidBlocknumber: uk.MaxValidBlocknumber,
LastPerformBlockNumber: uk.LastPerformedBlockNumber,
AmountSpent: uk.AmountSpent,
Paused: uk.Paused,
OffchainConfig: uk.OffchainConfig,
}, nil
}

func (v *EthereumKeeperRegistry) GetKeeperInfo(ctx context.Context, keeperAddr string) (*KeeperInfo, error) {
opts := &bind.CallOpts{
From: v.client.MustGetRootKeyAddress(),
Expand All @@ -566,7 +598,7 @@ func (v *EthereumKeeperRegistry) GetKeeperInfo(ctx context.Context, keeperAddr s
info, err = v.registry1_2.GetKeeperInfo(opts, common.HexToAddress(keeperAddr))
case ethereum.RegistryVersion_1_3:
info, err = v.registry1_3.GetKeeperInfo(opts, common.HexToAddress(keeperAddr))
case ethereum.RegistryVersion_2_0, ethereum.RegistryVersion_2_1, ethereum.RegistryVersion_2_2:
case ethereum.RegistryVersion_2_0, ethereum.RegistryVersion_2_1, ethereum.RegistryVersion_2_2, ethereum.RegistryVersion_2_3:
// this is not used anywhere
return nil, fmt.Errorf("not supported")
}
Expand Down Expand Up @@ -610,7 +642,7 @@ func (v *EthereumKeeperRegistry) SetKeepers(keepers []string, payees []string, o
ocrConfig.OffchainConfigVersion,
ocrConfig.OffchainConfig,
))
case ethereum.RegistryVersion_2_1, ethereum.RegistryVersion_2_2:
case ethereum.RegistryVersion_2_1, ethereum.RegistryVersion_2_2, ethereum.RegistryVersion_2_3:
return fmt.Errorf("not supported")
}

Expand Down Expand Up @@ -656,7 +688,7 @@ func (v *EthereumKeeperRegistry) RegisterUpkeep(target string, gasLimit uint32,
checkData,
nil, //offchain config
))
case ethereum.RegistryVersion_2_1, ethereum.RegistryVersion_2_2:
case ethereum.RegistryVersion_2_1, ethereum.RegistryVersion_2_2, ethereum.RegistryVersion_2_3:
return fmt.Errorf("not supported")
}

Expand Down Expand Up @@ -716,6 +748,8 @@ func (v *EthereumKeeperRegistry) SetUpkeepGasLimit(id *big.Int, gas uint32) erro
_, err = v.client.Decode(v.registry2_1.SetUpkeepGasLimit(opts, id, gas))
case ethereum.RegistryVersion_2_2:
_, err = v.client.Decode(v.registry2_2.SetUpkeepGasLimit(opts, id, gas))
case ethereum.RegistryVersion_2_3:
_, err = v.client.Decode(v.registry2_3.SetUpkeepGasLimit(opts, id, gas))
default:
return fmt.Errorf("keeper registry version %d is not supported for SetUpkeepGasLimit", v.version)
}
Expand Down Expand Up @@ -753,7 +787,7 @@ func (v *EthereumKeeperRegistry) GetKeeperList(ctx context.Context) ([]string, e
return []string{}, err
}
list = state.Transmitters
case ethereum.RegistryVersion_2_1, ethereum.RegistryVersion_2_2:
case ethereum.RegistryVersion_2_1, ethereum.RegistryVersion_2_2, ethereum.RegistryVersion_2_3:
return nil, fmt.Errorf("not supported")
}

Expand Down Expand Up @@ -781,6 +815,8 @@ func (v *EthereumKeeperRegistry) UpdateCheckData(id *big.Int, newCheckData []byt
_, err = v.client.Decode(v.registry2_1.SetUpkeepCheckData(opts, id, newCheckData))
case ethereum.RegistryVersion_2_2:
_, err = v.client.Decode(v.registry2_2.SetUpkeepCheckData(opts, id, newCheckData))
case ethereum.RegistryVersion_2_3:
_, err = v.client.Decode(v.registry2_3.SetUpkeepCheckData(opts, id, newCheckData))
default:
return fmt.Errorf("UpdateCheckData is not supported by keeper registry version %d", v.version)
}
Expand All @@ -798,6 +834,8 @@ func (v *EthereumKeeperRegistry) SetUpkeepTriggerConfig(id *big.Int, triggerConf
_, err = v.client.Decode(v.registry2_1.SetUpkeepTriggerConfig(opts, id, triggerConfig))
case ethereum.RegistryVersion_2_2:
_, err = v.client.Decode(v.registry2_2.SetUpkeepTriggerConfig(opts, id, triggerConfig))
case ethereum.RegistryVersion_2_3:
_, err = v.client.Decode(v.registry2_3.SetUpkeepTriggerConfig(opts, id, triggerConfig))
default:
return fmt.Errorf("SetUpkeepTriggerConfig is not supported by keeper registry version %d", v.version)
}
Expand All @@ -815,6 +853,8 @@ func (v *EthereumKeeperRegistry) SetUpkeepPrivilegeConfig(id *big.Int, privilege
_, err = v.client.Decode(v.registry2_1.SetUpkeepPrivilegeConfig(opts, id, privilegeConfig))
case ethereum.RegistryVersion_2_2:
_, err = v.client.Decode(v.registry2_2.SetUpkeepPrivilegeConfig(opts, id, privilegeConfig))
case ethereum.RegistryVersion_2_3:
_, err = v.client.Decode(v.registry2_3.SetUpkeepPrivilegeConfig(opts, id, privilegeConfig))
default:
return fmt.Errorf("SetUpkeepPrivilegeConfig is not supported by keeper registry version %d", v.version)
}
Expand All @@ -836,6 +876,8 @@ func (v *EthereumKeeperRegistry) PauseUpkeep(id *big.Int) error {
_, err = v.client.Decode(v.registry2_1.PauseUpkeep(opts, id))
case ethereum.RegistryVersion_2_2:
_, err = v.client.Decode(v.registry2_2.PauseUpkeep(opts, id))
case ethereum.RegistryVersion_2_3:
_, err = v.client.Decode(v.registry2_3.PauseUpkeep(opts, id))
default:
return fmt.Errorf("PauseUpkeep is not supported by keeper registry version %d", v.version)
}
Expand All @@ -857,6 +899,8 @@ func (v *EthereumKeeperRegistry) UnpauseUpkeep(id *big.Int) error {
_, err = v.client.Decode(v.registry2_1.UnpauseUpkeep(opts, id))
case ethereum.RegistryVersion_2_2:
_, err = v.client.Decode(v.registry2_2.UnpauseUpkeep(opts, id))
case ethereum.RegistryVersion_2_3:
_, err = v.client.Decode(v.registry2_3.UnpauseUpkeep(opts, id))
default:
return fmt.Errorf("UnpauseUpkeep is not supported by keeper registry version %d", v.version)
}
Expand Down Expand Up @@ -927,6 +971,16 @@ func (v *EthereumKeeperRegistry) ParseUpkeepPerformedLog(log *types.Log) (*Upkee
Success: parsedLog.Success,
From: utils.ZeroAddress,
}, nil
case ethereum.RegistryVersion_2_3:
parsedLog, err := v.registry2_3.ParseUpkeepPerformed(*log)
if err != nil {
return nil, err
}
return &UpkeepPerformedLog{
Id: parsedLog.Id,
Success: parsedLog.Success,
From: utils.ZeroAddress,
}, nil
}
return nil, fmt.Errorf("keeper registry version %d is not supported", v.version)
}
Expand Down Expand Up @@ -959,6 +1013,14 @@ func (v *EthereumKeeperRegistry) ParseStaleUpkeepReportLog(log *types.Log) (*Sta
return &StaleUpkeepReportLog{
Id: parsedLog.Id,
}, nil
case ethereum.RegistryVersion_2_3:
parsedLog, err := v.registry2_3.ParseStaleUpkeepReport(*log)
if err != nil {
return nil, err
}
return &StaleUpkeepReportLog{
Id: parsedLog.Id,
}, nil
}
return nil, fmt.Errorf("keeper registry version %d is not supported", v.version)
}
Expand Down
5 changes: 3 additions & 2 deletions integration-tests/contracts/ethereum_keeper_contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
goabi "github.com/umbracle/ethgo/abi"

"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_automation_registry_master_wrapper_2_2"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_automation_registry_master_wrapper_2_3"
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated/i_keeper_registry_master_wrapper_2_1"
goabi "github.com/umbracle/ethgo/abi"

"github.com/smartcontractkit/chainlink/integration-tests/contracts/ethereum"
cltypes "github.com/smartcontractkit/chainlink/v2/core/chains/evm/types"
Expand Down Expand Up @@ -167,7 +168,7 @@ func (rcs *KeeperRegistrySettings) Create23OnchainConfig(registrar string, regis
Transcoder: common.Address{},
Registrars: []common.Address{common.HexToAddress(registrar)},
UpkeepPrivilegeManager: registryOwnerAddress,
ChainModule: chainModuleAddress, // TODO here is the chainModule
ChainModule: chainModuleAddress,
ReorgProtectionEnabled: reorgProtectionEnabled,
FinanceAdmin: registryOwnerAddress,
FallbackNativePrice: big.NewInt(1),
Expand Down
7 changes: 3 additions & 4 deletions integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ require (
github.com/onsi/gomega v1.30.0
github.com/pelletier/go-toml/v2 v2.2.2
github.com/pkg/errors v0.9.1
github.com/rs/zerolog v1.30.0
github.com/rs/zerolog v1.31.0
github.com/scylladb/go-reflectx v1.0.1
github.com/segmentio/ksuid v1.0.4
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.20240620164046-1c03d0a97b20
github.com/smartcontractkit/chainlink-testing-framework v1.30.5
github.com/smartcontractkit/chainlink-testing-framework v1.31.1
github.com/smartcontractkit/chainlink-vrf v0.0.0-20231120191722-fef03814f868
github.com/smartcontractkit/chainlink/v2 v2.0.0-00010101000000-000000000000
github.com/smartcontractkit/havoc/k8schaos v0.0.0-20240409145249-e78d20847e37
github.com/smartcontractkit/libocr v0.0.0-20240419185742-fd3cab206b2c
github.com/smartcontractkit/seth v1.0.12-0.20240618124527-ca057b90a33b
github.com/smartcontractkit/seth v1.0.12
github.com/smartcontractkit/wasp v0.4.7
github.com/spf13/cobra v1.8.0
github.com/stretchr/testify v1.9.0
Expand All @@ -53,7 +53,6 @@ require (
exclude github.com/hashicorp/consul v1.2.1

replace (
// Pin K8s versions as their updates are highly disruptive and go mod keeps wanting to update them
k8s.io/api => k8s.io/api v0.25.11
k8s.io/client-go => k8s.io/client-go v0.25.11
k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20230303024457-afdc3dddf62d
Expand Down
Loading

0 comments on commit a2ff55c

Please sign in to comment.