Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bubblegum verify #150

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 28 additions & 12 deletions Cargo.lock

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

9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
members = [
"backfill",
"bubblegum",
"blockbuster",
"core",
"das_api",
Expand Down Expand Up @@ -48,7 +48,7 @@ cargo-lock = "9.0.0"
chrono = "0.4.19"
clap = "4.2.2"
das-core = { path = "core" }
das-backfill = { path = "backfill" }
das-bubblegum = { path = "bubblegum" }
das_api = { path = "das_api" }
derive_more = { version = "0.99.17" }
digital_asset_types = { path = "digital_asset_types" }
Expand Down Expand Up @@ -78,7 +78,7 @@ lru = "0.12.3"
metrics = "0.20.1"
migration = { path = "migration" }
mime_guess = "2.0.4"
mpl-bubblegum = "1.2.0"
mpl-bubblegum = "1.4.0"
mpl-core = { version = "0.8.0-beta.1", features = ["serde"] }
mpl-token-metadata = "4.1.1"
nft_ingester = { path = "nft_ingester" }
Expand Down Expand Up @@ -116,7 +116,7 @@ solana-program = "~1.18"
solana-sdk = "~1.18"
solana-transaction-status = "~1.18"
solana-zk-token-sdk = "1.17.16"
spl-account-compression = "0.3.0"
spl-account-compression = "0.4.0"
spl-associated-token-account = ">= 1.1.3, < 3.0"
spl-concurrent-merkle-tree = "0.2.0"
spl-noop = "0.2.0"
Expand All @@ -125,6 +125,7 @@ spl-token = ">= 3.5.0, < 5.0"
spl-token-2022 = { version = "1.0", features = ["no-entrypoint"] }
spl-token-group-interface = "0.1.0"
spl-token-metadata-interface = "0.2.0"
sha3 = "0.10.8"
sqlx = "0.6.2"
stretto = "0.8.4"
thiserror = "1.0.31"
Expand Down
3 changes: 2 additions & 1 deletion backfill/Cargo.toml → bubblegum/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "das-backfill"
name = "das-bubblegum"
version = { workspace = true }
edition = { workspace = true }
repository = { workspace = true }
Expand Down Expand Up @@ -28,6 +28,7 @@ num-traits = { workspace = true }
sea-orm = { workspace = true }
serde_json = { workspace = true }
solana-sdk = { workspace = true }
sha3 = { workspace = true }
solana-transaction-status = { workspace = true }
spl-account-compression = { workspace = true, features = ["no-entrypoint"] }
spl-token = { workspace = true, features = ["no-entrypoint"] }
Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions backfill/src/gap.rs → bubblegum/src/backfill/gap.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use super::ErrorKind;
use crate::Rpc;
use crate::{error::ErrorKind, Rpc};
use anyhow::Result;
use clap::Args;
use sea_orm::{DatabaseConnection, DbBackend, FromQueryResult, Statement, Value};
Expand Down
2 changes: 2 additions & 0 deletions bubblegum/src/backfill/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod gap;
pub mod worker;
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ use tokio::{
task::JoinHandle,
};

use crate::gap::TreeGapFill;
use crate::BubblegumBackfillContext;
use crate::{backfill::gap::TreeGapFill, BubblegumContext};

#[derive(Parser, Debug, Clone)]
pub struct GapWorkerArgs {
Expand All @@ -26,7 +25,7 @@ pub struct GapWorkerArgs {
impl GapWorkerArgs {
pub fn start(
&self,
context: BubblegumBackfillContext,
context: BubblegumContext,
forward: Sender<Signature>,
) -> Result<(JoinHandle<()>, Sender<TreeGapFill>)> {
let (gap_sender, mut gap_receiver) = channel::<TreeGapFill>(self.gap_channel_size);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::sync::Arc;
use tokio::sync::mpsc::{channel, Sender, UnboundedSender};
use tokio::task::JoinHandle;

use crate::BubblegumBackfillContext;
use crate::BubblegumContext;

#[derive(Parser, Debug, Clone)]
pub struct ProgramTransformerWorkerArgs {
Expand All @@ -22,7 +22,7 @@ pub struct ProgramTransformerWorkerArgs {
impl ProgramTransformerWorkerArgs {
pub fn start(
&self,
context: BubblegumBackfillContext,
context: BubblegumContext,
forwarder: UnboundedSender<DownloadMetadataInfo>,
) -> Result<(JoinHandle<()>, Sender<TransactionInfo>)> {
let (sender, mut receiver) =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::error::ErrorKind;
use crate::{error::ErrorKind, BubblegumContext};
use anyhow::Result;
use clap::Parser;
use das_core::Rpc;
Expand Down Expand Up @@ -143,11 +143,13 @@ pub struct SignatureWorkerArgs {
pub signature_worker_count: usize,
}

type TransactionSender = Sender<TransactionInfo>;

impl SignatureWorkerArgs {
pub fn start(
&self,
context: crate::BubblegumBackfillContext,
forwarder: Sender<TransactionInfo>,
context: BubblegumContext,
forwarder: TransactionSender,
) -> Result<(JoinHandle<()>, Sender<Signature>)> {
let (sig_sender, mut sig_receiver) = channel::<Signature>(self.signature_channel_size);
let worker_count = self.signature_worker_count;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
gap::{TreeGapFill, TreeGapModel},
backfill::gap::{TreeGapFill, TreeGapModel},
tree::TreeResponse,
BubblegumBackfillContext,
BubblegumContext,
};
use anyhow::Result;
use clap::Parser;
Expand Down Expand Up @@ -32,11 +32,7 @@ pub struct TreeWorkerArgs {
pub force: bool,
}
impl TreeWorkerArgs {
pub fn start(
&self,
context: BubblegumBackfillContext,
tree: TreeResponse,
) -> JoinHandle<Result<()>> {
pub fn start(&self, context: BubblegumContext, tree: TreeResponse) -> JoinHandle<Result<()>> {
let db_pool = context.database_pool.clone();
let metadata_json_download_db_pool = context.database_pool.clone();

Expand Down
File renamed without changes.
52 changes: 40 additions & 12 deletions backfill/src/lib.rs → bubblegum/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
mod backfill;
mod error;
mod gap;
mod tree;
mod worker;

use das_core::{MetadataJsonDownloadWorkerArgs, Rpc};
pub use error::ErrorKind;
mod verify;
pub use verify::ProofReport;

use anyhow::Result;
use backfill::worker::{ProgramTransformerWorkerArgs, SignatureWorkerArgs, TreeWorkerArgs};
use clap::Parser;
use digital_asset_types::dao::cl_audits_v2;
use futures::{stream::FuturesUnordered, StreamExt};
Expand All @@ -19,16 +21,14 @@ use solana_sdk::signature::Signature;
use std::str::FromStr;
use tracing::error;
use tree::TreeResponse;
use worker::ProgramTransformerWorkerArgs;
use worker::{SignatureWorkerArgs, TreeWorkerArgs};

#[derive(Clone)]
pub struct BubblegumBackfillContext {
pub struct BubblegumContext {
pub database_pool: sqlx::PgPool,
pub solana_rpc: Rpc,
}

impl BubblegumBackfillContext {
impl BubblegumContext {
pub const fn new(database_pool: sqlx::PgPool, solana_rpc: Rpc) -> Self {
Self {
database_pool,
Expand All @@ -38,7 +38,7 @@ impl BubblegumBackfillContext {
}

#[derive(Debug, Parser, Clone)]
pub struct BubblegumBackfillArgs {
pub struct BackfillArgs {
/// Number of tree crawler workers
#[arg(long, env, default_value = "20")]
pub tree_crawler_count: usize,
Expand All @@ -51,10 +51,7 @@ pub struct BubblegumBackfillArgs {
pub tree_worker: TreeWorkerArgs,
}

pub async fn start_bubblegum_backfill(
context: BubblegumBackfillContext,
args: BubblegumBackfillArgs,
) -> Result<()> {
pub async fn start_backfill(context: BubblegumContext, args: BackfillArgs) -> Result<()> {
let trees = if let Some(ref only_trees) = args.only_trees {
TreeResponse::find(&context.solana_rpc, only_trees.clone()).await?
} else {
Expand Down Expand Up @@ -99,7 +96,7 @@ pub struct BubblegumReplayArgs {
}

pub async fn start_bubblegum_replay(
context: BubblegumBackfillContext,
context: BubblegumContext,
args: BubblegumReplayArgs,
) -> Result<()> {
let pubkey = Pubkey::from_str(&args.tree)
Expand Down Expand Up @@ -154,3 +151,34 @@ pub async fn start_bubblegum_replay(

Ok(())
}

#[derive(Debug, Parser, Clone)]
pub struct VerifyArgs {
/// The list of trees to verify. If not specified, all trees will be crawled.
#[arg(long, env, use_value_delimiter = true)]
pub only_trees: Option<Vec<String>>,

#[arg(long, env, default_value = "20")]
pub max_concurrency: usize,
}

pub async fn verify_bubblegum(
context: BubblegumContext,
args: VerifyArgs,
) -> Result<Vec<verify::ProofReport>> {
let trees = if let Some(ref only_trees) = args.only_trees {
TreeResponse::find(&context.solana_rpc, only_trees.clone()).await?
} else {
TreeResponse::all(&context.solana_rpc).await?
};

let mut reports = Vec::new();

for tree in trees {
let report = verify::check(context.clone(), tree, args.max_concurrency).await?;

reports.push(report);
}

Ok(reports)
}
Loading
Loading