Skip to content

Commit

Permalink
Clean up anchor import situatoin
Browse files Browse the repository at this point in the history
  • Loading branch information
ebatsell committed Nov 30, 2024
1 parent cd892a0 commit c92e2b3
Show file tree
Hide file tree
Showing 13 changed files with 1,221 additions and 110 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ jobs:
with:
crate: cargo-audit
- run: cargo audit --ignore RUSTSEC-2022-0093 --ignore RUSTSEC-2023-0065 --ignore RUSTSEC-2024-0344
env:
ANCHOR_IDL_BUILD_SKIP_LINT: TRUE

code_gen:
name: code generation
Expand Down Expand Up @@ -88,10 +86,7 @@ jobs:
- run: cargo sort --workspace --check
- run: cargo fmt --all --check
- run: |
export ANCHOR_IDL_BUILD_SKIP_LINT=true
cargo clippy --all-features -- -D warnings -D clippy::all -D clippy::nursery -D clippy::integer_division -D clippy::arithmetic_side_effects -D clippy::style -D clippy::perf
env:
ANCHOR_IDL_BUILD_SKIP_LINT: true
build:
name: build
Expand All @@ -112,7 +107,6 @@ jobs:
env:
TIP_ROUTER_PROGRAM_ID: ${{ env.TIP_ROUTER_PROGRAM_ID }}
SBF_OUT_DIR: ${{ github.workspace }}/target/sbf-solana-solana/release
ANCHOR_IDL_BUILD_SKIP_LINT: true
- name: Upload MEV Tip Distribution NCN program
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -147,8 +141,6 @@ jobs:
runs-on: ubuntu-latest
needs:
- build
env:
ANCHOR_IDL_BUILD_SKIP_LINT: true
steps:
- uses: actions/checkout@v4
- uses: aarcangeli/[email protected]
Expand Down
30 changes: 2 additions & 28 deletions Cargo.lock

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

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"meta_merkle_tree",
"program",
"shank_cli",
"tip_distribution_sdk",
]

resolver = "2"
Expand All @@ -31,7 +32,7 @@ edition = "2021"
readme = "README.md"

[workspace.dependencies]
anchor-lang = { version = "0.30.0" }
anchor-lang = { version = "0.30.1" }
anyhow = "1.0.86"
assert_matches = "1.5.0"
borsh = { version = "0.10.3" }
Expand Down Expand Up @@ -73,8 +74,8 @@ syn = "2.0.72"
thiserror = "1.0.57"
tokio = { version = "1.36.0", features = ["full"] }
meta-merkle-tree = { path = "./meta_merkle_tree", version = "=0.0.1" }
jito-tip-distribution-sdk = { git = "https://github.com/jito-foundation/jito-programs", rev = "2849874101336e7ef6ee93bb64b1354d5e682bb9" }
jito-tip-distribution = { git = "https://github.com/jito-foundation/jito-programs", rev = "2849874101336e7ef6ee93bb64b1354d5e682bb9" }
jito-tip-distribution-sdk = { path = "./tip_distribution_sdk", version = "=0.0.1" }
# jito-tip-distribution = { default-features = false, features = ["no-entrypoint", "no-idl"], git = "https://github.com/jito-foundation/jito-programs", rev = "2849874101336e7ef6ee93bb64b1354d5e682bb9" }
jito-tip-router-client = { path = "./clients/rust/jito_tip_router", version = "0.0.1" }
jito-tip-router-core = { path = "./core", version = "=0.0.1" }
jito-tip-router-program = { path = "./program", version = "=0.0.1" }
Expand Down
20 changes: 10 additions & 10 deletions format.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#! /bin/zsh
echo "Executing: ANCHOR_IDL_BUILD_SKIP_LINT=true cargo sort --workspace"
ANCHOR_IDL_BUILD_SKIP_LINT=true cargo sort --workspace
echo "Executing: cargo sort --workspace"
cargo sort --workspace

echo "Executing: ANCHOR_IDL_BUILD_SKIP_LINT=true cargo fmt --all"
ANCHOR_IDL_BUILD_SKIP_LINT=true cargo fmt --all
echo "Executing: cargo fmt --all"
cargo fmt --all

echo "Executing: ANCHOR_IDL_BUILD_SKIP_LINT=true cargo nextest run --all-features"
ANCHOR_IDL_BUILD_SKIP_LINT=true cargo nextest run --all-features
echo "Executing: cargo nextest run --all-features"
cargo nextest run --all-features

echo "Executing: ANCHOR_IDL_BUILD_SKIP_LINT=true cargo clippy --all-features -- -D warnings -D clippy::all -D clippy::nursery -D clippy::integer_division -D clippy::arithmetic_side_effects -D clippy::style -D clippy::perf"
ANCHOR_IDL_BUILD_SKIP_LINT=true cargo clippy --all-features -- -D warnings -D clippy::all -D clippy::nursery -D clippy::integer_division -D clippy::arithmetic_side_effects -D clippy::style -D clippy::perf
echo "Executing: cargo clippy --all-features -- -D warnings -D clippy::all -D clippy::nursery -D clippy::integer_division -D clippy::arithmetic_side_effects -D clippy::style -D clippy::perf"
cargo clippy --all-features -- -D warnings -D clippy::all -D clippy::nursery -D clippy::integer_division -D clippy::arithmetic_side_effects -D clippy::style -D clippy::perf

echo "Executing: ANCHOR_IDL_BUILD_SKIP_LINT=true cargo b && ./target/debug/jito-tip-router-shank-cli && yarn install && yarn generate-clients && cargo b"
ANCHOR_IDL_BUILD_SKIP_LINT=true cargo b && ./target/debug/jito-tip-router-shank-cli && yarn install && yarn generate-clients && cargo b
echo "Executing: cargo b && ./target/debug/jito-tip-router-shank-cli && yarn install && yarn generate-clients && cargo b"
cargo b && ./target/debug/jito-tip-router-shank-cli && yarn install && yarn generate-clients && cargo b

echo "Executing: cargo-build-sbf"
cargo-build-sbf
Expand Down
1 change: 0 additions & 1 deletion integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jito-jsm-core = { workspace = true }
jito-restaking-core = { workspace = true }
jito-restaking-program = { workspace = true }
jito-restaking-sdk = { workspace = true }
jito-tip-distribution = { workspace = true }
jito-tip-distribution-sdk = { workspace = true }
jito-tip-router-core = { workspace = true }
jito-tip-router-program = { workspace = true }
Expand Down
67 changes: 26 additions & 41 deletions integration_tests/tests/fixtures/tip_distribution_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::borrow::BorrowMut;

use anchor_lang::AccountDeserialize;
use borsh::BorshDeserialize;
use jito_tip_distribution::state::TipDistributionAccount;
use jito_tip_distribution_sdk::TipDistributionAccount;
// Getters for the Tip Distribution account to verify that we've set the merkle root correctly
use solana_program::{pubkey::Pubkey, system_instruction::transfer};
use solana_program_test::{BanksClient, ProgramTestBanksClientExt};
Expand Down Expand Up @@ -153,19 +153,14 @@ impl TipDistributionClient {
bump: u8,
) -> TestResult<()> {
let ix = jito_tip_distribution_sdk::instruction::initialize_ix(
jito_tip_distribution::id(),
jito_tip_distribution_sdk::instruction::InitializeArgs {
authority,
expired_funds_account,
num_epochs_valid,
max_validator_commission_bps,
bump,
},
jito_tip_distribution_sdk::instruction::InitializeAccounts {
config,
system_program,
initializer,
},
config,
system_program,
initializer,
authority,
expired_funds_account,
num_epochs_valid,
max_validator_commission_bps,
bump,
);

let blockhash = self.banks_client.get_latest_blockhash().await?;
Expand Down Expand Up @@ -224,19 +219,14 @@ impl TipDistributionClient {
bump: u8,
) -> TestResult<()> {
let ix = jito_tip_distribution_sdk::instruction::initialize_tip_distribution_account_ix(
jito_tip_distribution::id(),
jito_tip_distribution_sdk::instruction::InitializeTipDistributionAccountArgs {
merkle_root_upload_authority,
validator_commission_bps,
bump,
},
jito_tip_distribution_sdk::instruction::InitializeTipDistributionAccountAccounts {
config,
tip_distribution_account,
system_program,
validator_vote_account,
signer: self.payer.pubkey(),
},
config,
tip_distribution_account,
system_program,
validator_vote_account,
self.payer.pubkey(),
merkle_root_upload_authority,
validator_commission_bps,
bump,
);

let blockhash = self.banks_client.get_latest_blockhash().await?;
Expand Down Expand Up @@ -301,20 +291,15 @@ impl TipDistributionClient {
bump: u8,
) -> TestResult<()> {
let ix = jito_tip_distribution_sdk::instruction::claim_ix(
jito_tip_distribution::id(),
jito_tip_distribution_sdk::instruction::ClaimArgs {
proof,
amount,
bump,
},
jito_tip_distribution_sdk::instruction::ClaimAccounts {
config,
tip_distribution_account,
claim_status,
claimant,
payer,
system_program,
},
config,
tip_distribution_account,
claim_status,
claimant,
payer,
system_program,
proof,
amount,
bump,
);

let blockhash = self.banks_client.get_latest_blockhash().await?;
Expand Down
2 changes: 1 addition & 1 deletion meta_merkle_tree/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jito-bytemuck = { workspace = true }
jito-jsm-core = { workspace = true }
jito-restaking-core = { workspace = true }
jito-restaking-sdk = { workspace = true }
jito-tip-distribution = { workspace = true }
jito-tip-distribution-sdk = { workspace = true }
jito-vault-core = { workspace = true }
jito-vault-sdk = { workspace = true }
rand = { workspace = true }
Expand Down
10 changes: 5 additions & 5 deletions meta_merkle_tree/src/generated_merkle_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// To be replaced by tip distributor code in this repo
use std::{fs::File, io::BufReader, path::PathBuf};

use jito_tip_distribution::state::ClaimStatus;
use jito_tip_distribution_sdk::{jito_tip_distribution, CLAIM_STATUS_SEED};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use solana_program::{
clock::{Epoch, Slot},
Expand Down Expand Up @@ -136,11 +136,11 @@ impl TreeNode {
.unwrap() as u64;
let (claim_status_pubkey, claim_status_bump) = Pubkey::find_program_address(
&[
ClaimStatus::SEED,
CLAIM_STATUS_SEED,
&stake_meta.validator_vote_account.to_bytes(),
&tip_distribution_meta.tip_distribution_pubkey.to_bytes(),
],
&jito_tip_distribution::id(),
&jito_tip_distribution::ID,
);
let mut tree_nodes = vec![TreeNode {
claimant: stake_meta.validator_vote_account,
Expand Down Expand Up @@ -170,11 +170,11 @@ impl TreeNode {
.unwrap();
let (claim_status_pubkey, claim_status_bump) = Pubkey::find_program_address(
&[
ClaimStatus::SEED,
CLAIM_STATUS_SEED,
&delegation.stake_account_pubkey.to_bytes(),
&tip_distribution_meta.tip_distribution_pubkey.to_bytes(),
],
&jito_tip_distribution::id(),
&jito_tip_distribution::ID,
);
Ok(TreeNode {
claimant: delegation.stake_account_pubkey,
Expand Down
20 changes: 7 additions & 13 deletions program/src/set_merkle_root.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use jito_bytemuck::AccountDeserialize;
use jito_restaking_core::ncn::Ncn;
use jito_tip_distribution_sdk::{
derive_tip_distribution_account_address,
instruction::{upload_merkle_root_ix, UploadMerkleRootAccounts, UploadMerkleRootArgs},
derive_tip_distribution_account_address, instruction::upload_merkle_root_ix,
};
use jito_tip_router_core::{ballot_box::BallotBox, error::TipRouterError, ncn_config::NcnConfig};
use solana_program::{
Expand Down Expand Up @@ -61,17 +60,12 @@ pub fn process_set_merkle_root(

invoke_signed(
&upload_merkle_root_ix(
*tip_distribution_program_id.key,
UploadMerkleRootArgs {
root: merkle_root,
max_total_claim,
max_num_nodes,
},
UploadMerkleRootAccounts {
config: *tip_distribution_config.key,
tip_distribution_account: *tip_distribution_account.key,
merkle_root_upload_authority: *ncn_config.key,
},
*tip_distribution_config.key,
*ncn_config.key,
*tip_distribution_account.key,
merkle_root,
max_total_claim,
max_num_nodes,
),
&[
tip_distribution_config.clone(),
Expand Down
13 changes: 13 additions & 0 deletions tip_distribution_sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "jito-tip-distribution-sdk"
description = "SDK for interacting with Jito's Tip Distribution Program via declare_program"
version = { workspace = true }
authors = { workspace = true }
repository = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
edition = { workspace = true }
readme = { workspace = true }

[dependencies]
anchor-lang = { workspace = true }
Loading

0 comments on commit c92e2b3

Please sign in to comment.