diff --git a/contracts/programs/ocr2/src/context.rs b/contracts/programs/ocr2/src/context.rs index 7422f8724..828987372 100644 --- a/contracts/programs/ocr2/src/context.rs +++ b/contracts/programs/ocr2/src/context.rs @@ -80,7 +80,7 @@ pub struct CloseProposal<'info> { } #[derive(Accounts)] -pub struct SetConfig<'info> { +pub struct ProposeConfig<'info> { #[account(mut)] pub proposal: AccountLoader<'info, Proposal>, pub authority: Signer<'info>, diff --git a/contracts/programs/ocr2/src/lib.rs b/contracts/programs/ocr2/src/lib.rs index 315b0d862..d84a1a111 100644 --- a/contracts/programs/ocr2/src/lib.rs +++ b/contracts/programs/ocr2/src/lib.rs @@ -83,7 +83,7 @@ pub mod ocr2 { Ok(()) } - pub fn create_config_proposal( + pub fn create_proposal( ctx: Context, offchain_config_version: u64, ) -> ProgramResult { @@ -99,7 +99,7 @@ pub mod ocr2 { #[access_control(proposal_owner(&ctx.accounts.proposal, &ctx.accounts.authority))] pub fn write_offchain_config( - ctx: Context, + ctx: Context, offchain_config: Vec, ) -> ProgramResult { let mut proposal = ctx.accounts.proposal.load_mut()?; @@ -114,7 +114,7 @@ pub mod ocr2 { } #[access_control(proposal_owner(&ctx.accounts.proposal, &ctx.accounts.authority))] - pub fn commit_config_proposal(ctx: Context) -> ProgramResult { + pub fn finalize_proposal(ctx: Context) -> ProgramResult { let mut proposal = ctx.accounts.proposal.load_mut()?; require!(proposal.state != Proposal::FINALIZED, InvalidInput); @@ -138,13 +138,13 @@ pub mod ocr2 { } #[access_control(proposal_owner(&ctx.accounts.proposal, &ctx.accounts.authority))] - pub fn close_config_proposal(ctx: Context) -> ProgramResult { + pub fn close_proposal(ctx: Context) -> ProgramResult { // NOTE: Close is handled by anchor on exit due to the `close` attribute Ok(()) } #[access_control(owner(&ctx.accounts.state, &ctx.accounts.authority))] - pub fn accept_config_proposal<'info>( + pub fn accept_proposal<'info>( ctx: Context<'_, '_, '_, 'info, AcceptProposal<'info>>, ) -> ProgramResult { let mut state = ctx.accounts.state.load_mut()?; @@ -159,7 +159,7 @@ pub mod ocr2 { let latest_round_id = state.config.latest_aggregator_round_id; let billing = state.config.billing; - // NOTE: if multisig supported multi instruction transactions, this could be [pay_oracles, accept_config_proposal] + // NOTE: if multisig supported multi instruction transactions, this could be [pay_oracles, accept_proposal] let payments: Vec<(u64, CpiContext<'_, '_, '_, 'info, token::Transfer<'info>>)> = state .oracles .iter_mut() @@ -268,8 +268,8 @@ pub mod ocr2 { } #[access_control(proposal_owner(&ctx.accounts.proposal, &ctx.accounts.authority))] - pub fn set_config( - ctx: Context, + pub fn propose_config( + ctx: Context, new_oracles: Vec, f: u8, ) -> ProgramResult { @@ -280,7 +280,7 @@ pub mod ocr2 { let mut proposal = ctx.accounts.proposal.load_mut()?; require!(proposal.state != Proposal::FINALIZED, InvalidInput); - // begin_config_proposal must be called first + // begin_proposal must be called first require!(proposal.offchain_config.version != 0, InvalidInput); // Clear out old oracles @@ -321,8 +321,8 @@ pub mod ocr2 { } #[access_control(proposal_owner(&ctx.accounts.proposal, &ctx.accounts.authority))] - pub fn set_payees( - ctx: Context, + pub fn propose_payees( + ctx: Context, token_mint: Pubkey, payees: Vec, ) -> ProgramResult { diff --git a/contracts/tests/ocr2.spec.ts b/contracts/tests/ocr2.spec.ts index f2d95becc..3ed862343 100644 --- a/contracts/tests/ocr2.spec.ts +++ b/contracts/tests/ocr2.spec.ts @@ -83,7 +83,7 @@ describe("ocr2", async () => { let oracles = []; const f = 6; - // NOTE: 17 is the most we can fit into one setConfig if we use a different payer + // NOTE: 17 is the most we can fit into one proposeConfig if we use a different payer // if the owner == payer then we can fit 19 const n = 19; // min: 3 * f + 1; @@ -496,8 +496,8 @@ describe("ocr2", async () => { // TODO: listen for SetConfig event let proposal = Keypair.generate(); - console.log("createConfigProposal"); - await program.rpc.createConfigProposal(new BN(offchain_config_version), { + console.log("createProposal"); + await program.rpc.createProposal(new BN(offchain_config_version), { accounts: { proposal: proposal.publicKey, authority: owner.publicKey, @@ -507,8 +507,8 @@ describe("ocr2", async () => { await program.account.proposal.createInstruction(proposal), ], }); - console.log("setConfig"); - await program.rpc.setConfig( + console.log("proposeConfig"); + await program.rpc.proposeConfig( oracles.map((oracle) => ({ signer: ethereumAddress(Buffer.from(oracle.signer.publicKey)), transmitter: oracle.transmitter.publicKey, @@ -537,8 +537,8 @@ describe("ocr2", async () => { }, }); - console.log("setPayees"); - await program.rpc.setPayees( + console.log("proposePayees"); + await program.rpc.proposePayees( token.publicKey, oracles.map((oracle) => oracle.payee.address), { @@ -549,8 +549,8 @@ describe("ocr2", async () => { } ); - console.log("commitConfigProposal"); - await program.rpc.commitConfigProposal({ + console.log("finalizeProposal"); + await program.rpc.finalizeProposal({ accounts: { proposal: proposal.publicKey, authority: owner.publicKey, @@ -563,8 +563,8 @@ describe("ocr2", async () => { return { pubkey: oracle.payee, isWritable: true, isSigner: false }; }); - console.log("approveConfigProposal"); - await program.rpc.acceptConfigProposal({ + console.log("approveProposal"); + await program.rpc.acceptProposal({ accounts: { state: state.publicKey, proposal: proposal.publicKey, @@ -586,9 +586,9 @@ describe("ocr2", async () => { [4, 5, 6, 4, 5, 6] ); - // Proposal already closed by acceptConfigProposal - // console.log("closeConfigProposal"); - // await program.rpc.closeConfigProposal( + // Proposal already closed by acceptProposal + // console.log("closeProposal"); + // await program.rpc.closeProposal( // { // accounts: { // proposal: proposal.publicKey, @@ -622,7 +622,7 @@ describe("ocr2", async () => { it("Can't begin config proposal if version is 0", async () => { try { - await program.rpc.createConfigProposal(new BN(0), { + await program.rpc.createProposal(new BN(0), { accounts: { proposal: proposal.publicKey, authority: owner.publicKey, @@ -632,7 +632,7 @@ describe("ocr2", async () => { // createOffchainConfig should fail return; } - assert.fail("createConfigProposal shouldn't have succeeded!"); + assert.fail("createProposal shouldn't have succeeded!"); }); it("Can't write offchain config if begin has not been called", async () => { @@ -653,7 +653,7 @@ describe("ocr2", async () => { // it("ResetPendingOffchainConfig clears pending state", async () => { - // await program.rpc.createConfigProposal( + // await program.rpc.createProposal( // new BN(2), // { // accounts: {