Skip to content

Commit cc33ff2

Browse files
committed
drop onramp
1 parent 0d456f8 commit cc33ff2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+549
-2263
lines changed

chains/solana/contracts/Anchor.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ skip-lint = false
99
firedrill_compound = "Dri11NnBPbx85w8a47ZXBZa3Hi7E2xvHAA9Xpyk7UivQ"
1010
firedrill_entrypoint = "Dri11c6TXJXELaZUgQtyw3doxbn7bGXQ6z5LRZ8bMPbc"
1111
firedrill_offramp = "Dri11kiWR5f1oTn5NLm3wmfaDq3cYauR92wrsTxNaudt"
12-
firedrill_onramp = "Dri11Hs4x2gXThgDwvjYoZ7xEPgfKNa5Ys2MWUqay3Tt"
1312
firedrill_token = "Dri11r4S1hY8iMpxNh6UoYZ9hsGgmGUUyZ3zxUb2rpc2"
1413
failing_receiver = "Dri11EwVRViqqkjs7SWV3d3ejcanBGMNrcGhD6HVn756"
1514

chains/solana/contracts/Cargo.lock

Lines changed: 1 addition & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chains/solana/contracts/programs/failing_receiver/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anchor_lang::prelude::*;
22

3-
declare_id!("F6vRTFegLwFDD8aZ6nQ1q18wfif34WkJ6uBjKdMcpvz5");
3+
declare_id!("Dri11e51CFemqdySVVhmJbRzKeyVBJjch49RF2zH6Nt6");
44

55
#[program]
66
pub mod failing_receiver {

chains/solana/contracts/programs/firedrill_compound/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ default = []
1919
solana-program = "1.17.25" # pin solana to 1.17
2020
anchor-lang = { version = "0.29.0", features = ["init-if-needed"] }
2121
anchor-spl = "0.29.0"
22+
ethnum = "1.5"
2223
shared = { path = "../../crate/shared" }

chains/solana/contracts/programs/firedrill_compound/src/lib.rs

Lines changed: 68 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
use anchor_lang::prelude::*;
22
use shared::seed;
33

4-
declare_id!("F1G3cHLWhRtFQTnc7JaLNiEc5mFnkgDXo3Fobr8NcAiA");
4+
pub mod messages;
5+
use crate::messages::*;
56

7+
use ethnum::U256;
8+
9+
declare_id!("Dri11ePx1XJ5Eu3DRDFjgCf4ZqB98qzNrHzEwqx2jpqk");
10+
11+
// FiredrillCompound is Router, OnRamp, RMNRemote, FeeQuoter and TokenAdminRegistry
612
#[program]
713
pub mod firedrill_compound {
814
use super::*;
@@ -14,6 +20,39 @@ pub mod firedrill_compound {
1420
Ok(())
1521
}
1622

23+
pub fn emit_ccip_message_sent(
24+
ctx: Context<EmitMessage>,
25+
sender: Pubkey,
26+
index: u64,
27+
) -> Result<()> {
28+
let compound = &ctx.accounts.compound;
29+
let message = SVM2AnyRampMessage {
30+
header: RampMessageHeader {
31+
message_id: [0u8; 32],
32+
source_chain_selector: compound.chain_selector,
33+
dest_chain_selector: compound.chain_selector,
34+
sequence_number: index,
35+
nonce: 1,
36+
},
37+
sender,
38+
data: vec![],
39+
receiver: sender.to_bytes().to_vec(),
40+
extra_args: vec![],
41+
fee_token: compound.token,
42+
token_amounts: vec![],
43+
fee_token_amount: U256::from(0u64).into(),
44+
fee_value_juels: U256::from(0u64).into(),
45+
};
46+
47+
emit!(CCIPMessageSent {
48+
dest_chain_selector: compound.chain_selector,
49+
sequence_number: index,
50+
message,
51+
});
52+
53+
Ok(())
54+
}
55+
1756
pub fn emit_usd_per_token_updated(ctx: Context<EmitUsdPerToken>) -> Result<()> {
1857
let compound = &ctx.accounts.compound;
1958

@@ -33,22 +72,30 @@ pub mod firedrill_compound {
3372
}
3473
}
3574

36-
#[account]
37-
pub struct FiredrillCompound {
38-
pub owner: Pubkey,
39-
pub token: Pubkey,
40-
}
75+
#[account]
76+
pub struct FiredrillCompound {
77+
pub owner: Pubkey,
78+
pub chain_selector: u64,
79+
pub token: Pubkey,
80+
}
4181

42-
#[derive(Accounts)]
43-
pub struct Initialize<'info> {
44-
#[account(init, seeds = [seed::COMPOUND], bump, payer = authority, space = 8 + 32 + 32)]
45-
pub compound: Account<'info, FiredrillCompound>,
82+
#[derive(Accounts)]
83+
pub struct Initialize<'info> {
84+
#[account(init, seeds = [seed::COMPOUND], bump, payer = authority, space = 8 + 32 + 32)]
85+
pub compound: Account<'info, FiredrillCompound>,
4686

47-
#[account(mut)]
48-
pub authority: Signer<'info>,
87+
#[account(mut)]
88+
pub authority: Signer<'info>,
4989

50-
pub system_program: Program<'info, System>,
51-
}
90+
pub system_program: Program<'info, System>,
91+
}
92+
93+
#[derive(Accounts)]
94+
pub struct EmitMessage<'info> {
95+
#[account(mut, has_one = owner)]
96+
pub compound: Account<'info, FiredrillCompound>,
97+
pub owner: Signer<'info>,
98+
}
5299

53100
#[derive(Accounts)]
54101
pub struct EmitUsdPerToken<'info> {
@@ -57,6 +104,13 @@ pub struct EmitUsdPerToken<'info> {
57104
pub owner: Signer<'info>,
58105
}
59106

107+
#[event]
108+
pub struct CCIPMessageSent {
109+
pub dest_chain_selector: u64,
110+
pub sequence_number: u64,
111+
pub message: SVM2AnyRampMessage,
112+
}
113+
60114
#[event]
61115
pub struct UsdPerTokenUpdated {
62116
pub token: Pubkey,

chains/solana/contracts/programs/firedrill_onramp/src/messages.rs renamed to chains/solana/contracts/programs/firedrill_compound/src/messages.rs

File renamed without changes.

chains/solana/contracts/programs/firedrill_entrypoint/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,4 @@ solana-program = "1.17.25" # pin solana to 1.17
2121
anchor-lang = { version = "0.29.0", features = ["init-if-needed"] }
2222
anchor-spl = "0.29.0"
2323
shared = { path = "../../crate/shared" }
24-
firedrill_onramp = { path = "../firedrill_onramp", features = ["cpi"] }
25-
firedrill_offramp = { path = "../firedrill_offramp", features = ["cpi"] }
26-
firedrill_compound = { path = "../firedrill_compound", features = ["cpi"] }
2724

Lines changed: 2 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
use anchor_lang::prelude::*;
22
use shared::seed;
33

4-
use firedrill_compound::program::FiredrillCompound;
5-
use firedrill_offramp::cpi::accounts::EmitCommitReport as OffRampCommitReport;
6-
use firedrill_offramp::program::FiredrillOfframp;
7-
use firedrill_onramp::cpi::accounts::EmitMessage as OnRampEmitMessage;
8-
use firedrill_onramp::program::FiredrillOnramp;
9-
10-
declare_id!("F2dazhBjqX19HZBLvEHoToeggmDMj8xu3gaKkZ9YEpkU");
4+
declare_id!("Dri11jJrhAN5DEr3b47WqFh6jvskcq4TT8ZWBJuvCphX");
115

126
#[program]
137
pub mod firedrill_entrypoint {
@@ -17,7 +11,6 @@ pub mod firedrill_entrypoint {
1711
ctx: Context<Initialize>,
1812
chain_selector: u64,
1913
token: Pubkey,
20-
on_ramp: Pubkey,
2114
off_ramp: Pubkey,
2215
compound: Pubkey,
2316
receiver: Pubkey,
@@ -26,85 +19,12 @@ pub mod firedrill_entrypoint {
2619
state.owner = ctx.accounts.authority.key();
2720
state.chain_selector = chain_selector;
2821
state.token = token;
29-
state.on_ramp = on_ramp;
3022
state.off_ramp = off_ramp;
3123
state.compound = compound;
3224
state.receiver = receiver;
3325
state.send_last = 0;
3426
Ok(())
3527
}
36-
37-
pub fn prepare_register(ctx: Context<PrepareRegister>) -> Result<()> {
38-
firedrill_offramp::cpi::emit_source_chain_added(CpiContext::new(
39-
ctx.accounts.offramp_program.to_account_info(),
40-
firedrill_offramp::cpi::accounts::EmitConfig {
41-
offramp: ctx.accounts.offramp.to_account_info(),
42-
owner: ctx.accounts.owner.to_account_info(),
43-
},
44-
))
45-
}
46-
47-
pub fn drill_pending_commit_queue_tx_spike(
48-
ctx: Context<OnlyOwner>,
49-
from: u8,
50-
to: u8,
51-
) -> Result<()> {
52-
let ep = &mut ctx.accounts.entrypoint;
53-
54-
require!(from <= to, CustomError::NothingToSend);
55-
require!(from > ep.send_last, CustomError::AlreadySent);
56-
57-
for i in from..=to {
58-
firedrill_onramp::cpi::emit_ccip_message_sent(
59-
CpiContext::new(
60-
ctx.accounts.onramp_program.to_account_info(),
61-
OnRampEmitMessage {
62-
onramp: ctx.accounts.onramp.to_account_info(),
63-
owner: ctx.accounts.owner.to_account_info(),
64-
},
65-
),
66-
ctx.program_id.key(),
67-
i as u64,
68-
)?;
69-
}
70-
71-
ep.send_last = to;
72-
Ok(())
73-
}
74-
75-
pub fn drill_pending_execution(ctx: Context<OnlyOwner>, from: u8, to: u8) -> Result<()> {
76-
require!(from <= to, CustomError::NothingToSend);
77-
require!(
78-
to <= ctx.accounts.entrypoint.send_last,
79-
CustomError::NotYetSent
80-
);
81-
82-
firedrill_offramp::cpi::emit_commit_report_accepted(
83-
CpiContext::new(
84-
ctx.accounts.offramp_program.to_account_info(),
85-
OffRampCommitReport {
86-
offramp: ctx.accounts.offramp.to_account_info(),
87-
owner: ctx.accounts.owner.to_account_info(),
88-
},
89-
),
90-
from.into(),
91-
to.into(),
92-
)?;
93-
94-
Ok(())
95-
}
96-
97-
pub fn drill_price_registries(ctx: Context<OnlyOwner>) -> Result<()> {
98-
firedrill_compound::cpi::emit_usd_per_token_updated(CpiContext::new(
99-
ctx.accounts.compound_program.to_account_info(),
100-
firedrill_compound::cpi::accounts::EmitUsdPerToken {
101-
compound: ctx.accounts.compound.to_account_info(),
102-
owner: ctx.accounts.owner.to_account_info(),
103-
},
104-
))?;
105-
106-
Ok(())
107-
}
10828
}
10929

11030
#[account]
@@ -113,7 +33,6 @@ pub struct FiredrillEntrypoint {
11333
pub owner: Pubkey,
11434
pub chain_selector: u64,
11535
pub token: Pubkey,
116-
pub on_ramp: Pubkey,
11736
pub off_ramp: Pubkey,
11837
pub compound: Pubkey,
11938
pub receiver: Pubkey,
@@ -127,53 +46,4 @@ pub struct Initialize<'info> {
12746
#[account(mut)]
12847
pub authority: Signer<'info>,
12948
pub system_program: Program<'info, System>,
130-
}
131-
132-
#[derive(Accounts)]
133-
pub struct PrepareRegister<'info> {
134-
#[account(mut, has_one = owner)]
135-
pub entrypoint: Account<'info, FiredrillEntrypoint>,
136-
137-
/// CHECK: account is passed to the OffRamp CPI, verified inside that program
138-
#[account(mut)]
139-
pub offramp: AccountInfo<'info>,
140-
141-
/// CHECK: only passed to CPI, validated in called program
142-
pub owner: Signer<'info>,
143-
144-
/// CHECK: CPI target program
145-
pub offramp_program: Program<'info, FiredrillOfframp>,
146-
}
147-
148-
#[derive(Accounts)]
149-
pub struct OnlyOwner<'info> {
150-
#[account(mut, has_one = owner)]
151-
pub entrypoint: Account<'info, FiredrillEntrypoint>,
152-
pub owner: Signer<'info>,
153-
154-
/// CHECK: CPI
155-
#[account(mut)]
156-
pub onramp: AccountInfo<'info>,
157-
158-
/// CHECK: CPI
159-
#[account(mut)]
160-
pub offramp: AccountInfo<'info>,
161-
162-
/// CHECK: CPI
163-
#[account(mut)]
164-
pub compound: AccountInfo<'info>,
165-
166-
pub onramp_program: Program<'info, FiredrillOnramp>,
167-
pub offramp_program: Program<'info, FiredrillOfframp>,
168-
pub compound_program: Program<'info, FiredrillCompound>,
169-
}
170-
171-
#[error_code]
172-
pub enum CustomError {
173-
#[msg("Nothing to send.")]
174-
NothingToSend,
175-
#[msg("Message already sent.")]
176-
AlreadySent,
177-
#[msg("Message not yet sent.")]
178-
NotYetSent,
179-
}
49+
}

chains/solana/contracts/programs/firedrill_offramp/src/context.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::program::FiredrillOfframp;
2-
use crate::{CcipOfframpError, Config};
2+
use crate::{CcipOfframpError, Config, SourceChain};
33
use anchor_lang::prelude::*;
44
use bytemuck::{Pod, Zeroable};
55
use shared::seed;
@@ -8,7 +8,17 @@ use shared::seed;
88
pub const ANCHOR_DISCRIMINATOR: usize = 8;
99

1010
#[derive(Accounts)]
11+
#[instruction(svm_chain_selector: u64)]
1112
pub struct InitializeConfig<'info> {
13+
#[account(
14+
init,
15+
seeds = [seed::SOURCE_CHAIN, svm_chain_selector.to_le_bytes().as_ref()],
16+
bump,
17+
payer = authority,
18+
space = ANCHOR_DISCRIMINATOR + SourceChain::INIT_SPACE,
19+
)]
20+
pub source_chain: Account<'info, SourceChain>,
21+
1222
#[account(
1323
init,
1424
seeds = [seed::CONFIG],

0 commit comments

Comments
 (0)