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

update VL contracts to work with 2.1 #9673

Merged
merged 2 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 14 additions & 13 deletions contracts/src/v0.8/tests/VerifiableLoadBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ pragma solidity ^0.8.6;

import "../vendor/openzeppelin-solidity/v4.7.3/contracts/utils/structs/EnumerableSet.sol";
import "../automation/2_0/KeeperRegistrar2_0.sol";
import "../automation/2_0/KeeperRegistry2_0.sol";
import "../dev/automation/2_1/interfaces/IKeeperRegistryMaster.sol";
import {ArbSys} from "../dev/vendor/@arbitrum/nitro-contracts/src/precompiles/ArbSys.sol";

abstract contract VerifiableLoadBase is ConfirmedOwner {
error IndexOutOfRange();
Expand Down Expand Up @@ -41,7 +42,7 @@ abstract contract VerifiableLoadBase is ConfirmedOwner {
EnumerableSet.UintSet internal s_upkeepIDs;
KeeperRegistrar2_0 public registrar;
LinkTokenInterface public linkToken;
KeeperRegistry2_0 public registry;
IKeeperRegistryMaster public registry;
// check if an upkeep is eligible for adding funds at this interval
uint256 public upkeepTopUpCheckInterval = 5;
// an upkeep will get this amount of LINK for every top up
Expand All @@ -63,7 +64,7 @@ abstract contract VerifiableLoadBase is ConfirmedOwner {
constructor(address registrarAddress, bool useArb) ConfirmedOwner(msg.sender) {
registrar = KeeperRegistrar2_0(registrarAddress);
(, , , address registryAddress, ) = registrar.getRegistrationConfig();
registry = KeeperRegistry2_0(payable(address(registryAddress)));
registry = IKeeperRegistryMaster(payable(address(registryAddress)));
linkToken = registrar.LINK();
useArbitrumBlockNum = useArb;
}
Expand Down Expand Up @@ -95,7 +96,7 @@ abstract contract VerifiableLoadBase is ConfirmedOwner {
function setConfig(KeeperRegistrar2_0 newRegistrar) external {
registrar = newRegistrar;
(, , , address registryAddress, ) = registrar.getRegistrationConfig();
registry = KeeperRegistry2_0(payable(address(registryAddress)));
registry = IKeeperRegistryMaster(payable(address(registryAddress)));
linkToken = registrar.LINK();

emit RegistrarSet(address(registrar));
Expand Down Expand Up @@ -154,7 +155,7 @@ abstract contract VerifiableLoadBase is ConfirmedOwner {
upkeepContract: address(this),
gasLimit: gasLimit,
adminAddress: address(this), // use address of this contract as the admin
checkData: bytes(""), // update check data later bc upkeep id is not available now
checkData: bytes(""), // update pipeline data later bc upkeep id is not available now
offchainConfig: bytes(""),
amount: amount
});
Expand Down Expand Up @@ -183,13 +184,13 @@ abstract contract VerifiableLoadBase is ConfirmedOwner {
}

/**
* @notice updates check data for an upkeep. In order for the upkeep to be performed, the check data must be the abi encoded upkeep ID.
* @notice updates pipeline data for an upkeep. In order for the upkeep to be performed, the pipeline data must be the abi encoded upkeep ID.
* @param upkeepId the upkeep ID
* @param checkData the new check data for the upkeep
* @param pipelineData the new pipeline data for the upkeep
*/
function updateCheckData(uint256 upkeepId, bytes calldata checkData) external {
registry.updateCheckData(upkeepId, checkData);
checkDatas[upkeepId] = checkData;
function updateUpkeepPipelineData(uint256 upkeepId, bytes calldata pipelineData) external {
registry.setUpkeepPipelineData(upkeepId, pipelineData);
checkDatas[upkeepId] = pipelineData;
Comment on lines +191 to +193
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is going to change back on the registry

}

function withdrawLinks(uint256 upkeepId) external {
Expand Down Expand Up @@ -297,14 +298,14 @@ abstract contract VerifiableLoadBase is ConfirmedOwner {
}

/**
* @notice batch updating check data for all upkeeps.
* @notice batch updating pipeline data for all upkeeps.
* @param upkeepIds an array of upkeep IDs
*/
function batchUpdateCheckData(uint256[] calldata upkeepIds) external {
function batchUpdatePipelineData(uint256[] calldata upkeepIds) external {
uint256 len = upkeepIds.length;
for (uint256 i = 0; i < len; i++) {
uint256 upkeepId = upkeepIds[i];
this.updateCheckData(upkeepId, abi.encode(upkeepId));
this.updateUpkeepPipelineData(upkeepId, abi.encode(upkeepId));
}
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v0.8/tests/VerifiableLoadMercuryUpkeep.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ contract VerifiableLoadMercuryUpkeep is VerifiableLoadBase, FeedLookupCompatible
// minBalanceThresholdMultiplier (20) * min balance. If not, add addLinkAmount (0.2) to the upkeep
// upkeepTopUpCheckInterval, minBalanceThresholdMultiplier, and addLinkAmount are configurable
if (blockNum - lastTopUpBlocks[upkeepId] > upkeepTopUpCheckInterval) {
UpkeepInfo memory info = registry.getUpkeep(upkeepId);
KeeperRegistryBase2_1.UpkeepInfo memory info = registry.getUpkeep(upkeepId);
uint96 minBalance = registry.getMinBalanceForUpkeep(upkeepId);
if (info.balance < minBalanceThresholdMultiplier * minBalance) {
this.addFunds(upkeepId, addLinkAmount);
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/v0.8/tests/VerifiableLoadUpkeep.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ contract VerifiableLoadUpkeep is VerifiableLoadBase {
// minBalanceThresholdMultiplier (20) * min balance. If not, add addLinkAmount (0.2) to the upkeep
// upkeepTopUpCheckInterval, minBalanceThresholdMultiplier, and addLinkAmount are configurable
if (blockNum - lastTopUpBlocks[upkeepId] > upkeepTopUpCheckInterval) {
UpkeepInfo memory info = registry.getUpkeep(upkeepId);
KeeperRegistryBase2_1.UpkeepInfo memory info = registry.getUpkeep(upkeepId);
uint96 minBalance = registry.getMinBalanceForUpkeep(upkeepId);
if (info.balance < minBalanceThresholdMultiplier * minBalance) {
this.addFunds(upkeepId, addLinkAmount);
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ type_and_version_interface_wrapper: ../../contracts/solc/v0.8.6/TypeAndVersionIn
upkeep_counter_wrapper: ../../contracts/solc/v0.7/UpkeepCounter.abi ../../contracts/solc/v0.7/UpkeepCounter.bin 901961ebf18906febc1c350f02da85c7ea1c2a68da70cfd94efa27c837a48663
upkeep_perform_counter_restrictive_wrapper: ../../contracts/solc/v0.7/UpkeepPerformCounterRestrictive.abi ../../contracts/solc/v0.7/UpkeepPerformCounterRestrictive.bin 8975a058fba528e16d8414dc6f13946d17a145fcbc66cf25a32449b6fe1ce878
upkeep_transcoder: ../../contracts/solc/v0.8.6/UpkeepTranscoder.abi ../../contracts/solc/v0.8.6/UpkeepTranscoder.bin 336c92a981597be26508455f81a908a0784a817b129a59686c5b2c4afcba730a
verifiable_load_mercury_upkeep_wrapper: ../../contracts/solc/v0.8.6/VerifiableLoadMercuryUpkeep.abi ../../contracts/solc/v0.8.6/VerifiableLoadMercuryUpkeep.bin f94c56c37fb64fab4201e4b218ebdb85602c98e1faa79948a27e4598b9432f30
verifiable_load_upkeep_wrapper: ../../contracts/solc/v0.8.6/VerifiableLoadUpkeep.abi ../../contracts/solc/v0.8.6/VerifiableLoadUpkeep.bin 0e0cf6c7f4540dcc84b77acaf68487b61656efcd6e39105b19686063084c78e6
verifiable_load_mercury_upkeep_wrapper: ../../contracts/solc/v0.8.6/VerifiableLoadMercuryUpkeep.abi ../../contracts/solc/v0.8.6/VerifiableLoadMercuryUpkeep.bin cecedbfaabc49f34311819fbcec38205d7f73ab98cdd3cbcd44af4ba65f75a89
verifiable_load_upkeep_wrapper: ../../contracts/solc/v0.8.6/VerifiableLoadUpkeep.abi ../../contracts/solc/v0.8.6/VerifiableLoadUpkeep.bin 75800e0a60709b8ed9668affd65ee06c4487cb51ca2938a5d4a95c2138c4dc8d
vrf_consumer_v2: ../../contracts/solc/v0.8.6/VRFConsumerV2.abi ../../contracts/solc/v0.8.6/VRFConsumerV2.bin 9ef258bf8e9f8d880fd229ceb145593d91e24fc89366baa0bf19169c5787d15f
vrf_consumer_v2_upgradeable_example: ../../contracts/solc/v0.8.6/VRFConsumerV2UpgradeableExample.abi ../../contracts/solc/v0.8.6/VRFConsumerV2UpgradeableExample.bin f1790a9a2f2a04c730593e483459709cb89e897f8a19d7a3ac0cfe6a97265e6e
vrf_coordinator_mock: ../../contracts/solc/v0.8.6/VRFCoordinatorMock.abi ../../contracts/solc/v0.8.6/VRFCoordinatorMock.bin 5c495cf8df1f46d8736b9150cdf174cce358cb8352f60f0d5bb9581e23920501
Expand Down
35 changes: 19 additions & 16 deletions core/scripts/chaincli/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const (
Conditional UpkeepType = iota
Mercury
LogTrigger
LogTriggeredFeedLookup
)

// Config represents configuration fields
Expand Down Expand Up @@ -43,22 +44,24 @@ type Config struct {
OCR2Keepers bool `mapstructure:"KEEPER_OCR2"`

// Keeper config
LinkETHFeedAddr string `mapstructure:"LINK_ETH_FEED"`
FastGasFeedAddr string `mapstructure:"FAST_GAS_FEED"`
PaymentPremiumPBB uint32 `mapstructure:"PAYMENT_PREMIUM_PBB"`
FlatFeeMicroLink uint32 `mapstructure:"FLAT_FEE_MICRO_LINK"`
BlockCountPerTurn int64 `mapstructure:"BLOCK_COUNT_PER_TURN"`
CheckGasLimit uint32 `mapstructure:"CHECK_GAS_LIMIT"`
StalenessSeconds int64 `mapstructure:"STALENESS_SECONDS"`
GasCeilingMultiplier uint16 `mapstructure:"GAS_CEILING_MULTIPLIER"`
MinUpkeepSpend int64 `mapstructure:"MIN_UPKEEP_SPEND"`
MaxPerformGas uint32 `mapstructure:"MAX_PERFORM_GAS"`
MaxCheckDataSize uint32 `mapstructure:"MAX_CHECK_DATA_SIZE"`
MaxPerformDataSize uint32 `mapstructure:"MAX_PERFORM_DATA_SIZE"`
FallbackGasPrice int64 `mapstructure:"FALLBACK_GAS_PRICE"`
FallbackLinkPrice int64 `mapstructure:"FALLBACK_LINK_PRICE"`
Transcoder string `mapstructure:"TRANSCODER"`
Registrar string `mapstructure:"REGISTRAR"`
Mode uint8 `mapstructure:"MODE"`
LinkETHFeedAddr string `mapstructure:"LINK_ETH_FEED"`
FastGasFeedAddr string `mapstructure:"FAST_GAS_FEED"`
PaymentPremiumPBB uint32 `mapstructure:"PAYMENT_PREMIUM_PBB"`
FlatFeeMicroLink uint32 `mapstructure:"FLAT_FEE_MICRO_LINK"`
BlockCountPerTurn int64 `mapstructure:"BLOCK_COUNT_PER_TURN"`
CheckGasLimit uint32 `mapstructure:"CHECK_GAS_LIMIT"`
StalenessSeconds int64 `mapstructure:"STALENESS_SECONDS"`
GasCeilingMultiplier uint16 `mapstructure:"GAS_CEILING_MULTIPLIER"`
MinUpkeepSpend int64 `mapstructure:"MIN_UPKEEP_SPEND"`
MaxPerformGas uint32 `mapstructure:"MAX_PERFORM_GAS"`
MaxCheckDataSize uint32 `mapstructure:"MAX_CHECK_DATA_SIZE"`
MaxPerformDataSize uint32 `mapstructure:"MAX_PERFORM_DATA_SIZE"`
FallbackGasPrice int64 `mapstructure:"FALLBACK_GAS_PRICE"`
FallbackLinkPrice int64 `mapstructure:"FALLBACK_LINK_PRICE"`
Transcoder string `mapstructure:"TRANSCODER"`
Registrar string `mapstructure:"REGISTRAR"`
UpkeepPrivilegeManager string `mapstructure:"UPKEEP_PRIVILEGE_MANAGER"`

// Upkeep Config
RegistryVersion keeper.RegistryVersion `mapstructure:"KEEPER_REGISTRY_VERSION"`
Expand Down
8 changes: 4 additions & 4 deletions core/scripts/chaincli/handler/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func (k *Keeper) deployRegistry21(ctx context.Context, verify bool) (common.Addr
registryLogicBAddr, tx, _, err := registrylogicb21.DeployKeeperRegistryLogicB(
k.buildTxOpts(ctx),
k.client,
0,
k.cfg.Mode,
common.HexToAddress(k.cfg.LinkTokenAddr),
common.HexToAddress(k.cfg.LinkETHFeedAddr),
common.HexToAddress(k.cfg.FastGasFeedAddr),
Expand Down Expand Up @@ -317,7 +317,7 @@ func (k *Keeper) deployRegistry20(ctx context.Context, verify bool) (common.Addr
registryLogicAddr, deployKeeperRegistryLogicTx, _, err := registrylogic20.DeployKeeperRegistryLogic(
k.buildTxOpts(ctx),
k.client,
0,
k.cfg.Mode,
common.HexToAddress(k.cfg.LinkTokenAddr),
common.HexToAddress(k.cfg.LinkETHFeedAddr),
common.HexToAddress(k.cfg.FastGasFeedAddr),
Expand Down Expand Up @@ -687,8 +687,8 @@ func (k *Keeper) deployUpkeeps(ctx context.Context, registryAddr common.Address,
log.Println(upkeepId, upkeepAddr.Hex(), ": Upkeep funded - ", helpers.ExplorerLink(k.cfg.ChainID, addFundsTx.Hash()))
}

// set upkeep privilege config for mercury upkeeps
if k.cfg.UpkeepType == config.Mercury && k.cfg.RegistryVersion == keeper.RegistryVersion_2_1 {
// set administrative offchain config for mercury upkeeps
if (k.cfg.UpkeepType == config.Mercury || k.cfg.UpkeepType == config.LogTriggeredFeedLookup) && k.cfg.RegistryVersion == keeper.RegistryVersion_2_1 {
reg21, err := iregistry21.NewIKeeperRegistryMaster(registryAddr, k.client)
if err != nil {
log.Fatalf("cannot create registry 2.1: %v", err)
Expand Down
31 changes: 16 additions & 15 deletions core/scripts/chaincli/handler/keeper_deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ func (d *v20KeeperDeployer) SetKeepers(opts *bind.TransactOpts, cls []cmd.HTTPCl
offC, err := json.Marshal(offchain.OffchainConfig{
PerformLockoutWindow: 100 * 3 * 1000, // ~100 block lockout (on mumbai)
MinConfirmations: 1,
MercuryLookup: d.cfg.UpkeepType == config.Mercury,
})
if err != nil {
panic(err)
Expand Down Expand Up @@ -293,7 +292,7 @@ func (d *v21KeeperDeployer) SetKeepers(opts *bind.TransactOpts, cls []cmd.HTTPCl
offC, err := json.Marshal(offchain.OffchainConfig{
PerformLockoutWindow: 100 * 3 * 1000, // ~100 block lockout (on mumbai)
MinConfirmations: 1,
MercuryLookup: d.cfg.UpkeepType == config.Mercury,
MercuryLookup: d.cfg.UpkeepType == config.Mercury || d.cfg.UpkeepType == config.LogTriggeredFeedLookup,
})
if err != nil {
panic(err)
Expand Down Expand Up @@ -351,25 +350,27 @@ func (d *v21KeeperDeployer) SetKeepers(opts *bind.TransactOpts, cls []cmd.HTTPCl
{Name: "fallback_link_price", Type: "uint256"},
{Name: "transcoder", Type: "address"},
{Name: "registrars", Type: "address[]"},
{Name: "upkeep_privilege_manager", Type: "address"},
})
if err != nil {
return nil, fmt.Errorf("error creating onChainConfigType: %v", err)
}
var args gethabi.Arguments = []gethabi.Argument{{Type: onchainConfigType}}
onchainConfig, err := args.Pack(iregistry21.KeeperRegistryBase21OnchainConfig{
PaymentPremiumPPB: d.cfg.PaymentPremiumPBB,
FlatFeeMicroLink: d.cfg.PaymentPremiumPBB,
CheckGasLimit: d.cfg.CheckGasLimit,
StalenessSeconds: big.NewInt(d.cfg.StalenessSeconds),
GasCeilingMultiplier: d.cfg.GasCeilingMultiplier,
MinUpkeepSpend: big.NewInt(d.cfg.MinUpkeepSpend),
MaxPerformGas: d.cfg.MaxPerformGas,
MaxCheckDataSize: d.cfg.MaxCheckDataSize,
MaxPerformDataSize: d.cfg.MaxPerformDataSize,
FallbackGasPrice: big.NewInt(d.cfg.FallbackGasPrice),
FallbackLinkPrice: big.NewInt(d.cfg.FallbackLinkPrice),
Transcoder: common.HexToAddress(d.cfg.Transcoder),
Registrars: []common.Address{common.HexToAddress(d.cfg.Registrar)},
PaymentPremiumPPB: d.cfg.PaymentPremiumPBB,
FlatFeeMicroLink: d.cfg.PaymentPremiumPBB,
CheckGasLimit: d.cfg.CheckGasLimit,
StalenessSeconds: big.NewInt(d.cfg.StalenessSeconds),
GasCeilingMultiplier: d.cfg.GasCeilingMultiplier,
MinUpkeepSpend: big.NewInt(d.cfg.MinUpkeepSpend),
MaxPerformGas: d.cfg.MaxPerformGas,
MaxCheckDataSize: d.cfg.MaxCheckDataSize,
MaxPerformDataSize: d.cfg.MaxPerformDataSize,
FallbackGasPrice: big.NewInt(d.cfg.FallbackGasPrice),
FallbackLinkPrice: big.NewInt(d.cfg.FallbackLinkPrice),
Transcoder: common.HexToAddress(d.cfg.Transcoder),
Registrars: []common.Address{common.HexToAddress(d.cfg.Registrar)},
UpkeepPrivilegeManager: common.HexToAddress(d.cfg.UpkeepPrivilegeManager),
})
if err != nil {
return nil, fmt.Errorf("error packing onChainConfigType: %v", err)
Expand Down