diff --git a/Cargo.lock b/Cargo.lock index df16aa51..e0655bbb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -125,6 +125,22 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "antithesis_sdk" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "987cdecd45a069a1bd755cce3c7f8434433ccd5f2f54e6545e9f7175256b3b1b" +dependencies = [ + "libc", + "libloading", + "linkme", + "once_cell", + "rand", + "rustc_version_runtime", + "serde", + "serde_json", +] + [[package]] name = "anyhow" version = "1.0.93" @@ -1048,6 +1064,15 @@ dependencies = [ "syn", ] +[[package]] +name = "envy" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f47e0157f2cb54f5ae1bd371b30a2ae4311e1c028f575cd4e81de7353215965" +dependencies = [ + "serde", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -1070,6 +1095,16 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +[[package]] +name = "eyre" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" +dependencies = [ + "indenter", + "once_cell", +] + [[package]] name = "fast_hilbert" version = "2.0.0" @@ -1698,6 +1733,25 @@ dependencies = [ "valence_text", ] +[[package]] +name = "hyperion-bot" +version = "0.1.0" +dependencies = [ + "antithesis_sdk", + "derive_more", + "dotenvy", + "envy", + "eyre", + "rand", + "regex", + "serde", + "tokio", + "tracing", + "tracing-subscriber", + "uuid", + "valence_protocol", +] + [[package]] name = "hyperion-clap" version = "0.1.0" @@ -2043,6 +2097,12 @@ dependencies = [ "png", ] +[[package]] +name = "indenter" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" + [[package]] name = "indexmap" version = "2.6.0" @@ -2215,6 +2275,26 @@ dependencies = [ "libc", ] +[[package]] +name = "linkme" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "566336154b9e58a4f055f6dd4cbab62c7dc0826ce3c0a04e63b2d2ecd784cdae" +dependencies = [ + "linkme-impl", +] + +[[package]] +name = "linkme-impl" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edbe595006d355eaf9ae11db92707d4338cd2384d16866131cc1afdbdd35d8d9" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -3226,6 +3306,25 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustc_version_runtime" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dd18cd2bae1820af0b6ad5e54f4a51d0f3fcc53b05f845675074efcc7af071d" +dependencies = [ + "rustc_version", + "semver", +] + [[package]] name = "rustix" version = "0.38.40" @@ -3373,6 +3472,12 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d659fa6f19e82a52ab8d3fff3c380bd8cc16462eaea411395618a38760eb85bc" +[[package]] +name = "semver" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" + [[package]] name = "serde" version = "1.0.215" diff --git a/Cargo.toml b/Cargo.toml index 5d5734a8..cb0ffd87 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,24 +13,25 @@ panic = 'abort' members = [ 'crates/bvh-region', 'crates/hyperion', + 'crates/hyperion-bot', + 'crates/hyperion-clap', + 'crates/hyperion-command', 'crates/hyperion-crafting', 'crates/hyperion-event-macros', 'crates/hyperion-inventory', + 'crates/hyperion-item', 'crates/hyperion-minecraft-proto', 'crates/hyperion-nerd-font', 'crates/hyperion-palette', + 'crates/hyperion-permission', 'crates/hyperion-proto', 'crates/hyperion-proxy', + 'crates/hyperion-rank-tree', 'crates/hyperion-scheduled', 'crates/hyperion-stats', 'crates/hyperion-text', 'crates/hyperion-utils', 'events/proof-of-concept', - 'crates/hyperion-permission', - 'crates/hyperion-clap', - 'crates/hyperion-command', - 'crates/hyperion-rank-tree', - 'crates/hyperion-item', ] resolver = '2' diff --git a/crates/hyperion-bot/src/bot.rs b/crates/hyperion-bot/src/bot.rs index 24aad4d0..7423c74e 100644 --- a/crates/hyperion-bot/src/bot.rs +++ b/crates/hyperion-bot/src/bot.rs @@ -1,4 +1,5 @@ use tokio::net::{TcpStream, ToSocketAddrs}; +use tracing::info; use uuid::Uuid; mod handshake; @@ -11,7 +12,9 @@ pub struct Bot { } impl Bot { - pub async fn new(name: String, uuid: Uuid, addr: impl ToSocketAddrs) -> Self { + #[tracing::instrument(skip_all, fields(name))] + pub async fn new(name: String, uuid: Uuid, addr: impl ToSocketAddrs + std::fmt::Display) -> Self { + info!("connecting to {addr}"); let addr = TcpStream::connect(addr).await.unwrap(); Self { diff --git a/crates/hyperion-bot/src/lib.rs b/crates/hyperion-bot/src/lib.rs index d8c46258..692da018 100644 --- a/crates/hyperion-bot/src/lib.rs +++ b/crates/hyperion-bot/src/lib.rs @@ -17,7 +17,7 @@ pub fn bootstrap(config: &Config) { // todo: use life cycle let mut rng = AntithesisRng; - + let first_name = generate::name(); assert_sometimes!(first_name.is_valid, "First name is never invalid"); assert_sometimes!(!first_name.is_valid, "First name is always valid"); diff --git a/docker-compose.yml b/docker-compose.yml index 9905fc77..1f4ad1a9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -40,6 +40,7 @@ services: environment: - RUST_LOG=info - HOST=hyperion-proxy:25565 + - MAX_NUMBER_OF_BOTS=10 networks: - proxy-network