Skip to content
Open
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
3 changes: 3 additions & 0 deletions Cargo.lock

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

19 changes: 11 additions & 8 deletions benches/howzit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,24 @@ name = "howzit-bench"
path = "src/bin/howzit-bench.rs"

[dependencies]
anyhow = { workspace = true }
aptos-cached-packages = { workspace = true }
aptos-framework = { workspace = true }
aptos-sdk = { workspace = true }
aptos-types = { workspace = true }
aptos-framework = { workspace = true }
aptos-cached-packages = { workspace = true }
tokio = { workspace = true }
serde = { workspace = true, features = ["derive"] }
anyhow = { workspace = true }
bcs = { workspace = true }
chrono = { workspace = true }
futures = { workspace = true }
godfig = { workspace = true }
dot-movement = { workspace = true }
movement-config = { workspace = true }
rand = { workspace = true }
futures = { workspace = true }
url = { workspace = true }
serde = { workspace = true, features = ["derive"] }
tokio = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
chrono = { workspace = true }
url = { workspace = true }
once_cell = { workspace = true }


[lints]
Expand Down
4 changes: 2 additions & 2 deletions benches/howzit/howzit/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ howzit = '_'
[dev-addresses]

[dependencies.AptosFramework]
git = "https://github.com/aptos-labs/aptos-core.git"
rev = "mainnet"
git = "https://github.com/movementlabsxyz/aptos-core"
rev = "movement"
subdir = "aptos-move/framework/aptos-framework"

[dev-dependencies]
75 changes: 62 additions & 13 deletions benches/howzit/src/bin/howzit-bench.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,62 @@
use anyhow::Context;
use aptos_sdk::rest_client::{AptosBaseUrl, Client};
use howzit::Howzit;
use once_cell::sync::Lazy;
use std::io::Write;
use std::{env, path::PathBuf};
use std::{env, path::PathBuf, str::FromStr};
use url::Url;

static SUZUKA_CONFIG: Lazy<movement_config::Config> = Lazy::new(|| {
let dot_movement = dot_movement::DotMovement::try_from_env().unwrap();
let config = dot_movement.try_get_config_from_json::<movement_config::Config>().unwrap();
config
});

static NODE_URL: Lazy<Url> = Lazy::new(|| {
let mut node_connection_address = SUZUKA_CONFIG
.execution_config
.maptos_config
.client
.maptos_rest_connection_hostname
.clone();

if node_connection_address == "0.0.0.0" {
node_connection_address = "127.0.0.1".to_string();
}

let node_connection_port = SUZUKA_CONFIG
.execution_config
.maptos_config
.client
.maptos_rest_connection_port
.clone();

let node_connection_url =
format!("http://{}:{}", node_connection_address, node_connection_port);
Url::from_str(&node_connection_url).unwrap()
});

static FAUCET_URL: Lazy<Url> = Lazy::new(|| {
let mut faucet_listen_address = SUZUKA_CONFIG
.execution_config
.maptos_config
.client
.maptos_faucet_rest_connection_hostname
.clone();

if faucet_listen_address == "0.0.0.0" {
faucet_listen_address = "127.0.0.1".to_string();
}

let faucet_listen_port = SUZUKA_CONFIG
.execution_config
.maptos_config
.client
.maptos_faucet_rest_connection_port
.clone();

let faucet_listen_url = format!("http://{}:{}", faucet_listen_address, faucet_listen_port);
Url::from_str(&faucet_listen_url).unwrap()
});

#[tokio::main]
pub async fn main() -> Result<(), anyhow::Error> {
Expand All @@ -14,27 +68,22 @@ pub async fn main() -> Result<(), anyhow::Error> {
)
.init();

let token = std::env::var("AUTH_TOKEN").context("AUTH_TOKEN not set")?;

let crate_path = env!("CARGO_MANIFEST_DIR");
let crate_path_buf = PathBuf::from(crate_path);
let token = std::env::var("AUTH_TOKEN").context("AUTH_TOKEN not set")?;
let rest_url = std::env::var("REST_URL")
.unwrap_or("https://aptos.devnet.suzuka.movementlabs.xyz".to_string());
let faucet_url = std::env::var("FAUCET_URL")
.unwrap_or("https://faucet.devnet.suzuka.movementlabs.xyz".to_string());
let bench_output_file =
std::env::var("BENCH_OUTPUT_FILE").unwrap_or("howzit_bench_output.dat".to_string());

let rest_client_builder = Client::builder(AptosBaseUrl::Custom(rest_url.parse()?))
.header("Authorization", format!("Bearer {}", token).as_str())?;
let rest_client = rest_client_builder.build();

let howzit = Howzit::generate(
crate_path_buf.join("howzit"),
rest_client.clone(),
faucet_url.parse()?,
NODE_URL.clone(),
FAUCET_URL.clone(),
token,
);

tracing::info!("Generated howzit");

howzit.build_and_publish().await?;

// fund the accounts in an orderly manner
Expand Down
33 changes: 19 additions & 14 deletions benches/howzit/src/howzit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,23 @@ pub struct Howzit {
pub rest_client: Client,
faucet_client_url: Url,
pub faucet_client: FaucetClient,
/// Only required if using on a live network
pub faucet_auth_token: String,
}

impl Clone for Howzit {
fn clone(&self) -> Self {
let mut faucet_client = FaucetClient::new_from_rest_client(
self.faucet_client_url.clone(),
self.rest_client.clone(),
);
faucet_client = faucet_client.with_auth_token(self.faucet_auth_token.clone());
Howzit {
howzit_package_path: self.howzit_package_path.clone(),
wallet: self.wallet.clone(),
rest_client: self.rest_client.clone(),
faucet_client_url: self.faucet_client_url.clone(),
faucet_client: FaucetClient::new_from_rest_client(
self.faucet_client_url.clone(),
self.rest_client.clone(),
)
.with_auth_token(self.faucet_auth_token.clone()),
faucet_client,
faucet_auth_token: self.faucet_auth_token.clone(),
}
}
Expand All @@ -104,19 +106,20 @@ impl Howzit {
/// Generates a new Howzit instance with a random wallet
pub fn generate(
howzit_package_path: PathBuf,
rest_client: Client,
node_url: Url,
faucet_client_url: Url,
faucet_auth_token: String,
token: String,
) -> Self {
let wallet = LocalAccount::generate(&mut rand::rngs::OsRng);
let mut faucet_client = FaucetClient::new(faucet_client_url.clone(), node_url.clone());
faucet_client = faucet_client.with_auth_token(token.clone());
Howzit {
howzit_package_path,
wallet: Arc::new(RwLock::new(wallet)),
rest_client: rest_client.clone(),
faucet_client_url: faucet_client_url.clone(),
faucet_client: FaucetClient::new_from_rest_client(faucet_client_url, rest_client)
.with_auth_token(faucet_auth_token.clone()),
faucet_auth_token,
rest_client: Client::new(node_url.clone()),
faucet_client_url,
faucet_client,
faucet_auth_token: token,
}
}

Expand Down Expand Up @@ -220,7 +223,8 @@ impl Howzit {
tracing::info!("Funding Alice");
let start_time = chrono::Utc::now();
match self.faucet_client.fund(alice.address(), 10_000_000_000).await {
Ok(_) => {
Ok(v) => {
tracing::info!("Successfully created Alice account: {:?}", v);
let end_time = chrono::Utc::now();
let mut results = results.write().await;
results.push((
Expand Down Expand Up @@ -249,7 +253,8 @@ impl Howzit {
tracing::info!("Funding Bob");
let start_time = chrono::Utc::now();
match self.faucet_client.fund(bob.address(), 10_000_000_000).await {
Ok(_) => {
Ok(v) => {
tracing::info!("Successfully created Bob account: {:?}", v);
let end_time = chrono::Utc::now();
let mut results = results.write().await;
results.push((
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: "3"


processes:

# setup:
# environment:
# - APTOS_ACCOUNT_WHITELIST=$DOT_MOVEMENT_PATH/default_signer_address_whitelist
# - MAPTOS_PRIVATE_KEY=random
#
# movement-faucet:
# command : |
# movement-faucet-service run-simple --do-not-delegate

howzit:
environment:
- "AUTH_TOKEN=notreal"
command: |
cargo run --bin howzit-bench
depends_on:
movement-full-node:
condition: process_healthy
movement-faucet:
condition: process_healthy
availability:
exit_on_end: true
19 changes: 0 additions & 19 deletions process-compose/movement-full-node/process-compose.howzit.yml

This file was deleted.

Loading