Kaynağa Gözat

example: Remove obsolete code

parazyd 2 yıl önce
ebeveyn
işleme
998ea5ac6b

+ 0 - 2
example/dummy-contract/.gitignore

@@ -1,2 +0,0 @@
-target/
-Cargo.lock

+ 0 - 36
example/dummy-contract/Cargo.toml

@@ -1,36 +0,0 @@
-[package]
-name = "darkfi_dummy_contract"
-version = "0.4.1"
-authors = ["Dyne.org foundation <foundation@dyne.org>"]
-license = "AGPL-3.0-only"
-edition = "2021"
-
-[workspace]
-
-[lib]
-crate-type = ["cdylib", "rlib"]
-
-[dependencies]
-darkfi-sdk = {path = "../../src/sdk"}
-
-# We need to disable random using "custom" which makes the crate a noop
-# so the wasm32-unknown-unknown target is enabled.
-[target.'cfg(target_arch = "wasm32")'.dependencies]
-getrandom = { version = "0.2.8", features = ["custom"] }
-
-[dev-dependencies]
-sled = "0.34.7"
-darkfi = {path = "../../", features = ["wasm-runtime"]}
-simplelog = "0.12.2"
-
-[[example]]
-name = "runtime"
-path = "src/runtime.rs"
-
-[features]
-default = []
-no-entrypoint = []
-
-[patch.crates-io]
-halo2_proofs = {git="https://github.com/parazyd/halo2", branch="v4"}
-halo2_gadgets = {git="https://github.com/parazyd/halo2", branch="v4"}

+ 0 - 11
example/dummy-contract/README.md

@@ -1,11 +0,0 @@
-# Build WASM
-
-```
-$ cargo +nightly build --target=wasm32-unknown-unknown --release --package darkfi_dummy_contract
-```
-
-# Run runtime.rs
-
-```
-$ cargo +nightly run --target=x86_64-unknown-linux-gnu --release --example runtime
-```

+ 0 - 53
example/dummy-contract/src/entrypoint.rs

@@ -1,53 +0,0 @@
-/* This file is part of DarkFi (https://dark.fi)
- *
- * Copyright (C) 2020-2024 Dyne.org foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <https://www.gnu.org/licenses/>.
- */
-
-use darkfi_sdk::{
-    crypto::ContractId,
-    db::{db_init, db_lookup},
-    error::ContractResult,
-};
-
-darkfi_sdk::define_contract!(
-    init: init_contract,
-    exec: process_instruction,
-    apply: process_update,
-    metadata: get_metadata
-);
-
-fn init_contract(cid: ContractId, _ix: &[u8]) -> ContractResult {
-    let db = match db_lookup(cid, "dummy_db") {
-        Ok(v) => v,
-        Err(_) => db_init(cid, "dummy_db")?,
-    };
-
-    Ok(())
-}
-
-fn get_metadata(_cid: ContractId, _ix: &[u8]) -> ContractResult {
-    Ok(())
-}
-
-fn process_instruction(cid: ContractId, _ix: &[u8]) -> ContractResult {
-    let db = db_lookup(cid, "dummy_db")?;
-
-    Ok(())
-}
-
-fn process_update(_cid: ContractId, _ix: &[u8]) -> ContractResult {
-    Ok(())
-}

+ 0 - 21
example/dummy-contract/src/lib.rs

@@ -1,21 +0,0 @@
-/* This file is part of DarkFi (https://dark.fi)
- *
- * Copyright (C) 2020-2024 Dyne.org foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <https://www.gnu.org/licenses/>.
- */
-
-#[cfg(not(feature = "no-entrypoint"))]
-/// WASM entrypoint functions
-pub mod entrypoint;

+ 0 - 63
example/dummy-contract/src/runtime.rs

@@ -1,63 +0,0 @@
-/* This file is part of DarkFi (https://dark.fi)
- *
- * Copyright (C) 2020-2024 Dyne.org foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <https://www.gnu.org/licenses/>.
- */
-
-use darkfi::{
-    blockchain::{Blockchain, BlockchainOverlay},
-    runtime::vm_runtime::Runtime,
-    util::time::{TimeKeeper, Timestamp},
-};
-use darkfi_sdk::{crypto::ContractId, pasta::pallas};
-
-fn init_logger() {
-    let mut cfg = simplelog::ConfigBuilder::new();
-    cfg.add_filter_ignore("sled".to_string());
-
-    simplelog::TermLogger::init(
-        simplelog::LevelFilter::Debug,
-        cfg.build(),
-        simplelog::TerminalMode::Mixed,
-        simplelog::ColorChoice::Auto,
-    )
-    .unwrap();
-}
-
-fn main() {
-    init_logger();
-
-    let sled_db = sled::Config::new().temporary(true).open().unwrap();
-    let blockchain = Blockchain::new(&sled_db).unwrap();
-    let overlay = BlockchainOverlay::new(&blockchain).unwrap();
-
-    let timekeeper = TimeKeeper::new(Timestamp::current_time(), 10, 90, 0);
-
-    let wasm_bytes =
-        include_bytes!("../target/wasm32-unknown-unknown/release/darkfi_dummy_contract.wasm");
-
-    let contract_id = ContractId::from(pallas::Base::from(69));
-
-    let mut runtime = Runtime::new(wasm_bytes, overlay, contract_id, timekeeper).unwrap();
-    match runtime.deploy(&[]) {
-        Ok(()) => {}
-        Err(e) => println!("Error running deploy: {:#?}", e),
-    }
-
-    match runtime.exec(&[]) {
-        Ok(_) => {}
-        Err(e) => println!("Error running exec: {:#?}", e),
-    }
-}

+ 0 - 116
example/net.rs

@@ -1,116 +0,0 @@
-/* This file is part of DarkFi (https://dark.fi)
- *
- * Copyright (C) 2020-2024 Dyne.org foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <https://www.gnu.org/licenses/>.
- */
-
-use std::sync::Arc;
-
-use clap::Parser;
-use simplelog::*;
-use smol::Executor;
-
-use darkfi::{
-    net,
-    util::cli::{get_log_config, get_log_level},
-    Result,
-};
-
-async fn start(executor: Arc<Executor<'static>>, options: ProgramOptions) -> Result<()> {
-    let p2p = net::P2p::new(options.network_settings, executor.clone()).await;
-
-    p2p.clone().start().await?;
-
-    Ok(())
-}
-
-struct ProgramOptions {
-    network_settings: net::Settings,
-}
-
-#[derive(Parser)]
-#[clap(name = "dnode")]
-pub struct DarkCli {
-    /// accept address
-    #[clap(short, long)]
-    pub accept: Option<String>,
-    /// seed nodes
-    #[clap(long, short)]
-    pub seeds: Option<Vec<String>>,
-    /// manual connections
-    #[clap(short, short)]
-    pub connect: Option<Vec<String>>,
-    ///  connections slots
-    #[clap(long)]
-    pub connect_slots: Option<usize>,
-    /// RPC port
-    #[clap(long)]
-    pub rpc_port: Option<String>,
-}
-
-impl ProgramOptions {
-    fn load() -> Result<ProgramOptions> {
-        let programcli = DarkCli::parse();
-
-        let accept_addr = if let Some(accept_addr) = programcli.accept {
-            vec![accept_addr.parse()?]
-        } else {
-            vec![]
-        };
-
-        let mut seed_addrs: Vec<url::Url> = vec![];
-        if let Some(seeds) = programcli.seeds {
-            for seed in seeds {
-                seed_addrs.push(seed.parse()?);
-            }
-        }
-
-        let mut manual_connects: Vec<url::Url> = vec![];
-        if let Some(connections) = programcli.connect {
-            for connect in connections {
-                manual_connects.push(connect.parse()?);
-            }
-        }
-
-        let connection_slots = if let Some(connection_slots) = programcli.connect_slots {
-            connection_slots
-        } else {
-            0
-        };
-
-        Ok(ProgramOptions {
-            network_settings: net::Settings {
-                inbound_addrs: accept_addr.clone(),
-                outbound_connections: connection_slots,
-                external_addrs: accept_addr,
-                peers: manual_connects,
-                seeds: seed_addrs,
-                ..Default::default()
-            },
-        })
-    }
-}
-
-fn main() -> Result<()> {
-    let options = ProgramOptions::load()?;
-
-    let lvl = get_log_level(1);
-    let conf = get_log_config(1);
-
-    TermLogger::init(lvl, conf, TerminalMode::Mixed, ColorChoice::Auto)?;
-
-    let ex = Arc::new(Executor::new());
-    smol::block_on(ex.run(start(ex.clone(), options)))
-}