Skip to content

Commit

Permalink
miscellaneous fixes to gauntlet + updates to local env (#399)
Browse files Browse the repository at this point in the history
* fix gauntlet parameters + add validation, update local env

* fix create feed logging, test no-historical feed

* yarn format
  • Loading branch information
aalu1418 authored Sep 22, 2022
1 parent ff2d8b4 commit 2dea18d
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ nodejs 14.19.1
rust 1.59.0
golang 1.18
golangci-lint 1.45.2
pulumi 3.25.1
pulumi 3.40.1
ginkgo 2.1.4
actionlint 1.6.15
shellcheck 0.8.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ export default class AcceptProposal extends SolanaCommand {
contractInput: ContractInput

makeInput = (userInput): Input => {
// validate LINK address present
this.require(this.flags.link || process.env.LINK, 'LINK token not found')

if (userInput) return userInput as Input
const rdd = RDD.load(this.flags.network, this.flags.rdd)
const aggregator = rdd.contracts[this.args[0]]
Expand Down Expand Up @@ -210,7 +213,7 @@ export default class AcceptProposal extends SolanaCommand {

makeRawTransaction = async (signer: PublicKey) => {
const linkPublicKey = new PublicKey(this.flags.link || process.env.LINK)
const tokenRecipient = await getOrCreateAssociatedTokenAccount(
const tokenReceiver = await getOrCreateAssociatedTokenAccount(
this.provider.connection,
this.wallet.payer,
linkPublicKey,
Expand All @@ -225,7 +228,7 @@ export default class AcceptProposal extends SolanaCommand {
proposal: new PublicKey(this.input.proposalId),
receiver: signer,
authority: signer,
tokenRecipient: tokenRecipient.address,
tokenReceiver: tokenReceiver.address,
tokenVault: this.contractInput.tokenVault,
vaultAuthority: this.contractInput.vaultAuthority,
tokenProgram: TOKEN_PROGRAM_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ type Input = {
payee: string
}[]
proposalId: string
// Allows to set payees that do not have a token generated address
allowFundRecipient?: boolean
}

type ContractInput = {
Expand Down Expand Up @@ -48,7 +46,6 @@ export default class ProposePayees extends SolanaCommand {

return {
operators,
allowFundRecipient: false,
proposalId: this.flags.proposalId || this.flags.configProposal,
}
}
Expand Down Expand Up @@ -103,10 +100,7 @@ export default class ProposePayees extends SolanaCommand {
)
).every((isValid) => isValid)

this.require(
areValidPayees || !!this.input.allowFundRecipient,
'Every payee needs to have a valid token recipient address',
)
this.require(areValidPayees, 'Every payee needs to have a valid token recipient address')

// Set the payees in the same order the oracles are saved in the proposal
// The length of the payees need to be same as the oracles saved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export default class SetBilling extends SolanaCommand {
input: Input

makeInput = (userInput: any): Input => {
// validate LINK address present
this.require(this.flags.link || process.env.LINK, 'LINK token not found')

if (userInput) return userInput as Input
const rdd = RDD.load(this.flags.network, this.flags.rdd)
const billingInfo = rdd.contracts[this.args[0]]?.billing
Expand Down Expand Up @@ -60,7 +63,7 @@ export default class SetBilling extends SolanaCommand {
const info = (await this.program.account.state.fetch(state)) as any

const linkPublicKey = new PublicKey(this.flags.link || process.env.LINK)
const tokenRecipient = await getOrCreateAssociatedTokenAccount(
const tokenReceiver = await getOrCreateAssociatedTokenAccount(
this.provider.connection,
this.wallet.payer,
linkPublicKey,
Expand All @@ -83,7 +86,7 @@ export default class SetBilling extends SolanaCommand {
state,
authority: signer,
accessController: billingAC,
tokenRecipient: tokenRecipient.address,
tokenReceiver: tokenReceiver.address,
tokenVault: tokenVault,
vaultAuthority: vaultAuthority,
tokenProgram: TOKEN_PROGRAM_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,18 @@ export default class CreateFeed extends SolanaCommand {
const description = input.description || ''

this.require(
feedAccountLength.gte(liveLength),
`Feed account Length (${feedAccountLength.toNumber()}) must be greater than liveLength (${liveLength.toNumber()})`,
length.gte(liveLength),
`Feed account Length (${length.toNumber()}) must be greater than liveLength (${liveLength.toNumber()})`,
)

logger.info(`
- Decimals: ${decimals}
- Description: ${description}
- Live Length: ${liveLength.toNumber()}
- Granularity (historical): ${granularity.toNumber()}
- Historical Length: ${feedAccountLength.toNumber() - liveLength.toNumber()}
- Total Length: ${feedAccountLength.toNumber()}
- Historical Length: ${length.toNumber() - liveLength.toNumber()}
- Total Length: ${length.toNumber()}
- Total Account Size: ${feedAccountLength.toNumber()}
- Feed Account: ${feed.toString()}
`)

Expand Down
37 changes: 28 additions & 9 deletions ops/solana/solana.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@ const (
LINK
StoreAuthority
Proposal

// deployer accounts
DeployerAccount
AssociatedTokenAccount
)

const (
testingSecret = "this is an testing only secret"
deployer = "./localnet.json"
)

type Deployer struct {
Expand Down Expand Up @@ -107,8 +112,6 @@ func deployProgram(program string, deployerKeyfile string, expectedAddress strin
}

func (d *Deployer) Load() error {
deployer := "./localnet.json"

// create key if doesn't exist
msg := relayUtils.LogStatus(fmt.Sprintf("create program deployer key at '%s'", deployer))
if _, err := os.Stat(deployer); err != nil {
Expand All @@ -130,7 +133,8 @@ func (d *Deployer) Load() error {
if err != nil {
return errors.Wrapf(err, "failed to parse pubkey from '%s'", deployer)
}
if err := d.Fund([]string{filterAlphaNumeric(string(out))}); err != nil {
d.Account[DeployerAccount] = filterAlphaNumeric(string(out))
if err := d.Fund([]string{d.Account[DeployerAccount]}); err != nil {
return errors.Wrap(err, "failed to fund program deployer")
}

Expand Down Expand Up @@ -171,6 +175,19 @@ func (d *Deployer) DeployLINK() error {
linkAddress := report.Responses[0].Contract
d.Account[LINK] = linkAddress

// create associated token account for payee
msg := relayUtils.LogStatus(fmt.Sprintf("created associated LINK token (%s) account for %s", d.Account[LINK], d.Account[DeployerAccount]))
out, err := exec.Command("spl-token", "create-account", d.Account[LINK], "--owner", d.Account[DeployerAccount], "--fee-payer", deployer).Output()
if err == nil {
// output structure: Creating account <associated-token-account> ...etc
d.Account[AssociatedTokenAccount] = strings.Fields(string(out))[2]
fmt.Printf(": %s", d.Account[AssociatedTokenAccount])
}

if msg.Check(err) != nil {
return err
}

return nil
}

Expand Down Expand Up @@ -222,8 +239,8 @@ func (d *Deployer) DeployOCR() error {
fmt.Println("Step 4: Create Feed")
input := map[string]interface{}{
"store": d.Account[StoreAccount],
"granularity": 30,
"liveLength": 1024,
"granularity": 1, // granularity > 0
"liveLength": 10,
"decimals": 8,
"description": "Test LINK/USD",
}
Expand All @@ -237,6 +254,7 @@ func (d *Deployer) DeployOCR() error {
"store:create_feed",
d.gauntlet.Flag("network", d.network),
d.gauntlet.Flag("input", string(jsonInput)),
d.gauntlet.Flag("length", "10"),
)
if err != nil {
return errors.Wrap(err, "'store:create_feed' call failed")
Expand Down Expand Up @@ -366,6 +384,7 @@ func (d Deployer) InitOCR(keys []opsChainlink.NodeKeys) error {
"ocr2:set_billing",
d.gauntlet.Flag("network", d.network),
d.gauntlet.Flag("input", string(jsonInput)),
d.gauntlet.Flag("link", d.Account[LINK]),
d.Account[OCRFeed],
); err != nil {
return errors.Wrap(err, "'ocr2:set_billing' call failed")
Expand Down Expand Up @@ -408,7 +427,7 @@ func (d Deployer) InitOCR(keys []opsChainlink.NodeKeys) error {
oracles = append(oracles, map[string]string{
"signer": k.OCR2OnchainPublicKey,
"transmitter": k.OCR2Transmitter,
"payee": k.OCR2Transmitter, // payee is the same as transmitter
"payee": d.Account[AssociatedTokenAccount], // payee is the associated token account of deployer
})
}

Expand Down Expand Up @@ -485,9 +504,8 @@ func (d Deployer) InitOCR(keys []opsChainlink.NodeKeys) error {

fmt.Println("Proposing Payees...")
input = map[string]interface{}{
"operators": oracles,
"proposalId": d.Account[Proposal],
"allowFundRecipient": true,
"operators": oracles,
"proposalId": d.Account[Proposal],
}

jsonInput, err = json.Marshal(input)
Expand Down Expand Up @@ -534,6 +552,7 @@ func (d Deployer) InitOCR(keys []opsChainlink.NodeKeys) error {
d.gauntlet.Flag("network", d.network),
d.gauntlet.Flag("proposalId", d.Account[Proposal]),
d.gauntlet.Flag("secret", testingSecret),
d.gauntlet.Flag("link", d.Account[LINK]),
d.gauntlet.Flag("input", string(jsonInput)),
d.Account[OCRFeed],
); err != nil {
Expand Down

0 comments on commit 2dea18d

Please sign in to comment.