Skip to content

Commit

Permalink
network: Fix stack overflow (#17)
Browse files Browse the repository at this point in the history
* network: Fix stack overflow

* Fix some intructions
  • Loading branch information
Aursen authored Feb 21, 2024
1 parent eca6aa6 commit 29a94e5
Show file tree
Hide file tree
Showing 35 changed files with 105 additions and 94 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ rayon = "1.7.0"
regex = "1.7.1"
async-trait = "0.1.64"
rustc_version = "0.4.0"
bytemuck = "1.4.0"
1 change: 1 addition & 0 deletions programs/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ default = []
anchor-lang.workspace = true
anchor-spl = { features = ["mint", "token"], workspace = true }
sablier-utils.workspace = true
bytemuck = { workspace = true, features = ["derive", "min_const_generics"] }
2 changes: 1 addition & 1 deletion programs/network/src/instructions/config_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct ConfigUpdate<'info> {
bump,
has_one = admin
)]
pub config: Account<'info, Config>,
pub config: AccountLoader<'info, Config>,
}

pub fn handler(ctx: Context<ConfigUpdate>, settings: ConfigSettings) -> Result<()> {
Expand Down
4 changes: 2 additions & 2 deletions programs/network/src/instructions/delegation_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct DelegationCreate<'info> {
pub authority: Signer<'info>,

#[account(address = Config::pubkey())]
pub config: Account<'info, Config>,
pub config: AccountLoader<'info, Config>,

#[account(
init,
Expand All @@ -36,7 +36,7 @@ pub struct DelegationCreate<'info> {
)]
pub delegation_tokens: Account<'info, TokenAccount>,

#[account(address = config.mint)]
#[account(address = config.load()?.mint)]
pub mint: Account<'info, Mint>,

#[account(
Expand Down
6 changes: 3 additions & 3 deletions programs/network/src/instructions/delegation_deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ pub struct DelegationDeposit<'info> {
#[account(
mut,
associated_token::authority = authority,
associated_token::mint = config.mint,
associated_token::mint = config.load()?.mint,
)]
pub authority_tokens: Account<'info, TokenAccount>,

#[account(address = Config::pubkey())]
pub config: Account<'info, Config>,
pub config: AccountLoader<'info, Config>,

#[account(
mut,
Expand All @@ -35,7 +35,7 @@ pub struct DelegationDeposit<'info> {
#[account(
mut,
associated_token::authority = delegation,
associated_token::mint = config.mint,
associated_token::mint = config.load()?.mint,
)]
pub delegation_tokens: Account<'info, TokenAccount>,

Expand Down
6 changes: 3 additions & 3 deletions programs/network/src/instructions/delegation_withdraw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ pub struct DelegationWithdraw<'info> {
#[account(
mut,
associated_token::authority = authority,
associated_token::mint = config.mint,
associated_token::mint = config.load()?.mint,
)]
pub authority_tokens: Account<'info, TokenAccount>,

#[account(address = Config::pubkey())]
pub config: Account<'info, Config>,
pub config: AccountLoader<'info, Config>,

#[account(
mut,
Expand All @@ -35,7 +35,7 @@ pub struct DelegationWithdraw<'info> {
#[account(
mut,
associated_token::authority = delegation,
associated_token::mint = config.mint,
associated_token::mint = config.load()?.mint,
)]
pub delegation_tokens: Account<'info, TokenAccount>,

Expand Down
2 changes: 1 addition & 1 deletion programs/network/src/instructions/initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct Initialize<'info> {
payer = admin,
space = 8 + Config::INIT_SPACE,
)]
pub config: Account<'info, Config>,
pub config: AccountLoader<'info, Config>,

pub mint: Account<'info, Mint>,

Expand Down
4 changes: 2 additions & 2 deletions programs/network/src/instructions/penalty_claim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use {

#[derive(Accounts)]
pub struct PenaltyClaim<'info> {
#[account(address = config.admin)]
#[account(address = config.load()?.admin)]
pub admin: Signer<'info>,

#[account(address = Config::pubkey())]
pub config: Account<'info, Config>,
pub config: AccountLoader<'info, Config>,

#[account(mut)]
pub pay_to: SystemAccount<'info>,
Expand Down
4 changes: 2 additions & 2 deletions programs/network/src/instructions/pool_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ use {

#[derive(Accounts)]
pub struct PoolCreate<'info> {
#[account(address = config.admin)]
#[account(address = config.load()?.admin)]
pub admin: Signer<'info>,

#[account(
address = Config::pubkey(),
has_one = admin
)]
pub config: Account<'info, Config>,
pub config: AccountLoader<'info, Config>,

#[account(mut)]
pub payer: Signer<'info>,
Expand Down
2 changes: 1 addition & 1 deletion programs/network/src/instructions/pool_rotate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use {
#[derive(Accounts)]
pub struct PoolRotate<'info> {
#[account(address = Config::pubkey())]
pub config: Account<'info, Config>,
pub config: AccountLoader<'info, Config>,

#[account(
mut,
Expand Down
2 changes: 1 addition & 1 deletion programs/network/src/instructions/pool_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct PoolUpdate<'info> {
address = Config::pubkey(),
has_one = admin
)]
pub config: Account<'info, Config>,
pub config: AccountLoader<'info, Config>,

#[account(mut)]
pub payer: Signer<'info>,
Expand Down
4 changes: 2 additions & 2 deletions programs/network/src/instructions/registry_nonce_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use {
#[derive(Accounts)]
pub struct RegistryNonceHash<'info> {
#[account(address = Config::pubkey())]
pub config: Account<'info, Config>,
pub config: AccountLoader<'info, Config>,

#[account(
mut,
Expand All @@ -17,7 +17,7 @@ pub struct RegistryNonceHash<'info> {
)]
pub registry: Account<'info, Registry>,

#[account(address = config.hasher_thread)]
#[account(address = config.load()?.hasher_thread)]
pub thread: Signer<'info>,
}

Expand Down
2 changes: 1 addition & 1 deletion programs/network/src/instructions/registry_unlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct RegistryUnlock<'info> {
pub admin: Signer<'info>,

#[account(seeds = [SEED_CONFIG], bump, has_one = admin)]
pub config: Account<'info, Config>,
pub config: AccountLoader<'info, Config>,

#[account(
mut,
Expand Down
16 changes: 8 additions & 8 deletions programs/network/src/instructions/worker_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ use {

#[derive(Accounts)]
pub struct WorkerCreate<'info> {
pub associated_token_program: Program<'info, AssociatedToken>,

#[account(mut)]
pub authority: Signer<'info>,

#[account(address = Config::pubkey())]
pub config: Account<'info, Config>,
pub config: AccountLoader<'info, Config>,

#[account(
init,
Expand All @@ -41,7 +39,7 @@ pub struct WorkerCreate<'info> {
)]
pub penalty: Account<'info, Penalty>,

#[account(address = config.mint)]
#[account(address = config.load()?.mint)]
pub mint: Account<'info, Mint>,

#[account(
Expand All @@ -55,10 +53,6 @@ pub struct WorkerCreate<'info> {
#[account(constraint = signatory.key() != authority.key() @ SablierError::InvalidSignatory)]
pub signatory: Signer<'info>,

pub system_program: Program<'info, System>,

pub token_program: Program<'info, Token>,

#[account(
init,
seeds = [
Expand All @@ -78,6 +72,12 @@ pub struct WorkerCreate<'info> {
associated_token::mint = mint,
)]
pub worker_tokens: Account<'info, TokenAccount>,

pub system_program: Program<'info, System>,

pub associated_token_program: Program<'info, AssociatedToken>,

pub token_program: Program<'info, Token>,
}

pub fn handler(ctx: Context<WorkerCreate>) -> Result<()> {
Expand Down
4 changes: 2 additions & 2 deletions programs/network/src/jobs/delete_snapshot/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ use crate::state::*;
#[derive(Accounts)]
pub struct DeleteSnapshotJob<'info> {
#[account(address = Config::pubkey())]
pub config: Account<'info, Config>,
pub config: AccountLoader<'info, Config>,

#[account(
address = Registry::pubkey(),
constraint = !registry.locked
)]
pub registry: Account<'info, Registry>,

#[account(address = config.epoch_thread)]
#[account(address = config.load()?.epoch_thread)]
pub thread: Signer<'info>,
}

Expand Down
4 changes: 2 additions & 2 deletions programs/network/src/jobs/delete_snapshot/process_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{constants::*, state::*};
#[derive(Accounts)]
pub struct DeleteSnapshotProcessEntry<'info> {
#[account(address = Config::pubkey())]
pub config: Account<'info, Config>,
pub config: AccountLoader<'info, Config>,

#[account(
address = Registry::pubkey(),
Expand Down Expand Up @@ -51,7 +51,7 @@ pub struct DeleteSnapshotProcessEntry<'info> {

#[account(
mut,
address = config.epoch_thread
address = config.load()?.epoch_thread
)]
pub thread: Signer<'info>,
}
Expand Down
4 changes: 2 additions & 2 deletions programs/network/src/jobs/delete_snapshot/process_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{constants::*, state::*};
#[derive(Accounts)]
pub struct DeleteSnapshotProcessFrame<'info> {
#[account(address = Config::pubkey())]
pub config: Account<'info, Config>,
pub config: AccountLoader<'info, Config>,

#[account(
address = Registry::pubkey(),
Expand Down Expand Up @@ -39,7 +39,7 @@ pub struct DeleteSnapshotProcessFrame<'info> {

#[account(
mut,
address = config.epoch_thread
address = config.load()?.epoch_thread
)]
pub thread: Signer<'info>,
}
Expand Down
4 changes: 2 additions & 2 deletions programs/network/src/jobs/delete_snapshot/process_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{constants::*, state::*};
#[derive(Accounts)]
pub struct DeleteSnapshotProcessSnapshot<'info> {
#[account(address = Config::pubkey())]
pub config: Account<'info, Config>,
pub config: AccountLoader<'info, Config>,

#[account(
address = Registry::pubkey(),
Expand All @@ -27,7 +27,7 @@ pub struct DeleteSnapshotProcessSnapshot<'info> {

#[account(
mut,
address = config.epoch_thread
address = config.load()?.epoch_thread
)]
pub thread: Signer<'info>,
}
Expand Down
4 changes: 2 additions & 2 deletions programs/network/src/jobs/distribute_fees/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{constants::*, state::*};
#[derive(Accounts)]
pub struct DistributeFeesJob<'info> {
#[account(address = Config::pubkey())]
pub config: Account<'info, Config>,
pub config: AccountLoader<'info, Config>,

#[account(
mut,
Expand All @@ -15,7 +15,7 @@ pub struct DistributeFeesJob<'info> {
)]
pub registry: Account<'info, Registry>,

#[account(address = config.epoch_thread)]
#[account(address = config.load()?.epoch_thread)]
pub thread: Signer<'info>,
}

Expand Down
4 changes: 2 additions & 2 deletions programs/network/src/jobs/distribute_fees/process_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{constants::*, state::*};
#[derive(Accounts)]
pub struct DistributeFeesProcessEntry<'info> {
#[account(address = Config::pubkey())]
pub config: Account<'info, Config>,
pub config: AccountLoader<'info, Config>,

#[account(
mut,
Expand Down Expand Up @@ -54,7 +54,7 @@ pub struct DistributeFeesProcessEntry<'info> {
)]
pub snapshot_frame: Account<'info, SnapshotFrame>,

#[account(address = config.epoch_thread)]
#[account(address = config.load()?.epoch_thread)]
pub thread: Signer<'info>,

#[account(address = worker.pubkey())]
Expand Down
4 changes: 2 additions & 2 deletions programs/network/src/jobs/distribute_fees/process_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{constants::*, state::*};
#[derive(Accounts)]
pub struct DistributeFeesProcessFrame<'info> {
#[account(address = Config::pubkey())]
pub config: Account<'info, Config>,
pub config: AccountLoader<'info, Config>,

#[account(
mut,
Expand Down Expand Up @@ -35,7 +35,7 @@ pub struct DistributeFeesProcessFrame<'info> {
)]
pub snapshot_frame: Account<'info, SnapshotFrame>,

#[account(address = config.epoch_thread)]
#[account(address = config.load()?.epoch_thread)]
pub thread: Signer<'info>,

#[account(mut)]
Expand Down
4 changes: 2 additions & 2 deletions programs/network/src/jobs/distribute_fees/process_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::{constants::*, state::*};
#[derive(Accounts)]
pub struct DistributeFeesProcessSnapshot<'info> {
#[account(address = Config::pubkey())]
pub config: Account<'info, Config>,
pub config: AccountLoader<'info, Config>,

#[account(seeds = [SEED_REGISTRY], bump)]
pub registry: Account<'info, Registry>,
Expand All @@ -35,7 +35,7 @@ pub struct DistributeFeesProcessSnapshot<'info> {
)]
pub snapshot: Account<'info, Snapshot>,

#[account(address = config.epoch_thread)]
#[account(address = config.load()?.epoch_thread)]
pub thread: Signer<'info>,
}

Expand Down
4 changes: 2 additions & 2 deletions programs/network/src/jobs/increment_epoch/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{constants::*, state::*};
#[derive(Accounts)]
pub struct EpochCutover<'info> {
#[account(address = Config::pubkey())]
pub config: Account<'info, Config>,
pub config: AccountLoader<'info, Config>,

#[account(
mut,
Expand All @@ -15,7 +15,7 @@ pub struct EpochCutover<'info> {
)]
pub registry: Account<'info, Registry>,

#[account(address = config.epoch_thread)]
#[account(address = config.load()?.epoch_thread)]
pub thread: Signer<'info>,
}

Expand Down
Loading

0 comments on commit 29a94e5

Please sign in to comment.