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

feat: migrate blueprint-manager #22

Merged
merged 4 commits into from
Dec 27, 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
58 changes: 58 additions & 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 @@ -31,6 +31,7 @@ broken_intra_doc_links = "deny"
[workspace.dependencies]
# Blueprint utils
blueprint-util-meta = { version = "0.1.0", path = "./crates/blueprint", default-features = false }
blueprint-manager = { version = "0.2.2", path = "./crates/blueprint/manager", default-features = false }
blueprint-metadata = { version = "0.2.1", path = "./crates/blueprint/metadata", default-features = false }
blueprint-build-utils = { version = "0.1.0", path = "./crates/blueprint/build-utils", default-features = false }
gadget-blueprint-serde = { version = "0.3.1", path = "./crates/blueprint/serde", default-features = false }
Expand Down
10 changes: 4 additions & 6 deletions cli/src/deploy/tangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ use alloy_rpc_types_eth::TransactionRequest;
use alloy_signer_local::PrivateKeySigner;
use color_eyre::eyre::{self, Context, ContextCompat, Result};
use gadget_blueprint_proc_macro_core::{BlueprintManager, ServiceBlueprint};
use gadget_clients::tangle::runtime::TangleConfig;
use gadget_crypto::tangle_pair_signer::TanglePairSigner;
use gadget_std::fmt::Debug;
use gadget_std::path::PathBuf;
use subxt::tx::Signer;
use tangle_subxt::subxt;
use tangle_subxt::subxt::ext::sp_core;
use tangle_subxt::subxt::tx::PairSigner;
use tangle_subxt::tangle_testnet_runtime::api as TangleApi;
use tangle_subxt::tangle_testnet_runtime::api::services::calls::types;

pub type TanglePairSigner = PairSigner<TangleConfig, sp_core::sr25519::Pair>;

#[derive(Clone)]
pub struct Opts {
/// The name of the package to deploy (if the workspace has multiple packages)
Expand All @@ -26,7 +24,7 @@ pub struct Opts {
/// The path to the manifest file
pub manifest_path: gadget_std::path::PathBuf,
/// The signer for deploying the blueprint
pub signer: Option<TanglePairSigner>,
pub signer: Option<TanglePairSigner<sp_core::sr25519::Pair>>,
/// The signer for deploying the smart contract
pub signer_evm: Option<PrivateKeySigner>,
}
Expand Down Expand Up @@ -106,7 +104,7 @@ pub async fn deploy_to_tangle(
let signer = if let Some(signer) = signer {
signer
} else {
crate::signer::load_signer_from_env()?.pair
crate::signer::load_signer_from_env()?
};

let my_account_id = signer.account_id();
Expand Down
1 change: 1 addition & 0 deletions crates/blueprint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ repository.workspace = true
publish = false

[dependencies]
blueprint-manager.workspace = true
blueprint-metadata.workspace = true
blueprint-build-utils.workspace = true
87 changes: 87 additions & 0 deletions crates/blueprint/manager/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.2.2](https://github.com/tangle-network/gadget/compare/blueprint-manager-v0.2.1...blueprint-manager-v0.2.2) - 2024-12-11

### Other

- Call ID Insertion and Resolution
For [#520](https://github.com/tangle-network/gadget/pull/520) ([#533](https://github.com/tangle-network/gadget/pull/533))

## [0.2.1](https://github.com/tangle-network/gadget/compare/blueprint-manager-v0.2.0...blueprint-manager-v0.2.1) - 2024-12-04

### Other

- updated the following local packages: gadget-sdk

## [0.2.0](https://github.com/tangle-network/gadget/compare/blueprint-manager-v0.1.3...blueprint-manager-v0.2.0) - 2024-11-29

### Other

- *(gadget-sdk)* [**breaking**] update to latest tangle ([#503](https://github.com/tangle-network/gadget/pull/503))

## [0.1.3](https://github.com/tangle-network/gadget/compare/blueprint-manager-v0.1.2...blueprint-manager-v0.1.3) - 2024-11-20

### Other

- updated the following local packages: gadget-sdk

## [0.1.2](https://github.com/tangle-network/gadget/compare/blueprint-manager-v0.1.1...blueprint-manager-v0.1.2) - 2024-11-16

### Other

- updated the following local packages: gadget-sdk

## [0.1.1](https://github.com/tangle-network/gadget/releases/tag/blueprint-manager-v0.1.1) - 2024-11-08

### Added

- [**breaking**] Refactor EventFlows for EVM and Remove
EventWatchers ([#423](https://github.com/tangle-network/gadget/pull/423))
- symbiotic initial integration ([#411](https://github.com/tangle-network/gadget/pull/411))
- add optional data dir to blueprint manager ([#342](https://github.com/tangle-network/gadget/pull/342))
- eigenlayer incredible squaring blueprint and test ([#312](https://github.com/tangle-network/gadget/pull/312))
- add EVM Provider and Tangle Client Context Extensions ([#319](https://github.com/tangle-network/gadget/pull/319))
- Keystore Context Extensions ([#316](https://github.com/tangle-network/gadget/pull/316))
- add benchmarking mode ([#248](https://github.com/tangle-network/gadget/pull/248))

### Fixed

- *(gadget-sdk)* [**breaking**] prevent duplicate and self-referential
messages ([#458](https://github.com/tangle-network/gadget/pull/458))
- *(sdk)* [**breaking**] allow for zero-based `blueprint_id` ([#426](https://github.com/tangle-network/gadget/pull/426))
- *(cargo-tangle)* CLI bugs ([#409](https://github.com/tangle-network/gadget/pull/409))
- *(sdk)* [**breaking**] downgrade substrate dependencies for now
- add `data_dir` back to `GadgetConfiguration` ([#350](https://github.com/tangle-network/gadget/pull/350))

### Other

- set blueprint-manager publishable ([#462](https://github.com/tangle-network/gadget/pull/462))
- add a p2p test for testing the networking layer ([#450](https://github.com/tangle-network/gadget/pull/450))
- Continue Improving Event Flows ([#399](https://github.com/tangle-network/gadget/pull/399))
- improve blueprint-manager and blueprint-test-utils ([#421](https://github.com/tangle-network/gadget/pull/421))
- Leverage blueprint in incredible squaring aggregator ([#365](https://github.com/tangle-network/gadget/pull/365))
- Event Listener Upgrade + Wrapper Types + sdk::main macro ([#333](https://github.com/tangle-network/gadget/pull/333))
- docs fix spelling issues ([#336](https://github.com/tangle-network/gadget/pull/336))
- Event listener ([#317](https://github.com/tangle-network/gadget/pull/317))
- Remove Logger ([#311](https://github.com/tangle-network/gadget/pull/311))
- Streamline keystore, cleanup testing, refactor blueprint manager, add tests, remove unnecessary
code ([#285](https://github.com/tangle-network/gadget/pull/285))
- CI Improvements ([#301](https://github.com/tangle-network/gadget/pull/301))
- [feat] Gadget Metadata ([#274](https://github.com/tangle-network/gadget/pull/274))
- [MEGA PR] Overhaul repo, add Eigenlayer AVS example, remove many crates, add testing, remove unused
code ([#246](https://github.com/tangle-network/gadget/pull/246))
- Add mpc blueprint starting point, cleanup abstractions ([#252](https://github.com/tangle-network/gadget/pull/252))
- Add more checks to CI ([#244](https://github.com/tangle-network/gadget/pull/244))
- [feat] benchmark proc-macro ([#238](https://github.com/tangle-network/gadget/pull/238))
- Spelling fix
- Promote all dependencies to workspace ([#233](https://github.com/tangle-network/gadget/pull/233))
- Make `{core, io, common}` no_std and WASM compatible ([#231](https://github.com/tangle-network/gadget/pull/231))
- Remove shell sdk and put inside blueprint manager ([#229](https://github.com/tangle-network/gadget/pull/229))
- Blueprint testing ([#206](https://github.com/tangle-network/gadget/pull/206))
47 changes: 47 additions & 0 deletions crates/blueprint/manager/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[package]
name = "blueprint-manager"
version = "0.2.2"
description = "Tangle Blueprint manager and Runner"
authors.workspace = true
edition.workspace = true
homepage.workspace = true
repository.workspace = true
license.workspace = true

[[bin]]
name = "blueprint-manager"
path = "src/main.rs"

[dependencies]
gadget-clients = { workspace = true, features = ["std", "tangle"] }
gadget-config = { workspace = true, features = ["std", "networking"] }
gadget-crypto = { workspace = true, features = ["std", "tangle-pair-signer"] }
gadget-keystore = { workspace = true, features = ["std", "tangle"] }
gadget-logging = { workspace = true, features = ["std"] }
gadget-networking = { workspace = true, features = ["std"] }
gadget-std = { workspace = true, features = ["std"] }

clap = { workspace = true, features = ["derive", "wrap_help"] }
color-eyre = { workspace = true, features = ["tracing-error", "color-spantrace", "issue-url"] }
serde = { workspace = true }
tangle-subxt = { workspace = true }
toml = { workspace = true }
hex = { workspace = true }
tokio = { workspace = true, features = ["process", "io-util", "signal", "macros"] }
reqwest = { workspace = true }
sha2 = { workspace = true }
futures = { workspace = true }
itertools = { workspace = true }
thiserror.workspace = true
tracing = { workspace = true, features = ["log"] }
tracing-subscriber = { workspace = true, features = ["env-filter", "ansi", "tracing-log"] }
libp2p = { workspace = true }
auto_impl = { workspace = true }
parking_lot = { workspace = true }
async-trait = { workspace = true }

[lints]
workspace = true

[package.metadata.dist]
dist = false
31 changes: 31 additions & 0 deletions crates/blueprint/manager/src/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use clap::Parser;
use std::path::PathBuf;

#[derive(Debug, Parser)]
#[command(
name = "Blueprint Manager",
about = "An program executor that connects to the Tangle network and runs protocols dynamically on the fly"
)]
pub struct BlueprintManagerConfig {
/// The path to the gadget configuration file
#[arg(short = 's', long)]
pub gadget_config: Option<PathBuf>,
/// The path to the keystore
#[arg(short = 'k', long)]
pub keystore_uri: String,
/// The directory in which all gadgets will store their data
#[arg(long, short = 'd', default_value = "./data")]
pub data_dir: PathBuf,
/// The verbosity level, can be used multiple times to increase verbosity
#[arg(long, short = 'v', action = clap::ArgAction::Count)]
pub verbose: u8,
/// Whether to use pretty logging
#[arg(long)]
pub pretty: bool,
/// An optional unique string identifier for the blueprint manager to differentiate between multiple
/// running instances of a BlueprintManager (mostly for debugging purposes)
#[arg(long, alias = "id")]
pub instance_id: Option<String>,
#[arg(long, short = 't')]
pub test_mode: bool,
}
39 changes: 39 additions & 0 deletions crates/blueprint/manager/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
pub type Result<T> = std::result::Result<T, Error>;

#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("No fetchers found for blueprint")]
NoFetchers,
#[error("Multiple fetchers found for blueprint")]
MultipleFetchers,
#[error("No testing fetcher found for blueprint, despite operating in test mode")]
NoTestFetcher,
#[error("Blueprint does not contain a supported fetcher")]
UnsupportedGadget,

#[error("Unable to find matching binary")]
NoMatchingBinary,
#[error("Binary hash {expected} mismatched expected hash of {actual}")]
HashMismatch { expected: String, actual: String },
#[error("Failed to build binary: {0:?}")]
BuildBinary(std::process::Output),
#[error("Failed to fetch git root: {0:?}")]
FetchGitRoot(std::process::Output),

#[error("Failed to get initial block hash")]
InitialBlock,
#[error("Finality Notification stream died")]
ClientDied,
#[error("{0}")]
Other(String),

#[error(transparent)]
Io(#[from] std::io::Error),
#[error(transparent)]
Utf8(#[from] std::string::FromUtf8Error),

#[error(transparent)]
Request(#[from] reqwest::Error),
#[error(transparent)]
TangleClient(#[from] gadget_clients::tangle::error::Error),
}
Loading
Loading