Skip to content
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
21 changes: 20 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ default-members = [
]

[workspace.package]
version = "3.2.0"
version = "4.0.0"
edition = "2024"
license = "LicenseRef-Acki-Nacki-Node-License"
license-file = "LICENSE.md"
Expand All @@ -41,6 +41,25 @@ rs_merkle = { version = "1.5.0", default-features = false }
serde = { version = "1", features = ["derive"] }
serde_json = "1"

# Replicated from ackinacki-kit v5.0.0 (itself replicated from tvm-sdk v3.0.4.an).
# Cargo `[patch]` tables only apply from the top-level workspace, so both tvm-sdk's
# and the kit's own patches are ignored when they are consumed as git deps —
# without these, tvm_vm's zk stack resolves TWO copies of halo2-axiom/halo2-base
# (gosh-sh fork vs crates.io/axiom-crypto) and fails with E0277 Circuit<F> mismatches.
[patch.crates-io]
halo2-base = { git = "https://github.com/gosh-sh/halo2-lib-zkevm-sha256-and-bls12-381", branch = "bump-halo2-lib-v0.4.1" }
halo2-axiom = { git = "https://github.com/gosh-sh/halo2-axiom", branch = "main" }

[patch."https://github.com/axiom-crypto/halo2-lib.git"]
halo2-base = { git = "https://github.com/gosh-sh/halo2-lib-zkevm-sha256-and-bls12-381", branch = "bump-halo2-lib-v0.4.1" }
halo2-ecc = { git = "https://github.com/gosh-sh/halo2-lib-zkevm-sha256-and-bls12-381", branch = "bump-halo2-lib-v0.4.1" }
zkevm-hashes = { git = "https://github.com/gosh-sh/halo2-lib-zkevm-sha256-and-bls12-381", branch = "bump-halo2-lib-v0.4.1" }

# gosh-sh stable-Rust fork of axiom-eth; pinned by rev so the transitively selected
# snark-verifier-sdk cannot drift (see tvm-sdk workspace Cargo.toml for details).
[patch."https://github.com/axiom-crypto/axiom-eth"]
axiom-eth = { git = "https://github.com/gosh-sh/axiom-eth", rev = "1d61be00a63ec73b3f709d74eb9e6b09b754b911" }

[profile.release]
# Tell `rustc` to optimize for small code size.
opt-level = "s"
Expand Down
2 changes: 1 addition & 1 deletion bee_connect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ wasm = ["dep:wasm-bindgen", "dep:wasm-bindgen-futures", "dep:serde-wasm-bindgen"
single-wasm = ["wasm"]

[dependencies]
ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v3.0.0", default-features = false, features = ["contracts"] }
ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v5.0.0", default-features = false, features = ["contracts"] }
base64 = "0.22.1"
bee-errors = { path = "../bee_errors", default-features = false }
bee-infra = { path = "../bee_infra", default-features = false, features = ["tokio"] }
Expand Down
2 changes: 1 addition & 1 deletion bee_crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ wasm = [
single-wasm = ["wasm"]

[dependencies]
ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v3.0.0", default-features = false }
ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v5.0.0", default-features = false }
base64 = "0.22.1"
bee-errors = { path = "../bee_errors", default-features = false }
chacha20poly1305 = "0.10.1"
Expand Down
2 changes: 1 addition & 1 deletion bee_errors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ wasm = ["ackinacki-kit/wasm", "ackinacki-kit/contracts"]
single-wasm = ["wasm"]

[dependencies]
ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v3.0.0", default-features = false }
ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v5.0.0", default-features = false }
base64 = "0.22.1"
hex = { workspace = true }
pbkdf2 = { version = "0.12.2", features = ["simple"] }
Expand Down
2 changes: 1 addition & 1 deletion bee_miner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ wasm = [
single-wasm = ["wasm"]

[dependencies]
ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v3.0.0", default-features = false, features = ["contracts"] }
ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v5.0.0", default-features = false, features = ["contracts"] }
base64 = "0.22.1"
blake3.workspace = true
borsh.workspace = true
Expand Down
28 changes: 23 additions & 5 deletions bee_wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,20 @@ wasm = [
"tokio",
]
single-wasm = ["wasm"]
# DEX voucher generation (`generate_voucher`), backed by `dodex-contracts`.
#
# OFF by default and currently NOT BUILDABLE: `dodex-backend` still declares kit
# v4.0.1 while this workspace is on v5.0.0, and cargo keys git packages by
# source+ref — so the graph carries two `ackinacki-kit` copies whose types don't
# unify across the dodex boundary (`ParamsOfNewContract`, `AbiAccessor`). Cargo
# `[patch]` cannot bridge them ("patches must point to different sources").
# Flip this back on together with a dodex rev that is on kit v5; the two kit tags
# differ only in the multisig binding, which dodex never touches, so it is a
# one-line bump on their side.
dex = ["dep:dodex-contracts"]

[dependencies]
ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v3.0.0", optional = true, default-features = false }
ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v5.0.0", optional = true, default-features = false }
base64 = "0.22.1"
bech32 = "0.9.1"
bee-errors = { path = "../bee_errors", default-features = false }
Expand Down Expand Up @@ -82,17 +93,20 @@ tokio = { optional = true, version = "1.49.0", features = ["rt", "macros"] }
# DEX contract wrappers (RootPn, PrivateNote, …) moved out of kit at v3.0.0 into
# dodex-backend's `dodex-contracts`, built on kit's trait surface via the new
# `KitModule::External` hook. Native-only: voucher generation isn't exposed on
# wasm, so this keeps the dodex graph out of the wasm build.
# wasm, so this keeps the dodex graph out of the wasm build. Gated behind the
# `dex` feature — see its comment above for why it is off.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
dodex-contracts = { git = "https://github.com/gosh-sh/dodex-backend.git", tag = "v1.0.0", package = "dodex-contracts" }
# Pinned by rev on `dev` (tag v1.0.0 is still on kit v3.0.0). Rev, not branch:
# a branch pin already broke CI once when the branch was deleted.
dodex-contracts = { git = "https://github.com/gosh-sh/dodex-backend.git", rev = "50b5f595bd6f99531fb0e77522ca2054e8d814e2", package = "dodex-contracts", optional = true }

# Native integration tests (`tests/integration.rs`, `tests/dex_flows/`) only.
# These pull the native tvm/kit/dodex graph, so they MUST stay off the wasm32
# build — otherwise `wasm-pack test` (which forces `--tests`) drags native-only
# crates (e.g. errno) into wasm32 and fails to compile. The matching test files
# are guarded with `#![cfg(not(target_arch = "wasm32"))]`.
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v3.0.0", features = ["default", "contracts"] }
ackinacki-kit = { git = "https://github.com/gosh-sh/ackinacki-kit.git", tag = "v5.0.0", features = ["default", "contracts"] }
base64 = "0.22.1"
bee-connect = { path = "../bee_connect" }
bee-crypto = { path = "../bee_crypto" }
Expand All @@ -105,7 +119,11 @@ tokio = { version = "1.49.0", features = ["rt", "macros", "time"] }
# full-flow tests under `tests/dex_flows/` — the two multifactor flows that
# exercise bee-wallet + DEX together. Native-only: pulls the heavy halo2 graph.
# Raw contract wrappers come from `dodex-contracts` (a regular dep above).
dodex-sdk = { git = "https://github.com/gosh-sh/dodex-backend.git", tag = "v1.0.0" }
#
# Dev-dependencies cannot be optional, so this stays declared while
# `tests/dex_flows/` itself is gated on the `dex` feature; with the feature off
# the test crate is empty and never names `dodex_sdk`.
dodex-sdk = { git = "https://github.com/gosh-sh/dodex-backend.git", rev = "50b5f595bd6f99531fb0e77522ca2054e8d814e2" }

# wasm-bindgen-test backs the `#[wasm_bindgen_test]` unit tests in
# `adapters/wasm` (run via `wasm-pack test --node`). Kept off the native build.
Expand Down
1 change: 1 addition & 0 deletions bee_wallet/src/adapters/native/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ impl Wallet {

/// Generate a DEX voucher: adds RootPN to whitelist, then sends ECC tokens
/// from the multifactor wallet to RootPN with `generatevoucher` payload.
#[cfg(feature = "dex")]
pub async fn generate_voucher(
&self,
params: crate::modules::dex::ParamsOfGenerateVoucher,
Expand Down
46 changes: 12 additions & 34 deletions bee_wallet/src/bin/wallet_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,20 +612,6 @@ async fn lenient_query_account_events(
page_size: u32,
) -> Result<Vec<KitEvent>, String> {
const GQL: &str = r#"
query($address: String!, $last: Int!, $before: String) {
blockchain {
account(address: $address) {
events(last: $last, before: $before) {
edges {
cursor
node { msg_id created_at dst body }
}
}
}
}
}
"#;
const GQL_V3: &str = r#"
query($account_id: String!, $dapp_id: String!, $last: Int!, $before: String) {
blockchain {
account(account_id: $account_id, dapp_id: $dapp_id) {
Expand All @@ -641,29 +627,22 @@ async fn lenient_query_account_events(
"#;

// Diagnostic accounts queried here are mvsystem (Mobile Verifiers dApp).
let v3 = bee_wallet::dapp::server_uses_dapp_id(ctx).await.map_err(|e| e.to_string())?;
let dapp_id = ackinacki_kit::contracts::dapp::SystemDapp::MobileVerifiers.dapp_id();
let mut all = Vec::new();
let before: Option<String> = None;
loop {
// Single page only (see the tail of this block) — a labeled block, not a
// `loop`, so the early exits read as what they are.
'page: {
let raw = gql_query(
ctx.clone(),
GqlParams {
query: if v3 { GQL_V3 } else { GQL }.to_string(),
variables: Some(if v3 {
serde_json::json!({
"account_id": bee_wallet::dapp::account_id(address),
"dapp_id": dapp_id,
"last": page_size,
"before": before,
})
} else {
serde_json::json!({
"address": address,
"last": page_size,
"before": before,
})
}),
query: GQL.to_string(),
variables: Some(serde_json::json!({
"account_id": bee_wallet::dapp::account_id(address),
"dapp_id": dapp_id,
"last": page_size,
"before": before,
})),
},
)
.await
Expand All @@ -677,11 +656,11 @@ async fn lenient_query_account_events(
.and_then(|v| v.get("account"))
.and_then(|v| v.get("events"));
let edges = match events {
None | Some(serde_json::Value::Null) => break,
None | Some(serde_json::Value::Null) => break 'page,
Some(v) => v.get("edges").and_then(|e| e.as_array()).cloned().unwrap_or_default(),
};
if edges.is_empty() {
break;
break 'page;
}

let next_before = edges
Expand All @@ -703,7 +682,6 @@ async fn lenient_query_account_events(
// Fetched a single page only — `limit` semantics in our caller mean
// "give me up to this many"; one page covers it for our use case.
let _ = next_before;
break;
}
Ok(all)
}
Expand Down
2 changes: 1 addition & 1 deletion bee_wallet/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl WalletClient {
modules::names::NamesModule::new(&self.ctx)
}

#[cfg(not(target_arch = "wasm32"))]
#[cfg(all(not(target_arch = "wasm32"), feature = "dex"))]
pub(crate) fn dex(&self) -> modules::dex::DexModule<'_> {
modules::dex::DexModule::new(&self.ctx)
}
Expand Down
47 changes: 11 additions & 36 deletions bee_wallet/src/dapp.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
//! Single source of truth for dApp IDs we must pass to the v3 kit, plus helpers
//! Single source of truth for dApp IDs we must pass to the kit, plus helpers
//! for our OWN raw GraphQL queries that address an account.
//!
//! On gql-server `< 1.0.0` (current shellnet/mainnet) `dapp_id` is ignored, so
//! a wrong value is harmless *today* — but it travels into the GraphQL query on
//! `>= 1.0.0` servers, where a wrong/placeholder dApp makes account-bearing
//! calls fail (`518 DappIdRequired` / query miss). Keep the real values here so
//! flipping them later is a one-line change, not a repo-wide hunt.

use std::sync::Arc;
//! Since kit v4 the kit speaks only the `>= 1.0.0` GraphQL, which addresses
//! accounts by `account_id` + `dapp_id` — the server-generation probe
//! (`supports_dapp_id`) is gone and there is no legacy `account(address:)`
//! fallback left. A wrong dApp therefore fails the call outright
//! (`518 DappIdRequired` / query miss), so the real values live here.

use ackinacki_kit::contracts::account::ParamsOfNewContract;
use ackinacki_kit::contracts::dapp::supports_dapp_id;
use ackinacki_kit::contracts::dapp::SystemDapp;
use ackinacki_kit::contracts::error::KitModule;
use ackinacki_kit::tvm_client::ClientContext;

use crate::errors::AppError;
use crate::errors::AppResult;

/// Build `ParamsOfNewContract` for a TIP-3 token-family contract
/// (`TokenRoot` / `TokenWallet` / `TokenTransaction`) at `address`.
///
/// Each token has its OWN dApp, so there is no single correct constant — the
/// caller supplies `dapp_id` (it arrives from the API request next to the token
/// root). Ignored on `< 1.0.0` servers; must be the token's real dApp on
/// `>= 1.0.0`.
/// root).
pub fn token_contract_params(
address: impl Into<String>,
dapp_id: impl Into<String>,
Expand All @@ -35,32 +26,16 @@ pub fn token_contract_params(
/// dApp for DEX contracts (`RootPn` / `RootOracle` / `Oracle` / `PrivateNote` /
/// `Pmp` / ...).
///
/// TODO(dapp): DEX dApp is **UNCONFIRMED**. The kit dropped its `System`
/// placeholder for DEX (`new_default` removed — "Skip dex defaults"), so we
/// pass it explicitly. Same deal as [`TOKEN_DAPP`]: harmless on `< 1.0.0`, must
/// be the real value before any `>= 1.0.0` server.
pub const DEX_DAPP: SystemDapp = SystemDapp::System;
/// Was a `System` placeholder while the kit had no DEX variant; kit v4 added
/// [`SystemDapp::Dex`] (`…0004`), which is the real value.
pub const DEX_DAPP: SystemDapp = SystemDapp::Dex;

/// Build `ParamsOfNewContract` for a DEX-family contract at `address`.
pub fn dex_contract_params(address: impl Into<String>) -> ParamsOfNewContract {
ParamsOfNewContract::new(address, DEX_DAPP)
}

/// Whether the server reached via `ctx` speaks the v3 (`>= 1.0.0`) GraphQL that
/// addresses accounts by `account_id` + `dapp_id` instead of legacy
/// `account(address:)`.
///
/// Use this to pick the query form for our OWN raw `net::query` calls — the
/// kit's own contract methods switch internally and need no help. The SDK
/// caches the parsed server version on the endpoint, so call it ONCE and hoist
/// the result out of paging loops.
pub async fn server_uses_dapp_id(ctx: &Arc<ClientContext>) -> AppResult<bool> {
supports_dapp_id(ctx, KitModule::Event)
.await
.map_err(|e| AppError::from(e).with_context("detect GraphQL server version"))
}

/// Bare account-id for the v3 `account_id` GraphQL arg: drops the `"0:"`
/// Bare account-id for the `account_id` GraphQL arg: drops the `"0:"`
/// workchain prefix (`"0:hex"` -> `"hex"`). Mirrors the kit's private
/// `account_id_from_address`.
pub fn account_id(address: &str) -> &str {
Expand Down
2 changes: 1 addition & 1 deletion bee_wallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub use types::SendTokensReq;
pub use types::UpdateMultifactorZkIdReq;
pub use types::WithdrawPopitgameRewardsReq;

#[cfg(not(target_arch = "wasm32"))]
#[cfg(all(not(target_arch = "wasm32"), feature = "dex"))]
pub use crate::modules::dex::ParamsOfGenerateVoucher;
pub use crate::modules::names::ResultOfValidateWalletName;
pub use crate::modules::names::WalletNameErrorCode;
Expand Down
2 changes: 1 addition & 1 deletion bee_wallet/src/modules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
pub(crate) mod balance;
pub(crate) mod connect;
pub(crate) mod deploy;
#[cfg(not(target_arch = "wasm32"))]
#[cfg(all(not(target_arch = "wasm32"), feature = "dex"))]
pub(crate) mod dex;
pub(crate) mod history;
pub(crate) mod miner;
Expand Down
5 changes: 3 additions & 2 deletions bee_wallet/src/services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ pub mod boost;
pub mod connect;
pub mod deploy;
// DEX wrappers live in `dodex-contracts` (native-only dep); voucher generation
// isn't exposed on wasm.
#[cfg(not(target_arch = "wasm32"))]
// isn't exposed on wasm. Behind the `dex` feature while dodex is a kit major
// behind us — see the feature's comment in Cargo.toml.
#[cfg(all(not(target_arch = "wasm32"), feature = "dex"))]
pub mod dex;
pub mod miner;
pub mod multifactor;
Expand Down
Loading
Loading