Skip to content

Commit

Permalink
update VL contracts to work with 2.1 (#9673)
Browse files Browse the repository at this point in the history
* update VL contracts to work with 2.1

* fix
  • Loading branch information
FelixFan1992 committed Jul 6, 2023
1 parent d41c961 commit 1e79dcf
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 36 deletions.
2 changes: 1 addition & 1 deletion contracts/src/v0.8/tests/VerifiableLoadBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -155,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
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

0 comments on commit 1e79dcf

Please sign in to comment.