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

Aptos binding #3

Draft
wants to merge 28 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4ad611b
Initial skeleton
circlespainter Nov 18, 2022
326c452
Draft of core logic, w/o metrics nor run duration
circlespainter Nov 27, 2022
1f981c2
Support cloning the configuration
circlespainter Nov 27, 2022
fe9ca2a
Implement duration
circlespainter Nov 27, 2022
2f8887c
Fix Tokio dependency features in core lib
circlespainter Nov 27, 2022
a40229b
Improve readability and add metrics
circlespainter Dec 2, 2022
43f8cf4
Add shortcircuited implementation and redesign API
circlespainter Dec 2, 2022
238efdc
Redesign API to lock only on single-node access handles
circlespainter Dec 3, 2022
860f22b
Simplify and document the shortcircuited binding
circlespainter Dec 3, 2022
19ce7e9
Reuse the first reader
circlespainter Dec 3, 2022
23e88c8
SC: do away with unneeded mutexes around channel ends
circlespainter Dec 3, 2022
182a0c4
Don't assume what receiving errors are
circlespainter Dec 3, 2022
7e6518a
SC: extract the buffer size into a constant
circlespainter Dec 3, 2022
3b994c9
Implement shortcircuited benchmark
circlespainter Dec 5, 2022
82cb5c5
Improve logging and shutdown
circlespainter Dec 5, 2022
5e4263f
Add metrics
circlespainter Dec 5, 2022
a7907ae
Use Uuuid for better logging
circlespainter Dec 7, 2022
c33b970
Use Bytes instead of Arc<Vec<u8>>
circlespainter Dec 7, 2022
d7f4258
Use histograms instead of improperly using metrics
circlespainter Dec 11, 2022
21fe1e9
Use channels to avoid deadlocks
circlespainter Dec 11, 2022
0c7cfa8
Fix read/write race
circlespainter Dec 11, 2022
34d6fb3
Use more compact form for dependencies
circlespainter Dec 12, 2022
27967be
Rename bft-bench-shortcircuited -> bft-bench-shortcircuit
circlespainter Dec 13, 2022
9de7a57
Add CLI to specify the configuration location
circlespainter Dec 13, 2022
a8b2169
Fail more gracefully when config file not found
circlespainter Dec 13, 2022
a794d83
Use histograms and JSON
circlespainter Jan 3, 2023
555a05c
Factor read completion logic
circlespainter Jan 3, 2023
38d1046
Merge branch 'main' into aptos
circlespainter Jan 3, 2023
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
2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[workspace]
members = ["bft-bench-core", "bft-bench-shortcircuit"]
members = ["bft-bench-core", "bft-bench-shortcircuit", "bft-bench-aptos"]
16 changes: 16 additions & 0 deletions rust/bft-bench-aptos/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "bft-bench-aptos"
version = "0.0.1"
edition = "2021"
authors = ["Fabio Tudone <[email protected]>"]

[dependencies]
bft-bench-core = { path = "../bft-bench-core" }
async-trait = "0.1.58"
tokio = { version = "1.21.2", features = ["full"] }
uuid = { version = "1.2.0", features = ["v4"] }
rand = "0.7.3"
anyhow = "1.0.66"
once_cell = "1.16.0"
url = "2.3.1"
aptos-sdk = { git = "https://github.com/aptos-labs/aptos-core", branch = "devnet" }
73 changes: 73 additions & 0 deletions rust/bft-bench-aptos/src/bin/aptos-bench.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
use anyhow::{Context, Result};
use aptos_sdk::coin_client::CoinClient;
use aptos_sdk::rest_client::{Client, FaucetClient};
use aptos_sdk::types::LocalAccount;
use once_cell::sync::Lazy;
use std::str::FromStr;
use url::Url;

static NODE_URL: Lazy<Url> = Lazy::new(|| {
Url::from_str(
std::env::var("APTOS_NODE_URL")
.as_ref()
.map(|s| s.as_str())
.unwrap_or("https://fullnode.devnet.aptoslabs.com"),
)
.unwrap()
});

static FAUCET_URL: Lazy<Url> = Lazy::new(|| {
Url::from_str(
std::env::var("APTOS_FAUCET_URL")
.as_ref()
.map(|s| s.as_str())
.unwrap_or("https://faucet.devnet.aptoslabs.com"),
)
.unwrap()
});

#[tokio::main]
async fn main() -> Result<()> {
// :!:>section_1a
let rest_client = Client::new(NODE_URL.clone());
let faucet_client = FaucetClient::new(FAUCET_URL.clone(), NODE_URL.clone()); // <:!:section_1a
let coin_client = CoinClient::new(&rest_client);

// Create two accounts locally, Alice and Bob.
let alice = LocalAccount::generate(&mut rand::rngs::OsRng);
let bob = LocalAccount::generate(&mut rand::rngs::OsRng); // <:!:section_2

// Print account addresses.
println!("\n=== Addresses ===");
println!("Alice: {}", alice.address().to_hex_literal());
println!("Bob: {}", bob.address().to_hex_literal());

// Create the accounts on chain, but only fund Alice.
faucet_client
.fund(alice.address(), 100_000_000)
.await
.context("Failed to fund Alice's account")?;
faucet_client
.create_account(bob.address())
.await
.context("Failed to fund Bob's account")?;

// Print initial balances.
println!("\n=== Initial Balances ===");
println!(
"Alice: {:?}",
coin_client
.get_account_balance(&alice.address())
.await
.context("Failed to get Alice's account balance")?
);
println!(
"Bob: {:?}",
coin_client
.get_account_balance(&bob.address())
.await
.context("Failed to get Bob's account balance")?
);

Ok(())
}