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

Offchain config version fixed on Flow Commands #76

Merged
merged 1 commit into from
Dec 29, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import CommitOffchainConfig from './offchainConfig/commit'
import SetConfig from './setConfig'
import SetBilling from './setBilling'
import { logger, prompt } from '@chainlink/gauntlet-core/dist/utils'
import OCR2Inspect from './inspection/inspect'
export default class OCR2InitializeFlow extends FlowCommand<TransactionResponse> {
static id = 'ocr2:initialize:flow'
static category = CONTRACT_LIST.OCR_2
static examples = [
'yarn gauntlet ocr2:initialize:flow --network=local --id=[ID] --rdd=[PATH_TO_RDD] --version=[OFFCHAIN_CONFIG_VERSION(optional)]',
]
static examples = ['yarn gauntlet ocr2:initialize:flow --network=local --id=[ID] --rdd=[PATH_TO_RDD]']

constructor(flags, args) {
super(flags, args, waitExecute, makeAbstractCommand)
Expand Down Expand Up @@ -44,7 +43,7 @@ export default class OCR2InitializeFlow extends FlowCommand<TransactionResponse>
command: BeginOffchainConfig,
flags: {
state: FlowCommand.ID.contract(this.stepIds.OCR_2),
version: this.flags.version || 1,
version: 2,
},
},
{
Expand Down Expand Up @@ -83,6 +82,16 @@ export default class OCR2InitializeFlow extends FlowCommand<TransactionResponse>
state: FlowCommand.ID.contract(this.stepIds.OCR_2),
},
},
{
name: 'Inspection',
command: OCR2Inspect,
flags: {
state: FlowCommand.ID.contract(this.stepIds.OCR_2),
billingAccessController: process.env.BILLING_ACCESS_CONTROLLER || this.flags.billingAccessController,
requesterAccessController: process.env.REQUESTER_ACCESS_CONTROLLER || this.flags.requesterAccessController,
link: process.env.LINK || this.flags.link,
},
},
]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ export default class OCR2Inspect extends SolanaCommand {
const rdd = getRDD(this.flags.rdd)
const info = rdd.contracts[this.flags.state]
const aggregatorOperators: string[] = info.oracles.map((o) => o.operator)
const transmitters = aggregatorOperators.map((operator) => rdd.operators[operator].nodeAddress[0])
const billingAccessController =
this.flags.billingAccessController || process.env.BILLING_ADMIN_ACCESS_CONTROLLER_ADDRESS
const requesterAccessController =
this.flags.requesterAccessController || process.env.REQUESTER_ADMIN_ACCESS_CONTROLLER_ADDRESS
const link = this.flags.link || process.env.LINK_ADDRESS
const transmitters = aggregatorOperators.map((operator) => rdd.operators[operator].ocrNodeAddress[0])
const billingAccessController = this.flags.billingAccessController || process.env.BILLING_ACCESS_CONTROLLER
const requesterAccessController = this.flags.requesterAccessController || process.env.REQUESTER_ACCESS_CONTROLLER
const link = this.flags.link || process.env.LINK
const offchainConfig = WriteOffchainConfig.makeInputFromRDD(rdd, this.flags.state)
return {
description: info.name,
Expand Down Expand Up @@ -80,6 +78,11 @@ export default class OCR2Inspect extends SolanaCommand {
)

const onChainOCRConfig = this.deserializeConfig(bufferedConfig)
const wrappedComparableLongNumber = (v: any) => {
// Proto encoding will ignore falsy values.
if (!v) return '0'
return toComparableLongNumber(v)
}
const longNumberInspections = [
'deltaProgressNanoseconds',
'deltaResendNanoseconds',
Expand All @@ -93,7 +96,7 @@ export default class OCR2Inspect extends SolanaCommand {
'maxDurationShouldTransmitAcceptedReportNanoseconds',
].map((prop) =>
inspection.makeInspection(
toComparableLongNumber(onChainOCRConfig[prop]),
wrappedComparableLongNumber(onChainOCRConfig[prop]),
toComparableNumber(input.offchainConfig[prop]),
`Offchain Config "${prop}"`,
),
Expand Down Expand Up @@ -129,7 +132,7 @@ export default class OCR2Inspect extends SolanaCommand {
inspection.makeInspection(
toComparablePubKey(onChainState.config.billingAccessController),
toComparablePubKey(input.billingAccessController),
'Requester access controller',
'Billing access controller',
),
inspection.makeInspection(
onChainState.oracles.xs
Expand Down Expand Up @@ -158,17 +161,17 @@ export default class OCR2Inspect extends SolanaCommand {
'Offchain Config "reportingPluginConfig.alphaAcceptInfinite"',
),
inspection.makeInspection(
toComparableLongNumber(onChainOCRConfig.reportingPluginConfig.alphaReportPpb),
wrappedComparableLongNumber(onChainOCRConfig.reportingPluginConfig.alphaReportPpb),
toComparableNumber(input.offchainConfig.reportingPluginConfig.alphaReportPpb),
`Offchain Config "reportingPluginConfig.alphaReportPpb"`,
),
inspection.makeInspection(
toComparableLongNumber(onChainOCRConfig.reportingPluginConfig.alphaAcceptPpb),
wrappedComparableLongNumber(onChainOCRConfig.reportingPluginConfig.alphaAcceptPpb),
toComparableNumber(input.offchainConfig.reportingPluginConfig.alphaAcceptPpb),
`Offchain Config "reportingPluginConfig.alphaAcceptPpb"`,
),
inspection.makeInspection(
toComparableLongNumber(onChainOCRConfig.reportingPluginConfig.deltaCNanoseconds),
wrappedComparableLongNumber(onChainOCRConfig.reportingPluginConfig.deltaCNanoseconds),
toComparableNumber(input.offchainConfig.reportingPluginConfig.deltaCNanoseconds),
`Offchain Config "reportingPluginConfig.deltaCNanoseconds"`,
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Result } from '@chainlink/gauntlet-core'
import { logger } from '@chainlink/gauntlet-core/dist/utils'
import { logger, prompt } from '@chainlink/gauntlet-core/dist/utils'
import { SolanaCommand, TransactionResponse } from '@chainlink/gauntlet-solana'
import { PublicKey } from '@solana/web3.js'
import BN from 'bn.js'
Expand Down Expand Up @@ -27,6 +27,8 @@ export default class BeginOffchainConfig extends SolanaCommand {
const state = new PublicKey(this.flags.state)
const owner = this.wallet.payer

await prompt(`Begin setting Offchain config version ${this.flags.version}?`)

const tx = await program.rpc.beginOffchainConfig(new BN(this.flags.version), {
accounts: {
state: state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import CommitOffchainConfig from './commit'
export default class SetOffchainConfigFlow extends FlowCommand<TransactionResponse> {
static id = 'ocr2:set_offchain_config:flow'
static category = CONTRACT_LIST.OCR_2
static examples = ['yarn gauntlet ocr2:set_offchain_config:flow --network=local --version=1 --rdd=[PATH_TO_RDD]']
static examples = ['yarn gauntlet ocr2:set_offchain_config:flow --network=local --rdd=[PATH_TO_RDD]']

constructor(flags, args) {
super(flags, args, waitExecute, makeAbstractCommand)
Expand All @@ -20,6 +20,9 @@ export default class SetOffchainConfigFlow extends FlowCommand<TransactionRespon
{
name: 'Begin Offchain Config',
command: BeginOffchainConfig,
flags: {
version: 2,
},
},
{
name: 'Write Offchain Config',
Expand Down